openGauss多主机主备集群安装及CM体验

Posted 澎湃2017

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了openGauss多主机主备集群安装及CM体验相关的知识,希望对你有一定的参考价值。

解压

cd /opengauss/soft
tar -xf openGauss-3.0.0-CentOS-64bit.tar.bz2
tar -zxf openGauss-3.0.0-CentOS-64bit-om.tar.gz
tar -zxf openGauss-3.0.0-CentOS-64bit-cm.tar.gz

准备xml配置文件cluster_config_opengauss.xml

cd script
vim cluster_config_opengauss.xml
<?xml version="1.0" encoding="UTF-8"?>
<ROOT>
<CLUSTER>
<PARAM name="clusterName" value="ogCluster" />
<PARAM name="nodeNames" value="opengauss01,opengauss02,opengauss03" />
<PARAM name="backIp1s" value="192.168.75.61,192.168.75.62,192.168.75.63"/>
<PARAM name="gaussdbAppPath" value="/opengauss/opengaussdb/app" />
<PARAM name="gaussdbLogPath" value="/opengauss/opengaussdb/log" />
<PARAM name="tmpMppdbPath" value="/opengauss/opengaussdb/tmp"/>
<PARAM name="gaussdbToolPath" value="/opengauss/opengaussdb/om" />
<PARAM name="corePath" value="/opengauss/opengaussdb/corefile"/>
<PARAM name="clusterType" value="single-inst"/>
</CLUSTER>
<DEVICELIST>
<DEVICE sn="1000001">
<PARAM name="name" value="opengauss01"/>
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<PARAM name="backIp1" value="192.168.75.61"/>
<PARAM name="sshIp1" value="192.168.75.61"/>
<!--CM-->
<PARAM name="cmDir" value="/opengauss/opengaussdb/data/cmserver" />
<PARAM name="cmsNum" value="1" />
<PARAM name="cmServerPortBase" value="15000" />
<PARAM name="cmServerlevel" value="1" />
<PARAM name="cmServerListenIp1" value="192.168.75.61,192.168.75.62,192.168.75.63" />
<PARAM name="cmServerRelation" value="opengauss01,opengauss02,opengauss03" />
<!--dbnode-->
<PARAM name="dataNum" value="1"/>
<PARAM name="dataPortBase" value="15400"/>
<PARAM name="dataNode1" value="/opengauss/opengaussdb/data/dn,opengauss02,/opengauss/opengaussdb/data/dn,opengauss03,/opengauss/opengaussdb/data/dn"/>
<PARAM name="dataNode1_syncNum" value="0"/>
</DEVICE>
<DEVICE sn="1000002">
<PARAM name="name" value="opengauss02"/>
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<PARAM name="backIp1" value="192.168.75.62"/>
<PARAM name="sshIp1" value="192.168.75.62"/>
<PARAM name="cmServerPortBase" value="15000" />
<PARAM name="cmDir" value="/opengauss/opengaussdb/data/cmserver" />
</DEVICE>
<DEVICE sn="1000003">
<PARAM name="name" value="opengauss03"/>
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<PARAM name="backIp1" value="192.168.75.63"/>
<PARAM name="sshIp1" value="192.168.75.63"/>
<PARAM name="cmServerPortBase" value="15000" />
<PARAM name="cmDir" value="/opengauss/opengaussdb/data/cmserver" />
</DEVICE>
</DEVICELIST>
</ROOT>

执行预安装

