溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶(hù)服務(wù)條款》

Mysql審核工具archery

發(fā)布時(shí)間:2020-07-22 15:24:13 來(lái)源:網(wǎng)絡(luò) 閱讀:1293 作者:輕狂書(shū)生999 欄目:MySQL數(shù)據(jù)庫(kù)
                Mysql審核工具archery

系統(tǒng):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

virtualenv

[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)境

編譯安裝python的使用

[root@www ~]# virtualenv venv4archery --python=python3

切換python運(yùn)行環(huán)境到虛擬環(huán)境

[root@www ~]# source venv4archery/bin/activate

安裝ODBC依賴(lài)

[root@www Archery-1.5.3]# yum install unixODBC-devel -y
下載release包,安裝依賴(lài)庫(kù)
[root@www ~]# wget "https://github.com/hhyo/archery/archive/v1.5.3.tar.gz"
[root@www ~]# tar -xzvf v1.5.3.tar.gz

安裝系統(tǒng)依賴(lài)

[root@www ~]# yum -y install gcc gcc-c++ python-devel mysql-devel openldap-devel unixODBC-devel gettext

安裝依賴(lài)庫(kù)

[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)報(bào)一下錯(cuò)誤
Mysql審核工具archery
解決方法:
安裝mysql5.7,然后安裝以下依賴(lài)即可
[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/
Mysql審核工具archery
出現(xiàn)報(bào)錯(cuò)

Mysql審核工具archery

解決方法:
[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ù)庫(kù)密碼等信息加密,目前是硬編碼在代碼內(nèi) aes_decryptor.py

基礎(chǔ)配置

關(guān)閉debug模式

DEBUG = False

設(shè)置ALLOWED_HOSTS,建議限制內(nèi)網(wǎng)訪問(wèn)

ALLOWED_HOSTS = ['*']

請(qǐng)求大小限制,如果提交SQL語(yǔ)句過(guò)大可以修改該值

DATA_UPLOAD_MAX_MEMORY_SIZE = 15728640

密碼校驗(yàn),用戶(hù)注冊(cè)和添加密碼校驗(yàn)規(guī)則

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以上
Mysql審核工具archery

MongoDB配置
themis審核需要執(zhí)行eval()命令,參考配置Allow user to execute eval() command on MongoDB 3.x}

創(chuàng)建角色

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" : [ ]
}

給用戶(hù)分配角色

use themis
switched to db themis
db.grantRolesToUser("dbuser", [ { role: "executeFunctions", db: "admin" } ])

修改配置
MONGODB_DATABASES = {
"default": {
"NAME": 'themis', # 數(shù)據(jù)庫(kù)
"USER": '', # 用戶(hù)名
"PASSWORD": '', # 密碼
"HOST": '127.0.0.1', # 數(shù)據(jù)庫(kù)HOST
"PORT": 27017, # 數(shù)據(jù)庫(kù)端口
},
}

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略
啟動(dòng)準(zhǔn)備
數(shù)據(jù)庫(kù)初始化
[root@www Archery-1.5.3]# python3 manage.py makemigrations sqlpython3 manage.py migrate
Mysql審核工具archery
[root@www Archery-1.5.3]# python3 manage.py migrate

Mysql審核工具archery

編譯翻譯文件

[root@www Archery-1.5.3]# python3 manage.py compilemessages
Mysql審核工具archery

創(chuàng)建管理用戶(hù)

python3 manage.py createsuperuser

(venv4archery) [root@www Archery-1.5.3]# python3 manage.py createsuperuser
Username: admin #用戶(hù)
Email address: #填寫(xiě)你的郵箱地址
Password: admin123
Password (again): admin123
Superuser created successfully.

啟動(dòng)Django-Q
需要保持后臺(tái)運(yùn)行,用于消息推送、工單執(zhí)行、定時(shí)執(zhí)行,可使用supervisor進(jìn)行管理

source /opt/venv4archery/bin/activate
python3 manage.py qcluster &
Mysql審核工具archery

啟動(dòng)服務(wù)
runserver啟動(dòng)
source /root/venv4archery/bin/activate
python3 manage.py runserver 0.0.0.0:9123 --insecure
關(guān)閉防火墻,或者開(kāi)放9123端口 賬號(hào)密碼就是剛剛創(chuàng)建的admin admin123

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI