当前位置:   article > 正文

KingbaseES V8R6集群运维案例之---同一主机节点部署多个集群

kingbase v8 主备部署

案例说明:
在同一主机环境,由于生产需要,需要部署两个集群;本案例详细描述了两个集群的部署过程。
注意:同一主机部署多个集群需要先部署securecmdd服务,节点之间通过securecmdd服务通讯。多个集群共享主机的securecmdd服务在节点之间通讯。

适用版本: KingbaseES V8R6

一、检测主机节点securecmdd服务

1、查看securecmdd服务及端口

  1. [kingbase@node101 bin]$ ps -ef |grep securecmd
  2. root 15486 1 0 14:34 ? 00:00:00 sys_securecmdd: /home/kingbase/cluster/securecmdd/bin/sys_securecmdd -f /etc/.kes/securecmdd_config [listener] 0 of 128-256 startups
  3. [kingbase@node101 bin]$ netstat -antlp|grep 8890
  4. (Not all processes could be identified, non-owned process info
  5. will not be shown, you would have to be root to see it all.)
  6. tcp 0 0 0.0.0.0:8890 0.0.0.0:* LISTEN -
  7. tcp6 0 0 :::8890 :::* LISTEN -

2、测试securecmd连接(所有节点)

  1. # 本机
  2. [kingbase@node101 bin]$ ./sys_securecmd kingbase@127.0.0.1 'whoami'
  3. kingbase
  4. [kingbase@node101 bin]$ ./sys_securecmd root@127.0.0.1 'whoami'
  5. root
  6. # 远程
  7. [kingbase@node101 bin]$ ./sys_securecmd kingbase@192.168.1.102 'whoami'
  8. kingbase
  9. [kingbase@node101 bin]$ ./sys_securecmd root@192.168.1.102 'whoami'
  10. root

二、第一个集群部署

1、集群部署(参考官方文档,可以采用部署工具或脚本部署)https://help.kingbase.com.cn/v8/install-updata/k-deploy/index.html

2、查看第一个集群节点状态

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

3、第一个集群配置

  1. [kingbase@node101 bin]$ cat ../etc/repmgr.conf
  2. use_scmd=on
  3. ha_running_mode='DG'
  4. node_id=1
  5. node_name='node1'
  6. conninfo='host=192.168.1.101 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3'
  7. connection_check_type='mix'
  8. data_directory='/data/kingbase/hac7/data'
  9. #data_directory='/home/kingbase/cluster/R6HA/ha7/kingbase/data'
  10. log_file='/home/kingbase/cluster/R6HA/ha7/kingbase/kingbase/log/hamgr.log'
  11. kbha_log_file='/home/kingbase/cluster/R6HA/ha7/kingbase/kingbase/log/kbha.log'
  12. sys_bindir='/home/kingbase/cluster/R6HA/ha7/kingbase/kingbase/bin'
  13. scmd_options='-q -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o ServerAliveInterval=2 -o ServerAliveCountMax=5 -p 8890'
  14. trusted_servers='192.168.1.1'
  15. running_under_failure_trusted_servers='on'
  16. repmgrd_pid_file='/home/kingbase/cluster/R6HA/ha7/kingbase/kingbase/etc/hamgrd.pid'
  17. kbha_pid_file='/home/kingbase/cluster/R6HA/ha7/kingbase/kingbase/etc/kbha.pid'
  18. ......

三、第二个集群部署(脚本部署)

1、脚本部署所需文件

  1. [kingbase@node102 r6_install]$ ls -l
  2. total 234236
  3. -rw-rw-r-- 1 kingbase kingbase 237558136 Apr 7 14:07 db.zip
  4. -rw-rw-r-- 1 kingbase kingbase 12397 Apr 19 16:09 install.conf
  5. -rw-r--r-- 1 kingbase kingbase 3454 Apr 7 14:08 license.dat
  6. -rw-rw-r-- 1 kingbase kingbase 2114981 Apr 19 15:43 securecmdd.zip
  7. -rw-rw-r-- 1 kingbase kingbase 3902 Apr 7 14:07 trust_cluster.sh
  8. -rw-rw-r-- 1 kingbase kingbase 152215 Apr 7 14:07 V8R6_cluster_install.sh

