centos7安装配置archery

官方文档:
https://github.com/hhyo/archery/wiki/manual

一、基础环境安装

1、升级Python

[root@localhost ~]# yum install epel-release -y
[root@localhost ~]# yum install python36 python36-pip -y

2、安装virtualenv

[root@localhost ~]# pip3.6 install virtualenv -i https://mirrors.aliyun.com/pypi/simple/

3、关闭SELinux

[root@localhost ~]# sed -i '/^SELINUX=enforcing/s/enforcing/disabled/' /etc/selinux/config &&cat /etc/selinux/config                  
[root@localhost ~]# setenforce 0

二、安装Archery

1、准备虚拟环境

[root@localhost ~]# cd /usr/local/
[root@localhost local]# virtualenv venv4archery --python=python3.6
[root@localhost local]# source /usr/local/venv4archery/bin/activate
(venv4archery) [root@localhost local]# deactivate(可利用deactivate退出)

2、安装依赖包

[root@localhost local]# yum install gcc \
gcc-c++ \
python-devel \
python36-devel \
mysql-devel \
openldap-devel \
unixODBC-devel \
git \
gettext -y

若mysql-devel安装报错,如下操作后重新执行即可

[root@localhost local]#cd /etc/yum.repos.d/
[root@localhost yum.repos.d]#rpm -ivh http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm
[root@localhost yum.repos.d]#yum install mysql-devel -y

3、下载源码包,安装Python相关依赖包

[root@localhost local]# cd /usr/local
[root@localhost local]# wget -c https://github.com/hhyo/archery/archive/v1.8.0.tar.gz
[root@localhost local]# tar -xzvf v1.8.0.tar.gz
[root@localhost local]# mv Archery-1.8.0 Archery
[root@localhost local]# cd Archery
[root@localhost Archery]# pip3 install -r requirements.txt -i https://mirrors.ustc.edu.cn/pypi/web/simple/
    ModuleNotFoundError: No module named 'setuptools_rust'
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-tn71562h/cryptography/

报错了
解决办法, 升级pip即可

[root@localhost Archery]# /usr/bin/python3.6 -m pip install --upgrade pip
Successfully installed pip-21.0.1
[root@localhost Archery]# pip3 install -r requirements.txt -i https://mirrors.ustc.edu.cn/pypi/web/simple/
    Running setup.py install for mybatis-mapper2sql ... done
    Running setup.py install for django-mirage-field ... done
    Running setup.py install for aliyun-python-sdk-rds ... done
Successfully installed Django-3.1.2 MarkupSafe-1.1.1 Schema-Object-0.5.11 aliyun-python-sdk-core-v3-2.13.32 aliyun-python-sdk-rds-2.1.1 arrow-1.0.3 asgiref-3.2.10 bcrypt-3.2.0 blessed-1.18.0 certifi-2020.12.5 cffi-1.14.5 chardet-3.0.4 click-7.1.2 cryptography-3.4.6 cx-Oracle-7.3.0 django-auth-ldap-2.2.0 django-mirage-field-1.1.6 django-picklefield-3.0.1 django-q-1.3.4 django-redis-4.12.1 future-0.18.2 gevent-1.4.0 greenlet-1.0.0 gunicorn-20.0.4 h11-0.12.0 httptools-0.1.1 idna-2.10 jinja2-2.11.3 jmespath-0.10.0 mybatis-mapper2sql-0.1.9 mysql-replication-0.22 mysqlclient-2.0.1 paramiko-2.7.2 parsedatetime-2.4 phoenixdb-0.7 prettytable-2.1.0 protobuf-3.15.6 psycopg2-binary-2.8.6 pyasn1-0.4.8 pyasn1-modules-0.2.8 pycparser-2.20 pyecharts-1.7.1 pymongo-3.11.0 pymysql-0.9.3 pynacl-1.4.0 pyodbc-4.0.30 python-dateutil-2.8.1 python-ldap-3.3.1 pytz-2021.1 redis-3.5.3 requests-2.24.0 schema-sync-0.9.7 simplejson-3.17.2 sqlparse-0.4.1 sshtunnel-0.1.5 supervisor-4.1.0 tqdm-4.59.0 urllib3-1.25.11 uvicorn-0.12.2 uvloop-0.14.0 wcwidth-0.2.5

三、MySQL的安装

5.7版本

