Yearning 是MYSQL SQL语句审核平台。提供查询审计,SQL审核等多种功能。
下载地址
https://github.com/cookieY/Yearning/releases/download/v2.2.0/Yearning-2.2.0.linux-amd64.zip
注意事项
unzip Yearning-2.2.0.linux-amd64.zip -d /usr/local/
cd /usr/local/Yearning-go/
cat conf.toml
[Mysql]
Db = "Yearning"
Host = "127.0.0.1"
Port = "3306"
Password = "Yearning"
User = "Yearning"
[General] #数据库加解密key,只可更改一次。
SecretKey = "dbcjqheupqjsuwsm"
SecretKey是token/数据库密码加密/解密的salt。
建议所有用户在初次安装Yearning之前将SecretKey更改(不更改将存在安全风险)
格式: 大小写字母均可, 长度必须为16位
特别注意:
此key仅可在初次安装时更改!之后不可再次更改!如再次更改会导致之前已存放的数据源密码无法解密,最终导致无法获取相关数据源信息
# ./Yearning -h
version: Yearning/2.2.0 author: HenryYee
Usage: Yearning [-m migrate] [-p port] [-s start] [-b web-bind] [-h help] [-c config file]
Options:
-s 启动Yearning
-m 数据初始化(第一次安装时执行)
-p 端口
-b 钉钉/邮件推送时显示的平台地址
-x 表结构修复,升级时可以操作。如出现错误可直接忽略。
-h 帮助
-c 配置文件路径
-k 用户权限变更为权限组(2.1.7以下升级至2.1.7及以上使用)
-f 初始化Admin用户密码
##初始化数据结构
./Yearning -m
(/var/jenkins_home/workspace/Yearning-go/src/service/migrate.go:31)
[2020-03-01 18:17:10] [0.47ms] INSERT INTO `core_accounts` (`username`,`password`,`rule`,`department`,`real_name`,`email`) VALUES ('admin','pbkdf2_sha256$120000$KMXHZJuaiVKW$EQ1XMcuApgEb6ysj6l9bOGzaVo+s/AGO13uOcNxpDD0=','admin','DBA','超级管理员','')
[1 rows affected or returned ]
(/var/jenkins_home/workspace/Yearning-go/src/service/migrate.go:39)
[2020-03-01 18:17:10] [0.80ms] INSERT INTO `core_global_configurations` (`authorization`,`ldap`,`message`,`other`,`stmt`,`audit_role`) VALUES ('global','{"url":"","user":"","password":"","type":1,"sc":"","ldaps":false}','{"web_hook":"","host":"","port":25,"user":"","password":"","to_user":"","mail":false,"ding":false,"ssl":false}','{"limit":"1000","idc":["Aliyun","AWS"],"multi":false,"query":false,"exclude_db_list":[],"insulate_word_list":[],"register":false,"export":false,"per_order":2,"ex_query_time":60,"query_timeout":0}',0,'{"DMLInsertColumns":false,"DMLMaxInsertRows":10,"DMLWhere":false,"DMLOrder":false,"DMLSelect":false,"DDLCheckTableComment":false,"DDlCheckColumnComment":false,"DDLCheckColumnNullable":false,"DDLCheckColumnDefault":false,"DDLTimeFieldDefault":false,"DDLEnableAcrossDBRename":false,"DDLEnableAutoincrementInit":false,"DDLEnableAutoIncrement":false,"DDLEnableAutoincrementUnsigned":false,"DDLEnableDropTable":false,"DDLEnableDropDatabase":false,"DDLEnableNullIndexName":false,"DDLIndexNameSpec":false,"DDLMaxKeyParts":5,"DDLMaxKey":5,"DDLMaxCharLength":10,"MaxTableNameLen":10,"MaxAffectRows":1000,"MaxDDLAffectRows":0,"EnableSetCollation":false,"EnableSetCharset":false,"SupportCharset":"","SupportCollation":"","CheckIdentifier":false,"MustHaveColumns":"","DDLMultiToSubmit":false,"DDLPrimaryKeyMust":false,"DDLAllowColumnType":false,"DDLImplicitTypeConversion":false,"DMLMinimalRollback":false,"DDLAllowPRINotInt":false,"IsOSC":false,"OscBinDir":"","OscDropNewTable":false,"OscDropOldTable":false,"OscCheckReplicationFilters":false,"OscCheckAlter":false,"OscAlterForeignKeysMethod":"rebuild_constraints","OscMaxLag":1,"OscRecursionMethod":"processlist","OscCheckInterval":1,"OscMaxThreadConnected":25,"OscMaxThreadRunning":25,"OscCriticalThreadConnected":20,"OscCriticalThreadRunning":20,"OscPrintSql":false,"OscChunkTime":0.5,"OscSize":0,"AllowCreateView":false,"AllowCreatePartition":false,"AllowSpecialType":false}')
[1 rows affected or returned ]
(/var/jenkins_home/workspace/Yearning-go/src/service/migrate.go:46)
[2020-03-01 18:17:10] [0.62ms] INSERT INTO `core_graineds` (`username`,`rule`,`permissions`,`group`) VALUES ('admin','','{"ddl":"1","ddl_source":[],"dml":"1","dml_source":[],"user":"1","base":"1","auditor":[],"query":"1","query_source":[]}',NULL)
[1 rows affected or returned ]
初始化成功!
用户名: admin
密码:Yearning_admin
##启动服务
./Yearning -s
检查更新.......
数据已更新!
__ __ _____ ___ _____ __ _ _ __ _ _____
\ \ / / | ____| / | | _ \ | \ | | | | | \ | | / ___|
\ \/ / | |__ / /| | | |_| | | \| | | | | \| | | |
\ / | __| / / | | | _ / | |\ | | | | |\ | | | _
/ / | |___ / / | | | | \ \ | | \ | | | | | \ | | |_| |
/_/ |_____| /_/ |_| |_| \_\ |_| \_| |_| |_| \_| \_____/ vgolang.ver
Welcome to Yearning
https://yearning.io
____________________________________O/_______
O\
⇨ http server started on [::]:8000
#注意端口开放
首先当然是登陆界面,登陆的默认账号密码在初始化的时候已经提示:用户名: admin密码:Yearning_admin。Yearning推荐使用Chrome浏览器。
进来后是首页,首页中可以看到当前的用户数、数据源、工单数、查询数、个人信息、工单提交统计、高频库、以及工单趋势。
在我的工单界面可以看到历史的工单,执行状态,执行信息,是否备份等等。。
工单提交界面分为DDL/DML,错误级别非0均为异常,如果没有设置定时执行的话工单会在审批后自动执行!
在查询界面执行查询SQL,其他SQL无法执行,SQL默认会有limit限制。
在审核界面可以看到待审核的工单,以及审核过的工单。
在记录界面可以看到历史的工单和查询审计。
在管理界面的用户一栏配置用户。
在数据库一栏配置数据源以及读写规则。
在用户权限界面为用户分配权限组来赋予指定权限。
在权限组界面设置N个权限组以对应不同的角色。
在设置界面可以设置消息推送(钉钉、邮件)以及LDAP。
在审核规则界面可以设置审核规则,还是蛮丰富的。
在AutoTask界面设置AutoTask。
在公告界面设置群体公告。
参考文档:https://guide.yearning.io/