v1.2.0 → v1.3.8
0.软件版本及项目地址
1.安装python venv环境
1.1.安装 python36
| 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 |
1.2.创建 Python venv 环境(Python>=3.6.5,建议使用虚拟环境 )
| |
| pip3 install virtualenv |
| cd /opt/ |
| virtualenv venv4archery --python=python36 |
| source /opt/venv4archery/bin/activate |
| |
| which mysql_config |
| cd /opt |
| |
| |
| yum install -y gcc |
| |
| |
| 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/ |
1.3.报错处理参考
1.3.1.mysql_config 找不到报错

1.3.2.openldap-devel 包未安装报错

2.组件安装配置
2.1.MySQL 安装、配置
-
MySQL 安装略
-
连接信息:
-
archery:
-
inception:
2.2.数据库账号授权
| # 创建 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; |
2.3.inception 安装、配置、启动
-
inception 编译安装略
-
inception 配置文件
| [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 --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/ |
2.5.Nginx 安装、配置
| yum install -y nginx |
| vim /etc/nginx/conf.d/nginx.conf |
| server{ |
| listen 9123; |
| server_name archery138; |
| proxy_read_timeout 600s; |
| location / { |
| proxy_pass http://127.0.0.1:8888; |
| proxy_set_header Host $host:9123; |
| 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; |
| } |
| |
| error_page 404 /404.html; |
| location = /40x.html { |
| } |
| |
| error_page 500 502 503 504 /50x.html; |
| location = /50x.html { |
| } |
| } |
2.6.上传 archery 第三方工具
| cd /opt/ |
| mkdir archery_tools |
| cd /opt/archery_tools |
| rz soar |
2.7. SQLAdvisor 安装
| 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 ] |
| |
| |
| 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 |
| |
| |
| /opt/archery_tools/sqladvisor --help |
2.7.1.报错处理
- 安装 Percona-Server-shared-56 报错,与 MariaDB-common-10.1.37-1.el7.centos.x86_64 包有冲突

- 因为机器部署时使用的 MariaDB-common-10.1.37-1.el7.centos.x86_64 包安装的 zabbix-agent

- 解决办法:从测试环境拷贝 libmysqlclient.so.18.1.0 文件,再创建软链接文件
2.8. SchemaSync 安装
| 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 |
3.安装 archery 环境
3.1. 1.2.步已下载源码,略过
3.2.修改 archery/settings.py 文件 DATABASES 配置项
| vim /opt/archery138/archery/settings.py |
| |
| DATABASES = { |
| 'default': { |
| 'ENGINE': 'django.db.backends.mysql', |
| 'NAME': 'archery138', |
| 'USER': 'archery', |
| 'PASSWORD': 'xxx', |
| 'HOST': '10.xx.xx.xx', |
| 'PORT': '3306', |
| 'OPTIONS': { |
| 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'", |
| 'charset': 'utf8mb4' |
| }, |
| 'TEST': { |
| 'NAME': 'test_archery', |
| 'CHARSET': 'utf8', |
| }, |
| } |
| } |
| |
| |
| ENABLE_LDAP = False |
| if ENABLE_LDAP: |
| import ldap |
| from django_auth_ldap.config import LDAPSearch |
| AUTHENTICATION_BACKENDS = ( |
| 'django_auth_ldap.backend.LDAPBackend', |
| 'django.contrib.auth.backends.ModelBackend', |
| ) |
| 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 |
| AUTH_LDAP_USER_ATTR_MAP = { |
| "username": "xxxxxxxxxxxx", |
| "display": "cn", |
| "email": "mail" |
| } |
3.3.数据库初始化
| cd /opt/archery138/ |
| python36 manage.py makemigrations sql |
| python36 manage.py migrate |
3.4.创建管理用户
| cd /opt/archery138/ |
| python3 manage.py createsuperuser |
| Username: archery_admin |
| Email address: dba-notice@ybm100.com |
| Password: xxxx |
| Password (again): xxxxx |
| Superuser created successfully. |
3.5.调试启动(runserver 方式)
| source /opt/venv4archery/bin/activate |
| python3 manage.py runserver 0.0.0.0:9123 --insecure & |
3.6.安装gunicorn
3.7.gunicorn + nginx 启动(正式环境启动方式)
| cd /opt/archery138/ |
| source /opt/venv4archery/bin/activate |
| sh startup.sh & |
3.8.一键启动脚本,启动 archery
| #!/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 & |
4.数据库升级
4.1.导出线上库
| |
| sudo su - |
| mysqldump -S xx/mysql.sock --single-transaction --master-data=2 --set-gtid-purged=OFF db_ops > db_ops.sql |
4.2.在目标实例上恢复数据
| |
| sudo su - |
| mysql -S xx/mysql.sock db_ops <db_ops.sql |
4.3.执行数据库升级脚本
| |
| 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 |
4.4.导出恢复库升级数据,并导入 archery 数据库
| |
| 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 |
5.配置archery
访问 http://10.xx.xx.xx:9123
“系统管理”-->“配置项管理”
Inception配置
——填写完成后点击测试,通过后保存
| 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 |
功能模块配置
SQL****查询
SQL优化
| SQLADVISOR_PATH /opt/archery_tools/sqladvisor |
| SOAR_PATH /opt/archery_tools/soar |
| SOAR_TEST_DSN xxx:xxx@10.xx.xx.xx:3306/archery |
通知配置
——填写完成后点击测试,通过后保存
| 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
6.Bug修复
6.1. vim sql/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" |
| |
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· PostgreSQL 和 SQL Server 在统计信息维护中的关键差异
· C++代码改造为UTF-8编码问题的总结
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 清华大学推出第四讲使用 DeepSeek + DeepResearch 让科研像聊天一样简单!
· 实操Deepseek接入个人知识库
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库