案例说明:

集群环境修改集群或数据库参数,需要在每个node上都要修改,在每个节点而执行修改操作,容易出现漏改或节点上参数不一致等错误;在KingbaseES V8R6的集群中增加了,一键修改参数的新功能,可以在一个节点配置后,同时修改集群中所有节点的参数,这样用户在修改集群中的参数时,避免以上错误的发生。

官方文档说明:

https://help.kingbase.com.cn/stage-api/profile/document/kes/v8r6/html/highly/highly-tools/cluster-use/cluster-use-6.html#id2

6. 一键修改集群参数

6.1. 命令行命令

6.1.1. sys_monitor.sh set/set --restart

sys_monitor.sh set/set --restart —一键修改集群配置和数据库配置

6.1.1.1. 描述

sys_monitor.sh set 脚本读取配置文件set_repmgr.conf和set_db.conf中的配置,分别修改集群的配置文件repmgr.conf和es_rep.conf

6.1.1.2. 使用

在$db_etc目录下配置set_repmgr.conf,该配置文件中设置参数,修改集群repmgr.conf文件

例:

图 6.1.20 修改集群repmgr.conf文件

在$db_etc目录下配置set_db.conf,该配置文件中设置参数,修改集群es_rep.conf文件

例:

图 6.1.21 修改集群es_rep.conf文件

6.1.1.3. 选项

以下是脚本执行参数:

set
脚本调用修改集群和数据库配置函数
set --restart
脚本调用修改集群和数据库配置函数,并重启集群。如果修改的参数必须重启数据库才能生效时,使用该项

例:



图 6.1.22 一键修改集群配置和数据库配置

例:



图 6.1.23 一键修改集群配置和数据库配置

6.1.1.4. 注意事项

1.必须在集群所有节点状态正常的情况下才能执行修改参数操作
2.set_db.conf中
不可以配置port参数
不可以配置kingbase.conf中没有的参数
不可以给参数配置错误的值
3.set_repmgr.conf中
不建议修改路径相关和数据库连接串等参数,以下是适合一键修改的参数 例如:
reconnect_attempts
reconnect_interval
recovery
trust_servers

测试案例:

测试数据库版本:

test=# select version();
version
----------------------------------------------------------------------------------------------------------------------
KingbaseES V008R006C005B0041 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46), 64-bit
(1 row)

集群node信息:

[kingbase@node102 bin]$ cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.1.101 node101 ### Standby
192.168.1.102 node102 ### Primary ID | Name | Role | Status | Upstream | repmgrd | PID | Paused? | Upstream last seen
----+---------+---------+-----------+----------+---------+-------+---------+--------------------
1 | node101 | standby | running | node102 | running | 15547 | no | 1 second(s) ago
2 | node102 | primary | * running | | running | 16388 | no | n/a

一、查看集群节点状态

=注意:在修改参数前,必须保证集群中所有节点是正常状态。=

[kingbase@node101 bin]$ ./repmgr cluster show
ID | Name | Role | Status | Upstream | Location | Priority | Timeline | Connection string
----+---------+---------+-----------+----------+----------+----------+----------+----------------------------------------------------------------------------------------------------------------------------------------------------
1 | node101 | standby | running | node102 | default | 100 | 2 | host=192.168.1.101 user=system dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
2 | node102 | primary | * running | | default | 100 | 2 | host=192.168.1.102 user=system dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3

二、修改参数测试

=在主节点的etc目录下,分别配置set_repmgr.conf和set_db.conf,将需要修改的repmgr和数据库参数及value写入到此配置文件中。=

1、查看需要修改的repmgr参数

[kingbase@node101 data]$ cat ../etc/repmgr.conf |grep -i recovery
#recovery='standby'
recovery='automatic' [kingbase@node102 etc]$ cat repmgr.conf |grep recovery
#recovery='standby'
recovery='automatic'

2、配置repmgr参数文件(将需要修改的参数写入此配置文件,注意文件名)

[kingbase@node102 etc]$ cat set_repmgr.conf
recovery=standby

3、查看需要修改的数据库参数