[root@localhost Archery]# cd /usr/local/
[root@localhost local]# wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.32-linux-glibc2.12-x86_64.tar.gz
[root@localhost local]# tar -xf mysql-5.7.32-linux-glibc2.12-x86_64.tar.gz 
[root@localhost local]# mv mysql-5.7.32-linux-glibc2.12-x86_64 mysql
[root@localhost local]# mkdir -p /usr/local/mysql/data
[root@localhost local]# groupadd mysql
[root@localhost local]# useradd -r -g mysql mysql
[root@localhost local]# chown -R mysql:mysql /usr/local/mysql
[root@localhost local]# chmod -R 755 /usr/local/mysql

安装依赖库

[root@localhost local]# yum -y install numactl		

初始化数据库,要记住密码

[root@localhost bin]# cat >/etc/my.cnf <<-EOF
 
[mysqld]
innodb_buffer_pool_size = 32M
 
datadir=/usr/local/mysql/data
port=3306
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
symbolic-links=0
max_connections=600
innodb_file_per_table=1
lower_case_table_names=1
character_set_server=utf8
 
 
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'
 
 
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
EOF
[root@localhost local]# cd /usr/local/mysql/bin
[root@localhost bin]# ./mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql
这里要记住密码:	!nsve4<qyE5A

设置软连接

[root@localhost bin]# ln -s /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql 
[root@localhost bin]# ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
[root@localhost bin]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@localhost bin]# /etc/init.d/mysql start

设置密码

[root@localhost bin]# mysql -h 127.0.0.1  -u root -p
mysql> set password for root@localhost = password('123456');
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set user.Host='%' where user.User='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

设置开机启动

[root@localhost bin]# chmod +x /etc/init.d/mysqld
[root@localhost bin]# chkconfig --add mysqld
[root@localhost bin]# /etc/init.d/mysqld stop
Shutting down MySQL.. SUCCESS! 
[root@localhost bin]# /etc/init.d/mysqld start
Starting MySQL. SUCCESS! 
[root@localhost bin]# /etc/init.d/mysqld restart
Shutting down MySQL.. SUCCESS! 
Starting MySQL. SUCCESS! 

四、Percona-Toolkits工具集

[root@localhost bin]# yum install perl-DBI \
perl-DBD-MySQL \
perl-Time-HiRes \
perl-IO-Socket-SSL \
perl-Digest-MD5 -y
[root@localhost bin]# cd /usr/local/
[root@localhost local]# 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
[root@localhost local]# tar zxvf percona-toolkit-3.0.13_x86_64.tar.gz

五、goInception

1、go环境安装

[root@localhost local]# wget -c https://dl.google.com/go/go1.13.4.linux-amd64.tar.gz
[root@localhost local]# tar -zxvf go1.13.4.linux-amd64.tar.gz -C /usr/local/
[root@localhost local]# echo "export PATH=$PATH:/usr/local/go/bin" >> /etc/profile
[root@localhost local]# source /etc/profile
[root@localhost local]# go version
go version go1.13.4 linux/amd64表示安装成功

2、安装goInception

[root@localhost local]# wget -c https://github.com/hanchuanchuan/goInception/releases/download/v1.1.5/goInception-linux-amd64-v1.1.5.tar.gz

[root@localhost local]# mkdir /usr/local/goInception
[root@localhost local]# tar -zxvf goInception-linux-amd64-v1.1.5.tar.gz -C /usr/local/goInception
goInception
config/config.toml.default
[root@localhost local]# cp /usr/local/goInception/config/config.toml.default /usr/local/goInception/config/config.toml

config.toml配置如下,基本配置为host、port,以及[inc] 内的备份库连接信息(需要SELECT, INSERT, CREATE权限)
vim /usr/local/goInception/config/config.toml

[root@localhost local]# vim /usr/local/goInception/config/config.toml  改下面几行即可
host = "127.0.0.1"
[inc]
backup_host = "127.0.0.1"
backup_port = 3306
backup_user = "inception_bak"
backup_password = "123456"

指定该配置文件启动:

[root@localhost local]# /usr/local/goInception/goInception -config=/usr/local/goInception/config/config.toml &
[1] 23981
[root@localhost local]# 2021/03/24 12:13:54.242 tidb.go:262: [info] new store
2021/03/24 12:13:54.284 tidb.go:63: [info] store eb06a8ca-b7e3-42f6-bdba-11d26069c969 new domain, ddl lease 0s, stats lease 0
2021/03/24 12:13:54.285 ddl.go:354: [info] [ddl] start DDL:f8727b0d-cecd-4e47-ad8f-42e9fb4387f1, run worker true
2021/03/24 12:13:54.289 ddl_worker.go:81: [info] [ddl] start delRangeManager OK, with emulator: true
2021/03/24 12:13:54.293 ddl_worker.go:81: [info] [ddl] start delRangeManager OK, with emulator: true
2021/03/24 12:13:54.293 domain.go:124: [info] [ddl] full load InfoSchema from version 0 to 0, in 118.251µs
2021/03/24 12:13:54.293 domain.go:318: [info] [ddl] full load and reset schema validator.
2021/03/24 12:13:54.474 tidb.go:63: [info] store eb06a8ca-b7e3-42f6-bdba-11d26069c969 new domain, ddl lease 0s, stats lease 0
2021/03/24 12:13:54.474 ddl.go:354: [info] [ddl] start DDL:95d28326-933d-49a9-8c2d-221e918eff36, run worker true
2021/03/24 12:13:54.474 ddl_worker.go:81: [info] [ddl] start delRangeManager OK, with emulator: true
2021/03/24 12:13:54.475 ddl_worker.go:81: [info] [ddl] start delRangeManager OK, with emulator: true
2021/03/24 12:13:54.475 ddl_worker.go:116: [info] [ddl-worker 3, tp general] start DDL worker
2021/03/24 12:13:54.475 delete_range.go:115: [info] [ddl] start delRange emulator
2021/03/24 12:13:54.475 ddl_worker.go:116: [info] [ddl-worker 4, tp add index] start DDL worker
2021/03/24 12:13:54.475 delete_range.go:115: [info] [ddl] start delRange emulator
2021/03/24 12:13:54.487 domain.go:124: [info] [ddl] full load InfoSchema from version 0 to 15, in 8.962421ms
2021/03/24 12:13:54.488 domain.go:318: [info] [ddl] full load and reset schema validator.
2021/03/24 12:13:54.493 server.go:196: [info] Secure connection is NOT ENABLED
2021/03/24 12:13:54.494 server.go:163: [info] Server is running MySQL Protocol at [127.0.0.1:4000]
2021/03/24 12:13:54.494 delete_range.go:104: [info] [ddl] closing delRange session pool
2021/03/24 12:13:54.494 ddl_worker.go:110: [info] [ddl-worker 3, tp general] close DDL worker
2021/03/24 12:13:54.494 delete_range.go:104: [info] [ddl] closing delRange session pool
2021/03/24 12:13:54.494 ddl_worker.go:110: [info] [ddl-worker 4, tp add index] close DDL worker
2021/03/24 12:13:54.494 ddl.go:400: [info] [ddl] closing DDL:95d28326-933d-49a9-8c2d-221e918eff36 takes time 109.459µs
2021/03/24 12:13:54.494 ddl.go:347: [info] [ddl] stop DDL:95d28326-933d-49a9-8c2d-221e918eff36

[root@localhost local]# ps -ef|grep goInception
root     23981  1570  9 12:13 pts/0    00:00:00 /usr/local/goInception/goInception -config=/usr/local/goInception/config/config.toml

使用4000端口连接(默认)测试:

[root@localhost local]# mysql -h127.0.0.1 -P4000

六、安装SOAR

[root@localhost local]# cd /usr/local
[root@localhost local]# mkdir soar
[root@localhost local]# cd soar
[root@localhost soar]# wget -c https://github.com/XiaoMi/soar/releases/download/0.11.0/soar.linux-amd64
[root@localhost soar]# mv soar.linux-amd64  soar
[root@localhost soar]# chmod a+x /usr/local/soar/soar

配置文件/usr/local/soar/soar.yaml

[root@localhost soar]# cat >/usr/local/soar/soar.yaml <<-EOF
# 线上环境配置
online-dsn:
addr: 127.0.0.1:3306
schema: test
user: root
password: 123456
disable: false
# 测试环境配置
test-dsn:
addr: 127.0.0.1:3306
schema: test
user: root
password: 123456
disable: false
# 是否允许测试环境与线上环境配置相同
allow-online-as-test: true
# 是否清理测试时产生的临时文件
drop-test-temporary: true
# 语法检查小工具
only-syntax-check: false
sampling-statistic-target: 100
sampling: false
# 日志级别,[0:Emergency, 1:Alert, 2:Critical, 3:Error, 4:Warning, 5:Notice, 6:Informational, 7:Debug]
log-level: 7
log-output: /usr/local/soar/soar.log
# 优化建议输出格式
report-type: markdown
ignore-rules:
- ""
# 黑名单中的 SQL 将不会给评审意见。一行一条 SQL,可以是正则也可以是指纹,填写指纹时注意问号需要加反斜线转义。
blacklist: /usr/local/soar/soar.blacklist
# 启发式算法相关配置
max-join-table-count: 5
max-group-by-cols-count: 5
max-distinct-count: 5
max-index-cols-count: 5
max-total-rows: 9999999
spaghetti-query-length: 2048
allow-drop-index: false
# EXPLAIN相关配置
explain-sql-report-type: pretty
explain-type: extended
explain-format: traditional
explain-warn-select-type:
- ""
explain-warn-access-type:
- ALL
explain-max-keys: 3
explain-min-keys: 0
explain-max-rows: 10000
explain-warn-extra:
- ""
explain-max-filtered: 100
explain-warn-scalability:
- O(n)
query: ""
list-heuristic-rules: false
list-test-sqls: false
verbose: true
EOF

测试
[root@localhost soar]# echo ‘select * from film’ | ./soar

# Query: 687D590364E29465

★ ★ ★ ☆ ☆ 75分

`sql

SELECT  
  * 
FROM  
  film
`

## 最外层 SELECT 未指定 WHERE 条件

* **Item:**  CLA.001

* **Severity:**  L4

* **Content:**  SELECT 语句没有 WHERE 子句,可能检查比预期更多的行(全表扫描)。对于 SELECT COUNT(\*) 类型的请求如果不要求精度,建议使用 SHOW TABLE STATUS 或 EXPLAIN 替代。

## 不建议使用 SELECT * 类型查询

* **Item:**  COL.001

* **Severity:**  L1

* **Content:**  当表结构变更时,使用 \* 通配符选择所有列将导致查询的含义和行为会发生更改,可能导致查询返回更多的数据。

MySQL environment verbose info
* test-dsn: 127.0.0.1:3306 is disable, please check log.
* online-dsn: 127.0.0.1:3306 is disable, please check log.

七、NGINX

安装:执行下面脚本
[root@localhost soar]# vim /data/installnginx.sh

#!/bin/bash
#Centos7源码安装nginx-1.18.0
#202052820:04:24
#author Toyix
############################
repobase="/etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo"
repoepel="/etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo"
soft1="vim wget lrzsz"
soft2="pcre-devel pcre gcc gcc-c++ openssl openssl-devel zlib-devel"
nginxversion="nginx-1.18.0"
nginxsoft="http://nginx.org/download/${nginxversion}.tar.gz"
nginxdir="/usr/local/nginx"
configuremoudule="--user=nginx \
--group=nginx \
--prefix=${nginxdir} \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_mp4_module \
--with-http_realip_module \
--with-pcre \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-stream"
netstat_nginx="netstat -tnlp |grep nginx"
selinuxconfigfile="/etc/selinux/config"
selinux_enforcing="SELINUX=enforcing"
selinux_disabled="SELINUX=disabled"
firewalld_open80="--zone=public --add-port=80/tcp --permanent"
firewalld_ports="--zone=public --list-ports"
yum install $soft1 -y
echo "安装国内base及epel源"
seleep 5
curl -o $repobase
wget -O $repoepel
yum clean all
yum makecache
echo "创建nginx用户nginx"
useradd -s /sbin/nologin -r nginx
echo "安装环境支持"
yum install $soft2 -y
echo "下载nginx"
cd /usr/src/
wget $nginxsoft
tar -xf ${
     nginxversion}.tar.gz
cd ${
     nginxversion}
echo "预编译"
./configure ${
     configuremoudule} 
echo "编译"
make
echo "安装"
make install
${
     nginxdir}/sbin/nginx
sed -i "s/${selinux_enforcing}/${selinux_disabled}/g" ${
     selinuxconfigfile}
setenforce 0
firewall-cmd ${
     firewalld_open80}
firewall-cmd --reload
firewall-cmd $firewalld_ports
echo "------------------end"

执行脚本

[root@localhost soar]# sh /data/installnginx.sh 

配置文件
[root@localhost soar]# vim /usr/local/nginx/conf/nginx.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 /usr/local/Archery/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 {
     
        }
    } 

