首先准备OS环境
centos7.9
主机两台:
192.92.29.89
192.92.29.90
89这台机操作如下
安装docker
yum install -y docker-ce
ps:我这边是有docker本地仓库的 所以可以直接下载,如果没有用阿里云仓库即可
安装docker-compose在89这台机
sudo curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
下载archery
wget https://codeload.github.com/hhyo/Archery/tar.gz/refs/tags/v1.7.12
systemctl stop firewalld
setenforce 0
40 systemctl start docker
33 cd /usr/local/
35 mv Archery-1.7.12/ archery
36 cd archery/src/docker-compose/
38 docker-compose -f docker-compose.yml up -d
39 docker ps
这是我发现我的mysql一直起不来 一直报 Restarting (1) 29 seconds ago 查看日志
docker log -f mysql
chown: changing ownership of './proc/irq/59/affinity_hint': Read-only file system
chown: changing ownership of './proc/irq/59/ens192-rxtx-3': Read-only file system
chown: changing ownership of './proc/irq/59/smp_affinity_list': Read-only file system
chown: changing ownership of './proc/irq/60': Read-only file system
chown: changing ownership of './proc/irq/60/node': Read-only file system
chown: changing ownership of './proc/irq/60/spurious': Read-only file system
这个不知道有这个问题为什么网上也没有资料,archery 我也换了很多版本解决不了所我打算本地化部署mysql
docker stop mysql
docker rm mysql
我修改了docker-compose.yml 文件 如下
cat /usr/local/archery/src/docker-compose/docker-compose.yml
version: '3'services:
redis:
image: redis:5
container_name: redis
restart: always
command: redis-server --requirepass 123456
expose:
- "6379"
inception:
image: hhyo/inception
container_name: inception
restart: always
expose:
- "6669"
volumes:
- "./inception/inc.cnf:/etc/inc.cnf"goinception:
image: hanchuanchuan/goinception
container_name: goinception
restart: always
expose:
- "4000"
volumes:
- "./inception/config.toml:/etc/config.toml"archery:
image: hhyo/archery:1.7.12
container_name: archery
restart: always
ports:
- "9123:9123"
volumes:
- "/usr/local/archery/src/docker-compose/archery/settings.py:/opt/archery/archery/settings.py"
- "/usr/local/archery/src/docker-compose/archery/settings.py:/opt/archery/src/docker-compose/archery/settings.py"
- "./archery/soar.yaml:/etc/soar.yaml"
- "./archery/docs.md:/opt/archery/docs/docs.md"
- "./archery/downloads:/opt/archery/downloads"
- "./archery/sql/migrations:/opt/archery/sql/migrations"
- "./archery/logs:/opt/archery/logs"
entrypoint: "dockerize -wait tcp://mysql:3306 -wait tcp://redis:6379 -timeout 60s /opt/archery/src/docker/startup.sh"
environment:
NGINX_PORT: 9123
在90机子操作
yum -y install mysql-community-server
ps:我有本地仓库所以直接yum下载MySQL 如果没有本地化,请自己部署 我选择的5.7
295 systemctl start mysqld
296 systemctl stop firewalld
298 setenforce 0
299 cat /var/log/mysqld.log | grep "pass"
301 mysqladmin -uroot -p'r#)Gvqsdg1u9' password '**********'
302 netstat -tnlp
303 ip a
304 mysql -u root -p'*******'
CREATE DATABASE archery CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
SELECT User, Host FROM mysql.user WHERE User='root';
+------+-----------+
| User | Host |
+------+-----------+
| root | % |
| root | localhost |
+------+-----------+
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'your_password' WITH GRANT OPTION;
FLUSH PRIVILEGES;
在89的机器上查看(如果连接不上mysql服务修改一下)
docker logs archery -f --tail=50
cat /usr/local/archery/src/docker-compose/archery/settings.py
里面的mysql模块
# 该项目本身的mysql数据库地址
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'archery',
'USER': 'root',
'PASSWORD': 'Luxshare#^2024',
'HOST': '地址',
'PORT': '3306',
'OPTIONS': {
'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
'charset': 'utf8mb4'
},
'TEST': {
'NAME': 'test_archery',
'CHARSET': 'utf8mb4',
},
}
}
docker restart archery
docker logs archery -f --tail=50
#如果还报错 那就加一个操作
docker exec -ti archery /bin/bash #进入容器拷贝host文件
cat /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.18.0.5 4ce90484acae
exit
在89的宿主机上操作
加入mysql映射地址
cat /usr/local/archery/src/docker-compose/archery/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.18.0.5 4ce90484acae
MySQL地址 mysql
添加archery的host映射文件
cat /usr/local/archery/src/docker-compose/docker-compose.yml
version: '3'services:
redis:
image: redis:5
container_name: redis
restart: always
command: redis-server --requirepass 123456
expose:
- "6379"
inception:
image: hhyo/inception
container_name: inception
restart: always
expose:
- "6669"
volumes:
- "./inception/inc.cnf:/etc/inc.cnf"goinception:
image: hanchuanchuan/goinception
container_name: goinception
restart: always
expose:
- "4000"
volumes:
- "./inception/config.toml:/etc/config.toml"archery:
image: hhyo/archery:1.7.12
container_name: archery
restart: always
ports:
- "9123:9123"
volumes:
- "/usr/local/archery/src/docker-compose/archery/settings.py:/opt/archery/archery/settings.py"
- "./archery/hosts:/etc/hosts"
- "/usr/local/archery/src/docker-compose/archery/settings.py:/opt/archery/src/docker-compose/archery/settings.py"
- "./archery/soar.yaml:/etc/soar.yaml"
- "./archery/docs.md:/opt/archery/docs/docs.md"
- "./archery/downloads:/opt/archery/downloads"
- "./archery/sql/migrations:/opt/archery/sql/migrations"
- "./archery/logs:/opt/archery/logs"
entrypoint: "dockerize -wait tcp://mysql:3306 -wait tcp://redis:6379 -timeout 60s /opt/archery/src/docker/startup.sh"
environment:
NGINX_PORT: 9123
docker rm archery
docker-compose -f docker-compose.yml up -d
docker logs archery -f --tail=50
2024/09/05 17:40:13 Received signal: terminated
2024/09/05 17:40:13 Command exited with error: signal: terminated
2024/09/05 17:40:14 Waiting for: tcp://mysql:3306
2024/09/05 17:40:14 Waiting for: tcp://redis:6379
2024/09/05 17:40:14 Connected to tcp://mysql:3306
2024/09/05 17:40:14 Connected to tcp://redis:6379
已成功
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 # 创建管理用户 python3 manage.py createsuperuser # 退出容器 exit # 日志查看和问题排查 docker logs archery -f --tail=50
后续访问
配置SSL/TLS
313 yum -y install nginx
cat /etc/nginx/conf.d/archery.conf
upstream archery {
server ********:9123;
}server {
listen 443 ssl;
server_name *******;
ssl_certificate "/SSl/******.pem"; #修改成自己的
ssl_certificate_key "/SSl/*****key"; #修改成自己的
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;location / {
proxy_pass http://archery;
proxy_set_header Host $host;
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;
proxy_redirect off;
}
}