[kingbase@node101 data]$ cat kingbase.conf |grep work_mem
#work_mem = 4MB # min 64kB
#maintenance_work_mem = 64MB # min 1MB
#autovacuum_work_mem = -1 # min 1MB, or -1 to use maintenance_work_mem [kingbase@node102 bin]$ cat ../data/kingbase.conf |grep -i work_mem
#work_mem = 4MB # min 64kB
#maintenance_work_mem = 64MB # min 1MB

4、配置数据库参数文件(将需要修改的参数写入此配置文件,注意文件名)

[kingbase@node102 etc]$ cat set_db.conf
work_mem = 16MB

5、一键修改参数

=注意:如果修改的参数不需要重启就生效,可以用set参数;如果参数修改需要重启集群或数据库才能生效,需要用set --restart参数。=

[kingbase@node102 bin]$ ./sys_monitor.sh set
2022-04-06 11:58:29 Begin to set the es_rep.conf for database ...
2022-04-06 11:58:30 End to set the es_rep.conf for database ... OK
2022-04-06 11:58:30 Begin to set the repmgr.conf for repmgrd ...
2022-04-06 11:58:31 End to set the repmgr.conf for repmgrd ... OK
2022-04-06 11:58:31 Sending signal to reload the database on "192.168.1.102"
server signaled
2022-04-06 11:58:31 Sending signal to reload the database on "192.168.1.101"
server signaled
2022-04-06 11:58:32 Sending signal(SIGKILL) to stop the kbha on "192.168.1.102"
2022-04-06 11:58:34 Sending signal(SIGKILL) to stop the repmgrd on "192.168.1.102"
2022-04-06 11:58:34 begin to stop repmgrd on "[192.168.1.102]".
2022-04-06 11:58:35 repmgrd on "[192.168.1.102]" stop success.
2022-04-06 11:58:36 Start the repmgrd on "192.168.1.102"
2022-04-06 11:58:36 begin to start repmgrd on "[192.168.1.102]".
[2022-04-06 11:58:36] [NOTICE] using provided configuration file "/home/kingbase/cluster/R6HA/kha/kingbase/bin/../etc/repmgr.conf"
[2022-04-06 11:58:36] [NOTICE] redirecting logging output to "/home/kingbase/cluster/R6HA/kha/kingbase/log/hamgr.log" 2022-04-06 11:58:38 repmgrd on "[192.168.1.102]" start success.
2022-04-06 11:58:38 Start the kbha on "192.168.1.102"
[2022-04-06 11:58:41] [NOTICE] redirecting logging output to "/home/kingbase/cluster/R6HA/kha/kingbase/log/kbha.log" 2022-04-06 11:58:42 Sending signal(SIGKILL) to stop the kbha on "192.168.1.101"
2022-04-06 11:58:45 Sending signal(SIGKILL) to stop the repmgrd on "192.168.1.101"
2022-04-06 11:58:45 begin to stop repmgrd on "[192.168.1.101]".
2022-04-06 11:58:46 repmgrd on "[192.168.1.101]" stop success.
2022-04-06 11:58:46 Start the repmgrd on "192.168.1.101"
2022-04-06 11:58:46 begin to start repmgrd on "[192.168.1.101]".
[2022-04-06 11:58:47] [NOTICE] using provided configuration file "/home/kingbase/cluster/R6HA/kha/kingbase/bin/../etc/repmgr.conf"
[2022-04-06 11:58:47] [NOTICE] redirecting logging output to "/home/kingbase/cluster/R6HA/kha/kingbase/log/hamgr.log" 2022-04-06 11:58:48 repmgrd on "[192.168.1.101]" start success.
2022-04-06 11:58:48 Start the kbha on "192.168.1.101"
[2022-04-06 11:58:51] [NOTICE] redirecting logging output to "/home/kingbase/cluster/R6HA/kha/kingbase/log/kbha.log" Some changes may not take effect by RELOAD, you can execute "./sys_monitor.sh restart" to restart the cluster

三、验证参数的修改

1、查看修改后的repmgr参数

