MySQL審核工具archery
系統(tǒng):Centos6.8
ip:192.168.122.150
成都網(wǎng)站建設(shè)哪家好,找成都創(chuàng)新互聯(lián)公司!專注于網(wǎng)頁設(shè)計、成都網(wǎng)站建設(shè)、微信開發(fā)、成都小程序開發(fā)、集團(tuán)成都定制網(wǎng)站等服務(wù)項目。核心團(tuán)隊均擁有互聯(lián)網(wǎng)行業(yè)多年經(jīng)驗,服務(wù)眾多知名企業(yè)客戶;涵蓋的客戶類型包括:效果圖設(shè)計等眾多領(lǐng)域,積累了大量豐富的經(jīng)驗,同時也獲得了客戶的一致認(rèn)可!
安裝Python和virtualenv
編譯安裝
[root@www ~]# yum install wget gcc make zlib-devel openssl openssl-devel
[root@www src]# wget "https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tar.xz"
[root@www src]# tar -xvf Python-3.6.5.tar.xz
[root@www src]# cd Python-3.6.5
[root@www Python-3.6.5]# ./configure prefix=/usr/local/python3
[root@www Python-3.6.5]# make && make install
[root@www Python-3.6.5]# ln -fs /usr/local/python3/bin/python3 /usr/bin/python3
[root@www Python-3.6.5]# ln -fs /usr/local/python3/bin/pip3 /usr/bin/pip3
[root@www ~]# pip3 install virtualenv -i https://mirrors.ustc.edu.cn/pypi/web/simple/
[root@www ~]# pip3 install -U pip
[root@www ~]# ln -fs /usr/local/python3/bin/virtualenv /usr/bin/virtualenv
安裝Archery
準(zhǔn)備虛擬環(huán)境
[root@www ~]# virtualenv venv4archery --python=python3
[root@www ~]# source venv4archery/bin/activate
[root@www Archery-1.5.3]# yum install unixODBC-devel -y
下載release包,安裝依賴庫
[root@www ~]# wget "https://github.com/hhyo/archery/archive/v1.5.3.tar.gz"
[root@www ~]# tar -xzvf v1.5.3.tar.gz
[root@www ~]# yum -y install gcc gcc-c++ python-devel mysql-devel openldap-devel unixODBC-devel gettext
[root@www ~]# cd Archery-1.5.3/
[root@www Archery-1.5.3]# pip3 install -r requirements.txt -i https://mirrors.ustc.edu.cn/pypi/web/simple/
如果出現(xiàn)報一下錯誤
解決方法:
安裝mysql5.7,然后安裝以下依賴即可
[root@www Archery-1.5.3]# yum install mysql-devel -y
(venv4archery) [root@www Archery-1.5.3]# find / -name mysql_config.1.gz
/usr/share/man/man1/mysql_config.1.gz
(venv4archery) [root@www Archery-1.5.3]# find / -name mysql_config
/usr/bin/mysql_config
[root@www Archery-1.5.3]# pip3 install -r requirements.txt -i https://mirrors.ustc.edu.cn/pypi/web/simple/
出現(xiàn)報錯
解決方法:
[root@www Archery-1.5.3]# yum install openldap -y
[root@www Archery-1.5.3]# yum install openldap-clients -y
[root@www Archery-1.5.3]# yum install openldap-devel -y
[root@www Archery-1.5.3]# pip3 install -r requirements.txt -i https://mirrors.ustc.edu.cn/pypi/web/simple/
(venv4archery) [root@www Archery-1.5.3]# echo $?
0
修改配置
[root@www Archery-1.5.3]# vim archery/settings.py
安全修改
修改Prpcrypt的key信息,該key用于數(shù)據(jù)庫密碼等信息加密,目前是硬編碼在代碼內(nèi) aes_decryptor.py
基礎(chǔ)配置
DEBUG = False
ALLOWED_HOSTS = ['*']
DATA_UPLOAD_MAX_MEMORY_SIZE = 15728640
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
'OPTIONS': {
'min_length': 9,
}
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
MySQL配置
建議MySQL版本5.6以上
MongoDB配置
themis審核需要執(zhí)行eval()命令,參考配置Allow user to execute eval() command on MongoDB 3.x}
use admin
switched to db admin
db.createRole( { role: "executeFunctions", privileges: [ { resource: { anyResource: true }, actions: [ "anyAction" ] } ], roles: [] } )
{
"role" : "executeFunctions",
"privileges" : [
{
"resource" : {
"anyResource" : true
},
"actions" : [
"anyAction"
]
}
],
"roles" : [ ]
}給用戶分配角色
use themis
switched to db themis
db.grantRolesToUser("dbuser", [ { role: "executeFunctions", db: "admin" } ])
修改配置
MONGODB_DATABASES = {
"default": {
"NAME": 'themis', # 數(shù)據(jù)庫
"USER": '', # 用戶名
"PASSWORD": '', # 密碼
"HOST": '127.0.0.1', # 數(shù)據(jù)庫HOST
"PORT": 27017, # 數(shù)據(jù)庫端口
},
}
Django-Q配置
默認(rèn)配置即可,也可參考django-q文檔修改
Q_CLUSTER = {
'name': 'archery',
'workers': 4,
'recycle': 500,
'timeout': 60,
'compress': True,
'cpu_affinity': 1,
'save_limit': 0,
'queue_limit': 50,
'label': 'Django Q',
'django_redis': 'default'
}
緩存配置
緩存使用redis
CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://127.0.0.1:6379/0", # redis://host:port/db
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
}
}
}
mysql> create database archery default character set utf8;
Query OK, 1 row affected (0.14 sec)
mysql> grant all privileges on archery.* to root@'127.0.0.1' identified by 'abc123';
Query OK, 0 rows affected, 1 warning (0.46 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.14 sec)
mysql>exit
安裝redis略
啟動準(zhǔn)備
數(shù)據(jù)庫初始化
[root@www Archery-1.5.3]# python3 manage.py makemigrations sqlpython3 manage.py migrate
[root@www Archery-1.5.3]# python3 manage.py migrate
[root@www Archery-1.5.3]# python3 manage.py compilemessages
python3 manage.py createsuperuser
(venv4archery) [root@www Archery-1.5.3]# python3 manage.py createsuperuser
Username: admin #用戶
Email address: #填寫你的郵箱地址
Password: admin123
Password (again): admin123
Superuser created successfully.
啟動Django-Q
需要保持后臺運行,用于消息推送、工單執(zhí)行、定時執(zhí)行,可使用supervisor進(jìn)行管理
source /opt/venv4archery/bin/activate
python3 manage.py qcluster &
啟動服務(wù)
runserver啟動
source /root/venv4archery/bin/activate
python3 manage.py runserver 0.0.0.0:9123 --insecure
關(guān)閉防火墻,或者開放9123端口 賬號密碼就是剛剛創(chuàng)建的admin admin123