[root@opengauss1 script]# ./gs_preinstall -X cluster_config_opengauss.xml -U opengauss -G opengauss
Parsing the configuration file.
Successfully parsed the configuration file.
Installing the tools on the local node.
Successfully installed the tools on the local node.
Are you sure you want to create trust for root (yes/no)?yes
Please enter password for root
Password:
Successfully created SSH trust for the root permission user.
Setting host ip env
Successfully set host ip env.
Distributing package.
Begin to distribute package to tool path.
Successfully distribute package to tool path.
Begin to distribute package to package path.
Successfully distribute package to package path.
Successfully distributed package.
Are you sure you want to create the user[opengauss] and create trust for it (yes/no)? yes
Preparing SSH service.
Successfully prepared SSH service.
Installing the tools in the cluster.
Successfully installed the tools in the cluster.
Checking hostname mapping.
Successfully checked hostname mapping.
Creating SSH trust for [opengauss] user.
Please enter password for current user[opengauss].
Password:
Checking network information.
All nodes in the network are Normal.
Successfully checked network information.
Creating SSH trust.
Creating the local key file.
Successfully created the local key files.
Appending local ID to authorized_keys.
Successfully appended local ID to authorized_keys.
Updating the known_hosts file.
Successfully updated the known_hosts file.
Appending authorized_key on the remote node.
Successfully appended authorized_key on all remote node.
Checking common authentication file content.
Successfully checked common authentication content.
Distributing SSH trust file to all node.
Distributing trust keys file to all node successfully.
Successfully distributed SSH trust file to all node.
Verifying SSH trust on all hosts.
Successfully verified SSH trust on all hosts.
Successfully created SSH trust.
Successfully created SSH trust for [opengauss] user.
Checking OS software.
Successfully check os software.
Checking OS version.
Successfully checked OS version.
Creating clusters path.
Successfully created clusters path.
Set and check OS parameter.
Setting OS parameters.
Successfully set OS parameters.
Warning: Installation environment contains some warning messages.
Please get more details by "/opengauss/soft/script/gs_checkos -i A -h opengauss01,opengauss02,opengauss03 --detail".
Set and check OS parameter completed.
Preparing CRON service.
Successfully prepared CRON service.
Setting user environmental variables.
Successfully set user environmental variables.
Setting the dynamic link library.
Successfully set the dynamic link library.
Setting Core file
Successfully set core path.
Setting pssh path
Successfully set pssh path.
Setting Cgroup.
Successfully set Cgroup.
Set ARM Optimization.
No need to set ARM Optimization.
Fixing server package owner.
Setting finish flag.
Successfully set finish flag.
Preinstallation succeeded.

安装

chown -R opengauss:opengauss /opengauss
su - opengauss
cd /opengauss/soft/script/
设置数据库初始密码:opengauss_123
[opengauss@opengauss01:/opengauss/soft/script]$./gs_install -X cluster_config_opengauss.xml
Parsing the configuration file.
Check preinstall on every node.
Successfully checked preinstall on every node.
Creating the backup directory.
Successfully created the backup directory.
begin deploy..
Installing the cluster.
begin prepare Install Cluster..
[GAUSS-51400] : Failed to execute the command: (if [ ! -d / ]; then mkdir -p / -m 755;fi); cd /;(if [ ! -d opengauss ]; then mkdir -p opengauss -m 755;fi); cd opengauss;(if [ ! -d soft ]; then mkdir -p soft -m 755;fi); cd soft;(if [ ! -d script ]; then mkdir -p script -m 755;fi); cd script. Result:opengauss02: Failure, opengauss03: Failure.
Error:
[FAILURE] opengauss02:
bash: 第 0 行:cd: script: 权限不够
[FAILURE] opengauss03:
bash: 第 0 行:cd: script: 权限不够

[opengauss@opengauss01:/opengauss/soft/script]$./gs_install -X cluster_config_opengauss.xml
Parsing the configuration file.
Check preinstall on every node.
Successfully checked preinstall on every node.
Creating the backup directory.
Successfully created the backup directory.
begin deploy..
Installing the cluster.
begin prepare Install Cluster..
Checking the installation environment on all nodes.
begin install Cluster..
Installing applications on all nodes.
Successfully installed APP.
begin init Instance..
encrypt cipher and rand files for database.
Please enter password for database:
Please repeat for database:
begin to create CA cert files
The sslcert will be generated in /opengauss/opengaussdb/app/share/sslcert/om
Create CA files for cm beginning.
Create CA files on directory [/opengauss/opengaussdb/app_02c14696/share/sslcert/cm]. file list: [cacert.pem, server.key, server.crt, client.key, client.crt, server.key.cipher, server.key.rand, client.key.cipher, client.key.rand]
Cluster installation is completed.
Configuring.
Deleting instances from all nodes.
Successfully deleted instances from all nodes.
Checking node configuration on all nodes.
Initializing instances on all nodes.
Updating instance configuration on all nodes.
Check consistence of memCheck and coresCheck on database nodes.
Successful check consistence of memCheck and coresCheck on all nodes.
Configuring pg_hba on all nodes.
Configuration is completed.
Starting cluster.
======================================================================
Successfully started primary instance. Wait for standby instance.
======================================================================
.
Successfully started cluster.
======================================================================
cluster_state : Normal
redistributing : No
node_count : 3
Datanode State
primary : 1
standby : 2
secondary : 0
cascade_standby : 0
building : 0
abnormal : 0
down : 0