如下所示:被修改的repmgr参数将追加到repmgr.conf文件的之后

[kingbase@node102 bin]$ cat ../etc/repmgr.conf |grep -i recovery
#recovery='standby'
recovery='automatic'
auto_cluster_recovery_level=1
recovery=standby ### 修改参数

2、查看数据库参数的修改

如下所示:被修改的数据库参数将追加到es_rep.conf文件的之后

[kingbase@node102 bin]$ cat ../data/es_rep.conf |grep -i work_mem
work_mem = 16MB
You have new mail in /var/spool/mail/kingbase #数据库环境查看:
[kingbase@node102 bin]$ ./ksql -U system test
ksql (V8.0)
Type "help" for help. test=# show work_mem;
work_mem
----------
16MB
(1 row)

四、验证重启集群参数的修改

=注意:在集群或数据库中有些参数的修改,需要重启集群或数据库服务才能生效,建议此类参数的修改,在业务低峰期间执行,防止生产环境中,业务访问受到影响。=

[kingbase@node102 bin]$ ./sys_monitor.sh set --restart
2022-04-06 12:00:23 Begin to set the es_rep.conf for database ...
2022-04-06 12:00:24 End to set the es_rep.conf for database ... OK
2022-04-06 12:00:24 Begin to set the repmgr.conf for repmgrd ...
2022-04-06 12:00:25 End to set the repmgr.conf for repmgrd ... OK
2022-04-06 12:00:25 Ready to stop all DB ...
Service process "node_export" was killed at process 8009
Service process "postgres_ex" was killed at process 8010
Service process "node_export" was killed at process 8135
Service process "postgres_ex" was killed at process 8136
2022-04-06 12:00:32 begin to stop repmgrd on "[192.168.1.102]".
2022-04-06 12:00:33 repmgrd on "[192.168.1.102]" stop success.
2022-04-06 12:00:33 begin to stop repmgrd on "[192.168.1.101]".
2022-04-06 12:00:34 repmgrd on "[192.168.1.101]" stop success.
2022-04-06 12:00:34 begin to stop DB on "[192.168.1.101]".
waiting for server to shut down.... done
server stopped
2022-04-06 12:00:34 DB on "[192.168.1.101]" stop success.
2022-04-06 12:00:34 begin to stop DB on "[192.168.1.102]".
waiting for server to shut down.... done
server stopped
2022-04-06 12:00:35 DB on "[192.168.1.102]" stop success.
2022-04-06 12:00:35 Done.
2022-04-06 12:00:35 Ready to start all DB ...
2022-04-06 12:00:35 begin to start DB on "[192.168.1.102]".
waiting for server to start.... done
server started
2022-04-06 12:00:36 execute to start DB on "[192.168.1.102]" success, connect to check it.
2022-04-06 12:00:37 DB on "[192.168.1.102]" start success.
2022-04-06 12:00:37 Try to ping trusted_servers on host 192.168.1.102 ...
2022-04-06 12:00:40 Try to ping trusted_servers on host 192.168.1.101 ...
2022-04-06 12:00:42 begin to start DB on "[192.168.1.101]".
waiting for server to start.... done
server started
2022-04-06 12:00:43 execute to start DB on "[192.168.1.101]" success, connect to check it.
2022-04-06 12:00:44 DB on "[192.168.1.101]" start success.
ID | Name | Role | Status | Upstream | Location | Priority | Timeline | Connection string
----+---------+---------+-----------+----------+----------+----------+----------+----------------------------------------------------------------------------------------------------------------------------------------------------
1 | node101 | standby | running | node102 | default | 100 | 2 | host=192.168.1.101 user=system dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
2 | node102 | primary | * running | | default | 100 | 2 | host=192.168.1.102 user=system dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
2022-04-06 12:00:44 The primary DB is started.
2022-04-06 12:00:44 begin to start repmgrd on "[192.168.1.102]".
[2022-04-06 12:00:45] [NOTICE] using provided configuration file "/home/kingbase/cluster/R6HA/kha/kingbase/bin/../etc/repmgr.conf"
[2022-04-06 12:00:45] [NOTICE] redirecting logging output to "/home/kingbase/cluster/R6HA/kha/kingbase/log/hamgr.log" 2022-04-06 12:00:47 repmgrd on "[192.168.1.102]" start success.
2022-04-06 12:00:47 begin to start repmgrd on "[192.168.1.101]".
[2022-04-06 12:00:49] [NOTICE] using provided configuration file "/home/kingbase/cluster/R6HA/kha/kingbase/bin/../etc/repmgr.conf"
[2022-04-06 12:00:49] [NOTICE] redirecting logging output to "/home/kingbase/cluster/R6HA/kha/kingbase/log/hamgr.log" 2022-04-06 12:00:50 repmgrd on "[192.168.1.101]" start success.
ID | Name | Role | Status | Upstream | repmgrd | PID | Paused? | Upstream last seen
----+---------+---------+-----------+----------+---------+-------+---------+--------------------
1 | node101 | standby | running | node102 | running | 15547 | no | 1 second(s) ago
2 | node102 | primary | * running | | running | 16388 | no | n/a
[2022-04-06 12:00:53] [NOTICE] redirecting logging output to "/home/kingbase/cluster/R6HA/kha/kingbase/log/kbha.log" [2022-04-06 12:00:57] [NOTICE] redirecting logging output to "/home/kingbase/cluster/R6HA/kha/kingbase/log/kbha.log" 2022-04-06 12:00:58 Done.