2、创建集群部署目录(两个集群分别在不同目录下)

[kingbase@node102 r6_install]$  mkdir -p /home/kingbase/cluster/R6HA/hac7/kingbase/

3、配置部署配置文件

  1. [kingbase@node102 r6_install]$ cat install.conf|grep -v ^$|grep -v ^#
  2. [install]
  3. on_bmj=0
  4. all_ip=(192.168.1.102 192.168.1.101)
  5. witness_ip=""
  6. production_ip=()
  7. local_disaster_recovery_ip=()
  8. remote_disaster_recovery_ip=()
  9. install_dir="/home/kingbase/cluster/R6HA/hac7"
  10. zip_package="/home/kingbase/r6_install/db.zip"
  11. license_file=(license.dat)
  12. db_user="system" # the user name of database
  13. db_port="54325" # the port of database, defaults is 54321
  14. db_mode="oracle" # database mode: pg, oracle
  15. db_auth="scram-sha-256" # database authority: scram-sha-256, md5, default is scram-sha-256
  16. 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").
  17. 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.
  18. archive_mode="on" # enables archiving; off, on, or always
  19. 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.
  20. 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.
  21. db_ctype="" # Character classification(LC_CTYPE) to use int the new database. This affects the categorization of characters, default value provided by locale command.
  22. other_db_init_options="" # addional initdb options,such as "--scenario-tuning"
  23. trusted_servers="192.168.1.1"
  24. running_under_failure_trusted_servers='on'
  25. data_directory="/home/kingbase/cluster/R6HA/hac7/kingbase/data"
  26. waldir=''
  27. virtual_ip=""
  28. net_device=(enp0s3 enp0s3)
  29. net_device_ip=(192.168.1.102 192.168.1.101)
  30. ipaddr_path="/sbin"
  31. arping_path=""
  32. ping_path="/bin"
  33. super_user="root"
  34. execute_user="kingbase"
  35. deploy_by_sshd=0 # 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)
  36. 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)
  37. reconnect_attempts="10" # the number of retries in the event of an error
  38. reconnect_interval="6" # retry interval
  39. recovery="standby" # the way of cluster recovery: standby/automatic/manual
  40. ssh_port="22" # the port of ssh, default is 22
  41. scmd_port="8890" # the port of sys_securecmdd, default is 8890
  42. auto_cluster_recovery_level='1'
  43. use_check_disk='off'
  44. synchronous=''
  45. sync_in_same_location=0
  46. failover_need_server_alive='off'

4、拷贝db.zip文件到集群安装目录下并解压(所有节点)

1)拷贝db.zip到所有节点

  1. [kingbase@node102 r6_install]$ cp db.zip /home/kingbase/cluster/R6HA/hac7/kingbase
  2. [kingbase@node102 r6_install]$ scp db.zip node101:/home/kingbase/cluster/R6HA/hac7/kingbase
  3. db.zip 100% 227MB 88.2MB/s 00:02

2)解压db.zip

  1. [kingbase@node101 kingbase]$ unzip db.zip
  2. [kingbase@node101 kingbase]$ ls -lh
  3. total 227M
  4. drwxr-xr-x 2 kingbase kingbase 4.0K Oct 29 14:57 bin
  5. -rw-rw-r-- 1 kingbase kingbase 227M Apr 19 16:07 db.zip
  6. drwxrwxr-x 5 kingbase kingbase 8.0K Oct 29 14:57 lib
  7. drwxrwxr-x 7 kingbase kingbase 4.0K Oct 29 14:57 share

5、拷贝license.dat文件到集群bin目录下

  1. [kingbase@node102 r6_install]$ cp license.dat /home/kingbase/cluster/R6HA/hac7/kingbase/bin/
  2. [kingbase@node102 r6_install]$ scp license.dat node101:/home/kingbase/cluster/R6HA/hac7/kingbase/bin/
  3. license.dat 100% 3454 3.3MB/s 00:00