Successfully installed application.
end deploy..


CM使用体验


[opengauss@opengauss01:/home/opengauss]$cm_ctl --help
cm_ctl is a utility to start, stop, query or control a mppdb cluster.

Usage:
cm_ctl start [-z AVAILABILITY_ZONE [--cm_arbitration_mode=ARBITRATION_MODE]] | [-n NODEID [-D DATADIR]] [-t SECS]
cm_ctl switchover [-z AVAILABILITY_ZONE] | [-n NODEID -D DATADIR [-f]] | [-a] | [-A] [-t SECS]
cm_ctl finishredo
cm_ctl build [-c] [-n NODEID] [-D DATADIR [-t SECS] [-f] [-b full] [-j NUM]]
cm_ctl check -B BINNAME -T DATAPATH
cm_ctl stop [[-z AVAILABILITY_ZONE] | [-n NODEID [-D DATADIR]]] [-t SECS] [-m SHUTDOWN-MODE]
cm_ctl query [-z ALL] [-l FILENAME] [-v [-C [-s] [-S] [-d] [-i] [-F] [-x] [-p]] | [-r]] [-t SECS] [--minorityAz=AZ_NAME]
cm_ctl view [-v | -N | -n NODEID] [-l FILENAME]
cm_ctl set [--log_level=LOG_LEVEL] [--cm_arbitration_mode=ARBITRATION_MODE] [--cm_switchover_az_mode=SWITCHOVER_AZ_MODE] [--cmsPromoteMode=CMS_PROMOTE_MODE -I INSTANCEID]
cm_ctl set --param --agent | --server [-n [NODEID]] -k [PARAMETER]="[value]"
cm_ctl get [--log_level] [--cm_arbitration_mode] [--cm_switchover_az_mode]
cm_ctl setrunmode -n NODEID -D DATADIR [[--xmode=normal] | [--xmode=minority --votenum=NUM]]
cm_ctl changerole [--role=PASSIVE | --role=FOLLOWER] -n NODEID -D DATADIR [-t SECS]
cm_ctl changemember [--role=PASSIVE | --role=FOLLOWER] [--group=xx] [--priority=xx] -n NODEID -D DATADIR [-t SECS]
cm_ctl reload --param [--agent | --server]
cm_ctl list --param --agent | --server
cm_ctl encrypt [-M MODE] -D DATADIR
cm_ctl ddb DCC_CMD
cm_ctl switch [--ddb_type=[DDB]] [--commit] [--rollback]

Common options:
-D DATADIR location of the database storage area
-l FILENAME write (or append) result to FILENAME
-n NODEID node id
-z AVAILABILITY_ZONE availability zone name
-t SECS seconds to wait
-V, --version output version information, then exit
-?, -h, --help show this help, then exit

Options for switchover:
-a auto switchover to rebalance mppdb service
-A switch all the datanodes standby instances with their master instances
-f fast switchover

Options for build:
-f force build
-b full full build
-c cm server build
-j [num] parallelism

Options for check:
-B BINNAME BINNAME can be "cm_agent", "gaussdb" or "cm_server"
-T DATAPATH location of the database storage area

Options for stop:
-m MODE MODE can be "smart" "fast" "immediate"

Options for query:
-s show instances that need to switchover
-C show query result by HA relation
-v show detail query result
-d show instance datapath
-i show physical node ip
-F show all fenced UDF master process status
-z show all availability zone status. The value must be "ALL"
-r show standby DN redo status
-g show backup and recovery cluster info
-x show abnormal instances
-S show the results of the status check when the cluster was started
--minorityAz check the cms status only in the pointed AZ
-p show the port of datanode

Options for set:
--log_level=LOG_LEVEL LOG_LEVEL can be "DEBUG5", "DEBUG1", "LOG", "WARNING", "ERROR" or "FATAL"
--cm_arbitration_mode=ARBITRATION_MODE ARBITRATION_MODE can be "MAJORITY", "MINORITY"
--cm_switchover_az_mode= SWITCHOVER_AZ_MODE SWITCHOVER_AZ_MODE can be "NON_AUTO", "AUTO"
--cmsPromoteMode=CMS_PROMOTE_MODE -I INSTANCEID CMS_PROMOTE_MODE can be "AUTO", "PRIMARY_F"
--agent set cm agent conf
--server set cm server conf
--k set parameter and value

Options for get:
--log_level show LOG_LEVEL
--cm_arbitration_mode show cm server arbitration mode
--cm_switchover_az_mode show az switchover mode

Options for view:
-v show details of static config
-N show local node static config

Options for setrunmode:
--xmode minority or normal.
--votenum in minority mode,available dn vote number.

Options for changerole:
--role switch dcf role to passive or to follower.

Options for changemember:
--role switch dcf role to passive or to follower.
--group change dcf group id.
--priority change dcf election priority.

Options for reload:
reload reload cluster static config online.
--agent reload cm_agent conf.
--server reload cm_server conf.

Options for list:
--agent list the cm_agent parameter.
--server list the cm_server parameter.

Options for encrypt:
-M encrypt mode (server,client), default value is server mode.
-D appoint encrypt file path.

Options for switch ddb:
--ddb_type switch to which ddb type.
--commit after switch success, need do commit.
--rollback when something wrong, can do rollback.

Shutdown modes are:
smart quit with fast shutdown on primary, and recovery done on standby
fast quit directly, with proper shutdown
immediate quit without complete shutdown; will lead to recovery on restart

Cluster state including:
Normal cluster is available with data replication
Degraded cluster is available without data replication
Unavailable cluster is unavailable

Instance state including:
Primary database system run as a primary server, send xlog to standby server
Standby database system run as a standby server, receive xlog from primary server
Cascade Standby database system run as a cascade standby server, receive xlog from standby server
Pending database system run as a pending server, wait for promoting to primary or demoting to standby
Down database system not running
Unknown database system not connected

HA state including:
Normal database system is normal
Need repair database system is not connected with primary/standby server or not matched with primary/standby server
Wait promoting database system is waiting to promote during switchover
Promoting database system is promoting
Building database system is building
Catchup database system is catching up xlog
Demoting database system is demoting
Starting database system is starting up
Manually stopped database system is down for being manually stopped
Disk damaged database system is down for disk damaged
Port conflicting database system is down for port conflicting
Unknown database system is down for some internal error

Options for dcc cmd:
--help, -h Shows help information of dcc cmd.
--version, -v Shows version information of dcc.
--get key Queries the value of a specified key.
--put key val Updates or insert the value of a specified key.
--delete key Deletes the specified key.
--prefix Prefix matching --get or --delete.
--cluster_info show cluster info.
--leader_info show leader nodeid.


测试几个命令

用cm查看集群状态

[opengauss@opengauss01:/home/opengauss]$cm_ctl query -Cvdi
[ CMServer State ]

node node_ip instance state
------------------------------------------------------------------------------------------
1 opengauss01 192.168.75.61 1 /opengauss/opengaussdb/data/cmserver/cm_server Primary
2 opengauss02 192.168.75.62 2 /opengauss/opengaussdb/data/cmserver/cm_server Standby
3 opengauss03 192.168.75.63 3 /opengauss/opengaussdb/data/cmserver/cm_server Standby

[ Cluster State ]

cluster_state : Normal
redistributing : No
balanced : Yes
current_az : AZ_ALL

[ Datanode State ]

node node_ip instance state | node node_ip instance state | node node_ip instance state
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 opengauss01 192.168.75.61 6001 /opengauss/opengaussdb/data/dn P Primary Normal | 2 opengauss02 192.168.75.62 6002 /opengauss/opengaussdb/data/dn S Standby Normal | 3 opengauss03 192.168.75.63 6003 /opengauss/opengaussdb/data/dn S Standby Normal
[opengauss@opengauss01:/home/opengauss]$
#节点一即是CMserver主节点为,也是DN主节点,Datanode state显示的格式不是很友好,没有使用gs_om 命令查询显示的格式友好


也可以用gs_om 查集群状态


[opengauss@opengauss01:/home/opengauss]$gs_om -t status --detail
[ CMServer State ]

node node_ip instance state
------------------------------------------------------------------------------------------
1 opengauss01 192.168.75.61 1 /opengauss/opengaussdb/data/cmserver/cm_server Primary
2 opengauss02 192.168.75.62 2 /opengauss/opengaussdb/data/cmserver/cm_server Standby
3 opengauss03 192.168.75.63 3 /opengauss/opengaussdb/data/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 opengauss01 192.168.75.61 6001 /opengauss/opengaussdb/data/dn P Primary Normal
2 opengauss02 192.168.75.62 6002 /opengauss/opengaussdb/data/dn S Standby Normal
3 opengauss03 192.168.75.63 6003 /opengauss/opengaussdb/data/dn S Standby Normal
[opengauss@opengauss01:/home/opengauss]$


停止集群


可以在任意节点执行

[opengauss@opengauss01:/home/opengauss]$cm_ctl stop
cm_ctl: stop cluster.
cm_ctl: stop nodeid: 1
cm_ctl: stop nodeid: 2
cm_ctl: stop nodeid: 3
...................
cm_ctl: stop cluster successfully.
[opengauss@opengauss01:/home/opengauss]$


启动集群


可以在任意节点执行

[opengauss@opengauss01:/home/opengauss]$cm_ctl start
cm_ctl: checking cluster status.
cm_ctl: checking cluster status.
cm_ctl: checking finished in 545 ms.
cm_ctl: start cluster.
cm_ctl: start nodeid: 1
cm_ctl: start nodeid: 2
cm_ctl: start nodeid: 3
..............
cm_ctl: start cluster successfully.
[opengauss@opengauss01:/home/opengauss]$


切换primary到节点3


[opengauss@opengauss01:/home/opengauss]$cm_ctl switchover -n 3 -D /opengauss/opengaussdb/data/dn
.......
cm_ctl: switchover successfully.
[opengauss@opengauss01:/home/opengauss]$gs_om -t status --detail
[ CMServer State ]

node node_ip instance state
------------------------------------------------------------------------------------------
1 opengauss01 192.168.75.61 1 /opengauss/opengaussdb/data/cmserver/cm_server Primary
2 opengauss02 192.168.75.62 2 /opengauss/opengaussdb/data/cmserver/cm_server Standby
3 opengauss03 192.168.75.63 3 /opengauss/opengaussdb/data/cmserver/cm_server Standby

[ Cluster State ]

cluster_state : Normal
redistributing : No
balanced : No
current_az : AZ_ALL

[ Datanode State ]

node node_ip instance state
------------------------------------------------------------------------------------
1 opengauss01 192.168.75.61 6001 /opengauss/opengaussdb/data/dn P Standby Normal
2 opengauss02 192.168.75.62 6002 /opengauss/opengaussdb/data/dn S Standby Normal
3 opengauss03 192.168.75.63 6003 /opengauss/opengaussdb/data/dn S Primary Normal
[opengauss@opengauss01:/home/opengauss]$cm_ctl query -Cvdi
[ CMServer State ]

node node_ip instance state
------------------------------------------------------------------------------------------
1 opengauss01 192.168.75.61 1 /opengauss/opengaussdb/data/cmserver/cm_server Primary
2 opengauss02 192.168.75.62 2 /opengauss/opengaussdb/data/cmserver/cm_server Standby
3 opengauss03 192.168.75.63 3 /opengauss/opengaussdb/data/cmserver/cm_server Standby

[ Cluster State ]

cluster_state : Normal
redistributing : No
balanced : No
current_az : AZ_ALL

