Kingbase V8R6集群安装部署案例---脚本在线一键缩容

案例说明:
KingbaseES V8R6支持图形化方式在线缩容,但是在一些生产环境,在服务器不支持图形化界面的情况下 ,只能通过脚本命令行的方式执行集群的部署或在线缩容。

Tips:
KingbaseES V8R6C5默认情况下部署脚本(V8R6_cluster_install.sh)和配置文件(install.conf)不支持在线缩容,需要从KingbaseES V8R6C6版本下拷贝脚本和配置文件到 KingbaseES V8R6C5环境下使用。

适用版本:KingbaseES V8R6

一、集群节点状态信息

1、主机节点信息

2、缩容前集群节点状态

[kingbase@node101 bin]$ ./repmgr cluster show
 ID | Name    | Role    | Status    | Upstream | Location | Priority | Timeline | Connection string                                 
----+---------+---------+-----------+----------+----------+----------+----------+----------------------------------------------------------------------------------------------------------------------------------------------------
 1  | node101 | primary | * running |          | default  | 100      | 3        | 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 | standby |   running | node101  | default  | 100      | 3        | 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
 3  | node3   | standby |   running | node101  | default  | 100      | 3        | host=192.168.1.103 user=system dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3

二、执行集群在线缩容

缩容说明参考官方文档:https://help.kingbase.com.cn/stage-api/profile/document/kes/v8r6/html/highly/availability/cluster-use/cluster-use-6.html#sshd

1、主库节点相关目录和文件

2、在主库节点配置install.conf文件

[kingbase@node101 r6_install]$ cat install.conf |grep -v ^$|grep -v ^#
[install]
on_bmj=0
all_ip=(192.168.1.101 192.168.1.102)
witness_ip=""
production_ip=()
local_disaster_recovery_ip=()
remote_disaster_recovery_ip=()
install_dir="/home/kingbase/cluster/HA_R6/kha/kingbase"
zip_package="/home/kingbase/r6_install/db.zip"
license_file=(license.dat)
db_user="system"                 # the user name of database
db_port="54321"                  # the port of database, defaults is 54321
db_mode="oracle"                 # database mode: pg, oracle
db_auth="scram-sha-256"          # database authority: scram-sha-256, md5, default is scram-sha-256
db_case_sensitive="yes"          # database case sensitive settings: yes, no. default is yes - case sensitive; no - case insensitive (NOTE. cannot set to 'no' when db_mode="pg").
trusted_servers="192.168.1.1"
data_directory="/home/kingbase/cluster/HA_R6/kha/kingbase/data"
virtual_ip=""
net_device=(enp0s3 enp0s3)
net_device_ip=(192.168.1.101 192.168.1.102)
ipaddr_path="/usr/sbin"
arping_path="/opt/Kingbase/ES/V8R6_041/Server/bin/"
ping_path="/bin"
super_user="root"
execute_user="kingbase"
deploy_by_sshd=1                 # choose whether to use sshd when deploy, 0 means not to use (deploy by sys_securecmdd), 1 means to use (deploy by sshd), default value is 1; when on_bmj=1, it will auto set to no(deploy_by_sshd=0)
use_scmd=1                       # Is the cluster running on sys_securecmdd or sshd? 1 means yes (on sys_securecmdd), 0 means no (on sshd), default value is 1; when on_bmj=1, it will auto set to yes(use_scmd=1)
reconnect_attempts="10"          # the number of retries in the event of an error
reconnect_interval="6"           # retry interval
recovery="standby"               # the way of cluster recovery: standby/automatic/manual
ssh_port="22"                    # the port of ssh, default is 22
scmd_port="8890"                 # the port of sys_securecmdd, default is 8890
auto_cluster_recovery_level='1'
use_check_disk='off'
synchronous='quorum'

########## shrink configure ###############
[shrink]
shrink_type="0"                   # The node type of standby/witness node, which would be delete from cluster. 0:standby  1:witness
primary_ip="192.168.1.101"                    # The ip addr of cluster primary node, which need to shrink a standby/witness node.
shrink_ip="192.168.1.103"                     # The ip addr of standby/witness node, which would be delete from cluster.
node_id="3"                       # The node_id of standby/witness node, which would be delete from cluster. It does not the same with any one in  cluster node
                                 # for example: node_id="3"
install_dir="/home/kingbase/cluster/R6HA/kha"
ssh_port="22"                    # the port of ssh, default is 22
scmd_port="8899"                 # the port of sys_securecmd, default is 8890

=如下所示,缩容配置信息,具体说明参考官方文档。=

3、执行在线缩容

[kingbase@node101 r6_install]$ sh V8R6_cluster_install.sh shrink
[CONFIG_CHECK] will deploy the cluster of
[RUNNING] success connect to the target "192.168.1.103" ..... OK
[RUNNING] success connect to "192.168.1.103" from current node by 'ssh' ..... OK
......
2022-07-21 11:04:10 DB on "[localhost]" stop success.
 ID | Name    | Role    | Status    | Upstream | Location | Priority | Timeline | Connection string                                 
----+---------+---------+-----------+----------+----------+----------+----------+----------------------------------------------------------------------------------------------------------------------------------------------------
 1  | node101 | primary | * running |          | default  | 100      | 3        | 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 | standby |   running | node101  | default  | 100      | 3        | 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
[Thu Jul 21 11:04:11 CST 2022] [INFO]  drop replication slot:repmgr_slot_3...
 pg_drop_replication_slot
--------------------------

(1 row)

[Thu Jul 21 11:04:12 CST 2022] [INFO]  drop replication slot:repmgr_slot_3...OK

=如上所示,集群缩容成功。=

三、检测集群节点信息

1、查看集群节点状态信息

[kingbase@node101 bin]$ ./repmgr cluster show
 ID | Name    | Role    | Status    | Upstream | Location | Priority | Timeline | Connection string                                 
----+---------+---------+-----------+----------+----------+----------+----------+----------------------------------------------------------------------------------------------------------------------------------------------------
 1  | node101 | primary | * running |          | default  | 100      | 3        | 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 | standby |   running | node101  | default  | 100      | 3        | 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

2、查看主备流复制信息

test=# select * from sys_stat_replication;
 pid  | usesysid | usename | application_name |  client_addr  | client_hostname | client_port |         backend_start         | backend_xmin |   state   |  sent_lsn  | write_lsn  | flush_lsn  | replay_lsn | write_lag | flush_lag | replay_lag | sync_priority | sync_state |          reply_time
------+----------+---------+------------------+---------------+-----------------+-------------+-------------------------------+-----
 3080 |       10 | system  | node102          | 192.168.1.102 |                 |       12435 | 2022-07-21 09:31:44.710518+08 |         | streaming | 0/930632F0 | 0/930632F0 | 0/930632F0 | 0/930632F0 |           |           |            |             1 | sync       | 2022-07-21 11:15:25.735078+08
(1 row)

3、查看复制槽信息

test=# select * from sys_replication_slots;
   slot_name   | plugin | slot_type | datoid | database | temporary | active | active_pid | xmin | catalog_xmin | restart_lsn | confirmed_flush_lsn
---------------+--------+-----------+--------+----------+-----------+--------+------------+------+--------------+-------------+-----
 repmgr_slot_2 |        | physical  |        |          | f         | t      |       3080 | 1620 |              | 0/930632F0  |
(1 row)

四、总结

1、KingbaseES V8R6通过脚本缩容操作比较简单,但是KingbaseES V8R6C5自带的脚本和配置文件不支持缩容操作,需要从KingbaseES V8R6C6的软件包下拷贝脚本和配置文件。
2、在集群缩容前保证集群所有节点的状态信息正常,流复制正常。
3、缩容后的节点的相关目录和文件没有被物理删除,需要手工清理 。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值