6、执行脚本部署

  1. [kingbase@node102 r6_install]$ sh V8R6_cluster_install.sh
  2. ........
  3. 2023-04-19 16:14:25 repmgrd on "[192.168.1.101]" start success.
  4. ID | Name | Role | Status | Upstream | repmgrd | PID | Paused? | Upstream last seen
  5. ----+-------+---------+-----------+----------+---------+-------+---------+--------------------
  6. 1 | node1 | primary | * running | | running | 32636 | no | n/a
  7. 2 | node2 | standby | running | node1 | running | 4895 | no | 1 second(s) ago
  8. [2023-04-19 16:14:26] [NOTICE] redirecting logging output to "/home/kingbase/cluster/R6HA/hac7/kingbase/log/kbha.log"
  9. [2023-04-19 16:14:28] [NOTICE] redirecting logging output to "/home/kingbase/cluster/R6HA/hac7/kingbase/log/kbha.log"
  10. 2023-04-19 16:14:28 Done.
  11. [INSTALL] start up the whole cluster ... OK
  12. ---如上所示,第二个集群部署完成。

7、第二个集群配置

  1. [kingbase@node102 bin]$ cat ../etc/repmgr.conf
  2. use_scmd=on
  3. ha_running_mode='DG'
  4. node_id=1
  5. node_name='node1'
  6. conninfo='host=192.168.1.102 user=esrep dbname=esrep port=54325 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3'
  7. connection_check_type='mix'
  8. data_directory='/home/kingbase/cluster/R6HA/hac7/kingbase/data'
  9. log_file='/home/kingbase/cluster/R6HA/hac7/kingbase/log/hamgr.log'
  10. kbha_log_file='/home/kingbase/cluster/R6HA/hac7/kingbase/log/kbha.log'
  11. sys_bindir='/home/kingbase/cluster/R6HA/hac7/kingbase/bin'
  12. scmd_options='-q -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o ServerAliveInterval=2 -o ServerAliveCountMax=5 -p 8890'
  13. trusted_servers='192.168.1.1'
  14. running_under_failure_trusted_servers='on'
  15. repmgrd_pid_file='/home/kingbase/cluster/R6HA/hac7/kingbase/etc/hamgrd.pid'
  16. kbha_pid_file='/home/kingbase/cluster/R6HA/hac7/kingbase/etc/kbha.pid'
  17. ......

四、集群验证

1、第一个集群节点状态

  1. [kingbase@node102 bin]$ pwd
  2. /home/kingbase/cluster/R6HA/hac7/kingbase/bin
  3. [kingbase@node102 bin]$ ./repmgr cluster show
  4. ID | Name | Role | Status | Upstream | Location | Priority | Timeline | LSN_Lag | Connection string
  5. ----+-------+---------+-----------+----------+----------+----------+----------+---------+---------------------------------------------------------------------------------------------------------------------------------------------------
  6. 1 | node1 | primary | * running | | default | 100 | 1 | | host=192.168.1.102 user=esrep dbname=esrep port=54325 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
  7. 2 | node2 | standby | running | node1 | default | 100 | 1 | 0 bytes | host=192.168.1.101 user=esrep dbname=esrep port=54325 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3

2、第二个集群节点状态

  1. [kingbase@node101 bin]$ pwd
  2. /home/kingbase/cluster/R6HA/ha7/kingbase/kingbase/bin
  3. [kingbase@node101 bin]$ ./repmgr cluster show
  4. ID | Name | Role | Status | Upstream | Location | Priority | Timeline | LSN_Lag | Connection string
  5. ----+-------+---------+-----------+----------+----------+----------+----------+---------+---------------------------------------------------------------------------------------------------------------------------------------------------
  6. 1 | node1 | primary | * running | | default | 100 | 6 | | host=192.168.1.101 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
  7. 2 | node2 | standby | running | node1 | default | 100 | 6 | 0 bytes | host=192.168.1.102 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3

五、总结
在通过脚本部署第二个集群时,需要先创建好集群安装目录,并将db.zip文件拷贝到集群安装目录下,解压;再将license.dat文件也要拷贝到集群安装目录下,然后执行脚本部署。对于需要vip的集群环境,不同的集群配置不同的vip地址。多个集群的数据库服务同时启动,需要配置不同的数据库服务端口。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/980346
推荐阅读
相关标签
  

闽ICP备14008679号