Skip to main content
Version: v3&v6

私有部署开放只读账号外部访问数据库

配置参数

配置项类型示例描述
mysql_expose_portstring"3306"开放给外部的数据库端口

操作步骤:

修改配置

登陆 ONES 服务器,进入当前运行中实例的安装目录

cd /data/ones/pkg/ones-example-3.14.xxxxx

添加 mysql 开发外部访问端口配置

端口一般设置为 3306,特殊要求可更换端口

./json-util -config config.json -operator add -key mysql_expose_port -valtype string -value "3306"

创建 mysql 只读账号

获取 mysql root 用户密码

./json-util -config config.json -operator select -key mysql_root_password

示例输出

[root@localhost ones-example-3.14.xxxxx]# ./json-util -config config.json -operator select -key mysql_root_password
9OnetVab2xTq7Mm # root 密码

使用 root 用户密码登陆 mysql

注意,命令中 <mysql_root_password> 指 mysql root 用户密码,请自己指定

./onesconfigure e
mysql -uroot -p<mysql_root_password>

创建用户,并授权 SELECT 查询权限,授权远程访问权限

注意,命令中 username/password 指用户名密码,请自己指定

GRANT SElECT ON *.* TO <username>@'%' IDENTIFIED BY <password>;
flush privileges;
exit

退出容器

exit

重启容器

注意:执行以下命令将造成 ONES 服务暂时不可用

进入 screen 终端,执行common.sh脚本后选择 2 号选项,等待命令执行完成

系统提示没有screen命令时,请通过yum install -y screen命令安装

sudo screen -S ones
sudo bash common.sh

交互示例

[root@localhost ones-example-3.14.xxxxx]# bash common.sh
the team_uuid is
BGwiSTx3

1.pull_image
2.local_upgrade(Unconventional upgrade)
3.open_automation
4.open_performance_pro
5.init
6.change_emailPsd
7.Not Yet Open
8.Not Yet Open
9.mysqlport_open
10.mysql5.7_ex
11.first_select_login
12.wps_install
13.replace_binary
14.replace_ssl
15.enable_plugin
16.change_port
17.skip_backup_to_upgrade
18.get_audit_log_info
19.mysql8_ex(Use with caution)

If mysqlrootuser is not root,Please pass the first parameter as mysqlrootuser!!Dedicated to external database
please input your select :2
Successfully copied 11.3kB to /data/ones/pkg/ones-sop-test2-3.12.613087/dockerconfig.json
please input the path of ssl file like .pem/.crt/..:test.pem
please input the path of ssl file .key:test.key

当观察到如下输出,则重启已经完成。稍等几分钟后 ONES 服务将可以正常访问,ONES 只读账号配置完成

15:29:15.764114 [SQL] SELECT COUNT(1) FROM marketplace_app_installed []
15:29:15.765044 [SQL] SHOW TABLES LIKE 'app_install_record' []
15:29:15.766297 [SQL] SELECT COUNT(1) FROM app_install_record []
2023/05/29 15:29:15 P3039: Table true Data false
2023/05/29 15:29:15 P3069: Table true Data true
15:29:15.767277 [SQL] begin; []
15:29:15.767694 [SQL] SELECT uuid, create_time, status, name, owner, logo, expire_time, scale, type, visibility FROM organization LIMIT 1; []
2023/05/29 15:29:15 --- start transaction org_uuid: D1X4EdeP---
15:29:15.768948 [SQL] SELECT uuid FROM team WHERE org_uuid=? AND status=?; [1:"D1X4EdeP" 2:1]
15:29:15.770020 [SQL] SELECT * FROM license WHERE org_uuid=?; [1:"D1X4EdeP"]
2023/05/29 15:29:15 P3069 already migrated, skip.
15:29:15.771617 [SQL] commit; []
[INFO] 2023/05/29 15:29:15 upgrade success!!

验证

  • 使用第三方工具或者命令行远程连接 mysql 数据库,能正常连接上即可
mysql -u<username> -p<password> -h<ones-server-ip> -P<mysql_expose_port>