Linux下安装Archery及相关环境配置

本文档详述了在Linux(CentOS 7.8)环境下安装Archery的过程,包括Python环境配置、MySQL、Percona-Toolkits、goInception、SOAR、Nginx、Redis的安装,以及Archery的配置、数据库初始化、管理用户创建等步骤。在安装过程中,遇到了yum错误、pip版本警告、mysql-devel依赖问题和审核状态问题,分别提供了相应的解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

前言

Archery 定位于 SQL 审核查询平台,旨在提升 DBA 的工作效率,支持多种数据库的 SQL 上线和查询,同时支持丰富的 MySQL 运维功能,所有功能都兼容手机端操作
在这里插入图片描述

官网: https://archerydms.com/
GitHub: https://github.com/hhyo/Archery

准备工作

环境信息

os:CentOS Linux release 7.8.2003 (Core)
python:Python 3.6.8
redis:Redis server v=5.0.11
mysql: 5.7.33
MySQL推荐版本>=5.6

1.安装升级Python36

yum install wget gcc make zlib-devel openssl openssl-devel
yum install epel-release
yum install python36 python36-pip

2.创建 Python venv 环境(Python>=3.6.5,建议使用虚拟环境 )

cd /opt
pip3.6 install virtualenv -i https://mirrors.ustc.edu.cn/pypi/web/simple/
# 编译安装python的使用
virtualenv venv4archery --python=python3
# yum安装的使用
virtualenv venv4archery --python=python3.6
# 切换python运行环境到虚拟环境
source /opt/venv4archery/bin/activate

deactivate可以退出venv 环境

3.关闭SeLinux

sed -i '/^SELINUX=/s/=.*/=disabled/' /etc/selinux/config

Archey环境安装

1.archery安装

1.1 下载源码及解压

cd /opt && wget https://github.com/hhyo/archery/archive/v1.8.0.tar.gz
tar -zxvf v1.8.0.tar.gz

1.2 安装相关依赖包

# 安装系统依赖
yum -y install gcc gcc-c++ python-devel mysql-devel openldap-devel unixODBC-devel gettext
# 如果使用yum安装的python3,安装mysqlclient可能提示提示缺少Python.h,可安装
yum -y install python36-devel
cd Archery-1.8.0
# 安装依赖库
pip3 install -r requirements.txt -i https://mirrors.ustc.edu.cn/pypi/web/simple/

2.安装Mysql

参考:文章

3.安装Percona-Toolkits

参考:文章

4.安装goInception

参考:文章

5.安装SOAR

参考:文章

6.安装Nginx

参考:文章

安装好之后采用如下nginx配置 进入目录

cd /opt/tengine/conf/servers
touch archery.conf
vi archery.conf

配置文件如下

server{
        listen 9123; # 监听的端口
        server_name archery;
        client_max_body_size 20M; # 处理Request Entity Too Large
        proxy_read_timeout 600s;  # 超时时间与Gunicorn超时时间设置一致,主要用于在线查询
 
        location / {
          proxy_pass http://127.0.0.1:8000;
          proxy_set_header Host $host:9123; # 解决重定向404的问题,和listen端口保持一致,如果是docker则和宿主机映射端口保持一致
          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/Archery-1.8.0/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 {
        }
} 

6.1 启动nginx

/usr/local/nginx/sbin/nginx -t  //检查语法
/usr/local/nginx/sbin/nginx 

7.安装Redis

yum install redis -y
#修改配置文件
requirepass newpass //添加密码
systemctl start redis

8.Archery配置

cd /opt/Archery-1.8.0/archery && vi settings.py

修改如下配置 文件内容过多 这里贴出我改动过的地方

# 关闭debug模式
DEBUG = False
 
# 该项目本身的mysql数据库地址
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'archery',
        'USER': 'root',
        'PASSWORD': 'newpass',
        'HOST': '127.0.0.1',
        'PORT': '3306',
        'OPTIONS': {
            'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
            'charset': 'utf8mb4'
        },
        'TEST': {
            'NAME': 'test_archery',
            'CHARSET': 'utf8mb4',
        },
    }
}
 
CACHES = {
    "default": {
        "BACKEND": "django_redis.cache.RedisCache",
        "LOCATION": "redis://127.0.0.1:6379/0",
        "OPTIONS": {
            "CLIENT_CLASS": "django_redis.client.DefaultClient",
            "PASSWORD": "newpass"
        }
    },
    "dingding": {
        "BACKEND": "django_redis.cache.RedisCache",
        "LOCATION": "redis://127.0.0.1:6379/1",
        "OPTIONS": {
            "CLIENT_CLASS": "django_redis.client.DefaultClient",
            "PASSWORD": "newpass"
        }
    }
}

9.创建数据库

mysql -h 127.0.0.1  -u root -p newpass
mysql > create database archery default character set=utf8mb4;

10.数据库初始化

cd /opt/Archery-1.8.0
source /opt/venv4archery/bin/activate
python3 manage.py makemigrations sql
python3 manage.py migrate

报错:ModuleNotFoundError: No module named 'Crypto'
解决方法:pip3.6 install pycrypto

pip3 uninstall crypto
pip3 uninstall pycrypto
pip3 install pycrypto

11.数据初始化

python3 manage.py dbshell<sql/fixtures/auth_group.sql
python3 manage.py dbshell<src/init_sql/mysql_slow_query_review.sql

12.创建管理用户

python3 manage.py createsuperuser

此时会要求输入用户名密码,用于web页面登录

Username: admin
Email address: admin@qq.com
Password: adminpassword

13.启动

source /opt/venv4archery/bin/activate
cd /opt/Archery-1.8.0
#启动
./startup.sh &

14.访问 http://ip:9123

需要开启防火墙端口
在这里插入图片描述
输入用户名密码 admin/adminpassword 进入主页
在这里插入图片描述
在这里插入图片描述

问题

1. File “/usr/bin/yum”, line 30 except KeyboardInterrupt, e:

修改/usr/bin/yum文件中的第一行为#!/usr/bin/python2.7

2. WARNING: You are using pip version 20.1.1; however,version 20.2.3 is available

升级pip 输入python -m pip install -U pip

3. 依赖包mysql-devel安装报错

方式一

cd /etc/yum.repos.d/
rpm -ivh http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm
yum install mysql-devel

方式二

先安装Mysql 再安装依赖包

4.审核状态一直处于排队中

解决方法
重新启动qcluster,杀死进程默认会自动重启;详细看配置文件supervisord.conf中的autorestart=true参数

参考:文章
文章
文章

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值