Yearning
开源的MYSQL SQL语句审核平台
提供数据库字典查询,查询审计,SQL审核等多种功能
操作手册 http://guide.yearning.io/
环境:
os:CentOS Linux release 7.6.1810 (Core)
docker:Docker version 18.09.4, build d14af54266
inception:Inception2.1.50
一、安装Docker
参考 https://docs.docker.com/install/linux/docker-ce/centos/
系统要求centos7及以上
卸载老的docker
yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
安装依赖包
yum install -y yum-utils device-mapper-persistent-data lvm2
新增docker稳定版源
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
安装docker
yum install docker-ce docker-ce-cli containerd.io -y
下载docker-compose
curl -L https://github.com/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
赋执行权限
chmod +x /usr/local/bin/docker-compose
启动docker
systemctl start/stop docker ## 启动后才能继续后面的Yearning安装
查看所有容器:docker ps -a
查看镜像: docker images
删除容器 docker rm <container id>
删除镜像 docker rmi <image id>
二、 安装Inception
Inception参考文档:https://github.com/cookieY/inception-document
Inception已经闭源,Yearning作者已经编译好,放在了包里面,直接使用即可。
下载Yearning,进入install目录
git clone https://github.com/cookieY/Yearning.git ##没有git的需自行安装 yum install git
cd Yearning/install
tar -xvf inception.tar
cd inception
编辑 配置文件,vi inc.cnf
[inception]
general_log=1
# 日志路径
general_log_file=inception.log
# inception端口
port=6669
socket=/tmp/inc.socket
character-set-client-handshake=0
character-set-server=utf8
inception_support_charset=utf8mb4
inception_enable_nullable=0
inception_check_primary_key=1
inception_check_column_comment=1
inception_check_table_comment=1
inception_enable_blob_type=1
inception_check_column_default_value=1
inception_support_charset=utf8
inception_osc_on=OFF
inception_check_column_default_value=OFF
inception_check_column_comment=OFF
inception_check_table_comment=OFF
inception_enable_identifer_keyword=ON
#备份数据库配置,可以是与Yearning同一个实例,也可以单独搭建数据库
#这里是配置与Inception同一个实例
# 备份数据库的地址
inception_remote_backup_host = 192.168.100.88
# 备份数据库的端⼝
inception_remote_backup_port = 3306
# 备份数据库相关备份库的⽤户名,如果rds用户有超级权限
inception_remote_system_user = root
# 备份数据库相关备份库的密码,必须有权限
inception_remote_system_password = yearning
启动: nohup bin/Inception --defaults-file=inc.cnf &
其中,备份数据库的账号需要至少具有以下权限。
此处简化实验,我用了root。
grant create,insert on . to inception@'192.168.100.88' identified by "inception"; ### 若需要安装完Yearning之后才可以创建此账号
三、安装Yearning
进入install/yearning-docker-compose目录,然后启动即可:
cd Yearning/install/yearning-docker-compose
docker-compose up -d
等待10分钟左右
安装完成默认启动
查看启动的容器: docker ps
四、 Yearning启停
docker start/stop yearning-docker-compose_yearning_1
docker start/stop yearning-docker-compose_db_1
五、 Yearning访问
主页访问:若无法访问,容器或者docker服务尝试重启下
http://192.168.100.88:8080
初始账号:admin / Yearning_admin
数据库访问:
mysql -h192.168.100.88 -P3306 -uroot -pyearning
六、 Inception设置
Inception是作为一个sql审核的工具,无需设置用户密码
第二步和以下Yearning设置界面均需配置备份库用户密码。
备份库就与当前Yearning同实例即可。
配置备份库之后DDL、DML工单便会保存回滚语句在数据库中,按不同实例和DBname组合后创建独立的备份数据库。
