v1.2.0 → v1.3.8python
yum install -y python36 python36-devel python-devel openldap-devel cd /tmp wget https://bootstrap.pypa.io/get-pip.py python3.6 get-pip.py
# 建立 vevn pip3 install virtualenv cd /opt/ virtualenv venv4archery --python=python36 source /opt/venv4archery/bin/activate which mysql_config #確認命令在 $PATH 中,不然安裝包時報錯 cd /opt # 安裝 gcc yum install -y gcc # 下載 archery 源碼 wget https://github.com/hhyo/archery/archive/v1.3.8.tar.gz tar -zxvf v1.3.8.tar.gz cd archery138/ pip3 install -r requirements.txt -i https://mirrors.ustc.edu.cn/pypi/web/simple/
MySQL 安裝略mysql
# 建立 archery 1.38 版本數據庫 create database archery138 charset utf8mb4; # 建立 archery 後臺數據庫帳號 create user archery@'127.0.0.1' identified by 'xxxxxx'; grant all on archery138.* to archery@'127.0.0.1'; # 建立線上 v1.2.0 版本數據庫恢復庫 create database archery120to138 charset utf8mb4; # 建立 inception 備份庫鏈接帳號 create user incep@'127.0.0.1' identified by 'xxxxxx'; grant all on *.* to incep@'127.0.0.1'; flush privileges;
inception 編譯安裝略nginx
inception 配置文件c++
[inception] general_log=1 general_log_file=inception.log port=6669 socket=/tmp/inc.socket character-set-client-handshake=0 character-set-server=utf8 inception_remote_system_password=123456 inception_remote_system_user=incep inception_remote_backup_port=3306 inception_remote_backup_host=127.0.0.1 inception_support_charset=utf8,utf8mb4 inception_osc_on=ON inception_osc_bin_dir=/usr/local/bin inception_enable_nullable=0 inception_check_primary_key=1 inception_check_column_comment=1 inception_check_table_comment=1 inception_osc_min_table_size=1 inception_osc_chunk_time=0.1 inception_ddl_support=1 inception_enable_blob_type=1 inception_check_column_default_value=1 # 啓動 inception inception --defaults-file=incep.cnf &
cd /tmp wget -r -np -nd --accept=gz --no-check-certificate https://www.percona.com/downloads/percona-toolkit/3.0.13/binary/tarball/percona-toolkit-3.0.13_x86_64.tar.gz tar zxvf percona-toolkit-3.0.13_x86_64.tar.gz cp percona-toolkit-3.0.13/bin/* /usr/local/bin/
yum install -y nginx vim /etc/nginx/conf.d/nginx.conf
server{ listen 9123; #監聽的端口 server_name archery138; proxy_read_timeout 600s; #超時時間與gunicorn超時時間設置一致,主要用於在線查詢 location / { proxy_pass http://127.0.0.1:8888; proxy_set_header Host $host:9123; #解決重定向404的問題 proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } location /static { alias /opt/archery138/archery/common/static; #此處指向settings.py配置項STATIC_ROOT目錄的絕對路徑,用於nginx收集靜態資源 } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } }
cd /opt/ mkdir archery_tools cd /opt/archery_tools rz soar
git clone https://github.com/Meituan-Dianping/SQLAdvisor.git yum install -y cmake libaio-devel libffi-devel glib2 glib2-devel gcc-c++ bison yum install -y Percona-Server-shared-56 [ --enablerepo=Percona56 ] # 若是不能安裝 Percona-Server-shared-56 報錯找不到包,那麼須要執行下面語句 yum install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm cd SQLAdvisor cmake -DBUILD_CONFIG=mysql_release -DCMAKE_BUILD_TYPE=debug -DCMAKE_INSTALL_PREFIX=/usr/local/sqlparser ./ make && make install cd sqladvisor cmake -DCMAKE_BUILD_TYPE=debug ./ make cp /opt/archery_tools/SQLAdvisor/sqladvisor/sqladvisor /opt/archery_tools/ yes | rm /opt/archery_tools/SQLAdvisor -r # 在本路徑下生成一個sqladvisor可執行文件,這便是咱們想要的。 /opt/archery_tools/sqladvisor --help
cd /opt/archery_tools/ virtualenv venv4schemasync --python=python2 source venv4schemasync/bin/activate git clone https://github.com/hhyo/SchemaSync.git git clone https://github.com/hhyo/SchemaObject.git cd SchemaObject && python setup.py install cd ../SchemaSync && python setup.py install yum install -y python-devel pip install mysql-python schemasync --version which schemasync cd .. ln -s /opt/archery_tools/venv4schemasync/bin/schemasync schemasync
vim /opt/archery138/archery/settings.py
# 該項目自己的mysql數據庫地址 DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'archery138', #archery信息庫,執行py腳本生成 'USER': 'archery', #archery 特權登陸用戶,執行py腳本生成 'PASSWORD': 'xxx', #archery 特權登陸用戶密碼 'HOST': '10.xx.xx.xx', #archery 數據庫ip 'PORT': '3306', #archery 數據庫端口 'OPTIONS': { 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'", 'charset': 'utf8mb4' #archery 數據庫字符集,默認爲utf8mb4 }, 'TEST': { 'NAME': 'test_archery', 'CHARSET': 'utf8', #archery 數據庫字符集,默認爲utf8 }, } } # LDAP ENABLE_LDAP = False # 測試時能夠設置爲 false,生產啓用 LDAP 時開啓 if ENABLE_LDAP: import ldap from django_auth_ldap.config import LDAPSearch AUTHENTICATION_BACKENDS = ( 'django_auth_ldap.backend.LDAPBackend', # 配置爲先使用LDAP認證,如經過認證則再也不使用後面的認證方式 'django.contrib.auth.backends.ModelBackend', # django系統中手動建立的用戶也可以使用,優先級靠後。注意這2行的順序 ) AUTH_LDAP_SERVER_URI = "ldap://xx.xx.xx.com" AUTH_LDAP_BIND_DN = "CN=auth,CN=Users,DC=xx,DC=xx,DC=com" AUTH_LDAP_BIND_PASSWORD = "xxxxxxxxxxxxxxx" AUTH_LDAP_USER_SEARCH = LDAPSearch("ou=xxx,dc=xx,dc=xxx,dc=com",ldap.SCOPE_SUBTREE, "(sAMAccountName=%(user)s)") AUTH_LDAP_ALWAYS_UPDATE_USER = True # 每次登陸從ldap同步用戶信息 AUTH_LDAP_USER_ATTR_MAP = { # key爲archery.sql_users字段名,value爲ldap中字段名,用戶同步信息 "username": "xxxxxxxxxxxx", "display": "cn", "email": "mail" }
cd /opt/archery138/ python36 manage.py makemigrations sql #這一步若是遇到報錯可忽略 python36 manage.py migrate
cd /opt/archery138/ python3 manage.py createsuperuser Username: archery_admin # 手動輸入 Email address: dba-notice@ybm100.com Password: xxxx #輸入密碼 Password (again): xxxxx #確認密碼 Superuser created successfully.
source /opt/venv4archery/bin/activate python3 manage.py runserver 0.0.0.0:9123 --insecure &
cd /opt/archery138/ source /opt/venv4archery/bin/activate sh startup.sh &
#!/bin/bash inception --defaults-file=/opt/inception/inc.cnf & source /opt/venv4archery/bin/activate cd /opt/archery138 python3 /opt/archery138/manage.py runserver 0.0.0.0:9123 --insecure & sh /opt/archery138/startup.sh &
# 10.xx.xx.xx sudo su - mysqldump -S xx/mysql.sock --single-transaction --master-data=2 --set-gtid-purged=OFF db_ops > db_ops.sql
# 10.xx.xx.xx sudo su - mysql -S xx/mysql.sock db_ops <db_ops.sql
# 10.xx.xx.xx sudo su - cd /opt/archery138/src/init_sql mysql -h 10.xx.xx.xx -P3306 -uxx -p db_ops < v1.2.0_1.3.0.sql mysql -h 10.xx.xx.xx -P3306 -uxx -p db_ops < v1.3.0_1.3.2.sql mysql -h 10.xx.xx.xx -P3306 -uxx -p db_ops < v1.3.6_v1.3.7.sql
# 10.xx.xx.xx sudo su - mysqldump -S xx/mysql.sock --single-transaction --master-data=2 --set-gtid-purged=OFF --no-create-info db_ops > updated_db_data.sql.bak mysql -h 10.xx.xx.xx -P3306 -uxx -p archery < updated_db_data.sql,bak
訪問 http://10.xx.xx.xx:9123git
「系統管理」-->「配置項管理」github
——填寫完成後點擊測試,經過後保存web
INCEPTION_HOST 10.xx.xx.xx INCEPTION_PORT 6669 REMOTE_BACKUP_HOST 10.xx.xx.xx REMOTE_BACKUP_PORT 3306 REMOTE_BACKUP_USER incep REMOTE_BACKUP_PASSWORD xxxx
QUERY ON
SQLADVISOR_PATH /opt/archery_tools/sqladvisor SOAR_PATH /opt/archery_tools/soar SOAR_TEST_DSN xxx:xxx@10.xx.xx.xx:3306/archery
——填寫完成後點擊測試,經過後保存sql
MAIL ON MAIL_SSL ON MAIL_SMTP_SERVER xxx MAIL_SMTP_PORT xxx MAIL_SMTP_USER xxx MAIL_SMTP_PASSWORD xxx DDL_NOTIFY_AUTH_GROUP dinglu@ybm100.com DING ON
SCHEMASYNC /opt/archery_tools/venv4schemasync/bin/schemasync數據庫
若是在archery平臺上使用schemasync進行表對比的時候出現問題,多是登陸mysql的密碼中出現了特殊字符,使得schemasync
沒法識別這個密碼,能夠將含有特殊字符的密碼改爲不含有特殊字符的密碼,問題就能夠解決了,或者是修改instance.py 文件中的代碼
修改前:
command = path + ' %s --output-directory=%s --tag=%s \ mysql://%s:%s@%s:%d/%s mysql://%s:%s@%s:%d/%s'
修改後:
command = path + " %s --output-directory=%s --tag=%s \ mysql://%s:'%s'@%s:%d/%s mysql://%s:'%s'@%s:%d/%s" # 將其中的密碼用單引號引發來就能夠了