Mysql审核工具archery
admin
2023-04-17 12:41:45
0
                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

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
准备虚拟环境

编译安装python的使用

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

切换python运行环境到虚拟环境

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

安装ODBC依赖

[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/
如果出现报一下错误
Mysql审核工具archery
解决方法:
安装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/
Mysql审核工具archery
出现报错

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用于数据库密码等信息加密,目前是硬编码在代码内 aes_decryptor.py

基础配置

关闭debug模式

DEBUG = False

设置ALLOWED_HOSTS,建议限制内网访问

ALLOWED_HOSTS = ['*']

请求大小限制,如果提交SQL语句过大可以修改该值

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

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
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

创建管理用户

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 &
Mysql审核工具archery

启动服务
runserver启动
source /root/venv4archery/bin/activate
python3 manage.py runserver 0.0.0.0:9123 --insecure
关闭防火墙,或者开放9123端口 账号密码就是刚刚创建的admin admin123

相关内容

热门资讯

缺油!日本快撑不住了 日本零食巨头卡乐比为节省油墨竟将原本漂亮的包装改成了黑白两色,从“喜食”变得看上去像“丧食”。日本石...
英国首相斯塔默再遭逼宫,在内阁... 【文/观察者网 熊超然】在上周经历地方选举惨败后,作为执政党领袖的英国首相斯塔默于当地时间5月11日...
日防相声称:新西兰考虑进口日本... 据凤凰卫视报道,5月12日,日本防卫大臣小泉进次郎在记者会上表示,新西兰已将日本海上自卫队最上型改良...
小米YU7 GT“车厘子红”无... 5 月 12 日消息,博主 @王的男人、昨日晒出了小米 YU7 GT「车厘子红」实车照片。画面显示,...
中关村论坛重磅发布!大兴机场临... 3月27日,在中关村论坛数据跨境流动创新发展论坛上,北京大兴国际机场临空经济区(大兴)正式发布跨境可...
白宫公布随特朗普访华16位商界... 白宫11日公布了将随特朗普一同访华的商界领袖名单。据多家美媒报道,总共将有16位美国商界代表来到北京...
荣耀申请代码生成方法专利,提高... 国家知识产权局信息显示,南京荣耀软件技术有限公司申请一项名为“代码生成方法、电子设备及存储介质”的专...
凤凰连线:中美新一轮经贸磋商,... 中美双方将在韩国举行第七轮经贸磋商。美方的阵容和日程安排如何?在这轮磋商中有哪些关切?凤凰卫视驻韩国...
知情人士:阿联酋秘密打击伊朗,... 据参考消息援引美国《华尔街日报》网站5月11日报道,多名知情人士透露,阿联酋已对伊朗发动军事打击,令...
美防长称美伊停火协议依然有效 △赫格塞思(资料图)当地时间5月12日,美国国防部长赫格塞思表示,他们针对伊朗问题的所有情况都制定了...