一、節點擴容
192.168.43.111 node1 備節點,192.168.43.112 主節點,192.168.43.116 node3擴容節點
1、安裝securecmdd服務並已啟動(安裝步驟省略)
systemctl status securecmdd.service
在要擴容的節點node3上準備軟體:
2、trust_cluster.sh V8R6_cluster_install.sh install.conf license.dat db.zip
需要配置install.conf的expand模組資訊
[expand]
expand_type="0" # The node type of standby/witness node, which would be add to cluster. 0:standby 1:witness
primary_ip="192.168.43.112" # The ip addr of cluster primary node, which need to expand a standby/witness node.
expand_ip="192.168.43.116" # The ip addr of standby/witness node, which would be add to cluster.
node_id="3" # 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="/home/kingbase/cluster_v8r6" (資料庫安裝目錄)
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="0"
ssh_port="22"
scmd_port="8890"
3、將db.zip解壓到到install_dir 目錄下,license.dat 存放在install_dir目錄下,即/home/kingbase/cluster_v8r6目錄下
cd /home/kingbase/cluster_v8r6/ && unzip db.zip
cp /home/kingbase/install_path/license.dat /home/kingbase/cluster_v8r6/kingbase/bin/
4、執行節點擴充套件命令(在擴充套件節點的root賬號執行擴充套件節點命令)
[root@node3 install_path]# bash V8R6_cluster_install.sh expand
5、檢查叢集狀態
[kingbase@node2 ~]$ repmgr cluster show
ID | Name | Role | Status | Upstream | Location | Priority | Timeline | LSN_Lag | Connection string
----+-------+---------+-----------+----------+----------+----------+----------+---------+----------------------------------------------------------------------------------------------------------------------------------------------------
1 | node1 | standby | running | node2 | default | 100 | 8 | 0 bytes | host=192.168.43.111 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
2 | node2 | primary | * running | | default | 100 | 8 | | host=192.168.43.112 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
3 | node3 | standby | running | node2 | default | 100 | 8 | 0 bytes | host=192.168.43.116 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
二、叢集主備切換
repmgr standby switchover 將備用資料庫升級為主機,並將現有的主機降級為備用資料庫
說明:將備用資料庫升級為主機,並將現有的主機降級為備用資料庫。此命令必須在備用資料庫上執行才能升級,並且需要配置與當前主機的免密 SSH 連線。如果執行 repmgr standby switchover 時指定了選項--siblings-follow,則 repmgr 可以使其他備機跟隨新的主節點。
node2是主節點,node1和node3是備節點,現將node1升為主節點,並將node2,和node3升為node1的備節點
1、在要升為主節點的伺服器上node1上執行switchover操作
[kingbase@node1 ~]$ repmgr standby switchover --siblings-follow
2、檢視叢集狀態
[kingbase@node1 ~]$ repmgr cluster show
ID | Name | Role | Status | Upstream | Location | Priority | Timeline | LSN_Lag | Connection string
----+-------+---------+-----------+----------+----------+----------+----------+---------+----------------------------------------------------------------------------------------------------------------------------------------------------
1 | node1 | primary | * running | | default | 100 | 9 | | host=192.168.43.111 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
2 | node2 | standby | running | node1 | default | 100 | 8 | 0 bytes | host=192.168.43.112 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
3 | node3 | standby | running | node1 | default | 100 | 8 | 0 bytes | host=192.168.43.116 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
3、以下是選項:--dry-run 檢查先決條件,但實際上不執行切換。-F -force忽略警告,然後繼續。具體而言,如果在關閉當前主資料庫遇到問題時,使用-F /-force 將透過備用資料庫升級為新的主資料庫來使 repmgr 繼續進行,並且如果指定了--siblings-follow,使任何其他備用資料庫連線到新的主機。--force-rewind[=/path/to/sys_rewind] 強制使用 sys_rewind 使原主機加入叢集(需滿足使用 sys_rewind 的先決條件)。--siblings-follow 使連線到舊主節點的備機節點跟隨新主節點。
三、節點重新加入叢集
repmgr node rejoin --force-rewindrepmgr node rejoin —將休眠(已停止)節點重新加入叢集
node1 (原主)資料庫停機後,重新加入新的叢集中,node2是主節點,node3是備節點
[kingbase@node3 ~]$ repmgr cluster show (因為node1重新啟動後變成雙主,一下叢集資訊是node1節點啟動後有停止的情況)
ID | Name | Role | Status | Upstream | Location | Priority | Timeline | LSN_Lag | Connection string
----+-------+---------+-----------+----------+----------+----------+----------+---------+----------------------------------------------------------------------------------------------------------------------------------------------------
1 | node1 | primary | - failed | ? | default | 100 | | | host=192.168.43.111 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
2 | node2 | primary | * running | | default | 100 | 10 | | host=192.168.43.112 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
3 | node3 | standby | running | node2 | default | 100 | 10 | 0 bytes | host=192.168.43.116 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
WARNING: following issues were detected
- unable to connect to node "node1" (ID: 1)
HINT: execute with --verbose option to see connection error messag
1、[kingbase@node1 ~]$ repmgr node rejoin --force-rewind -h 192.168.43.112 -Uesrep -d esrep
2、檢視叢集狀態
[kingbase@node2 ~]$ repmgr cluster show
ID | Name | Role | Status | Upstream | Location | Priority | Timeline | LSN_Lag | Connection string
----+-------+---------+-----------+----------+----------+----------+----------+---------+----------------------------------------------------------------------------------------------------------------------------------------------------
1 | node1 | standby | running | node2 | default | 100 | 9 | 0 bytes | host=192.168.43.111 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
2 | node2 | primary | * running | | default | 100 | 10 | | host=192.168.43.112 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
3 | node3 | standby | running | node2 | default | 100 | 10 | 0 bytes | host=192.168.43.116 user=esrep dbname=esrep port=54321 connect_timeout=10 keepalives=1 keepalives_idle=10 keepalives_interval=1 keepalives_count=3
3、以下是連線選項
:-h 主機或者作為上游節點的備機所在 OS 的 ip-U 連線使用的使用者,只能使用 esrep-p 連線使用的埠-d 連線使用的資料庫名稱,只能使用 esrep--dry-run 檢查先決條件,但實際上不執行重新加入。--force-rewind 執行 sys_rewind。