配置测试等

[root@localhost soar]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost soar]# /usr/local/nginx/sbin/nginx -s reload
[root@localhost soar]# firewall-cmd --add-port=9123/tcp --permanent
success
[root@localhost soar]# firewall-cmd --reload

八、Redis

[root@localhost local]# wget -c http://distfiles.macports.org/redis/redis-5.0.7.tar.gz
[root@localhost local]# tar -xf redis-5.0.7.tar.gz
[root@localhost local]# cd redis-5.0.7
[root@localhost redis-5.0.7]# make
[root@localhost redis-5.0.7]# make install PREFIX=/usr/local/redis
[root@localhost redis-5.0.7]# mkdir /usr/local/redis/etc
[root@localhost redis-5.0.7]# cp redis.conf /usr/local/redis/etc
[root@localhost redis-5.0.7]# vim /usr/local/redis/etc/redis.conf
#实现后台运行
daemonize yes

运行(配置文件有更新,直接再次运行,重载配置)

[root@localhost redis-5.0.7]# /usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf 
33965:C 25 Mar 2021 14:34:31.886 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
33965:C 25 Mar 2021 14:34:31.886 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=33965, just started
33965:C 25 Mar 2021 14:34:31.886 # Configuration loaded
[root@localhost redis-5.0.7]# ps -ef|grep redis
root     33966     1  0 14:34 ?        00:00:00 /usr/local/redis/bin/redis-server 127.0.0.1:6379
root     33971  1570  0 14:34 pts/0    00:00:00 grep --color=auto redis

登录

[root@localhost redis-5.0.7]# /usr/local/redis/bin/redis-cli 
127.0.0.1:6379> CONFIG SET requirepass "123456"
OK
127.0.0.1:6379> AUTH 123456
OK
127.0.0.1:6379> exit
后续登录先输入密码

或者
可以在配置文件中永久设置密码

[root@localhost redis-5.0.7]# vim /usr/local/redis/etc/redis.conf 
requirepass 123456

九、Archery配置

1、配置信息修改

[root@localhost redis-5.0.7]# cd /usr/local/Archery/
[root@localhost Archery]# vim /usr/local/Archery/archery/settings.py

DEBUG = False
# 该项目本身的mysql数据库地址
DATABASES = {
     
    'default': {
     
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'archery',
        'USER': 'root',
        'PASSWORD': '123456',
        '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": "123456"
        }
    },
    "dingding": {
     
        "BACKEND": "django_redis.cache.RedisCache",
        "LOCATION": "redis://127.0.0.1:6379/1",
        "OPTIONS": {
     
            "CLIENT_CLASS": "django_redis.client.DefaultClient",
            "PASSWORD": ""
        }
    }
}

2、数据库初始化

1.创建 archery 数据库

[root@localhost Archery]# mysql -uroot -p123456
mysql> create database archery default character set=utf8mb4;
[root@localhost Archery]# cd /usr/local/Archery/
[root@localhost Archery]# source /usr/local/venv4archery/bin/activate   #deactivate   可以退出
(venv4archery) [root@localhost Archery]# python3 manage.py makemigrations sql
Traceback (most recent call last):
  File "manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'
报错了,执行下面两行
(venv4archery) [root@localhost Archery]# pip3 install Crypto
(venv4archery) [root@localhost Archery]# pip3 install pycrypto
(venv4archery) [root@localhost Archery]# pip3 install pymysql
(venv4archery) [root@localhost Archery]# python3 -m pip install --upgrade pip
(venv4archery) [root@localhost Archery]# /usr/bin/python3.6 -m pip install --upgrade pip
继续报以上错误了,,deactivate退出模式执行执行下面两行
[root@localhost Archery]# pip3 install Crypto
[root@localhost Archery]# pip3 install pycrypto
[root@localhost Archery]# python3 manage.py makemigrations sql
没有报错了,继续
[root@localhost Archery]# python3 manage.py migrate
(venv4archery) [root@localhost Archery]# python3 manage.py makemigrations sql
  1. 数据初始化
[root@localhost Archery]# python3 manage.py dbshell<sql/fixtures/auth_group.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@localhost Archery]# python3 manage.py dbshell<src/init_sql/mysql_slow_query_review.sql
mysql: [Warning] Using a password on the command line interface can be insecure.

3 、 创建管理用户

