官方教程见:archerydms.com/home/ 本文参考官方教程实现并附上踩坑记录。
1、安装docker和docker-compose
2、实践安装archery
在github.com/hhyo/archer… 找到需要的版本,复制下载地址并下载到虚拟机目标位置,1.9.0部署过程中archery有报错,所以我选择1.8.5版本
mkdir archery
cd archery
wget https://github.com/hhyo/Archery/archive/refs/tags/v1.8.5.tar.gz
解压后进入src/docker-compose 目录,
tar -zxvf v1.8.5.tar.gz
cd Archery-1.8.5/src/docker-compose
执行启动脚本:
docker-compose -f docker-compose.yml up -d
踩坑1
查看服务状态
docker-compose ps
可以看到mysql和goinception一直在重启
docker logs mysql 查看mysql的日志
查看容器日志看到 chown: changing ownership of '/var/lib/mysql/': Permission denied,搜索后发现Centos7的安全Selinux禁止了一些安全权限,导致挂载信息时出现权限不足 解决办法是关闭selinux
setenforce 0
关闭服务后重启 docker-compose down docker-compose -f docker-compose.yml up -d
踩坑2
然后看到服务启动了 查看mysql日志发现有chown: changing ownership of './proc/sys/net/netfilter/nf_conntrack_sctp_timeout_shutdown_recd': Read-only file system,没有写入权限
于是给mysql目录页设置权限:
chmod -R 777 ./mysql
关闭服务后重启 docker-compose down docker-compose -f docker-compose.yml up -d
查看mysql和archery的日志 终于正常启动。
3、mysql表结构和数据初始化
表结构初始化
docker exec -ti archery /bin/bash
cd /opt/archery
source /opt/venv4archery/bin/activate
python3 manage.py makemigrations sql
python3 manage.py migrate
数据初始化
python3 manage.py dbshell<sql/fixtures/auth_group.sql
python3 manage.py dbshell<src/init_sql/mysql_slow_query_review.sql
踩坑3
表结构初始化后 检查数据库和表和字段的编码是不是utf8,不是则需要修改编码,参考最后的修改编码语句。
4、创建用户登录系统使用
创建管理用户,此时会让设置账号和登录密码
python3 manage.py createsuperuser
重启服务
docker restart archery
日志查看和问题排查
docker logs archery -f --tail=10
我的虚拟机ip是192.168.23.134,上面执行完重启archery服务后访问http://192.168.23.134:9123/,成功看到登录界面。
用之前设置的账号和登录密码登录后:
至此 部署完成。
附:修改编码语句(数据库,表,字段编码不是utf-8时使用)
alter database archery character set utf8;
alter table 2fa_config convert to character set utf8;
alter table aliyun_rds_config convert to character set utf8;
alter table archive_config convert to character set utf8;
alter table archive_log convert to character set utf8;
alter table audit_log convert to character set utf8;
alter table auth_group convert to character set utf8;
alter table auth_group_permissions convert to character set utf8;
alter table auth_permission convert to character set utf8;
alter table cloud_access_key convert to character set utf8;
alter table data_masking_columns convert to character set utf8;
alter table data_masking_rules convert to character set utf8;
alter table django_admin_log convert to character set utf8;
alter table django_content_type convert to character set utf8;
alter table django_migrations convert to character set utf8;
alter table django_q_ormq convert to character set utf8;
alter table django_q_schedule convert to character set utf8;
alter table django_q_task convert to character set utf8;
alter table django_session convert to character set utf8;
alter table instance_account convert to character set utf8;
alter table instance_database convert to character set utf8;
alter table param_history convert to character set utf8;
alter table param_template convert to character set utf8;
alter table query_log convert to character set utf8;
alter table query_privileges convert to character set utf8;
alter table query_privileges_apply convert to character set utf8;
alter table resource_group convert to character set utf8;
alter table sql_config convert to character set utf8;
alter table sql_instance convert to character set utf8;
alter table sql_instance_instance_tag convert to character set utf8;
alter table sql_instance_resource_group convert to character set utf8;
alter table sql_instance_tag convert to character set utf8;
alter table sql_permission convert to character set utf8;
alter table sql_users convert to character set utf8;
alter table sql_users_groups convert to character set utf8;
alter table sql_users_resource_group convert to character set utf8;
alter table sql_users_user_permissions convert to character set utf8;
alter table sql_workflow convert to character set utf8;
alter table sql_workflow_content convert to character set utf8;
alter table ssh_tunnel convert to character set utf8;
alter table workflow_audit convert to character set utf8;
alter table workflow_audit_detail convert to character set utf8;
alter table workflow_audit_setting convert to character set utf8;
alter table workflow_log convert to character set utf8;