[ Datanode State ]

node node_ip instance state | node node_ip instance state | node node_ip instance state
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 opengauss01 192.168.75.61 6001 /opengauss/opengaussdb/data/dn P Standby Normal | 2 opengauss02 192.168.75.62 6002 /opengauss/opengaussdb/data/dn S Standby Normal | 3 opengauss03 192.168.75.63 6003 /opengauss/opengaussdb/data/dn S Primary Normal
[opengauss@opengauss01:/home/opengauss]$
#注:cm_ctl查询状态的显示没有gs_om查询状态显示的友好


切回primary到节点1


[opengauss@opengauss01:/home/opengauss]$cm_ctl switchover -n 1 -D /opengauss/opengaussdb/data/dn
...........
cm_ctl: switchover successfully.
[opengauss@opengauss01:/home/opengauss]$gs_om -t status --detail
[ CMServer State ]

node node_ip instance state
------------------------------------------------------------------------------------------
1 opengauss01 192.168.75.61 1 /opengauss/opengaussdb/data/cmserver/cm_server Primary
2 opengauss02 192.168.75.62 2 /opengauss/opengaussdb/data/cmserver/cm_server Standby
3 opengauss03 192.168.75.63 3 /opengauss/opengaussdb/data/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 opengauss01 192.168.75.61 6001 /opengauss/opengaussdb/data/dn P Primary Normal
2 opengauss02 192.168.75.62 6002 /opengauss/opengaussdb/data/dn S Standby Normal
3 opengauss03 192.168.75.63 6003 /opengauss/opengaussdb/data/dn S Standby Normal
[opengauss@opengauss01:/home/opengauss]$


模拟故障主节点宕机


#前后集群状态查看:Datanode的primary自动切到节点2,CMServer的primary切到了节点3
[opengauss@opengauss02:/home/opengauss]$gs_om -t status --detail
[ CMServer State ]

node node_ip instance state
------------------------------------------------------------------------------------------
1 opengauss01 192.168.75.61 1 /opengauss/opengaussdb/data/cmserver/cm_server Primary
2 opengauss02 192.168.75.62 2 /opengauss/opengaussdb/data/cmserver/cm_server Standby
3 opengauss03 192.168.75.63 3 /opengauss/opengaussdb/data/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 opengauss01 192.168.75.61 6001 /opengauss/opengaussdb/data/dn P Primary Normal
2 opengauss02 192.168.75.62 6002 /opengauss/opengaussdb/data/dn S Standby Normal
3 opengauss03 192.168.75.63 6003 /opengauss/opengaussdb/data/dn S Standby Normal
[opengauss@opengauss02:/home/opengauss]$gs_om -t status --detail
[ CMServer State ]

node node_ip instance state
------------------------------------------------------------------------------------------
1 opengauss01 192.168.75.61 1 /opengauss/opengaussdb/data/cmserver/cm_server Down
2 opengauss02 192.168.75.62 2 /opengauss/opengaussdb/data/cmserver/cm_server Standby
3 opengauss03 192.168.75.63 3 /opengauss/opengaussdb/data/cmserver/cm_server Primary

[ Cluster State ]

cluster_state : Degraded
redistributing : No
balanced : No
current_az : AZ_ALL

[ Datanode State ]

node node_ip instance state
------------------------------------------------------------------------------------
1 opengauss01 192.168.75.61 6001 /opengauss/opengaussdb/data/dn P Down Unknown
2 opengauss02 192.168.75.62 6002 /opengauss/opengaussdb/data/dn S Primary Normal
3 opengauss03 192.168.75.63 6003 /opengauss/opengaussdb/data/dn S Standby Normal
[opengauss@opengauss02:/home/opengauss]$


启动故障节点主机后...


# 本打算启动主机后启动一下故障节点的数据库,发现已经自动启动了,神奇
[opengauss@opengauss02:/home/opengauss]$cm_ctl query -Cvdi
[ CMServer State ]

