案例说明:
本案例用于通用机环境生产环境,为了保证系统的安全,禁止启用ssh通讯情况。KingbaseES R3集群在通用机部署 需要通过ssh通讯,本案例通过启用es_server进行通讯,通过shell脚本一键部署KingbaseES R3集群。
数据库版本 :
集群架构:
防火墙需要开放端口:
一、准备部署环境
1、创建kingbase用户
[kingbase@node1 Lin64]$ id kingbase
uid=1001(kingbase) gid=1001(kingbase) groups=1001(kingbase)
2、安装kingbaseES R3通用机软件
[kingbase@node1 Lin64]$ pwd
/opt/Kingbase/ES/V8R3/DeployTools/zip/Lin64
[kingbase@node1 Lin64]$ ls -lh
total 33M
-rw-rw-r--. 1 kingbase kingbase 29M Mar 4 2021 db.zip
-rw-rw-r--. 1 kingbase kingbase 4.3M Mar 4 2021 kingbasecluster.zip
3、创建集群安装目录(所有节点)
[kingbase@node3 kha]$ mkdir -p /home/kingbase/cluster/ha
[kingbase@node1 Lin64]$ mkdir -p /home/kingbase/cluster/ha
4、从软件安装目录上传压缩包到集群目录下并解压
=如下所示一键安装目录,包括集群软件安装包、license文件、部署脚本、部署配置文件=
[kingbase@node1 ha]$ ls -lh
total 33M
drwxrwxr-x 7 kingbase kingbase 65 Mar 4 2021 db
-rw-rw-r-- 1 kingbase kingbase 29M Mar 1 12:08 db.zip
-rwxrwxr-x 1 kingbase kingbase 5.2K Mar 1 12:22 install.conf
drwxrwxr-x 6 kingbase kingbase 48 Mar 4 2021 kingbasecluster
-rw-rw-r-- 1 kingbase kingbase 4.3M Mar 1 12:08 kingbasecluster.zip
-rwxr-x--- 1 kingbase kingbase 3.2K Mar 1 12:21 license.dat
-rwxrwxr-x 1 kingbase kingbase 81K Mar 1 12:21 V8R3_cluster_install.sh
其他节点:(不需要部署脚本和部署配置文件)
[kingbase@node3 ha]$ ls -lh
total 33M
drwxrwxr-x 7 kingbase kingbase 65 Mar 4 2021 db
-rw-rw-r-- 1 kingbase kingbase 29M Mar 1 12:10 db.zip
drwxrwxr-x 6 kingbase kingbase 48 Mar 4 2021 kingbasecluster
-rw-rw-r-- 1 kingbase kingbase 4.3M Mar 1 12:10 kingbasecluster.zip
-rwxr-x--- 1 kingbase kingbase 3.2K Mar 1 12:30 license.dat
二、配置并启动es_server通讯(所有节点)
1、查看es_server脚本文件
[kingbase@node1 ha]$ cd db/bin/
[kingbase@node1 bin]$ ls -lh es_*
-rwxr-xr-x 1 kingbase kingbase 60K Mar 4 2021 es_client
-rwxr-xr-x 1 kingbase kingbase 249K Mar 4 2021 es_server
-rwxr-xr-x 1 kingbase kingbase 148 Mar 4 2021 es_server.conf
2、查看es_server配置文件
[kingbase@node1 bin]$ cat es_server.conf
[Server]
user=kingbase
password=e10adc3949ba59abbe56e057f20f883e
port=8890
connect_timeout=10
health_check_max_retries=2
health_check_retry_delay=5
3、启动es_server
[kingbase@node1 bin]$ ./es_server start &
[1] 12175
[kingbase@node1 bin]$ Usage: ./server -f /path/filename
[Begin start.........]
bind success.
listen success.
[kingbase@node1 bin]$ netstat -an |grep 8890
tcp 0 0 0.0.0.0:8890 0.0.0.0:* LISTEN
[kingbase@node3 bin]$ ./es_server start &
[1] 4915
[kingbase@node3 bin]$ Usage: ./server -f /path/filename
[Begin start.........]
bind success.
listen success.
[kingbase@node3 bin]$ netstat -an |grep 8890
tcp 0 0 0.0.0.0:8890 0.0.0.0:* LISTEN
4、测试es_server通讯
[kingbase@node3 bin]$ ./es_client -h 192.168.7.248 -U kingbase -W 123456 -o 'echo $HOSTNAME'
node1
[kingbase@node1 bin]$ ./es_client -h 192.168.7.243 -U kingbase -W 123456 -o 'echo $HOSTNAME'
node3
三、一键部署集群
1、配置部署配置文件install.conf
[kingbase@node1 ha]$ cat install.conf |grep -v ^$|grep -v ^#
on_bmj=1
all_node_ip=(192.168.7.243 192.168.7.248)
cluster_path="/home/kingbase/cluster/ha"
db_package="/home/kingbase/cluster/ha/db.zip"
cluster_package="/home/kingbase/cluster/ha/kingbasecluster.zip"
license_file=(license.dat)
db_user="SYSTEM" # the user name of database
db_password="123456" # the password of database, since the R3 has a special feature that password cannot be stored in clear text, please delete the password after the cluster deployment is complete.
db_port="54321" # the port of database, defaults is 54321
trust_ip="192.168.7.1"
db_vip="192.168.7.240"
cluster_vip="192.168.7.241"
net_device=(enp0s3 enp0s3)
kb_data="/home/kingbase/cluster/ha/db/data"
ipaddr_path="/sbin"
arping_path="/opt/Kingbase/ES/V8R3/Server/bin"
super_user="root"
cluster_user="kingbase"
wd_deadtime="30" # cluster heartbeats timeout, unit: seconds
check_retries="6" # number of detection retries in case of database failure
check_delay="10" # detection retry interval in case of database failure
connect_timeout="10000" # timeout value in milliseconds before giving up to connect to backend
auto_primary_recovery="0" # automatic recovery parameter of cluster primary host, default value is 0
2、需要修改配置脚本V8R3_cluster_install.sh
1)修改部署脚本中集群安装目录(默认bmj使用:"/opt/Kingbase/ES/V8")
function read_conf()
112 {
113 [ "${install_conf}"x = ""x ] && install_conf="${shell_folder}/install.conf"
115 [ ! -e $install_conf ] && echo "[ERROR] $install_conf is not exits" && exit 1
116 if [ -f $install_conf ]
117 then
118 source $install_conf
119 fi
121 [ "${on_bmj}"x = ""x ] && on_bmj=0
122 #[ $on_bmj -eq 1 ] && cluster_path="/opt/Kingbase/ES/V8"
123 [ $on_bmj -eq 1 ] && cluster_path="/home/kingbase/cluster/ha"
124 [ $on_bmj -eq 1 ] && license_path=(${cluster_path}/license.dat)
2)修改部署脚本中集群部署路径
if [ $on_bmj -eq 0 ]
then
kb_bin="$cluster_path/Server/bin"
kb_etc="$cluster_path/Server/etc"
kb_lib="$cluster_path/Server/lib"
cluster_etc="$cluster_path/Cluster/etc"
cluster_bin="$cluster_path/Cluster/bin"
cluster_lib="$cluster_path/Cluster/lib"
else
kb_bin="$cluster_path/db/bin"
kb_etc="$cluster_path/db/etc"
kb_lib="$cluster_path/db/lib"
cluster_etc="$cluster_path/kingbasecluster/etc"
cluster_bin="$cluster_path/kingbasecluster/bin"
cluster_lib="$cluster_path/kingbasecluster/lib"
fi
kb_archive="$cluster_path/archivedir"
log_path="$cluster_path/log"
3、开始部署
[root@node1 ha]# ./V8R3_cluster_install.sh
[CONFIG_CHECK] file format is correct ... OK
[CONFIG_CHECK] file format is correct ... OK
[INFO]-Check if the cluster_vip "192.168.7.241" is already exist ...
[INFO] There is no "192.168.7.241" on any host, OK
[INFO]-Check if the db_vip "192.168.7.240" is already exist ...
[INFO] There is no "192.168.7.240" on any host, OK
[CONFIG_CHECK] the number of net_device matches the length of all_node_ip or the number of net_device is 1 ... OK
[Mon Mar 1 12:59:12 CST 2021] [INFO] change ulimit on 192.168.7.243 ...
[Mon Mar 1 12:59:12 CST 2021] [INFO] change ulimit on 192.168.7.243 ... Done
[Mon Mar 1 12:59:12 CST 2021] [INFO] change kernel.sem on 192.168.7.243 ...
[Mon Mar 1 12:59:12 CST 2021] [INFO] change kernel.sem on 192.168.7.243 ... Done
[Mon Mar 1 12:59:12 CST 2021] [INFO] change RemoveIPC on 192.168.7.243 ...
[Mon Mar 1 12:59:12 CST 2021] [INFO] change RemoveIPC on 192.168.7.243 ... Done
[Mon Mar 1 12:59:12 CST 2021] [INFO] change DefaultTasksAccounting on 192.168.7.243 ...
[Mon Mar 1 12:59:12 CST 2021] [INFO] change DefaultTasksAccounting on 192.168.7.243 ... Done
[Mon Mar 1 12:59:12 CST 2021] [INFO] configuration to take effect on 192.168.7.243 ...
[Mon Mar 1 12:59:12 CST 2021] [INFO] configuration to take effect on 192.168.7.243 ... Done
[Mon Mar 1 12:59:12 CST 2021] [INFO] change ulimit on 192.168.7.248 ...
.......
四、部署完成测试
1、查看流复制信息
1)查看主备库数据库服务(如下所示,主备库数据库服务启动正常,如未启动可以用sys_ctl手工启动)
主库:
[kingbase@node3 db]$ ps -ef |grep kingbase
kingbase 4915 2980 0 12:30 pts/0 00:00:00 ./es_server start
kingbase 7515 1 0 13:00 pts/0 00:00:00 /home/kingbase/cluster/ha/db/bin/kingbase -D /home/kingbase/cluster/ha/db/data
kingbase 7516 7515 0 13:00 ? 00:00:00 kingbase: logger process
kingbase 7518 7515 0 13:00 ? 00:00:00 kingbase: checkpointer process
kingbase 7519 7515 0 13:00 ? 00:00:00 kingbase: writer process
kingbase 7520 7515 0 13:00 ? 00:00:00 kingbase: wal writer process
kingbase 7521 7515 0 13:00 ? 00:00:00 kingbase: autovacuum launcher process
kingbase 7522 7515 0 13:00 ? 00:00:00 kingbase: archiver process last was 000000010000000000000002
kingbase 7523 7515 0 13:00 ? 00:00:00 kingbase: stats collector process
kingbase 7524 7515 0 13:00 ? 00:00:00 kingbase: bgworker: syslogical supervisor
备库:
[kingbase@node1 bin]$ ps -ef |grep kingbase
kingbase 12175 1 0 12:28 pts/0 00:00:00 ./es_server start
kingbase 27927 1 0 13:09 pts/0 00:00:00 /home/kingbase/cluster/ha/db/bin/kingbase -D /home/kingbase/cluster/ha/db/data
kingbase 27928 27927 0 13:09 ? 00:00:00 kingbase: logger process
kingbase 27929 27927 0 13:09 ? 00:00:00 kingbase: startup process recovering 000000010000000000000003
kingbase 27934 27927 0 13:09 ? 00:00:00 kingbase: checkpointer process
kingbase 27935 27927 0 13:09 ? 00:00:00 kingbase: writer process
kingbase 27936 27927 0 13:09 ? 00:00:00 kingbase: stats collector process
kingbase 27937 27927 0 13:09 ? 00:00:00 kingbase: wal receiver process
2)查看路复制状态
[kingbase@node3 bin]$ ./ksql -U SYSTEM -W 123456 TEST
ksql (V008R003C002B0270)
Type "help" for help.
TEST=# select * from sys_stat_replication;
PID | USESYSID | USENAME | APPLICATION_NAME | CLIENT_ADDR | CLIENT_HOSTNAME | CLIENT_PORT | BACKEND_START | BACKEND_XMIN |
STATE | SENT_LOCATION | WRITE_LOCATION | FLUSH_LOCATION | REPLAY_LOCATION | SYNC_PRIORITY | SYNC_STATE
------+----------+---------+------------------+---------------+-----------------+-------------+-------------------------------+--------------+---
7839 | 10 | SYSTEM | node2 | 192.168.7.248 | | 11998 | 2021-03-01 13:10:15.273987+08 | | st
reaming | 0/3000220 | 0/3000220 | 0/3000220 | 0/3000220 | 2 | sync
(1 row)
2、启动集群服务
=默认通用机环境kingbase_monitor.sh启动集群是通过ssh通讯,所以在部署完成后,仍然无法通过kingbase_monitor.sh启动集群=
**1)kingbase_monitor.sh **
2)手工启动kingbasecluster服务(root用户,所有节点)
[root@node3 .ssh]# cd /home/kingbase/cluster/ha/kingbasecluster/bin
[root@node3 bin]# ./kingbasecluster -n > cluster.log 2>&1 &
[1] 9437
[root@node3 bin]# ps -ef |grep kingbase
kingbase 4915 1 0 12:30 pts/0 00:00:00 ./es_server start
kingbase 7515 1 0 13:00 pts/0 00:00:00 /home/kingbase/cluster/ha/db/bin/kingbase -D /home/kingbase/cluster/ha/db/data
kingbase 7516 7515 0 13:00 ? 00:00:00 kingbase: logger process
kingbase 7518 7515 0 13:00 ? 00:00:00 kingbase: checkpointer process
kingbase 7519 7515 0 13:00 ? 00:00:00 kingbase: writer process
kingbase 7520 7515 0 13:00 ? 00:00:00 kingbase: wal writer process
kingbase 7521 7515 0 13:00 ? 00:00:00 kingbase: autovacuum launcher process
kingbase 7522 7515 0 13:00 ? 00:00:00 kingbase: archiver process last was 000000010000000000000002
kingbase 7523 7515 0 13:00 ? 00:00:00 kingbase: stats collector process
kingbase 7524 7515 0 13:00 ? 00:00:00 kingbase: bgworker: syslogical supervisor
kingbase 7839 7515 0 13:10 ? 00:00:00 kingbase: wal sender process SYSTEM 192.168.7.248(11998) streaming 0/30004C0
root 9437 2304 0 13:28 pts/0 00:00:00 ./kingbasecluster -n
root 9456 9437 0 13:28 pts/0 00:00:00 kingbasecluster: watchdog
root 9460 9437 0 13:28 pts/0 00:00:00 kingbasecluster: lifecheck
root 9461 9460 0 13:28 pts/0 00:00:00 kingbasecluster: heartbeat receiver
root 9462 9460 0 13:28 pts/0 00:00:00 kingbasecluster: heartbeat sender
root 9463 9437 0 13:28 pts/0 00:00:00 kingbasecluster: wait for connection request
root 9464 9437 0 13:28 pts/0 00:00:00 kingbasecluster: wait for connection request
root 9465 9437 0 13:28 pts/0 00:00:00 kingbasecluster: wait for connection request
root 9466 9437 0 13:28 pts/0 00:00:00 kingbasecluster: wait for connection request
root 9467 9437 0 13:28 pts/0 00:00:00 kingbasecluster: wait for connection request
root 9468 9437 0 13:28 pts/0 00:00:00 kingbasecluster: wait for connection request
root 9469 9437 0 13:28 pts/0 00:00:00 kingbasecluster: wait for connection request
root 9470 9437 0 13:28 pts/0 00:00:00 kingbasecluster: wait for connection request
root 9471 9437 0 13:28 pts/0 00:00:00 kingbasecluster: wait for connection request
root 9472 9437 0 13:28 pts/0 00:00:00 kingbasecluster: wait for connection request
root 9473 9437 0 13:28 pts/0 00:00:00 kingbasecluster: wait for connection request
root 9474 9437 0 13:28 pts/0 00:00:00 kingbasecluster: wait for connection request
root 9475 9437 0 13:28 pts/0 00:00:00 kingbasecluster: wait for connection request
root 9476 9437 0 13:28 pts/0 00:00:00 kingbasecluster: wait for connection request
root 9477 9437 0 13:28 pts/0 00:00:00 kingbasecluster: wait for connection request
root 9478 9437 0 13:28 pts/0 00:00:00 kingbasecluster: wait for connection request
root 9479 9437 0 13:28 pts/0 00:00:00 kingbasecluster: PCP: wait for connection request
root 9480 9437 0 13:28 pts/0 00:00:00 kingbasecluster: worker process
[root@node1 bin]# netstat -an |egrep '54321|9000|9999'
tcp 0 0 0.0.0.0:9000 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:9999 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:54321 0.0.0.0:* LISTEN
3)集群信息查看
[root@node3 bin]# ./ksql -U SYSTEM -W 123456 TEST -p 9999
ksql (V008R003C002B0270)
Type "help" for help.
TEST=# show pool_nodes;
node_id | hostname | port | status | lb_weight | role | select_cnt | load_balance_node | replication_delay
---------+---------------+-------+--------+-----------+---------+------------+-------------------+-------------------
0 | 192.168.7.243 | 54321 | up | 0.500000 | primary | 0 | true | 0
1 | 192.168.7.248 | 54321 | up | 0.500000 | standby | 0 | false | 0
(2 rows)
TEST=# select * from sys_stat_replication;
PID | USESYSID | USENAME | APPLICATION_NAME | CLIENT_ADDR | CLIENT_HOSTNAME | CLIENT_PORT | BACKEND_START | BACKEND_XMIN |
STATE | SENT_LOCATION | WRITE_LOCATION | FLUSH_LOCATION | REPLAY_LOCATION | SYNC_PRIORITY | SYNC_STATE
------+----------+---------+------------------+---------------+-----------------+-------------+-------------------------------+--------------+---
--------+---------------+----------------+----------------+-----------------+---------------+------------
7839 | 10 | SYSTEM | node2 | 192.168.7.248 | | 11998 | 2021-03-01 13:10:15.273987+08 | | st
reaming | 0/30005A0 | 0/30005A0 | 0/30005A0 | 0/30005A0 | 2 | sync
(1 row)
=如以上所示,可以通过手工启动kingbasecluster集群服务及数据库服务完成集群的启动=
五、部署kingbase_monitor.sh一键管理集群
1、安装R3专用机版本数据库服务
2、如下所示kingbase_monitor.sh(专用机通过es_server通讯)
3、将专用机安装目录下sh脚本拷贝到所有节点
[root@node1 bin]# pwd
/opt/Kingbase/ES/V8/Server/bin
![](https://www.icode9.com/i/l/?n=22&i=blog/2420370/202201/2420370-20220121144827172-868786745.png)
[root@node1 bin]# cp change_vip.sh /home/kingbase/cluster/ha/db/bin
[root@node1 bin]# cp network_rewind.sh /home/kingbase/cluster/ha/db/bin
[root@node1 bin]# cp kingbase_monitor.sh /home/kingbase/cluster/ha/db/bin
[root@node1 bin]# cp kingbase_promote.sh /home/kingbase/cluster/ha/db/bin
=注意:需要将all_mornitor.sh 拷贝到db/bin 和kingbasecluster/bin下=
[root@node1 bin]# cp all_monitor.sh /home/kingbase/cluster/ha/db/bin
[root@node1 bin]# cp all_monitor.sh /home/kingbase/cluster/ha/kingbasecluster/bin
4、kingbase_monitor.sh启动集群
[root@node3 bin]# ./kingbase_monitor.sh restart
2021-03-01 16:17:43 KingbaseES automation beging...
2021-03-01 16:17:43 stop kingbasecluster [192.168.7.243] ...
remove socket /tmp/.s.KINGBASECLUSTERWD_CMD.9000.lock
remove status file /home/kingbase/cluster/ha/run/kingbasecluster/kingbasecluster_status
2021-03-01 16:17:43 Done...
2021-03-01 16:17:43 stop kingbasecluster [192.168.7.248] ...
remove socket /tmp/.s.KINGBASECLUSTERWD_CMD.9000.lock
remove status file /home/kingbase/cluster/ha/run/kingbasecluster/kingbasecluster_status
2021-03-01 16:17:43 Done...
2021-03-01 16:17:43 stop kingbase [192.168.7.243] ...
set /home/kingbase/cluster/ha/db/data down now...
2021-03-01 16:17:50 Done...
2021-03-01 16:17:51 Del kingbase VIP [192.168.7.240/24] ...
DEL VIP NOW AT 2021-03-01 16:17:51 ON enp0s3
execute: [/sbin/ip addr del 192.168.7.240/24 dev enp0s3]
Oprate del ip cmd end.
2021-03-01 16:17:51 Done...
2021-03-01 16:17:51 stop kingbase [192.168.7.248] ...
set /home/kingbase/cluster/ha/db/data down now...
2021-03-01 16:17:58 Done...
2021-03-01 16:17:59 Del kingbase VIP [192.168.7.240/24] ...
DEL VIP NOW AT 2021-03-01 16:17:37 ON enp0s3
No VIP on my dev, nothing to do.
2021-03-01 16:17:59 Done...
......................
all stop..
start crontab kingbase position : [7]
ADD VIP NOW AT 2021-03-01 16:18:02 ON enp0s3
execute: [/sbin/ip addr add 192.168.7.240/24 dev enp0s3 label enp0s3:2]
execute: /home/kingbase/cluster/ha/db/bin/arping -U 192.168.7.240 -I enp0s3 -w 1
ARPING 192.168.7.240 from 192.168.7.240 enp0s3
Sent 1 probes (1 broadcast(s))
Received 0 response(s)
start crontab kingbase position : [5]
wait kingbase recovery 5 sec...
start crontab kingbasecluster line number: [8]
start crontab kingbasecluster line number: [6]
......................
all started..
...
now we check again
| ip | program| [status]
[ 192.168.7.243]| [kingbasecluster]| [active]
[ 192.168.7.248]| [kingbasecluster]| [active]
[ 192.168.7.243]| [kingbase]| [active]
[ 192.168.7.248]| [kingbase]| [active]
5、验证集群状态
1)查看主备库数据库服务
[root@node3 bin]# ps -ef |grep kingbase
kingbase 4915 1 0 12:30 ? 00:00:00 ./es_server start
kingbase 10726 1 0 16:17 ? 00:00:00 /home/kingbase/cluster/ha/db/bin/kingbase -D /home/kingbase/cluster/ha/db/data
kingbase 10727 10726 0 16:17 ? 00:00:00 kingbase: logger process
kingbase 10729 10726 0 16:17 ? 00:00:00 kingbase: checkpointer process
kingbase 10730 10726 0 16:17 ? 00:00:00 kingbase: writer process
kingbase 10731 10726 0 16:17 ? 00:00:00 kingbase: wal writer process
kingbase 10732 10726 0 16:17 ? 00:00:00 kingbase: autovacuum launcher process
kingbase 10733 10726 0 16:17 ? 00:00:00 kingbase: archiver process
kingbase 10734 10726 0 16:17 ? 00:00:00 kingbase: stats collector process
kingbase 10735 10726 0 16:17 ? 00:00:00 kingbase: bgworker: syslogical supervisor
kingbase 10854 10726 0 16:18 ? 00:00:00 kingbase: wal sender process SYSTEM 192.168.7.248(25558) streaming 0/A0000D0
kingbase 11081 1 0 16:18 ? 00:00:00 ./kingbasecluster -n
kingbase 11113 11081 0 16:18 ? 00:00:00 kingbasecluster: watchdog
kingbase 11167 11081 0 16:18 ? 00:00:00 kingbasecluster: lifecheck
kingbase 11169 11167 0 16:18 ? 00:00:00 kingbasecluster: heartbeat receiver
kingbase 11170 11167 0 16:18 ? 00:00:00 kingbasecluster: heartbeat sender
kingbase 11172 11081 0 16:18 ? 00:00:00 kingbasecluster: wait for connection request
kingbase 11173 11081 0 16:18 ? 00:00:00 kingbasecluster: wait for connection request
kingbase 11174 11081 0 16:18 ? 00:00:00 kingbasecluster: wait for connection request
kingbase 11175 11081 0 16:18 ? 00:00:00 kingbasecluster: wait for connection request
kingbase 11176 11081 0 16:18 ? 00:00:00 kingbasecluster: wait for connection request
kingbase 11177 11081 0 16:18 ? 00:00:00 kingbasecluster: wait for connection request
kingbase 11178 11081 0 16:18 ? 00:00:00 kingbasecluster: wait for connection request
kingbase 11179 11081 0 16:18 ? 00:00:00 kingbasecluster: wait for connection request
kingbase 11180 11081 0 16:18 ? 00:00:00 kingbasecluster: wait for connection request
kingbase 11181 11081 0 16:18 ? 00:00:00 kingbasecluster: wait for connection request
kingbase 11182 11081 0 16:18 ? 00:00:00 kingbasecluster: wait for connection request
kingbase 11183 11081 0 16:18 ? 00:00:00 kingbasecluster: wait for connection request
kingbase 11184 11081 0 16:18 ? 00:00:00 kingbasecluster: wait for connection request
kingbase 11185 11081 0 16:18 ? 00:00:00 kingbasecluster: wait for connection request
kingbase 11186 11081 0 16:18 ? 00:00:00 kingbasecluster: wait for connection request
kingbase 11187 11081 0 16:18 ? 00:00:00 kingbasecluster: wait for connection request
kingbase 11189 11081 0 16:18 ? 00:00:00 kingbasecluster: PCP: wait for connection request
kingbase 11190 11081 0 16:18 ? 00:00:00 kingbasecluster: worker process
[kingbase@node1 bin]$ ps -ef |grep kingbase
kingbase 1742 1 0 16:17 ? 00:00:00 /home/kingbase/cluster/ha/db/bin/kingbase -D /home/kingbase/cluster/ha/db/data
kingbase 1744 1742 0 16:17 ? 00:00:00 kingbase: logger process
kingbase 1745 1742 0 16:17 ? 00:00:00 kingbase: startup process recovering 00000001000000000000000A
kingbase 1749 1742 0 16:17 ? 00:00:00 kingbase: checkpointer process
kingbase 1750 1742 0 16:17 ? 00:00:00 kingbase: writer process
kingbase 1751 1742 0 16:17 ? 00:00:00 kingbase: stats collector process
kingbase 1752 1742 0 16:17 ? 00:00:00 kingbase: wal receiver process streaming 0/A0000D0
kingbase 2144 1 0 16:18 ? 00:00:00 ./kingbasecluster -n
kingbase 2175 2144 0 16:18 ? 00:00:00 kingbasecluster: watchdog
kingbase 2186 2144 0 16:18 ? 00:00:00 kingbasecluster: lifecheck
kingbase 2187 2186 0 16:18 ? 00:00:00 kingbasecluster: heartbeat receiver
kingbase 2188 2186 0 16:18 ? 00:00:00 kingbasecluster: heartbeat sender
kingbase 2189 2144 0 16:18 ? 00:00:00 kingbasecluster: wait for connection request
kingbase 2190 2144 0 16:18 ? 00:00:00 kingbasecluster: wait for connection request
kingbase 2191 2144 0 16:18 ? 00:00:00 kingbasecluster: wait for connection request
kingbase 2192 2144 0 16:18 ? 00:00:00 kingbasecluster: wait for connection request
kingbase 2193 2144 0 16:18 ? 00:00:00 kingbasecluster: wait for connection request
kingbase 2194 2144 0 16:18 ? 00:00:00 kingbasecluster: wait for connection request
kingbase 2195 2144 0 16:18 ? 00:00:00 kingbasecluster: wait for connection request
kingbase 2196 2144 0 16:18 ? 00:00:00 kingbasecluster: wait for connection request
kingbase 2197 2144 0 16:18 ? 00:00:00 kingbasecluster: wait for connection request
kingbase 2198 2144 0 16:18 ? 00:00:00 kingbasecluster: wait for connection request
kingbase 2199 2144 0 16:18 ? 00:00:00 kingbasecluster: wait for connection request
kingbase 2200 2144 0 16:18 ? 00:00:00 kingbasecluster: wait for connection request
kingbase 2201 2144 0 16:18 ? 00:00:00 kingbasecluster: wait for connection request
kingbase 2202 2144 0 16:18 ? 00:00:00 kingbasecluster: wait for connection request
kingbase 2203 2144 0 16:18 ? 00:00:00 kingbasecluster: wait for connection request
kingbase 2204 2144 0 16:18 ? 00:00:00 kingbasecluster: wait for connection request
kingbase 2206 2144 0 16:18 ? 00:00:00 kingbasecluster: PCP: wait for connection request
kingbase 2207 2144 0 16:18 ? 00:00:00 kingbasecluster: worker process
2)查看集群节点及流复制状态
连接集群服务:
[kingbase@node1 bin]$ ./ksql -U SYSTEM -W 123456 TEST -p 9999
ksql (V008R003C002B0270)
Type "help" for help.
TEST=# show pool_nodes;
node_id | hostname | port | status | lb_weight | role | select_cnt | load_balance_node | replication_delay
---------+---------------+-------+--------+-----------+---------+------------+-------------------+-------------------
0 | 192.168.7.243 | 54321 | up | 0.500000 | primary | 0 | true | 0
1 | 192.168.7.248 | 54321 | up | 0.500000 | standby | 0 | false | 0
(2 rows)
TEST=# select * from sys_stat_replication;
PID | USESYSID | USENAME | APPLICATION_NAME | CLIENT_ADDR | CLIENT_HOSTNAME | CLIENT_PORT | BACKEND_START | BACKEND_XMIN |
STATE | SENT_LOCATION | WRITE_LOCATION | FLUSH_LOCATION | REPLAY_LOCATION | SYNC_PRIORITY | SYNC_STATE
-------+----------+---------+------------------+---------------+-----------------+-------------+-------------------------------+--------------+--
10854 | 10 | SYSTEM | node2 | 192.168.7.248 | | 25558 | 2021-03-01 16:18:04.065673+08 | | s
treaming | 0/A0000D0 | 0/A0000D0 | 0/A0000D0 | 0/A0000D0 | 2 | sync
(1 row)
连接数据库服务:
[kingbase@node3 bin]$ ./ksql -U SYSTEM -W 123456 TEST
ksql (V008R003C002B0270)
Type "help" for help.
TEST=# select * from sys_stat_replication;
PID | USESYSID | USENAME | APPLICATION_NAME | CLIENT_ADDR | CLIENT_HOSTNAME | CLIENT_PORT | BACKEND_START | BACKEND_XMIN |
STATE | SENT_LOCATION | WRITE_LOCATION | FLUSH_LOCATION | REPLAY_LOCATION | SYNC_PRIORITY | SYNC_STATE
-------+----------+---------+------------------+---------------+-----------------+-------------+-------------------------------+--------------+--
10854 | 10 | SYSTEM | node2 | 192.168.7.248 | | 25558 | 2021-03-01 16:18:04.065673+08 | | s
treaming | 0/A0000D0 | 0/A0000D0 | 0/A0000D0 | 0/A0000D0 | 2 | sync
(1 row)
TEST=# select * from sys_replication_slots;
SLOT_NAME | PLUGIN | SLOT_TYPE | DATOID | DATABASE | ACTIVE | ACTIVE_PID | XMIN | CATALOG_XMIN | RESTART_LSN | CONFIRMED_FLUSH_LSN
------------+--------+-----------+--------+----------+--------+------------+------+--------------+-------------+---------------------
slot_node1 | | physical | | | f | | | | |
slot_node2 | | physical | | | t | 10854 | 2076 | | 0/A0000D0 |
(2 rows)
六、总结
对于通用机使用es_server部署成本较高,需要修改部署脚本及集群启动脚本,建议尽量使用ssh部署。