SQL审核平台 Archery 之安装篇

Posted xww0119

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SQL审核平台 Archery 之安装篇相关的知识,希望对你有一定的参考价值。

一、安装前环境准备

1、更换阿里源
[root@localhost ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@localhost ~]# yum makecache

2、配置NTP时间同步  (非必须,结合实际情况操作)
[root@localhost ~]# yum -y install chrony 
[root@localhost ~]# sed -i "/server/d" /etc/chrony.conf
[root@localhost ~]# echo "server ntp.aliyun.com iburst"  >> /etc/chrony.conf
[root@localhost ~]# systemctl restart chronyd
[root@localhost ~]# date

3、关闭 SELINUX、FIREWALLD  
[root@localhost ~]# setenforce 0
[root@localhost ~]# sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
[root@localhost ~]# systemctl stop firewalld && systemctl disable firewalld

 
安装说明: ++本次安装是采用 Docker + DockerCompose 的方式++

二、安装 Docker

1、配置依赖和YUM源
[root@localhost ~]# yum install -y yum-utils device-mapper-persistent-data lvm2 
[root@localhost ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

2、安装 Docker
[root@localhost ~]# yum install -y docker-ce-19.03.11 docker-ce-cli-19.03.11 containerd
[root@localhost ~]# systemctl enable docker && systemctl start docker
[root@localhost ~]# docker --version
Docker version 19.03.11, build 42e35e61f3

3、修改 Cgroup Driver
[root@localhost ~]# sed -i "s#^ExecStart=/usr/bin/dockerd.*#ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --exec-opt native.cgroupdriver=systemd#g" /usr/lib/systemd/system/docker.service

4、设置加速器
[root@localhost ~]# vim /etc/docker/daemon.json

"registry-mirrors": ["https://registry.docker-cn.com"]


[root@localhost ~]# systemctl  daemon-reload  &&  systemctl  restart docker

三、安装 Docker-Compose

1、下载安装包
[root@localhost ~]# curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

# 如果网络情况不佳,可采用如下的指令进行安装
[root@localhost ~]# curl -L https://get.daocloud.io/docker/compose/releases/download/1.24.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose

2、配置启动权限
[root@localhost ~]# chmod +x /usr/local/bin/docker-compose
[root@localhost ~]# docker-compose version
docker-compose version 1.24.1, build 4667896b
docker-py version: 3.7.3
CPython version: 3.6.8
OpenSSL version: OpenSSL 1.1.0j  20 Nov 2018

四、安装 Archery

1、下载安装包
[root@localhost ~]# wget https://github.com/hhyo/archery/archive/v1.8.0.tar.gz
[root@localhost ~]# tar -zxvf v1.8.0.tar.gz -C /usr/local
[root@localhost ~]# mv /usr/local/Archery-1.8.0 /usr/local/Archery

2、启动 Docker-Compose
[root@localhost ~]# cd /usr/local/Archery/src/docker-compose
[root@localhost docker-compose]# docker-compose -f docker-compose.yml up -d   (此处时间较长)

3、表结构初始化
[root@localhost docker-compose]# docker ps  
CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS              PORTS                               NAMES
a333e364b407        redis:5                     "docker-entrypoint.s…"   2 weeks ago         Up 23 hours         6379/tcp                            redis
8ec336fb9bd7        hanchuanchuan/goinception   "/usr/local/bin/dumb…"   2 weeks ago         Up 23 hours         4000/tcp                            goinception
c3fe74f742ac        hhyo/archery:1.8.0          "dockerize -wait tcp…"   2 weeks ago         Up 23 hours         0.0.0.0:9123->9123/tcp              archery
70f045f968b5        mysql:5.7                   "docker-entrypoint.s…"   2 weeks ago         Up 23 hours         0.0.0.0:3306->3306/tcp, 33060/tcp   mysql
c225ba8127f4        hhyo/inception              "/bin/sh -c nohup /…"   2 weeks ago         Up 23 hours         6669/tcp                            inception

[root@localhost docker-compose]# docker exec -it c3 bash
[root@c3fe74f742ac archery]# cd /opt/archery/
[root@c3fe74f742ac archery]# ls
admin.sh    CODE_OF_CONDUCT.md  CONTRIBUTING.md     docs     LICENSE   manage.py  requirements.txt  sql_api     startup.sh          supervisord.conf    archery  common    debug.sh   downloads   
logs        README.md           sql                 src       static   supervisord.pid

[root@c3fe74f742ac archery]# source /opt/venv4archery/bin/activate
(venv4archery) [root@c3fe74f742ac archery]# python3 manage.py makemigrations sql
(venv4archery) [root@c3fe74f742ac archery]# python3 manage.py migrate

(venv4archery) [root@c3fe74f742ac archery]# python3 manage.py dbshell<sql/fixtures/auth_group.sql
(venv4archery) [root@c3fe74f742ac archery]# python3 manage.py dbshell<src/init_sql/mysql_slow_query_review.sql

4、编译翻译文件 (非必须步骤)
(venv4archery) [root@c3fe74f742ac archery]# python3 manage.py compilemessages
processing file django.po in /opt/archery/sql/locale/en/LC_MESSAGES
processing file djangojs.po in /opt/archery/sql/locale/en/LC_MESSAGES
processing file django.po in /opt/archery/sql/locale/zh_Hans/LC_MESSAGES
processing file djangojs.po in /opt/archery/sql/locale/zh_Hans/LC_MESSAGES

5、创建管理员用户
(venv4archery) [root@c3fe74f742ac archery]# python3 manage.py createsuperuser
用户名: admin
电子邮件地址: admin@qq.com
Password: admin123          ( 实际操作中密码是不显示的 )
Password (again): admin123
密码跟 用户名 太相似了。
密码长度太短。密码必须包含至少 9 个字符。
这个密码太常见了。
Bypass password validation and create user anyway? [y/N]: y
Superuser created successfully.

五、浏览器访问测试

以上是关于SQL审核平台 Archery 之安装篇的主要内容,如果未能解决你的问题,请参考以下文章

搭建sql审核平台archery

SQL审核平台 Archery 之使用进阶二

SQL审核平台 Archery 之集成 Ldap 篇

SQL审核平台 Archery 之配置 DingDing 通知篇

SQL审核平台 Archery 之简单使用篇

Node之安装篇