满堂花醉三千客,一剑霜寒十四州。这篇文章主要讲述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="https://www.songbingjia.com/android/ogCluster" />
< PARAM name="nodeNames" value="https://www.songbingjia.com/android/opengauss01,opengauss02,opengauss03" />
< PARAM name="backIp1s" value="https://www.songbingjia.com/android/192.168.75.61,192.168.75.62,192.168.75.63"/>
< PARAM name="gaussdbAppPath" value="https://www.songbingjia.com/opengauss/opengaussdb/app" />
< PARAM name="gaussdbLogPath" value="https://www.songbingjia.com/opengauss/opengaussdb/log" />
< PARAM name="tmpMppdbPath" value="https://www.songbingjia.com/opengauss/opengaussdb/tmp"/>
< PARAM name="gaussdbToolPath" value="https://www.songbingjia.com/opengauss/opengaussdb/om" />
< PARAM name="corePath" value="https://www.songbingjia.com/opengauss/opengaussdb/corefile"/>
< PARAM name="clusterType" value="https://www.songbingjia.com/android/single-inst"/>
< /CLUSTER>
< DEVICELIST>
< DEVICE sn="1000001">
< PARAM name="name" value="https://www.songbingjia.com/android/opengauss01"/>
< PARAM name="azName" value="https://www.songbingjia.com/android/AZ1"/>
< PARAM name="azPriority" value="https://www.songbingjia.com/android/1"/>
< PARAM name="backIp1" value="https://www.songbingjia.com/android/192.168.75.61"/>
< PARAM name="sshIp1" value="https://www.songbingjia.com/android/192.168.75.61"/>
< !--CM-->
< PARAM name="cmDir" value="https://www.songbingjia.com/opengauss/opengaussdb/data/cmserver" />
< PARAM name="cmsNum" value="https://www.songbingjia.com/android/1" />
< PARAM name="cmServerPortBase" value="https://www.songbingjia.com/android/15000" />
< PARAM name="cmServerlevel" value="https://www.songbingjia.com/android/1" />
< PARAM name="cmServerListenIp1" value="https://www.songbingjia.com/android/192.168.75.61,192.168.75.62,192.168.75.63" />
< PARAM name="cmServerRelation" value="https://www.songbingjia.com/android/opengauss01,opengauss02,opengauss03" />
< !--dbnode-->
< PARAM name="dataNum" value="https://www.songbingjia.com/android/1"/>
< PARAM name="dataPortBase" value="https://www.songbingjia.com/android/15400"/>
< PARAM name="dataNode1" value="https://www.songbingjia.com/opengauss/opengaussdb/data/dn,opengauss02,/opengauss/opengaussdb/data/dn,opengauss03,/opengauss/opengaussdb/data/dn"/>
< PARAM name="dataNode1_syncNum" value="https://www.songbingjia.com/android/0"/>
< /DEVICE>
< DEVICE sn="1000002">
< PARAM name="name" value="https://www.songbingjia.com/android/opengauss02"/>
< PARAM name="azName" value="https://www.songbingjia.com/android/AZ1"/>
< PARAM name="azPriority" value="https://www.songbingjia.com/android/1"/>
< PARAM name="backIp1" value="https://www.songbingjia.com/android/192.168.75.62"/>
< PARAM name="sshIp1" value="https://www.songbingjia.com/android/192.168.75.62"/>
< PARAM name="cmServerPortBase" value="https://www.songbingjia.com/android/15000" />
< PARAM name="cmDir" value="https://www.songbingjia.com/opengauss/opengaussdb/data/cmserver" />
< /DEVICE>
< DEVICE sn="1000003">
< PARAM name="name" value="https://www.songbingjia.com/android/opengauss03"/>
< PARAM name="azName" value="https://www.songbingjia.com/android/AZ1"/>
< PARAM name="azPriority" value="https://www.songbingjia.com/android/1"/>
< PARAM name="backIp1" value="https://www.songbingjia.com/android/192.168.75.63"/>
< PARAM name="sshIp1" value="https://www.songbingjia.com/android/192.168.75.63"/>
< PARAM name="cmServerPortBase" value="https://www.songbingjia.com/android/15000" />
< PARAM name="cmDir" value="https://www.songbingjia.com/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 DATADIRlocation of the database storage area
-l FILENAMEwrite (or append) result to FILENAME
-n NODEIDnode id
-z AVAILABILITY_ZONEavailability zone name
-t SECSseconds to wait
-V, --versionoutput version information, then exit
-?, -h, --helpshow this help, then exit
Options for switchover:
-aauto switchover to rebalance mppdb service
-Aswitch all the datanodes standby instances with their master instances
-ffast switchover
Options for build:
-fforce build
-b fullfull build
-ccm server build
-j [num]parallelism
Options for check:
-B BINNAMEBINNAME can be "cm_agent", "gaussdb" or "cm_server"
-T DATAPATHlocation of the database storage area
Options for stop:
-m MODEMODE can be "smart" "fast" "immediate"
Options for query:
-sshow instances that need to switchover
-Cshow query result by HA relation
-vshow detail query result
-dshow instance datapath
-ishow physical node ip
-Fshow all fenced UDF master process status
-zshow all availability zone status. The value must be "ALL"
-rshow standby DN redo status
-gshow backup and recovery cluster info
-xshow abnormal instances
-Sshow the results of the status check when the cluster was started
--minorityAzcheck the cms status only in the pointed AZ
-pshow the port of datanode
Options for set:
--log_level=LOG_LEVELLOG_LEVEL can be "DEBUG5", "DEBUG1", "LOG", "WARNING", "ERROR" or "FATAL"
--cm_arbitration_mode=ARBITRATION_MODEARBITRATION_MODE can be "MAJORITY", "MINORITY"
--cm_switchover_az_mode= SWITCHOVER_AZ_MODESWITCHOVER_AZ_MODE can be "NON_AUTO", "AUTO"
--cmsPromoteMode=CMS_PROMOTE_MODE -I INSTANCEID CMS_PROMOTE_MODE can be "AUTO", "PRIMARY_F"
--agentset cm agent conf
--serverset cm server conf
--kset parameter and value
Options for get:
--log_levelshow LOG_LEVEL
--cm_arbitration_modeshow cm server arbitration mode
--cm_switchover_az_modeshow az switchover mode
Options for view:
-vshow details of static config
-Nshow local node static config
Options for setrunmode:
--xmodeminority or normal.
--votenumin minority mode,available dn vote number.
Options for changerole:
--roleswitch dcf role to passive or to follower.
Options for changemember:
--roleswitch dcf role to passive or to follower.
--groupchange dcf group id.
--prioritychange dcf election priority.
Options for reload:
reloadreload cluster static config online.
--agentreload cm_agent conf.
--serverreload cm_server conf.
Options for list:
--agentlist the cm_agent parameter.
--serverlist the cm_server parameter.
Options for encrypt:
-Mencrypt mode (server,client), default value is server mode.
-Dappoint encrypt file path.
Options for switch ddb:
--ddb_typeswitch to which ddb type.
--commitafter switch success, need do commit.
--rollbackwhen something wrong, can do rollback.
Shutdown modes are:
smartquit with fast shutdown on primary, and recovery done on standby
fastquit directly, with proper shutdown
immediatequit without complete shutdown; will lead to recovery on restart
Cluster state including:
Normalcluster is available with data replication
Degradedcluster is available without data replication
Unavailablecluster is unavailable
Instance state including:
Primarydatabase system run as a primary server, send xlog to standby server
Standbydatabase system run as a standby server, receive xlog from primary server
Cascade Standbydatabase system run as a cascade standby server, receive xlog from standby server
Pendingdatabase system run as a pending server, wait for promoting to primary or demoting to standby
Downdatabase system not running
Unknowndatabase system not connected
HA state including:
Normaldatabase system is normal
Need repairdatabase system is not connected with primary/standby server or not matched with primary/standby server
Wait promotingdatabase system is waiting to promote during switchover
Promotingdatabase system is promoting
Buildingdatabase system is building
Catchupdatabase system is catching up xlog
Demotingdatabase system is demoting
Startingdatabase system is starting up
Manually stoppeddatabase system is down for being manually stopped
Disk damageddatabase system is down for disk damaged
Port conflictingdatabase system is down for port conflicting
Unknowndatabase system is down for some internal error
Options for dcc cmd:
--help, -hShows help information of dcc cmd.
--version, -vShows version information of dcc.
--get keyQueries the value of a specified key.
--put key valUpdates or insert the value of a specified key.
--delete keyDeletes the specified key.
--prefixPrefix matching --get or --delete.
--cluster_infoshow cluster info.
--leader_infoshow leader nodeid.
测试几个命令用cm查看集群状态
[opengauss@opengauss01:/home/opengauss]$cm_ctl query -Cvdi
[CMServer State]
nodenode_ipinstancestate
------------------------------------------------------------------------------------------
1opengauss01 192.168.75.611/opengauss/opengaussdb/data/cmserver/cm_server Primary
2opengauss02 192.168.75.622/opengauss/opengaussdb/data/cmserver/cm_server Standby
3opengauss03 192.168.75.633/opengauss/opengaussdb/data/cmserver/cm_server Standby
[Cluster State]
cluster_state: Normal
redistributing: No
balanced: Yes
current_az: AZ_ALL
[Datanode State]
nodenode_ipinstancestate| nodenode_ipinstancestate| nodenode_ipinstancestate
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1opengauss01 192.168.75.616001 /opengauss/opengaussdb/data/dn P Primary Normal | 2opengauss02 192.168.75.626002 /opengauss/opengaussdb/data/dn S Standby Normal | 3opengauss03 192.168.75.636003 /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]
nodenode_ipinstancestate
------------------------------------------------------------------------------------------
1opengauss01 192.168.75.611/opengauss/opengaussdb/data/cmserver/cm_server Primary
2opengauss02 192.168.75.622/opengauss/opengaussdb/data/cmserver/cm_server Standby
3opengauss03 192.168.75.633/opengauss/opengaussdb/data/cmserver/cm_server Standby
[Cluster State]
cluster_state: Normal
redistributing: No
balanced: Yes
current_az: AZ_ALL
[Datanode State]
nodenode_ipinstancestate
------------------------------------------------------------------------------------
1opengauss01 192.168.75.616001 /opengauss/opengaussdb/data/dn P Primary Normal
2opengauss02 192.168.75.626002 /opengauss/opengaussdb/data/dn S Standby Normal
3opengauss03 192.168.75.636003 /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]
nodenode_ipinstancestate
------------------------------------------------------------------------------------------
1opengauss01 192.168.75.611/opengauss/opengaussdb/data/cmserver/cm_server Primary
2opengauss02 192.168.75.622/opengauss/opengaussdb/data/cmserver/cm_server Standby
3opengauss03 192.168.75.633/opengauss/opengaussdb/data/cmserver/cm_server Standby
[Cluster State]
cluster_state: Normal
redistributing: No
balanced: No
current_az: AZ_ALL
[Datanode State]
nodenode_ipinstancestate
------------------------------------------------------------------------------------
1opengauss01 192.168.75.616001 /opengauss/opengaussdb/data/dn P Standby Normal
2opengauss02 192.168.75.626002 /opengauss/opengaussdb/data/dn S Standby Normal
3opengauss03 192.168.75.636003 /opengauss/opengaussdb/data/dn S Primary Normal
[opengauss@opengauss01:/home/opengauss]$cm_ctl query -Cvdi
[CMServer State]
nodenode_ipinstancestate
------------------------------------------------------------------------------------------
1opengauss01 192.168.75.611/opengauss/opengaussdb/data/cmserver/cm_server Primary
2opengauss02 192.168.75.622/opengauss/opengaussdb/data/cmserver/cm_server Standby
3opengauss03 192.168.75.633/opengauss/opengaussdb/data/cmserver/cm_server Standby
[Cluster State]
cluster_state: Normal
redistributing: No
balanced: No
current_az: AZ_ALL
[Datanode State]
nodenode_ipinstancestate| nodenode_ipinstancestate| nodenode_ipinstancestate
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1opengauss01 192.168.75.616001 /opengauss/opengaussdb/data/dn P Standby Normal | 2opengauss02 192.168.75.626002 /opengauss/opengaussdb/data/dn S Standby Normal | 3opengauss03 192.168.75.636003 /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]
nodenode_ipinstancestate
------------------------------------------------------------------------------------------
1opengauss01 192.168.75.611/opengauss/opengaussdb/data/cmserver/cm_server Primary
2opengauss02 192.168.75.622/opengauss/opengaussdb/data/cmserver/cm_server Standby
3opengauss03 192.168.75.633/opengauss/opengaussdb/data/cmserver/cm_server Standby
[Cluster State]
cluster_state: Normal
redistributing: No
balanced: Yes
current_az: AZ_ALL
[Datanode State]
nodenode_ipinstancestate
------------------------------------------------------------------------------------
1opengauss01 192.168.75.616001 /opengauss/opengaussdb/data/dn P Primary Normal
2opengauss02 192.168.75.626002 /opengauss/opengaussdb/data/dn S Standby Normal
3opengauss03 192.168.75.636003 /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]
nodenode_ipinstancestate
------------------------------------------------------------------------------------------
1opengauss01 192.168.75.611/opengauss/opengaussdb/data/cmserver/cm_server Primary
2opengauss02 192.168.75.622/opengauss/opengaussdb/data/cmserver/cm_server Standby
3opengauss03 192.168.75.633/opengauss/opengaussdb/data/cmserver/cm_server Standby
[Cluster State]
cluster_state: Normal
redistributing: No
balanced: Yes
current_az: AZ_ALL
[Datanode State]
nodenode_ipinstancestate
------------------------------------------------------------------------------------
1opengauss01 192.168.75.616001 /opengauss/opengaussdb/data/dn P Primary Normal
2opengauss02 192.168.75.626002 /opengauss/opengaussdb/data/dn S Standby Normal
3opengauss03 192.168.75.636003 /opengauss/opengaussdb/data/dn S Standby Normal
[opengauss@opengauss02:/home/opengauss]$gs_om -t status --detail
[CMServer State]
nodenode_ipinstancestate
------------------------------------------------------------------------------------------
1opengauss01 192.168.75.611/opengauss/opengaussdb/data/cmserver/cm_server Down
2opengauss02 192.168.75.622/opengauss/opengaussdb/data/cmserver/cm_server Standby
3opengauss03 192.168.75.633/opengauss/opengaussdb/data/cmserver/cm_server Primary
[Cluster State]
cluster_state: Degraded
redistributing: No
balanced: No
current_az: AZ_ALL
[Datanode State]
nodenode_ipinstancestate
------------------------------------------------------------------------------------
1opengauss01 192.168.75.616001 /opengauss/opengaussdb/data/dn P DownUnknown
2opengauss02 192.168.75.626002 /opengauss/opengaussdb/data/dn S Primary Normal
3opengauss03 192.168.75.636003 /opengauss/opengaussdb/data/dn S Standby Normal
[opengauss@opengauss02:/home/opengauss]$
启动故障节点主机后...
# 本打算启动主机后启动一下故障节点的数据库,发现已经自动启动了,神奇
[opengauss@opengauss02:/home/opengauss]$cm_ctl query -Cvdi
[CMServer State]
nodenode_ipinstancestate
------------------------------------------------------------------------------------------
1opengauss01 192.168.75.611/opengauss/opengaussdb/data/cmserver/cm_server Standby
2opengauss02 192.168.75.622/opengauss/opengaussdb/data/cmserver/cm_server Standby
3opengauss03 192.168.75.633/opengauss/opengaussdb/data/cmserver/cm_server Primary
[Cluster State]
cluster_state: Normal
redistributing: No
balanced: No
current_az: AZ_ALL
[Datanode State]
nodenode_ipinstancestate| nodenode_ipinstancestate| nodenode_ipinstancestate
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1opengauss01 192.168.75.616001 /opengauss/opengaussdb/data/dn P Standby Normal | 2opengauss02 192.168.75.626002 /opengauss/opengaussdb/data/dn S Primary Normal | 3opengauss03 192.168.75.636003 /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]
nodenode_ipinstancestate
------------------------------------------------------------------------------------------
1opengauss01 192.168.75.611/opengauss/opengaussdb/data/cmserver/cm_server Standby
2opengauss02 192.168.75.622/opengauss/opengaussdb/data/cmserver/cm_server Standby
3opengauss03 192.168.75.633/opengauss/opengaussdb/data/cmserver/cm_server Primary
[Cluster State]
cluster_state: Normal
redistributing: No
balanced: No
current_az: AZ_ALL
[Datanode State]
nodenode_ipinstancestate
------------------------------------------------------------------------------------
1opengauss01 192.168.75.616001 /opengauss/opengaussdb/data/dn P Standby Normal
2opengauss02 192.168.75.626002 /opengauss/opengaussdb/data/dn S Primary Normal
3opengauss03 192.168.75.636003 /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]
nodenode_ipinstancestate
------------------------------------------------------------------------------------------
1opengauss01 192.168.75.611/opengauss/opengaussdb/data/cmserver/cm_server Standby
2opengauss02 192.168.75.622/opengauss/opengaussdb/data/cmserver/cm_server Standby
3opengauss03 192.168.75.633/opengauss/opengaussdb/data/cmserver/cm_server Primary
[Cluster State]
cluster_state: Normal
redistributing: No
balanced: Yes
current_az: AZ_ALL
[Datanode State]
nodenode_ipinstancestate
------------------------------------------------------------------------------------
1opengauss01 192.168.75.616001 /opengauss/opengaussdb/data/dn P Primary Normal
2opengauss02 192.168.75.626002 /opengauss/opengaussdb/data/dn S Standby Normal
3opengauss03 192.168.75.636003 /opengauss/opengaussdb/data/dn S Standby Normal
[opengauss@opengauss02:/home/opengauss]$
总结: 暂时还不知道怎么切换CMServer的primary,感觉也没必要切换了,本身就是用来做故障转移的组件。
【openGauss多主机主备集群安装及CM体验】 openGauss3.0可以不依赖于第三方工具实现primary自动切换,高可用方面增强了不少。
推荐阅读
- 使用Rust实现一个Brainfuck解释器
- 数据结构 串
- flutter系列之:移动端的手势基础GestureDetector
- [ C语言练习题 5 ] 矩阵转置(将矩阵的行列互换得到的新矩阵)
- element-ui(el-table合并单元格后的行高亮显示)
- IDEA+Maven使用MyBatis实现CRUD操作
- flutter系列之:Material主题的基础-MaterialApp
- Harbor故障篇(服务启动失败问题处理记录)
- 十个公司九个问之面试考点索引失效()