[root@localhost Archery]# python3 manage.py createsuperuser
用户名: admin
电子邮件地址: lejianyuan@curefun.com
Password: 
Password (again): 
密码跟 用户名 太相似了。
密码长度太短。密码必须包含至少 9 个字符。
这个密码太常见了。
Bypass password validation and create user anyway? [y/N]: y
Superuser created successfully.

4、启动

[root@localhost Archery]# source /usr/local/venv4archery/bin/activate
(venv4archery) [root@localhost Archery]# cd /usr/local/Archery/
(venv4archery) [root@localhost Archery]# ./startup.sh &
Traceback (most recent call last):
  File "manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'

[2]+  Done                    ./startup.sh
报错了,deactivate退出模式来启动
(venv4archery) [root@localhost Archery]# deactivate 
[root@localhost Archery]# ./startup.sh &
[2] 35120
[root@localhost Archery]# Error: Another program is already listening on a port that one of our HTTP servers is configured to use.  Shut this program down first before starting supervisord.
For help, use /usr/local/bin/supervisord -h

[2]+  Exit 2                  ./startup.sh
(venv4archery) [root@localhost Archery]# ps -ef|grep archery
root     35058 35056  1 15:00 ?        00:00:00 /usr/bin/python3 /usr/local/bin/gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 127.0.0.1:8000 --timeout 600 archery.asgi:application
root     35062 35058  2 15:00 ?        00:00:00 /usr/bin/python3 /usr/local/bin/gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 127.0.0.1:8000 --timeout 600 archery.asgi:application
root     35063 35058  2 15:00 ?        00:00:00 /usr/bin/python3 /usr/local/bin/gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 127.0.0.1:8000 --timeout 600 archery.asgi:application
root     35064 35058  2 15:00 ?        00:00:00 /usr/bin/python3 /usr/local/bin/gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 127.0.0.1:8000 --timeout 600 archery.asgi:application
root     35067 35058  2 15:00 ?        00:00:00 /usr/bin/python3 /usr/local/bin/gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b 127.0.0.1:8000 --timeout 600 archery.asgi:application
root     35080  1570  0 15:00 pts/0    00:00:00 grep --color=auto archery

十、访问

http://IP:9123/
centos7安装配置archery_第1张图片
centos7安装配置archery_第2张图片

十一、启动管理脚本

开机启动脚本
[root@localhost ~]# vim /etc/init.d/archery

#!/bin/bash
# chkconfig: 235 95 65
start (){
     
        /usr/local/goInception/goInception -config=/usr/local/goInception/config/config.toml &
        sleep 1
        ps -ef|grep -v grep|grep goInception >/dev/null
        if [ $? -ne 0 ];then 
                echo 'goInception未启动成功,请检查'
        else
                echo 'goInception启动成功!'
        fi
         echo "检查soar"
         echo 'select * from film' | /usr/local/soar/soar
         echo "启动nginx"
         /usr/local/nginx/sbin/nginx
         echo "启动redis"
         /usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf
         sleep 1
         echo "启动archery"
         cd /usr/local/Archery/ && ./startup.sh &
}
 
stop (){
     
        ps -ef|grep -v grep|grep goInception|awk '{print $2}'|xargs kill -9
        pkill nginx
        pkill redis
        ps -ef|grep supervisord|grep -v grep|awk '{print $2}'|xargs kill -9
        ps -ef|grep -v grep |grep archery|awk '{print $2}'|xargs kill -9
}

status (){
     
        ps -ef|grep -v grep|grep mysql >/dev/null
        if [ $? -eq 0 ];then
                echo "mysql已启动"
        fi
        ps -ef|grep -v grep|grep nginx >/dev/null
        if [ $? -eq 0 ];then
                echo "nginx已启动"
        fi
        ps -ef|grep -v grep |grep goInception >/dev/null
        if [ $? -eq 0 ];then
                echo "goInception已启动"
        fi
        ps -ef|grep -v grep|grep supervisord >/dev/null
        if [ $? -eq 0 ];then
                echo "supervisord已启动"
        fi
}
 
case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        restart)
                stop
                start
                ;;
        status)
                status
                ;;
        *)
        echo "Please use start | stop |status as first argument"
        ;;
esac

开机启动

[root@localhost ~]#  chkconfig archery on
[root@localhost ~]#  /etc/init.d/archery stop
[root@localhost ~]#  /etc/init.d/archery start

--------------------------------end

你可能感兴趣的:(linux常用基础技能,archery,centos7)