说明
环境信息
[omm@testosa ~]$ arch
x86_64
[omm@testosa ~]$ uname -a
Linux testosa 3.10.0-957.el7.x86_64
[omm@testosa ~]$ cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
[omm@testosa ~]$ cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[omm@testosa ~]$
[omm@testosa ~]$ cm_ctl query -Cvdip
[ CMServer State ]
node node_ip instance state
---------------------------------------------------------------------
1 testosa 192.168.1.80 1 /opengauss/cmserver/cm_server Primary
2 testosb 192.168.1.81 2 /opengauss/cmserver/cm_server Standby
3 testosc 192.168.1.82 3 /opengauss/cmserver/cm_server Standby
4 testosd 192.168.1.83 4 /opengauss/cmserver/cm_server Standby
[ Cluster State ]
cluster_state : Normal
redistributing : No
balanced : Yes
current_az : AZ_ALL
[ Datanode State ]
node node_ip instance state
--------------------------------------------------------------------------
1 testosa 192.168.1.80 6001 12345 /opengauss/data/dn P Primary Normal
2 testosb 192.168.1.81 6002 12345 /opengauss/data/dn S Standby Normal
3 testosc 192.168.1.82 6003 12345 /opengauss/data/dn S Standby Normal
4 testosd 192.168.1.83 6004 12345 /opengauss/data/dn C Cascade Standby Normal
[omm@testosa ~]$
[omm@testosa ~]$ gs_ssh -c "gsql -d postgres -p 12345 -c \"select regexp_substr(version(),'.*\d{2} ') as version\""
Successfully execute command on all nodes.
Output:
[SUCCESS] testosa:
version
-------------------------------------------------------------------
(openGauss 3.0.3 build 46134f73) compiled at 2022-12-30 20:48:06
(1 row)
[SUCCESS] testosb:
version
-------------------------------------------------------------------
(openGauss 3.0.3 build 46134f73) compiled at 2022-12-30 20:48:06
(1 row)
[SUCCESS] testosc:
version
-------------------------------------------------------------------
(openGauss 3.0.3 build 46134f73) compiled at 2022-12-30 20:48:06
(1 row)
[SUCCESS] testosd:
version
-------------------------------------------------------------------
(openGauss 3.0.3 build 46134f73) compiled at 2022-12-30 20:48:06
(1 row)
[omm@testosa ~]$
[omm@testosa ~]$ gs_ssh -c "gaussdb -V"
Successfully execute command on all nodes.
Output:
[SUCCESS] testosa:
gaussdb (openGauss 3.0.3 build 46134f73) compiled at 2022-12-30 20:48:06 commit 0 last mr
[SUCCESS] testosb:
gaussdb (openGauss 3.0.3 build 46134f73) compiled at 2022-12-30 20:48:06 commit 0 last mr
[SUCCESS] testosc:
gaussdb (openGauss 3.0.3 build 46134f73) compiled at 2022-12-30 20:48:06 commit 0 last mr
[SUCCESS] testosd:
gaussdb (openGauss 3.0.3 build 46134f73) compiled at 2022-12-30 20:48:06 commit 0 last mr
[omm@testosa ~]$ gs_ssh -c "cm_ctl -V"
Successfully execute command on all nodes.
Output:
[SUCCESS] testosa:
cm_ctl (openGauss CM 3.0.3 build 313feba8) compiled at 2022-12-30 20:58:21 Release
[SUCCESS] testosb:
cm_ctl (openGauss CM 3.0.3 build 313feba8) compiled at 2022-12-30 20:58:21 Release
[SUCCESS] testosc:
cm_ctl (openGauss CM 3.0.3 build 313feba8) compiled at 2022-12-30 20:58:21 Release
[SUCCESS] testosd:
cm_ctl (openGauss CM 3.0.3 build 313feba8) compiled at 2022-12-30 20:58:21 Release
[omm@testosa ~]$ gs_ssh -c "gs_om -V"
Successfully execute command on all nodes.
Output:
[SUCCESS] testosa:
gs_om (openGauss OM 3.0.3 build 698397ea) compiled at 2022-12-30 20:58:12 commit 0 last mr
[SUCCESS] testosb:
gs_om (openGauss OM 3.0.3 build 698397ea) compiled at 2022-12-30 20:58:12 commit 0 last mr
[SUCCESS] testosc:
gs_om (openGauss OM 3.0.3 build 698397ea) compiled at 2022-12-30 20:58:12 commit 0 last mr
[SUCCESS] testosd:
gs_om (openGauss OM 3.0.3 build 698397ea) compiled at 2022-12-30 20:58:12 commit 0 last mr
[omm@testosa ~]$
测试说明
[root@testosb ~]
testosb
[root@testosb ~]
192.168.1.81
[root@testosb ~]
192.168.1.81 testosb
[root@testosb ~]
测试过程
停止数据库集群
[omm@testosa ~]$ cm_ctl stop
修改主机IP
[root@testosb ~]
IPADDR="192.168.1.81"
sed -i '/IPADDR/s/192.168.1.81/192.168.1.90/' /etc/sysconfig/network-scripts/ifcfg-ens33
[root@testosb ~]
[root@testosb ~]
IPADDR="192.168.1.90"
systemctl restart network
[root@testosb ~]
192.168.1.90
[root@testosb ~]
修改/etc/hosts文件
[root@testosa ~]
[root@testosb ~]
[root@testosc ~]
[root@testosd ~]
修复子用户互信
[omm@testosa ~]$ grep '192.168.1.81' /home/omm/.ssh/known_hosts
192.168.1.81 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJUFWSx4LdDZPSiG2YJL8e7elgSWhT7BiVADsZ1rVML1
[omm@testosa ~]$ sed -i 's/192.168.1.81/192.168.1.90/' /home/omm/.ssh/known_hosts
[omm@testosa ~]$ grep '192.168.1.81' /home/omm/.ssh/known_hosts
[omm@testosa ~]$
[omm@testosb ~]$ grep '192.168.1.81' /home/omm/.ssh/known_hosts
192.168.1.81 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJUFWSx4LdDZPSiG2YJL8e7elgSWhT7BiVADsZ1rVML1
[omm@testosb ~]$ sed -i 's/192.168.1.81/192.168.1.90/' /home/omm/.ssh/known_hosts
[omm@testosb ~]$ grep '192.168.1.81' /home/omm/.ssh/known_hosts
[omm@testosb ~]$
[omm@testosc ~]$ grep '192.168.1.81' /home/omm/.ssh/known_hosts
192.168.1.81 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJUFWSx4LdDZPSiG2YJL8e7elgSWhT7BiVADsZ1rVML1
[omm@testosc ~]$ sed -i 's/192.168.1.81/192.168.1.90/' /home/omm/.ssh/known_hosts
[omm@testosc ~]$ grep '192.168.1.81' /home/omm/.ssh/known_hosts
[omm@testosc ~]$
[root@testosd ~]
192.168.1.81 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJUFWSx4LdDZPSiG2YJL8e7elgSWhT7BiVADsZ1rVML1
[root@testosd ~]
[root@testosd ~]
[root@testosd ~]
for i in {testosa,testosb,testosc,testosd,192.168.1.80,192.168.1.90,192.168.1.82,192.168.1.83};do
ssh $i hostname
done
修改各节点数据库配置文件(postgresql.conf)
[omm@testosb dn]$ grep '192.168.1.81' /opengauss/data/dn/postgresql.conf
listen_addresses = 'localhost,192.168.1.81'
local_bind_address = '192.168.1.81'
replconninfo1 = 'localhost=192.168.1.81 localport=12346 localheartbeatport=12350 localservice=12349 remotehost=192.168.1.80 remoteport=12346 remoteheartbeatport=12350 remoteservice=12349'
replconninfo2 = 'localhost=192.168.1.81 localport=12346 localheartbeatport=12350 localservice=12349 remotehost=192.168.1.82 remoteport=12346 remoteheartbeatport=12350 remoteservice=12349'
replconninfo3 = 'localhost=192.168.1.81 localport=12346 localheartbeatport=12350 localservice=12349 remotehost=192.168.1.83 remoteport=12346 remoteheartbeatport=12350 remoteservice=12349 iscascade=true'
[omm@testosb dn]$ sed -i 's/192.168.1.81/192.168.1.90/' /opengauss/data/dn/postgresql.conf
[omm@testosb dn]$ grep '192.168.1.81' /opengauss/data/dn/postgresql.conf
[omm@testosb dn]$
[omm@testosa ~]$ grep '192.168.1.81' /opengauss/data/dn/postgresql.conf
replconninfo1 = 'localhost=192.168.1.80 localport=12346 localheartbeatport=12350 localservice=12349 remotehost=192.168.1.81 remoteport=12346 remoteheartbeatport=12350 remoteservice=12349'
[omm@testosa ~]$ sed -i 's/192.168.1.81/192.168.1.90/' /opengauss/data/dn/postgresql.conf
[omm@testosa ~]$ grep '192.168.1.81' /opengauss/data/dn/postgresql.conf
[omm@testosa ~]$
[root@testosc ~]
replconninfo2 = 'localhost=192.168.1.82 localport=12346 localheartbeatport=12350 localservice=12349 remotehost=192.168.1.81 remoteport=12346 remoteheartbeatport=12350 remoteservice=12349'
[root@testosc ~]
[root@testosc ~]
[root@testosc ~]
[root@testosd ~]
replconninfo2 = 'localhost=192.168.1.83 localport=12346 localheartbeatport=12350 localservice=12349 remotehost=192.168.1.81 remoteport=12346 remoteheartbeatport=12350 remoteservice=12349'
[root@testosd ~]
[root@testosd ~]
[root@testosd ~]
修改各个节点pg_hba.conf文件
[omm@testosa dn]$ grep '192.168.1.81' /opengauss/data/dn/pg_hba.conf
host all omm 192.168.1.81/32 trust
host all all 192.168.1.81/32 sha256
[omm@testosa dn]$ sed -i 's/192.168.1.81/192.168.1.90/' /opengauss/data/dn/pg_hba.conf
[omm@testosa dn]$ grep '192.168.1.81' /opengauss/data/dn/pg_hba.conf
[omm@testosa dn]$
[omm@testosb dn]$ grep '192.168.1.81' /opengauss/data/dn/pg_hba.conf
host all omm 192.168.1.81/32 trust
host all all 192.168.1.81/32 sha256
[omm@testosb dn]$ sed -i 's/192.168.1.81/192.168.1.90/' /opengauss/data/dn/pg_hba.conf
[omm@testosb dn]$ grep '192.168.1.81' /opengauss/data/dn/pg_hba.conf
[omm@testosb dn]$
[root@testosc ~]
host all omm 192.168.1.81/32 trust
host all all 192.168.1.81/32 sha256
[root@testosc ~]
[root@testosc ~]
[root@testosc ~]
[root@testosd ~]
host all omm 192.168.1.81/32 trust
host all all 192.168.1.81/32 sha256
[root@testosd ~]
[root@testosd ~]
[root@testosd ~]
重新生成静态配置文件
[omm@testosa dn]$ gs_om -t view|grep -E '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+'
sshChannel 1:192.168.1.80
datanodeListenIP 1:192.168.1.80
datanodeLocalHAIP 1:192.168.1.80
datanodePeer0HAIP 1:192.168.1.81
datanodePeer1HAIP 1:192.168.1.82
datanodePeer2HAIP 1:192.168.1.83
sshChannel 1:192.168.1.81
datanodeListenIP 1:192.168.1.81
datanodeLocalHAIP 1:192.168.1.81
datanodePeer0HAIP 1:192.168.1.80
datanodePeer1HAIP 1:192.168.1.82
datanodePeer2HAIP 1:192.168.1.83
sshChannel 1:192.168.1.82
datanodeListenIP 1:192.168.1.82
datanodeLocalHAIP 1:192.168.1.82
datanodePeer0HAIP 1:192.168.1.80
datanodePeer1HAIP 1:192.168.1.81
datanodePeer2HAIP 1:192.168.1.83
sshChannel 1:192.168.1.83
datanodeListenIP 1:192.168.1.83
datanodeLocalHAIP 1:192.168.1.83
datanodePeer0HAIP 1:192.168.1.80
datanodePeer1HAIP 1:192.168.1.81
datanodePeer2HAIP 1:192.168.1.82
[omm@testosa dn]$
[omm@testosa dn]$ grep '192.168.1.81' /tmp/3standby_cm.xml
<PARAM name="backIp1s" value="192.168.1.80,192.168.1.81,192.168.1.82,192.168.1.83"/>
<PARAM name="cmServerListenIp1" value="192.168.1.80,192.168.1.81,192.168.1.82,192.168.1.83"/>
<PARAM name="cmServerHaIp1" value="192.168.1.80,192.168.1.81,192.168.1.82,192.168.1.83"/>
<PARAM name="backIp1" value="192.168.1.81"/>
<PARAM name="sshIp1" value="192.168.1.81"/>
[omm@testosa dn]$ sed -i 's/192.168.1.81/192.168.1.90/' /tmp/3standby_cm.xml
[omm@testosa dn]$ grep '192.168.1.81' /tmp/3standby_cm.xml
[omm@testosa dn]$
[omm@testosa ~]$ gs_om -t generateconf -X /tmp/3standby_cm.xml --distribute
Generating static configuration files for all nodes.
Creating temp directory to store static configuration files.
Successfully created the temp directory.
Generating static configuration files.
Successfully generated static configuration files.
Static configuration files for all nodes are saved in /opengauss/om/script/static_config_files.
Distributing static configuration files to all nodes.
Successfully distributed static configuration files.
[omm@testosa ~]$
[omm@testosa ~]$ gs_ssh -c "gs_om -t view|grep -E '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+'"|awk -F : '{print $2}'|sort|uniq
192.168.1.80
192.168.1.82
192.168.1.83
192.168.1.90
[omm@testosa ~]$
cm配置处理
[omm@testosa ~]$ gs_ssh -c "ls -ld /opengauss/cmserver/dcf_data/metadata"
Successfully execute command on all nodes.
Output:
[SUCCESS] testosa:
drwx------ 2 omm dbgrp 72 Feb 1 22:33 /opengauss/cmserver/dcf_data/metadata
[SUCCESS] testosb:
drwx------ 2 omm dbgrp 72 Feb 1 22:33 /opengauss/cmserver/dcf_data/metadata
[SUCCESS] testosc:
drwx------ 2 omm dbgrp 72 Feb 1 22:33 /opengauss/cmserver/dcf_data/metadata
[SUCCESS] testosd:
drwx------ 2 omm dbgrp 72 Feb 1 22:33 /opengauss/cmserver/dcf_data/metadata
[omm@testosa ~]$
[omm@testosa ~]$ gs_ssh -c "rm -rf /opengauss/cmserver/dcf_data/metadata"
Successfully execute command on all nodes.
Output:
[SUCCESS] testosa:
[SUCCESS] testosb:
[SUCCESS] testosc:
[SUCCESS] testosd:
[omm@testosa ~]$ gs_ssh -c "ls -ld /opengauss/cmserver/dcf_data/metadata"
Failed to execute command on all nodes.
Output:
[GAUSS-51400] : Failed to execute the command: sh /opengauss/tmp/ClusterCall_71151.sh. Error:
[FAILURE] testosa:
ls: cannot access /opengauss/cmserver/dcf_data/metadata: No such file or directory
[FAILURE] testosb:
ls: cannot access /opengauss/cmserver/dcf_data/metadata: No such file or directory
[FAILURE] testosc:
ls: cannot access /opengauss/cmserver/dcf_data/metadata: No such file or directory
[FAILURE] testosd:
ls: cannot access /opengauss/cmserver/dcf_data/metadata: No such file or directory
[omm@testosa ~]$
[omm@testosa ~]$ gs_ssh -c "ls -l /opengauss/app_46134f73/bin/cluster_dynamic_config"
Successfully execute command on all nodes.
Output:
[SUCCESS] testosa:
-rw------- 1 omm dbgrp 9068 Feb 1 22:38 /opengauss/app_46134f73/bin/cluster_dynamic_config
[SUCCESS] testosb:
-rw------- 1 omm dbgrp 9068 Feb 1 22:53 /opengauss/app_46134f73/bin/cluster_dynamic_config
[SUCCESS] testosc:
-rw------- 1 omm dbgrp 9068 Feb 1 22:53 /opengauss/app_46134f73/bin/cluster_dynamic_config
[SUCCESS] testosd:
-rw------- 1 omm dbgrp 9068 Feb 1 22:53 /opengauss/app_46134f73/bin/cluster_dynamic_config
[omm@testosa ~]$
[omm@testosa ~]$ gs_ssh -c "rm -rf /opengauss/app_46134f73/bin/cluster_dynamic_config"
Successfully execute command on all nodes.
Output:
[SUCCESS] testosa:
[SUCCESS] testosb:
[SUCCESS] testosc:
[SUCCESS] testosd:
[omm@testosa ~]$
启动集群
[omm@testosa ~]$ cm_ctl start
cm_ctl: checking cluster status.
cm_ctl: checking cluster status.
cm_ctl: checking finished in 480 ms.
cm_ctl: start cluster.
cm_ctl: start nodeid: 1
cm_ctl: start nodeid: 2
cm_ctl: start nodeid: 3
cm_ctl: start nodeid: 4
................
cm_ctl: start cluster successfully.
[omm@testosa ~]$
[omm@testosa ~]$ cm_ctl query -Cvdip
[ CMServer State ]
node node_ip instance state
---------------------------------------------------------------------
1 testosa 192.168.1.80 1 /opengauss/cmserver/cm_server Primary
2 testosb 192.168.1.90 2 /opengauss/cmserver/cm_server Standby
3 testosc 192.168.1.82 3 /opengauss/cmserver/cm_server Standby
4 testosd 192.168.1.83 4 /opengauss/cmserver/cm_server Standby
[ Cluster State ]
cluster_state : Normal
redistributing : No
balanced : Yes
current_az : AZ_ALL
[ Datanode State ]
node node_ip instance state
---------------------------------------------------------------------------
1 testosa 192.168.1.80 6001 12345 /opengauss/data/dn P Primary Normal
2 testosb 192.168.1.90 6002 12345 /opengauss/data/dn S Standby Normal
3 testosc 192.168.1.82 6003 12345 /opengauss/data/dn S Standby Normal
4 testosd 192.168.1.83 6004 12345 /opengauss/data/dn C Cascade Standby Normal
[omm@testosa ~]$