一、Yearning簡介
Yearning 是MYSQL SQL語句審覈平臺。提供查詢審計,SQL審覈等多種功能。
- Yearning 1.x版本需inception提供SQL審覈及回滾功能。
- Yearning 2.0開始無需依賴Inception,已自己實現了SQL審覈/回滾功能
本文版本爲Yearning2.2.0。
二、安裝
下載地址
https://github.com/cookieY/Yearning/releases/download/v2.2.0/Yearning-2.2.0.linux-amd64.zip
注意事項
- Yearning 不依賴於任何第三方SQL審覈工具作爲審覈引擎,內部已自己實現審覈/回滾相關邏輯。
- 僅依賴Mysql數據庫。
- mysql版本必須5.7及以上版本,請事先自行安裝完畢且創建Yearning庫,字符集應爲UTF8mb4 (僅Yearning所需mysql版本)
- Yearning日誌僅輸出error級別,沒有日誌即可認爲無運行錯誤!
- Yearning 基於1080p分辨率開發僅支持1080p及以上顯示器訪問
- 由於使用較多新的前端技術棧,請使用Chrome最新版本(不包括360等其他魔改版本)
安裝步驟
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/