KingbaseES RWC软件简介
KingbaseES软件(简称:KES) 能够提供一主一备以及一主多备的高可用集群架构,实现数据及实例级 (异地) 故障容灾,也能够提供多节点并行服务,内存融合及存储共享,实现高并发性能利用最大化,结合读写分离或备份使用同步实现数据保护最大化。
金仓数据守护集群软件(简称:Kingbase Data Watch)是由主库、备库和守护进程组成的集群,主库提供数据库读写服务,备库和主库通过流复制同步数据作为备份,守护进程检查各个数据库状态以及环境状态,当主库故障后可以进行故障转移将备库提升为主库继续对外提供服务,确保主备集群持续提供服务。
金仓数据库读写分离集群软件(简称:KingbaseRWC)在金仓数据守护集群软件的基础上增加了对应用透明的读写负载均衡能力。相比数据守护集群,该类集群中所有备库均可对外提供查询能力,从而减轻了主库的读负载压力,可实现更高的事务吞吐率;该软件支持在多个备库间进行读负载均衡。一般情况下,应用系统中查询等只读操作远多于写入操作,KingbaseRWC为了保证集群在高并发、高压力下性能不下降,需要借助读写分离将读操作分发到备库来分担业务压力,从而减轻主库压力,提升集群的整体吞吐量。
KingbaseES 读写分离集群架构图:
集群每个节点都存在两个守护进程:
1、守护进程repmgrd:主要负责数据库的状态检查和故障处理,包括:故障自动切换、故障自动恢复等。
2、守护进程kbha:主要负责repmgrd进程的状态监控,以及一些环境的检查,包括:信任网关检查、存储检测等。
读写分离集群功能特点:
a、多实例冗余,支持实例级(含异地)容灾切换。
b、节点独立存储多份数据冗余,支持数据(存储)级容灾(集群内任一存储完好均可恢复其余节点介质故障)。
c、平衡应用读写负载,可将交易类系统指向主库,只读类系统指向备库实现读写分离均衡负载。
d、支持坏块检测与修复。
本文主要讲述RWC集群部署过程,单机部署请参考:
中电科金仓KingbaseES(KES)V9单机部署
KingbaseES(KES)RWC集群部署
KES 软件下载
https://download.kingbase.com.cn/xzzx/index.htm
license下载
license文件版本差异说明:
license文件下载:这里下载企业版,有效期90天。
安装前环境准备
由于磁盘空间有限,本次RWC部署架构为一主一从。本节的操作需要在两个节点都执行。
主机、目录规划
主机名 | ip地址 | OS版本 | 内存、CPU | 节点角色 | 数据库端口 |
---|---|---|---|---|---|
node1 | 192.*.*.60 | Centos7.9 | 4G 、 1个双核 | 主节点 | 54321 |
node2 | 192.*.*.62 | Centos7.9 | 4G 、 1个双核 | 备节点 | 54321 |
软件包:/soft/KingbaseES_V009R001C002B0014_Lin64_install.iso
license文件:/soft/license_企业版.zip
kes单机软件安装目录 /opt/kes/v9
单机数据存放目录 /data
kes集群软件安装目录 /opt/kes/v9
集群数据存放目录 /data/cluster(注:本环境中的/data是提前挂载到文件系统的,此处不能用/data)
关闭SELINUX
#查看是否开启SELINUX
getenforce
#永久关闭
vi /etc/selinux/config
修改SELINUX=disabled
或者
sed -i 's/^SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
修改后,重启系统。
#临时关闭
setenforce 0
关闭防火墙
systemctl disable firewalld.service
systemctl stop firewalld.service
systemctl status firewalld
关闭RemoveIPC
systemd-logind服务中引入的一个特性,是当一个用户退出系统后,会删除所有有关的IPC对象。该特性由/etc/systemd/logind.conf文件中的RemoveIPC参数控制。某些操作系统会默认打开,会造成程序信号丢失等问题(只有redhat7及以上和一些特殊的国产Linux的版本需要修改,改之前可先查看此项是否为默认yes)。
在各数据库节点上,关闭RemoveIPC。
(1) 修改/etc/systemd/logind.conf文件中的“RemoveIPC”值为“no”
cat >> /etc/systemd/logind.conf << EOF
RemoveIPC=no
EOF
(2) 修改/usr/lib/systemd/system/systemd-logind.service文件中的“RemoveIPC”值为“no”
cat >> /usr/lib/systemd/system/systemd-logind.service << EOF
RemoveIPC=no
EOF
(3) 重启服务
systemctl daemon-reload
systemctl restart systemd-logind.service
(4) 结果验证确认
loginctl show-session | grep RemoveIPC
systemctl show systemd-logind | grep RemoveIPC
配置sudo权限
cat >>/etc/sudoers << EOF
kingbase ALL=(ALL) NOPASSWD:ALL
EOF
配置时间同步
yum install -y ntpdate
--每天凌晨2点进行同步
crontab -e
0 2 * * * /usr/sbin/ntpdate time.windows.com >> /var/log/ntpdate.log 2>&1
设置/etc/hosts
cat >> /etc/hosts <<EOF
192.*.*.60 node1 #注意*要根据实际情况替换
192.*.*.62 node2
EOF
设置内核参数
cat >> /etc/sysctl.conf <<EOF
#added by kingbase
fs.aio-max-nr= 1048576
fs.file-max= 6815744
kernel.shmall= 2097152
kernel.shmmax= 4294967295
kernel.shmmni= 4096
kernel.sem= 250 32000 100 128
net.ipv4.ip_local_port_range= 9000 65500
net.core.rmem_default= 262144
net.core.rmem_max= 4194304
net.core.wmem_default= 262144
net.core.wmem_max= 1048576
EOF
sysctl -p 生效
设置资源限制
cat >> /etc/security/limits.conf <<EOF
#added by kingbase
kingbase soft nproc 65536
kingbase hard nproc 65536
kingbase soft nofile 65536
kingbase hard nofile 65536
kingbase soft stack 10240
kingbase hard stack 32768
kingbase soft core unlimited
kingbase hard core unlimited
EOF
创建用户及用户组
groupadd -g 1101 kingbase
useradd -g kingbase -u 1101 -m kingbase
echo "new密码" | passwd --stdin kingbase
创建软件安装目录并授权
mkdir -p /opt/kes/v9 chown -R kingbase:kingbase /opt/kes/v9 chmod 755 /opt/kes/v9
创建数据目录并授权
mkdir -p /data #本环境中的/data是提前挂载的,此处不需要创建
chown -R kingbase:kingbase /data
chmod 755 /data
命令行安装KES软件(只在主节点操作)
KES安装包挂载
mount -o loop /soft/KingbaseES_V009R001C002B0014_Lin64_install.iso /mnt/
解压license文件
unzip /soft/license_企业版.zip -d /soft
命令回显如下:
[root@node1 /]# unzip /soft/license_企业版.zip -d /soft
Archive: license_企业版.zip
creating: /soft/license_41248/
inflating: /soft/license_41248/license_41248_0.dat
开始安装kes软件
使用kingbase用户进行安装,主要安装过程如下:
su - kingbase
cd /mnt
./setup.sh
1、接受许可协议
2、选择安装方式
->1- Full
2- Client
3- Custom
3、选择license文件:
File Path: /soft/license_41248/license_41248_0.dat
4、选择软件安装文件夹
ENTER AN ABSOLUTE PATH, OR PRESS <ENTER> TO ACCEPT THE DEFAULT
: /opt/kes/v9
5、选择数据目录文件夹
Data folder (Default: /opt/kes/v9/data): /data
6、输入端口
Please enter database service listened port, default 54321.
Port (Default: 54321):
5、输入数据库管理用户和密码
Please enter database administrator user name.
User: (Default: system):
Please Enter the Password: Please Enter the Password:******
6、输入服务器字符集编码
Please enter server character set encoding.
1- default
->2- UTF8
3- GBK
4- GB2312
5- GB18030
ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS <ENTER> TO ACCEPT THE DEFAULT: 2
7、输入数据库的区域设置
Please enter the Database Locale.
1- C
->2- zh_CN.UTF-8
3- en_US.UTF-8
ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS <ENTER> TO ACCEPT THE DEFAULT: 3
8、输入数据库模式
Please enter database mode.
1- PG
->2- ORACLE
3- MySQL
ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS <ENTER> TO ACCEPT THE DEFAULT: 2
9、输入大小写敏感性
Please enter the case sensitivity.
->1- YES
2- NO
ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS <ENTER> TO ACCEPT THE DEFAULT: 2
10、输入数据库block大小
Please enter block size used in storing data.
->1- 8k
2- 16k
3- 32k
ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS <ENTER> TO ACCEPT THE DEFAULT: 1
11、输入加密方法
Please enter the encrypt method.
->1- scram-sha-256
2- scram-sm3
3- sm4
4- sm3
ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS <ENTER> TO ACCEPT THE DEFAULT: 1
12、自定义参数
Please enter database custom parameters.
Custom (Default: ):
13、初始化数据库
The database will be initialized, which may take some time. Please be patient.
PRESS <ENTER> TO CONTINUE:
14、安装完成
Congratulations. KingbaseES V9 has been successfully installed to:
/opt/kes/v9
If you want to register KingbaseES V9 as OS service, please run
/opt/kes/v9/install/script/root.sh
PRESS <ENTER> TO EXIT THE INSTALLER:
Complete.
本次要部署集群,不需要执行/opt/kes/v9/install/script/root.sh脚本。
说明:kes软件静默安装也是非常方便,配置/mnt/setup/silent.cfg文件即可。
集群部署(只在主节点操作)
关闭数据库
如果前面部署kes软件时启动了数据库,需要先关闭。
sys_ctl stop -D /data
waiting for server to shut down.... done
server stopped
集群安装目录及部署文件说明
kes集群软件目录: /opt/kes/v9,这里使用前面kes软件安装时的目录,也可以使用其他目录,如果使用其他目录需提前创建。
kes集群数据目录: /data/cluster,该目录不能提前创建,kes集群软件部署时会自动创建。注意:本环境中/data目录是提前挂载到文件系统上的,不能直接删除,所以此处不能指定/data目录,指定了/data/cluster新目录。
集群部署文件在{kes软件安装目录}/KESRealPro/V009R001C002B0014/ClientTools/guitools/DeployTools/zip/目录下,如下:
su - kingbase
cd /opt/kes/v9/KESRealPro/V009R001C002B0014/ClientTools/guitools/DeployTools/zip/
[kingbase@node1 zip]$ ll
total 322408
-rwxrwxr-x 1 kingbase kingbase 252402 Sep 23 18:41 cluster_install.sh #集群部署脚本
-rw-rw-r-- 1 kingbase kingbase 327258132 Sep 23 18:41 db.zip #数据库压缩包
-rw-rw-r-- 1 kingbase kingbase 19379 Sep 23 18:41 install.conf #部署配置文件
-rw-rw-r-- 1 kingbase kingbase 2595145 Sep 23 18:41 securecmdd.zip #安全工具包
-rwxrwxr-x 1 kingbase kingbase 9677 Sep 23 18:41 trust_cluster.sh #配置SSH免密脚本
拷贝授权文件
拷贝授权文件到{kes软件安装目录}/KESRealPro/V009R001C002B0014/ClientTools/guitools/DeployTools/zip/目录。
cp /soft/license_41248/license_41248_0.dat /opt/kes/v9/KESRealPro/V009R001C002B0014/ClientTools/guitools/DeployTools/zip/ mv license_41248_0.dat license.dat
配置ssh免密
[kingbase@node1 cluster]$ sudo ./trust_cluster.sh
[INFO] set password-free between root and kingbase
known_hosts 100% 529 380.1KB/s 00:00
id_rsa 100% 1679 8.8MB/s 00:00
id_rsa.pub 100% 392 2.6MB/s 00:00
authorized_keys 100% 784 6.2MB/s 00:00
known_hosts 100% 529 365.7KB/s 00:00
id_rsa 100% 1679 1.8MB/s 00:00
id_rsa.pub 100% 392 664.5KB/s 00:00
authorized_keys 100% 784 1.5MB/s 00:00
connect to "192.*.*.60" from current node by 'ssh' kingbase:0..... OK
connect to "192.*.*.60" from current node by 'ssh' root:0..... OK
connect to "192.*.*.62" from "192.*.*.60" by 'ssh' kingbase->kingbase:0 .... OK
connect to "192.*.*.62" from "192.*.*.60" by 'ssh' root->root:0 root->kingbase:0 kingbase->root:0.... OK
connect to "192.*.*.62" from current node by 'ssh' kingbase:0..... OK
connect to "192.*.*.62" from current node by 'ssh' root:0..... OK
connect to "192.*.*.60" from "192.*.*.62" by 'ssh' kingbase->kingbase:0 .... OK
connect to "192.*.*.60" from "192.*.*.62" by 'ssh' root->root:0 root->kingbase:0 kingbase->root:0.... OK
check ssh connection success!
编辑install.conf脚本
在install.conf文件中修改了10处,都用<-------数字------->标识出来了。
[kingbase@node1 cluster]$ vi /opt/kes/v9/cluster/install.conf
## install.conf
## cluster deployment script configuration instructions:
## path: in the same path as cluster_install.sh.
## parameter: colud be set in the config file, also could be set in cluster_install.sh script(give priority to the configuration in this file).
## constraints: 1. SSH encryption needs to be manually configured between the devices on which the script is run and the devices installed in the cluster, including between root users, ordinary users, root user and ordinary users.
## 2. general-purpose computers can only be executed on ordinary users who are configured with SSH encryption, and BMJ can only be executed on root user, and all must be executed on the primary host.
## 3. db.zip package decompression is completed at the directory level such as lib, bin, share, there can not be one more layer of directories in the middle, the directory like "kingbase/bin" can not be supported.
## 4. automatic switching, automatic recovery, quorum syncgronization mode are enabled by default, scram-sha-256 cluster is enabled by default.
## instructions:
## if you are currently in BMJ or deploy_by_sshd=0, you need to ensure that all hosts have successfully installed the database and that sys_securecmdd is in the startup state
######################################################################
# Required parameters
#####################################################################
[install]
## whether it is BMJ, if so, on_bmj=1, if not on_bmj=0, defaults to on_bmj=0
on_bmj=0
## the cluster node IP which needs to be deployed, is separated by spaces, for example: all_ip=(192.168.1.10 192.168.1.11)
## or all_ip=(host1 host2)
## means deployed cluster of DG ==> ha_running_mode='DG'
all_ip=(192.*.*.60 192.*.*.62) <-------1------->
## only set if need to setup witness node in cluster. The value is the IP of witness node, for example: witness_ip="192.168.1.12"
## or witness_ip="host"
## it must be NULL when ha_running_mode='TPTC'
witness_ip=""
## the node IP will deployed in PRODUCTION, could not set it when all_ip is not NULL.
## the virtual_ip must be NULL, and auto_cluster_recovery_level will be 0.
## means deployed cluster of TPTC ==> ha_running_mode='TPTC'
## Cannot be configured as a domain name
production_ip=()
## the node IP will deployed in LOCAL DISASTER, could not be NULL if the production_ip is not NULL.
## Cannot be configured as a domain name
local_disaster_recovery_ip=()
## the node IP will deployed in REMOTE DISASTER, it could be NULL even the production_ip is not NULL.
## Cannot be configured as a domain name
remote_disaster_recovery_ip=()
## the path of cluster to be deployed, for example: install_dir="/home/kingbase/tmp_kingbase" [if it is BMJ, you do not need to configure this parameter]
## the directory structure after deployment:
## ${install_dir}/kingbase/data the data directory
## ${install_dir}/kingbase/archive log archive directory
## ${install_dir}/kingbase/etc configuration file directory
## ${install_dir}/kingbase/bin、lib、share、log install file directory
## the last layer of directory could not add '/'
install_dir="/opt/kes/v9" <-------2------->
## the absolute path of zip package, for example: zip_package="/home/kingbase/db.zip" [if it is BMJ or deploy_by_sshd=0, you do not need to configure this parameter]
## zip、tar and tar.gz package can be supported.
zip_package="/opt/kes/v9/KESRealPro/V009R001C002B0014/ClientTools/guitools/DeployTools/zip/db.zip" <-------3------->
## the name of license.dat [if it is BMJ or deploy_by_sshd=0, you do not need to configure this parameter]
## if there are multiple license files, please write down all of them.
## make sure that the write order of license.dat file is the same as that of all_ip, if the same license file can be used in different devices, you can just write once.
## since the license file must named with "license.dat", if you have more than one license files, please use different name to distinguish them.
## example: license_file=(license.dat) or license_file=(license.dat-1 license.dat-2)
license_file=(license.dat)
# database initializes user configuration
db_user="system" # the user name of database
#db_password="" # the password of database.
db_port="54321" # the port of database, defaults is 54321
db_mode="oracle" # database mode: pg, oracle, mysql
db_auth="scram-sha-256" # database authority: scram-sha-256, md5, scram-sm3, sm4, default is scram-sha-256
db_case_sensitive="no" # database case sensitive settings: yes, no. default is yes - case sensitive; no - case insensitive
# (NOTE. cannot set to 'no' when db_mode="pg", and cannot set to 'yes' when db_mode="mysql").
db_checksums="yes" # the checksum for data: yes, no. default is yes - a checksum is calculated for each data block to prevent corruption; no - nothing to do.
archive_mode="on" # enables archiving; off, on, or always
db_encoding="" # Cararcter set encoding to use in the new database.Specify a tring constant,or an integer encoding number, default value provided by locale command.
db_collate="" # Collation order(LC_COLLATE) to use in the new database,This affects the sort order applied to strings, default value provided by locale command.
db_ctype="" # Character classification(LC_CTYPE) to use int the new database. This affects the categorization of characters, default value provided by locale command.
other_db_init_options="" # addional initdb options,such as "--scenario-tuning" (NOTE. cannot set --scenario-tuning when db_mode="mysql")
sync_security_guc="no" # sync security GUC parameters in cluster (exclude witness): yes, no. default is no.
# yes - for auto sync security GUC, create extension kdb_schedule and security_utils; no - nothing to do.
tcp_keepalives_idle="2" # (integer; default: 7200; since Linux 2.2)
# The number of seconds a connection needs to be idle before TCP begins sending out keep-alive counts. Keep-alives are sent only when the
# SO_KEEPALIVE socket option is enabled. The default value is 7200 seconds (2 hours). An idle connection is terminated after approximately an
# additional 11 minutes (9 counts an interval of 75 seconds apart) when keep-alive is enabled.
tcp_keepalives_interval="2" # (integer; default: 75; since Linux 2.4)
# The number of seconds between TCP keep-alive counts.
tcp_keepalives_count="3" # (integer; default: 9; since Linux 2.2)
# The maximum number of TCP keep-alive counts to send before giving up and killing the connection if no response is obtained from the other end.
tcp_user_timeout="9000" # (since Linux 2.6.37)
connection_timeout="10" # connection timeout when use ssh or sys_securecmdd
wal_sender_timeout="30000" # in milliseconds; 0 disables
wal_receiver_timeout="30000" # time that receiver waits for
# communication from master
# in milliseconds; 0 disables
## the trust ip, which separated by English ',', and spaces are not allowed.
## For example: trusted_servers="192.168.28.1,192.168.29.1" or trusted_servers="host1,host2"
trusted_servers="192.*.*.60,192.*.*.62" <-------4------->
## if failed to ping trusted_servers, the database can still be running? on, off. default is on - do nothing, the database will running; off - will stop the database.
running_under_failure_trusted_servers='on'
#####################################################################
# Optional parameters
#####################################################################
## the path of data directory, BMJ defaults to "/opt/Kingbase/ES/V8/data", the general machine defaults to "install_dir/kingbase/data"
data_directory="/data/cluster" <-------5------->
## if seperate sys_wal from data directory, set the sys_wal location to waldir.
## the location should not be under the data directory
## the location should be an absolute path
## the waldir should be an empty path or nonexistent, initdb would create the location if it's nonexistent
waldir=''
## the vitural IP, for example: virtual_ip="192.168.28.188/24"
virtual_ip="192.*.*.64/24" <-------6------->
## the net device, after configuring the vitural IP, net_device must been configured.
## please make sure that the writing order of net_device is the same as all_ip, if the net_device is the same, it should also be written together.
## do not need to consider net_device on witness node if configured witness_ip
## for example: net_device=(ens192 ens192) or net_device=(ens192 eth0)
net_device=(ens33 ens33) <-------7------->
## the net device ip, after configuring the vitural IP, net_device_ip must been configured.
## please make sure that the writing order of net_device_ip is the same as all_ip
## do not need to consider net_device_ip on witness node if configured witness_ip
## for example: net_device_ip=(10.10.11.128 10.10.11.129)
net_device_ip=(192.*.*.60 192.*.*.62) <-------8------->
## the path of ip, arping, ping command, defaults is /sbin or /bin
## by default, the arping_path is located in the bin directory of the database installation directory, if arping_path is null, then use default value.
## for example, if there is BMJ, arping_path=/opt/Kingbase/ES/V8/Server/bin
ipaddr_path="/usr/sbin" <-------9------->
arping_path=""
ping_path="/usr/bin" <-------10------->
## super user, defaults is root
super_user="root"
## ordinary user, defaults is kingbase
execute_user="kingbase"
## other cluster parameters
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
## ssl option, default value is '0', will not use ssl in cluster.
## set use_ssl=1 in database, and the cluster will use 'sslmode=require' to connect to database.
use_ssl=0
## all nodes failed recovery option, default value 1, do auto recovery when all nodes failed when network is OK and only one primary in cluster.
## 0 means disable the all fails recovery feature
auto_cluster_recovery_level='1'
## enable the disk check, default value is 'off', will do nothing when disk is error.
## if set to 'on', stop the database when disk is error.
use_check_disk='off'
## setting for kingbase synchronous_standby_names mode, values in "quorum\sync\all\async"
## quorum: the first do WAL replay standby can be sync node
## sync: the first standby in synchronous_standby_names, which connect to primary now, is sync node
## all: all the standbys in synchronous_standby_names, which connect to primary now, are sync node, and if there is no standby connect to primary, it is equal to async
## async: no standby is sync node
## For ha_running_mode='TPTC' the synchronous default value is 'all'.
## For ha_running_mode='DG', the synchronous default value is 'quorum'.
synchronous=''
## For ha_running_mode='TPTC', if the sync nodes have the same location with primary ?
## 0: some nodes could be sync nodes. (don't care what the location is)
## 1: only the nodes have same location with primary, could be sync nodes.
## the default is 0. (when ha_running_mode='DG' or synchronous='async', this parameter has no effect)
sync_in_same_location=0
## For ha_running_mode='TPTC', if we can do failover when the standby node has different location with failure primary?
## 'off': can not do failover, if the standby node has different location with primary.
## 'none': can do failover.
## 'any': can do failover, need ANY server alive in primary's location if the standby node has different location with primary.
## 'all': can do failover, need ALL servers alive in primary's location if the standby node has different location with primary.
## the default is off. (when ha_running_mode='DG', this parameter has no effect)
failover_need_server_alive='off'
## config of create a standby/witness node.
[expand]
expand_type="" # The node type of standby/witness node, which would be add to cluster. 0:standby 1:witness
primary_ip="" # The ip addr of cluster primary node, which need to expand a standby/witness node.
expand_ip="" # The ip addr of standby/witness node, which would be add to cluster.
node_id="" # The node_id of standby/witness node, which would be add to cluster. It does not the same with any one in cluster node
# for example: node_id="3"
## Specific instructions ,see it under [install]
install_dir=""
zip_package=""
net_device=() # if virtual_ip set,it must be set
net_device_ip=() # if virtual_ip set,it must be set
license_file=(license.dat)
deploy_by_sshd="1"
ssh_port="22"
scmd_port="8890"
## config of drop a standby/witness node
[shrink]
shrink_type="" # The node type of standby/witness node, which would be delete from cluster. 0:standby 1:witness
primary_ip="" # The ip addr of cluster primary node, which need to shrink a standby/witness node.
shrink_ip="" # The ip addr of standby/witness node, which would be delete from cluster.
node_id="" # 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"
## Specific instructions ,see it under [install]
install_dir=""
ssh_port="22" # the port of ssh, default is 22
scmd_port="8890" # the port of sys_securecmd, default is 8890
集群部署
kingbase用户在主节点执行cluster_install.sh脚本进行集群部署,cluster_install.sh脚本会调用install.conf脚本。
sh /opt/kes/v9/KESRealPro/V009R001C002B0014/ClientTools/guitools/DeployTools/zip/cluster_install.sh
设置kingbase用户的环境变量
cat >>/home/kingbase/.bash_profile<<EOF
export KINGBASE_DATA=/data/cluster
export LANG=zh_CN.UTF8
export KINGBASE_PORT=54321
export PATH=$PATH:/opt/kes/v9/kingbase/bin
EOF
source /home/kingbase/.bash_profile
查看集群状态
[kingbase@node1 ~]$ repmgr cluster show ID | Name | Role | Status | Upstream | Location | Priority | Timeline | LSN_Lag | Connection string ----+-------+---------+-----------+----------+----------+----------+----------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1 | node1 | primary | * running | | default | 100 | 1 | | host=192.*.*.60 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=2 keepalives_interval=2 keepalives_count=3 tcp_user_timeout=9000 2 | node2 | standby | running | node1 | default | 100 | 1 | 0 bytes | host=192.*.*.62 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=2 keepalives_interval=2 keepalives_count=3 tcp_user_timeout=9000
连接测试
system用户默认密码是12345678ab,可以使用alter user命令修改。
esrep用户默认密码Kingbaseha110,集群部署过程中创建的用户,可以使用sys_monitor.sh修改。 sys_monitor.sh主要用于修改集群使用的用户的密码,语法如下:
sys_monitor.sh change_password user new_password
ksql连接测试
[kingbase@node1 bin]$ ksql -h 192.*.*.62 -U system -d kingbase
Password for user system:
Type "help" for help.
kingbase=# select version();
version
----------------------------------------------------------------------------------------------------------------------
KingbaseES V009R001C002B0014 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28), 64-bit
(1 行记录)
kingbase=#
集群启停
#启动数据库服务
sys_monitor.sh start
#停止数据库服务
sys_monitor.sh stop
集群主备切换
将node2节点切换为primary节点,在node2上执行:
[kingbase@node2 ~]$ repmgr standby switchover --siblings-follow
查看切换后的集群状态
[kingbase@node2 ~]$ repmgr cluster show ID | Name | Role | Status | Upstream | Location | Priority | Timeline | LSN_Lag | Connection string ----+-------+---------+-----------+----------+----------+----------+----------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1 | node1 | standby | running | node2 | default | 100 | 1 | 0 bytes | host=192.*.*.60 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=2 keepalives_interval=2 keepalives_count=3 tcp_user_timeout=9000 2 | node2 | primary | * running | | default | 100 | 2 | | host=192.*.*.62 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=2 keepalives_interval=2 keepalives_count=3 tcp_user_timeout=9000 [kingbase@node2 ~]$
node2已经正常切换成了primary节点。
参考文章
https://help.kingbase.com.cn/v9/index.html
https://help.kingbase.com.cn/v9/highly/availability/highly-availability/highly-availability-3.html#id9
总结
金仓KES V9 RWC集群的安装部署依然非常丝滑~~~
关于作者:
网名:飞天,墨天轮2024年度优秀原创作者,拥有 Oracle 10g OCM 认证、PGCE认证以及OBCA、KCP、ACP、磐维等众多国产数据库认证证书,目前从事Oracle、Mysql、PostgresSQL、磐维数据库管理运维工作,喜欢结交更多志同道合的朋友,热衷于研究、分享数据库技术。
微信公众号:飞天online
墨天轮:https://www.modb.pro/u/15197
如有任何疑问,欢迎大家留言,共同探讨~~~