node node_ip instance state
------------------------------------------------------------------------------------------
1 opengauss01 192.168.75.61 1 /opengauss/opengaussdb/data/cmserver/cm_server Standby
2 opengauss02 192.168.75.62 2 /opengauss/opengaussdb/data/cmserver/cm_server Standby
3 opengauss03 192.168.75.63 3 /opengauss/opengaussdb/data/cmserver/cm_server Primary

[ Cluster State ]

cluster_state : Normal
redistributing : No
balanced : No
current_az : AZ_ALL

[ Datanode State ]

node node_ip instance state | node node_ip instance state | node node_ip instance state
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 opengauss01 192.168.75.61 6001 /opengauss/opengaussdb/data/dn P Standby Normal | 2 opengauss02 192.168.75.62 6002 /opengauss/opengaussdb/data/dn S Primary Normal | 3 opengauss03 192.168.75.63 6003 /opengauss/opengaussdb/data/dn S Standby Normal
[opengauss@opengauss02:/home/opengauss]$
[opengauss@opengauss02:/home/opengauss]$
[opengauss@opengauss02:/home/opengauss]$gs_om -t status --detail
[ CMServer State ]

node node_ip instance state
------------------------------------------------------------------------------------------
1 opengauss01 192.168.75.61 1 /opengauss/opengaussdb/data/cmserver/cm_server Standby
2 opengauss02 192.168.75.62 2 /opengauss/opengaussdb/data/cmserver/cm_server Standby
3 opengauss03 192.168.75.63 3 /opengauss/opengaussdb/data/cmserver/cm_server Primary

[ Cluster State ]

cluster_state : Normal
redistributing : No
balanced : No
current_az : AZ_ALL

[ Datanode State ]

node node_ip instance state
------------------------------------------------------------------------------------
1 opengauss01 192.168.75.61 6001 /opengauss/opengaussdb/data/dn P Standby Normal
2 opengauss02 192.168.75.62 6002 /opengauss/opengaussdb/data/dn S Primary Normal
3 opengauss03 192.168.75.63 6003 /opengauss/opengaussdb/data/dn S Standby Normal
[opengauss@opengauss02:/home/opengauss]$


Datanode的primary切换节点1

[opengauss@opengauss02:/home/opengauss]$cm_ctl switchover -n 1 -D /opengauss/opengaussdb/data/dn
.......
cm_ctl: switchover successfully.
[opengauss@opengauss02:/home/opengauss]$
[opengauss@opengauss02:/home/opengauss]$
[opengauss@opengauss02:/home/opengauss]$gs_om -t status --detail
[ CMServer State ]

node node_ip instance state
------------------------------------------------------------------------------------------
1 opengauss01 192.168.75.61 1 /opengauss/opengaussdb/data/cmserver/cm_server Standby
2 opengauss02 192.168.75.62 2 /opengauss/opengaussdb/data/cmserver/cm_server Standby
3 opengauss03 192.168.75.63 3 /opengauss/opengaussdb/data/cmserver/cm_server Primary

[ Cluster State ]

cluster_state : Normal
redistributing : No
balanced : Yes
current_az : AZ_ALL

[ Datanode State ]

node node_ip instance state
------------------------------------------------------------------------------------
1 opengauss01 192.168.75.61 6001 /opengauss/opengaussdb/data/dn P Primary Normal
2 opengauss02 192.168.75.62 6002 /opengauss/opengaussdb/data/dn S Standby Normal
3 opengauss03 192.168.75.63 6003 /opengauss/opengaussdb/data/dn S Standby Normal
[opengauss@opengauss02:/home/opengauss]$


总结:

      暂时还不知道怎么切换CMServer的primary,感觉也没必要切换了,本身就是用来做故障转移的组件。

      openGauss3.0可以不依赖于第三方工具实现primary自动切换,高可用方面增强了不少。

以上是关于openGauss多主机主备集群安装及CM体验的主要内容,如果未能解决你的问题,请参考以下文章

openGauss主备流程与参数的详细介绍

openGauss主备流程与参数的详细介绍

猿创征文 | 国产数据库之openGauss的单机主备部署及快速入门

云原生使用Docker快速部署openGauss主备环境

G025-DB-GS-INS-02 OpenEuler 部署 OpenGauss(1主1备)

keepalive集群工作原理及应用