一键修改KES V9集群和数据库参数实战案例
一、概要
金仓数据库支持多节点集群部署,并提供了一键修改数据库参数的功能,极大地简化了开发和运维人员对数据库集群的维护与管理工作。本文将通过具体案例演示这些功能的操作方法,以供参考。
二、一键修改集群配置和数据库配置命令介绍
1.一键修改集群配置和数据库配置命令
sys_monitor.sh set/set --restart
set
脚本调用修改集群和数据库配置函数,固定传此字符串。
set --restart
脚本调用修改集群和数据库配置函数,并重启集群。如果修改的参数必须重启数据库才能生效时,使用该项。
2.调用说明
sys_monitor.sh set 脚本读取配置文件 set_repmgr.conf 和 set_db.conf 中的配置,分别修改集群配置文件 repmgr.conf 和集群中数据库配置文件 es_rep.conf。
在${集群目录}/etc 目录下配置 set_repmgr.conf,该配置文件中设置参数,修改集群 repmgr.conf 文件:
在${集群目录}/etc 目录下配置 set_db.conf,该配置文件中设置参数,修改集群中所有数据库的 es_rep.conf 文 件:
三、案例说明
本次修改如下内容:
调整数据库正常情况下sys_wal下的最大保存文件个数:
wal_keep_segments = 1000
调整集群监控数据库设置参数:
reconnect_attempts=6
reconnect_interval=8
1、查看当前配置参数
使用用户kingbase登录任意集群节点执行如下命令:
grep -E 'wal_keep_segments' $KINGBASE_DATA/es_rep.conf
wal_keep_segments = 512
grep -E 'reconnect_attempts|reconnect_interval' $KINGBASE_HOME/etc/repmgr.conf
reconnect_attempts=10
reconnect_interval=6
2、创建配置文件set_repmgr.conf 和 set_db.conf
touch set_repmgr.conf set_db.conf
3、修改集群部分参数:
vi set_repmgr.conf
reconnect_attempts=6
reconnect_interval=8
4、修改数据库部分参数:
vi set_db.conf
wal_keep_segments=1024
5、执行一键修改配置命令
sys_monitor.sh set
2025-02-05 09:52:48 success to access "node01".
2025-02-05 09:52:48 success to found the repmgr.conf file on node "node01".
2025-02-05 09:52:49 success to access "node02".
2025-02-05 09:52:49 success to found the repmgr.conf file on node "node02".
2025-02-05 09:52:49 success to access "node03".
2025-02-05 09:52:49 success to found the repmgr.conf file on node "node03".
2025-02-05 09:52:49 Begin to set the es_rep.conf for database ...
2025-02-05 09:52:50 End to set the es_rep.conf for database ... OK
2025-02-05 09:52:50 Begin to set the repmgr.conf for repmgrd ...
2025-02-05 09:52:52 End to set the repmgr.conf for repmgrd ... OK
2025-02-05 09:52:52 Sending signal to reload the database on "node01"
server signaled
2025-02-05 09:52:52 Sending signal to reload the database on "node02"
server signaled
2025-02-05 09:52:52 Sending signal to reload the database on "node03"
server signaled
2025-02-05 09:52:53 Sending signal(SIGKILL) to stop the kbha on "node01"
2025-02-05 09:52:56 Sending signal(SIGKILL) to stop the repmgrd on "node01"
2025-02-05 09:52:56 begin to stop repmgrd on "[node01]".
2025-02-05 09:52:57 repmgrd on "[node01]" stop success.
2025-02-05 09:52:57 Start the repmgrd on "node01"
2025-02-05 09:52:57 begin to start repmgrd on "[node01]".
[2025-02-05 09:52:58] [NOTICE] using provided configuration file "/opt/Kingbase/ES/V9/kingbase/bin/../etc/repmgr.conf"
[2025-02-05 09:52:58] [NOTICE] redirecting logging output to "/opt/Kingbase/ES/V9/kingbase/log/hamgr.log"
2025-02-05 09:52:59 repmgrd on "[node01]" start success.
2025-02-05 09:52:59 Start the kbha on "node01"
[2025-02-05 09:53:02] [NOTICE] redirecting logging output to "/opt/Kingbase/ES/V9/kingbase/log/kbha.log"
2025-02-05 09:53:03 Sending signal(SIGKILL) to stop the kbha on "node02"
2025-02-05 09:53:06 Sending signal(SIGKILL) to stop the repmgrd on "node02"
2025-02-05 09:53:06 begin to stop repmgrd on "[node02]".
2025-02-05 09:53:07 repmgrd on "[node02]" stop success.
2025-02-05 09:53:07 Start the repmgrd on "node02"
2025-02-05 09:53:07 begin to start repmgrd on "[node02]".
[2025-02-05 09:53:08] [NOTICE] using provided configuration file "/opt/Kingbase/ES/V9/kingbase/bin/../etc/repmgr.conf"
[2025-02-05 09:53:08] [NOTICE] redirecting logging output to "/opt/Kingbase/ES/V9/kingbase/log/hamgr.log"
2025-02-05 09:53:09 repmgrd on "[node02]" start success.
2025-02-05 09:53:09 Start the kbha on "node02"
[2025-02-05 09:53:12] [NOTICE] redirecting logging output to "/opt/Kingbase/ES/V9/kingbase/log/kbha.log"
2025-02-05 09:53:13 Sending signal(SIGKILL) to stop the kbha on "node03"
2025-02-05 09:53:17 Sending signal(SIGKILL) to stop the repmgrd on "node03"
2025-02-05 09:53:17 begin to stop repmgrd on "[node03]".
2025-02-05 09:53:17 repmgrd on "[node03]" stop success.
2025-02-05 09:53:17 Start the repmgrd on "node03"
2025-02-05 09:53:17 begin to start repmgrd on "[node03]".
[2025-02-05 09:53:18] [NOTICE] using provided configuration file "/opt/Kingbase/ES/V9/kingbase/bin/../etc/repmgr.conf"
[2025-02-05 09:53:18] [NOTICE] redirecting logging output to "/opt/Kingbase/ES/V9/kingbase/log/hamgr.log"
2025-02-05 09:53:20 repmgrd on "[node03]" start success.
2025-02-05 09:53:20 Start the kbha on "node03"
[2025-02-05 09:53:23] [NOTICE] redirecting logging output to "/opt/Kingbase/ES/V9/kingbase/log/kbha.log"
Some changes may not take effect by RELOAD, you can execute "/opt/Kingbase/ES/V9/kingbase/bin/sys_monitor.sh restart" to restart the cluster
提示需要重启集群
sys_monitor.sh restart
6、查看参数是否修改成功
使用用户kingbase登录所有集群节点执行如下命令:
grep -E 'wal_keep_segments' $KINGBASE_DATA/es_rep.conf
wal_keep_segments = 512
wal_keep_segments = 1000
grep -E 'reconnect_attempts|reconnect_interval' $KINGBASE_HOME/etc/repmgr.conf
reconnect_attempts=10
reconnect_interval=6
reconnect_attempts=6
reconnect_interval=8
四、注意事项
1. 必须在集群所有节点状态正常的情况下才能执行修改参数操作。
2. 如果没有创建配置文件set_repmgr.conf 和 set_db.conf,执行sys_monitor.sh set会报ERROR如下,需要创建至少一个配置文件:
sys_monitor.sh set --restart
2025-02-05 12:03:27 WRNING: there is no file "/opt/Kingbase/ES/V9/kingbase/bin/../etc/set_db.conf", don't change the es_rep.conf for database
2025-02-05 12:03:27 WRNING: there is no file "/opt/Kingbase/ES/V9/kingbase/bin/../etc/set_repmgr.conf", don't change the repmgr.conf for repmgrd
2025-02-05 12:03:27 ERROR: the file "/opt/Kingbase/ES/V9/kingbase/bin/../etc/set_db.conf" and "/opt/Kingbase/ES/V9/kingbase/bin/../etc/set_repmgr.conf" do not exist, exit
3.set_db.conf 配置要求:
不可以配置 port 参数;
不可以配置 kingbase.conf 中没有的参数;
不可以给参数配置错误的值 。
4.set_repmgr.conf 配置要求:
不建议修改路径相关和数据库连接串等参数;建议仅修改以下参数:
reconnect_attempts #监控数据库设置-连接失败重试次数,默认10
reconnect_interval #监控数据库设置-重试时的时间间隔单位秒,默认6秒
recovery #故障自动恢复设置-自动恢复控制参数。’manual’,关闭自动恢复; ’standby’,自动恢复故障备 库;’automatic’,自动恢复所有故障数据库。默认为 standby。
trust_servers #信任网关
5.所有节点修改方式为参数追加,并没有删除或者修改原始参数,如果需要删除多余追加参数,恢复默认参数,只能分别修改所有集群配置文件 repmgr.conf 和集群中数据库配置文件 es_rep.conf中追加的参数。
6. sys_monitor.sh set --restart 命令等同于 sys_monitor.sh set + sys_monitor.sh restart
五、总结
一键修改集群配置和数据库配置命令很方便,不过修改前查询相关参数是否支持修改。详细的参数说明请查阅官网如下: