您好,登錄后才能下訂單哦!
Mysql審核工具archery
系統:Centos6.8
ip:192.168.122.150
安裝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
準備虛擬環境
[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/
如果出現報一下錯誤
解決方法:
安裝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/
出現報錯
解決方法:
[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用于數據庫密碼等信息加密,目前是硬編碼在代碼內 aes_decryptor.py
基礎配置
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審核需要執行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', # 數據庫
"USER": '', # 用戶名
"PASSWORD": '', # 密碼
"HOST": '127.0.0.1', # 數據庫HOST
"PORT": 27017, # 數據庫端口
},
}
Django-Q配置
默認配置即可,也可參考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略
啟動準備
數據庫初始化
[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
需要保持后臺運行,用于消息推送、工單執行、定時執行,可使用supervisor進行管理
source /opt/venv4archery/bin/activate
python3 manage.py qcluster &
啟動服務
runserver啟動
source /root/venv4archery/bin/activate
python3 manage.py runserver 0.0.0.0:9123 --insecure
關閉防火墻,或者開放9123端口 賬號密碼就是剛剛創建的admin admin123
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。