赞
踩
上篇我们学习了Yearning稳定版本的部署和使用,这篇来学下目前最新版的部署方式,后面会补充使用方法;其实两种版本的使用方法差不了多少,只是新版本得去拉取前后端代码然后编译后再运行,还有一点就是源码编译部署的话需要将Juno服务单独运行(主要负责审核sql语句);
环境准备:
mysql | v5.7.38 |
---|---|
Yearning | v3.0.1/next分支 |
mysql 版本必须为5.7及以上版本(8.0及以上请将sql_mode 设置为空)并已事先自行安装完毕且创建 Yearning 库,字符集应为 UTF8mb4 (仅 Yearning 所需 mysql 版本)
[root@iZbp1ekeiqryx9a71hj5ieZ ~]# tar -zxf go1.18.3.linux-amd64.tar.gz
[root@iZbp1ekeiqryx9a71hj5ieZ ~]# mv go /usr/local/go
[root@iZbp1ekeiqryx9a71hj5ieZ ~]# vim /etc/profile
#####go######
export GOROOT=/usr/local/go
export GOPATH=/home/gopath
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
export GO111MODULE=on
export GOPROXY=https://goproxy.io
[root@iZbp1ekeiqryx9a71hj5ieZ ~]# source /etc/profile
[root@iZbp1ekeiqryx9a71hj5ieZ ~]# go version
go version go1.18.3 linux/amd64
GOPATH=/home/gopath:go的工作空间
GO111MODULE=on:启用 go module,编译时会忽略 GOPATH 和 vendor 文件夹,只根据 项目的go.mod下载依赖;
GOPROXY=https://goproxy.io:设置go的代理,有时候会因为网络原因导致的包拉不下来
[root@iZbp1ekeiqryx9a71hj5ieZ ~]# tar -zxf node-v16.15.1-linux-x64.tar.gz
[root@iZbp1ekeiqryx9a71hj5ieZ ~]# mv node-v16.15.1-linux-x64 /usr/local/node
[root@iZbp1ekeiqryx9a71hj5ieZ ~]# vim /etc/profile
######node######
export NODE_HOME=/usr/local/node
export PATH=$NODE_HOME/bin:$PATH
[root@iZbp1ekeiqryx9a71hj5ieZ ~]# source /etc/profile
[root@iZbp1ekeiqryx9a71hj5ieZ ~]# node -v
v16.15.1
[root@iZbp1ekeiqryx9a71hj5ieZ ~]# npm -v
8.11.0
[root@iZbp1ekeiqryx9a71hj5ieZ home]# git clone https://github.com/cookieY/gemini-next.git
[root@iZbp1ekeiqryx9a71hj5ieZ home]# git clone https://github.com/cookieY/Yearning.git
需要先在前端代码目录编译前端代码,然后将编译好的dist目录放到后端代码的src/service目录下;
[root@iZbp1ekeiqryx9a71hj5ieZ home]# cd /home/gemini-next/
[root@iZbp1ekeiqryx9a71hj5ieZ gemini-next]# npm install
[root@iZbp1ekeiqryx9a71hj5ieZ gemini-next]# npm run build
[root@iZbp1ekeiqryx9a71hj5ieZ gemini-next]# mv dist /home/Yearning/src/service/
[root@iZbp1ekeiqryx9a71hj5ieZ Yearning]# cd /home/Yearning/ [root@iZbp1ekeiqryx9a71hj5ieZ Yearning]# go run main.go [root@iZbp1ekeiqryx9a71hj5ieZ Yearning]# go mod tidy go: downloading github.com/cookieY/yee v0.3.4 go: downloading gorm.io/gorm v1.23.6 ... [root@iZbp1ekeiqryx9a71hj5ieZ Yearning]# go run main.go Yearning Mysql数据审核平台 (Version: 3.0.0 Uranus) Usage: /tmp/go-build371386274/b001/exe/main [Global Options...] {command} [--option ...] [argument ...] Global Options: -h, --help Display the help information --no-color Disable color when outputting message --no-interactive Disable interactive confirmation operations --no-progress Disable display progress message --verbose Set error reporting level(quiet 0 - 4 debug) (default 1) -V, --version Display app version information Available Commands: genac Generate auto complete scripts for current application (alias: gen-ac) install Yearning安装及数据初始化 migrate 破坏性版本升级修复 reset_super 重置超级管理员密码 run 启动Yearning help Display help information Use "/tmp/go-build371386274/b001/exe/main {COMMAND} -h" for more information about a command
由于我上篇帖子部署好了mysqlv5.7.38的帖子,所以我这里就直接创建数据库并配置了;如果有不知道数据库怎么部署和配置的话可以看贴:
Yearning SQL审核平台部署与使用 详细步骤【生产环境】
[root@iZbp1ekeiqryx9a71hj5ieZ Yearning]# ll total 8432 drwxr-xr-x 2 root root 4096 Jul 8 16:16 cmd -rw-r--r-- 1 root root 693 Jul 8 16:16 conf.toml.template drwxr-xr-x 2 root root 4096 Jul 8 16:16 docker -rw-r--r-- 1 root root 2938 Jul 8 16:16 go.mod -rw-r--r-- 1 root root 41953 Jul 8 16:36 go.sum drwxr-xr-x 2 root root 4096 Jul 8 16:16 img -rwxr-xr-x 1 root root 8476568 Jul 8 16:16 Juno -rw-r--r-- 1 root root 34519 Jul 8 16:16 LICENSE -rw-r--r-- 1 root root 32373 Jul 8 16:16 logo_s.png -rw-r--r-- 1 root root 579 Jul 8 16:16 main.go drwxr-xr-x 2 root root 4096 Jul 8 16:16 migration -rw-r--r-- 1 root root 1940 Jul 8 16:16 README_EN.md -rw-r--r-- 1 root root 2274 Jul 8 16:16 README.md drwxr-xr-x 11 root root 4096 Jul 8 16:16 src [root@iZbp1ekeiqryx9a71hj5ieZ Yearning]# cp conf.toml.template conf.toml [root@iZbp1ekeiqryx9a71hj5ieZ Yearning]# vim conf.toml [Mysql] Db = "Yearning_go" Host = "127.0.0.1" Port = "3306" Password = "xxxxxxx" User = "root" [General] SecretKey = "dbcjqheupqjsuwsm" RpcAddr = "127.0.0.1:50001" [Oidc] Enable = true ClientId = "yearning" ClientSecret = "fefehelj23jlj22f3jfjdfd" Scope = "openid profile" AuthUrl = "https://keycloak.xxx.ca/auth/realms/master/protocol/openid-connect/auth" TokenUrl = "https://keycloak.xxx.ca/auth/realms/master/protocol/openid-connect/token" UserUrl = "https://keycloak.xxx.ca/auth/realms/master/protocol/openid-connect/userinfo" RedirectUrL = "http://127.0.0.1:8000/oidc/_token-login" UserNameKey = "preferred_username" RealNameKey = "name" EmailKey = "email" SessionKey = "session_state" [root@iZbp1ekeiqryx9a71hj5ieZ Yearning]# go run main.go install 是否已将数据库字符集设置为UTF8/UTF8MB4? [yes|no]: yes 2022/07/12 20:08:37 /home/Yearning/src/service/migrate.go:34 [1.702ms] [rows:1] INSERT INTO `core_accounts` (`username`,`password`,`department`,`real_name`,`email`,`is_recorder`) VALUES ('admin','pbkdf2_sha256$120000$LwSop65y17f4$AgXGkzmZLF7Lw3K1gToLkOBHqziBC0Wpf3bBIHoWA5Q=','DBA','超级管理员','',0) 2022/07/12 20:08:37 /home/Yearning/src/service/migrate.go:41 [1.735ms] [rows:1] INSERT INTO `core_global_configurations` (`authorization`,`ldap`,`message`,`other`,`stmt`,`audit_role`,`board`) VALUES ('global','{"url":"","user":"","password":"","type":"(\u0026(objectClass=organizationalPerson)(sAMAccountName=%s))","sc":"","ldaps":false,"map":"","test_user":"","test_password":""}','{"web_hook":"","host":"","port":25,"user":"","password":"","to_user":"","mail":false,"ding":false,"ssl":false,"push_type":false,"key":""}','{"limit":1000,"idc":["Aliyun","AWS"],"query":false,"register":false,"export":false,"ex_query_time":60}',0,'{"DMLAllowLimitSTMT":false,"DMLInsertColumns":false,"DMLMaxInsertRows":10,"DMLWhere":false,"DMLAllowInsertNull":false,"DMLOrder":false,"DMLSelect":false,"DMLInsertMustExplicitly":false,"DDLEnablePrimaryKey":false,"DDLCheckTableComment":false,"DDlCheckColumnComment":false,"DDLCheckColumnNullable":false,"DDLCheckColumnDefault":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,"SupportCharset":"","SupportCollation":"","CheckIdentifier":false,"MustHaveColumns":"","DDLMultiToCommit":false,"DDLPrimaryKeyMust":false,"DDLAllowColumnType":false,"DDLImplicitTypeConversion":false,"DDLAllowPRINotInt":false,"DDLEnableForeignKey":false,"DDLTablePrefix":"","DDLColumnsMustHaveIndex":"","DDLAllowChangeColumnPosition":false,"DDLCheckFloatDouble":false,"IsOSC":false,"OSCExpr":"","OscSize":0,"AllowCreateView":false,"AllowCrateViewWithSelectStar":false,"AllowCreatePartition":false,"AllowSpecialType":false,"PRIRollBack":false}','') 2022/07/12 20:08:37 /home/Yearning/src/service/migrate.go:48 [1.491ms] [rows:1] INSERT INTO `core_graineds` (`username`,`group`) VALUES ('admin','["admin"]') 2022/07/12 20:08:37 /home/Yearning/src/service/migrate.go:52 [1.479ms] [rows:1] INSERT INTO `core_role_groups` (`name`,`permissions`,`group_id`) VALUES ('admin','{"ddl_source":[],"dml_source":[],"query_source":[]}','') 初始化成功! 用户名: admin 密码:Yearning_admin 请通过./Yearning run 运行,默认地址:http://<host>:8000 [root@iZbp1ekeiqryx9a71hj5ieZ Yearning]# go run main.go run //-也可以nohup后台运行 检查更新....... 数据已更新! 2022/07/12 19:54:33 /home/Yearning/src/service/yearning.go:55 record not found [0.294ms] [rows:0] SELECT * FROM `core_global_configurations` ORDER BY `core_global_configurations`.`id` LIMIT 1 __ __ _ \/ /_________ __ /_ _ \ _ \ _ / / __/ __/ /_/ \___/\___/ yee v0.3.3 -----Easier and Faster----- Creator: Henry Yee
提示:如果是直接下载作者编译好的版本的话就不用开启了,这里是自己编译,需要单独开启Juno,否则在代码检测的时候会报错
[root@iZbp1ekeiqryx9a71hj5ieZ Yearning]# ./Juno --help
version: Juno/2.3.6
Usage: Juno [-p port]
Options:
-h 帮助
-l 许可
-p string
Juno端口 (default "50001")
-s string
如何使用 (default "juno的配置文件与Yearning本体相同,如需要分开部署请copy配置文件!")
[root@iZbp1ekeiqryx9a71hj5ieZ Yearning]# ./Juno -p 50001
Started....... Port is 50001
作者:HenryYee 坐标:杭州,此软件未经许可严禁用于任何商业用途(包括但不限于复制,分发,传播,提供基于web的服务)!二次开发及其他合作联系方式:henry@yearning.io 网址:yearning.io
访问ip:8000即可
目前这个新版本还不是很完善,等作者大大完善些再写使用的方法,目前是创建权限组以及权限分配的时候会有点差别,然后还有就是在代码检测的阶段得鼠标右键才能检测,其它的和老版本的大差不差;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。