五、参数修改故障案例

=在修改参数时,如果只是配置了set_repmgr.conf文件,缺少set_db.conf文件,则执行一键修改时出现以下错误,需要同时创建以上两个文件。=

[kingbase@node102 bin]$ ./sys_monitor.sh set
2022-04-06 11:51:18 WRNING: there is no file "/home/kingbase/cluster/R6HA/kha/kingbase/bin/../etc//set_db.conf", don't change the es_rep.conf for database
2022-04-06 11:51:18 WRNING: there is no file "/home/kingbase/cluster/R6HA/kha/kingbase/bin/../etc//set_repmgr.conf", don't change the repmgr.conf for repmgrd
2022-04-06 11:51:18 ERROR: the file "/home/kingbase/cluster/R6HA/kha/kingbase/bin/../etc//set_db.conf" and "/home/kingbase/cluster/R6HA/kha/kingbase/bin/../etc//set_repmgr.conf" do not exist, exit

六、总结

对于KingbaseES V8R6集群一键修改参数的功能,方便了集群的维护和管理,但注意,并不是所有参数都能修改,具体可以参考官方文档说明。

KingbaseES R6 集群一键修改集群和数据库参数测试案例的更多相关文章

  1. KingbaseES R3 集群一键修改集群用户密码案例

    案例说明: 在KingbaseES R3集群的最新版本中增加了kingbase_monitor.sh一键修改集群用户密码的功能,本案例是对此功能的测试. kingbaseES R3集群一键修改密码说明 ...

  2. KingbaseES R6 集群sys_monitor.sh change_password一键修改集群用户密码

    案例说明: kingbaseES R6集群用户密码修改,需要修改两处: 1)修改数据库用户密码(alter user): 2)修改.encpwd文件中用户密码: 可以通过sys_monitor.sh ...

  3. KingbaseES R6 主备流复制集群创建级联复制案例

    案例环境: 数据库: test=# select version(); version -------------------------------------------------------- ...

  4. KingbaseES R6 集群修改物理IP和VIP案例

    在用户的实际环境里,可能有时需要修改主机的IP,这就涉及到集群的配置修改.以下以例子的方式,介绍下KingbaseES R6集群如何修改IP. 一.案例测试环境 操作系统: [KINGBASE@nod ...

  5. KingbaseES R6 集群修改data目录

    案例说明: 本案例是在部署完成KingbaseES R6集群后,由于业务的需求,集群需要修改data(数据存储)目录的测试.本案例分两种修改方式,第一种是离线修改data目录,即关闭整个集群后,修改数 ...

  6. KingbaseES R6 集群禁用 root ssh 后需要修改集群为es_server 案例

    案例说明: 在生产环境下,由于安全需要,主机间不允许建立root用户的ssh信任连接,这样导致KingbaseES R6 repmgr集群,通过sys_monitor.sh脚本启动集群时,节点之间不能 ...

  7. KingbaseES R6 集群修改ssh端口执行sys_backup.sh备份案例

    数据库环境:** test=# select version(); version ---------------------------------------------------------- ...

  8. KingbaseES R6 通过脚本构建集群案例

      案例说明: KingbaseES V8R6部署一般可采用图形化方式快速部署,但在生产一线,有的服务器系统未启用图形化环境,所以对于KingbaseES V8R6的集群需采用手工字符界面方式部署,本 ...

  9. KingbaseES R6 集群创建流复制只读副本库案例

    一.环境概述 [kingbase@node2 bin]$ ./ksql -U system test ksql (V8.0) Type "help" for help. test= ...

随机推荐

  1. Spring Data JPA系列3:JPA项目中核心场景与进阶用法介绍

    大家好,又见面了. 到这里呢,已经是本SpringData JPA系列文档的第三篇了,先来回顾下前面两篇: 在第1篇<Spring Data JPA系列1:JDBC.ORM.JPA.Spring ...

  2. UiPath选择器之页面选择器的介绍和使用

    一.页面选择器的介绍 某些软件程序的布局和属性节点具有易变的值,例如某些Web应用程序.UiPath Studio无法预测这些变化,因此,您可能必须手动生成一些选择器. 每个属性都有一个分配的值.选择 ...

  3. NC202498 货物种类

    NC202498 货物种类 题目 题目描述 某电商平台有 \(n\) 个仓库,编号从 \(1\) 到 \(n\) . 当购进某种货物的时候,商家会把货物分散的放在编号相邻的几个仓库中. 我们暂时不考虑 ...

  4. 12月15日DP作业

    [APIO2014]连珠线 考虑一组以 \(x\) 为中点的蓝边,有两种可能: \[son[x]->x->fa[x] \] \[son[x]->x->son[x] \] 其中若 ...

  5. Thread类的常用方法_获取线程名称的方法和设置线程名称的方法

    Thread类的常用方法 获取线程的名称: 1.使用Thread类中的方法getName() String getName() 返回该线程的名称 2.可以先获取到当前正在执行的线程,使用线程中的方法g ...

  6. throws关键字_异常处理的第一种方式(交给别人处理)和try_catch_异常处理的第二种方式(自己处理)

    throws关键字:异常处理的第一种方式,交给别人处理 作用: 当方法内部抛出异常对象的时候,那么我们就必须处理这个异常对象 可以使用throws关键字处理异常对象, 会把异常对象声明抛出给方法的调用 ...

  7. c# SerialPort HEX there is no data received

    C#窗口程序进行串口通信,按照串口通信协议,设置com口,波特率,停止位,校验位,数据位,本地虚拟串口调试ok,但是和外设调试时,发送HEX模式数据命令,没有数据返回, 所以关键问题在于HEX模式,发 ...

  8. 2022-7-10 css 第七组 刘昀航

    ​ 样式通常存储在样式表中(先定义样式表),再把样式表添加到html元素中 定义CSS样式的方式: 行内样式(内联样式) ​ ·行内样式仅针对当前标签生效,如果当前的样式不需要复用,可以用行内样式 · ...

  9. vue使用vuex报错 "export 'watch' was not found in 'vue'

    问题 安装Vuex后报错"export 'watch' was not found in 'vue' 解决方法 如果你的vue版本是 2.X ,将vuex升到 3.X.X 就能够解决 npm ...

  10. .net6与英雄联盟邂逅之——根据官方LCU API制作游戏助手

    看了网上很多自己开发的英雄联盟的小助手工具,当时苦于没有api,自己也想做一个.后来发现了其实拳头本身就提供了LCU API在客户端运行的时候会暴露出来. 现在我们就来了解下工具的实现. 查询数据:h ...