首页 > 数据库 > > 数据库管理工具-gs_replace
数据库集群是由多台服务器组成的,当集群中某些服务器故障或者服务器上的某些实例发生故障后,为了使GaussDB 100快速地恢复正常,用户可以使用gs_replace工具将发生故障的服务器替换为正常服务器,将发生故障的实例替换为正常实例。
其中替换服务器根据使用场景不同,可分为如下两种:
“不换IP”和“换IP”是从集群配置角度的差异,“不换IP”指不修改集群配置文件的IP和hostname信息,“换IP”是指需要修改集群配置文件的IP和hostname信息。
替换主机-换IP的方案相当于集群温备方案,即无需修改新机IP、hostname的情况下,将处于运行态的服务器直接替换为新服务器。
gs_replace -t install -h HOSTNAME [-l LOGFILE]配置实例、服务器
gs_replace -t config -h HOSTNAME [-l LOGFILE]启动新增服务器
gs_replace -t start -h HOSTNAME [-l LOGFILE]替换服务器(换IP)
gs_replace -t warm-standby -X XMLFILE [-l LOGFILE]显示帮助信息
gs_replace { -? | --help }显示版本号信息
gs_replace { -V | --version }参数说明
gs_replace参数可以分为如下几类:
om命令的类型。
取值范围:warm-standby、install、config和start.

进行过主备切换后,如果当前集群状态中balanced字段为false,再继续执行warm-standby,集群状态中balanced字段会显示为true,但实际集群DN主备状态并未改变。
指定日志文件及存放路径。
默认值:$GAUSSLOG/om/gs_replace.log
-h
指定新增服务器或新增实例所在服务器的名称。可以指定多个服务器名称,以逗号分隔。
取值范围:服务器名称。
-h
指定替换服务器或替换实例所在服务器的名称。可以指定多个服务器名称,以逗号分隔。
取值范围:服务器名称。
-h
指定需要启动服务器或实例所在服务器的名称。可以指定多个服务器名称,以逗号分隔。
取值范围:服务器名称。
集群配置文件路径。
取值范围:clusterconfig.xml的路径。
指定日志文件及存放路径。
在内部会自动给日志名添加一个时间戳。
显示帮助信息。
显示版本号信息。
omm@plat1:/opt/software/gaussdb/script> gs_replace -t config -h plat1
Check cluster status for replace.
Check the status of ETCD cluster.
Successfully check the status of ETCD cluster.
Successfully check cluster status.
Filter out all valid hosts for replacing.
Distributing configuration to remote host.
Successfully distributed configuration to remote host.
Configuring
Stopping replace instances.
Successfully stopped replace instances.
Configuring replacement instances.
Config replace instances.
Successfully config replace instances.
Config standby DN of new instances.
.......67s
Config standby DN of new instances successfully.
Successfully configured replacement instances.
Configuration succeeded.
==============================
Time statistics:
Config replacement nodes: 95s
total: 95somm@plat1:/opt/software/gaussdb/script> gs_replace -t start -h plat1
Starting.
==============================
..2s
Start cm agent on new nodes.
Successfully start cm agent for new nodes.
Starting the cluster.
.1s
Successfully started instance process. Waiting to become Normal.
==============================
Successfully started cluster.
==============================
Time statistics:
Start replacement nodes: 27s
total: 27s
omm@plat4:/opt/software/gaussdb/script> gs_uninstall --delete-data -L
Check preinstall on every node.
Successfully checked preinstall on every node.
Stop cluster.
Check logfile path.
Clean crontab.
Clean crontab successfully.
Kill process for components.
Kill process for components successfully.
Uninstall components
Uninstall components successfully.
Modifying user's environmental variable.
Successfully modified user's environmental variable.
Clean tmp files and logs.
Successfully clean cluster's tmp and logs.
Successful uninstallation
plat1:/opt/software/gaussdb/script # ./gs_preinstall -U omm -G dbgrp -X /opt/software/gaussdb/clusterconfig.xml
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:
Creating SSH trust for the root permission user.
Successfully created SSH trust for the root permission user.
Pass over configuring LVM
Distributing package.
Successfully distributed package.
Are you sure you want to create the user[omm] and create trust for it (yes/no)? yes
Please enter password for cluster user.
Password:
Please enter password for cluster user again.
Password:
Creating [omm] user on all nodes.
Successfully created [omm] user on all nodes.
Installing the tools in the cluster.
Successfully installed the tools in the cluster.
Checking hostname mapping.
Successfully checked hostname mapping.
Creating SSH trust for [omm] user.
Start creating SSH trust for [omm] user.
Successfully created SSH trust for [omm] user.
Checking OS version.
Successfully checked OS version.
Creating cluster's path.
Successfully created cluster's path.
Setting SCTP service.
Successfully set SCTP service.
Set and check OS parameter.
Setting OS parameters.
Successfully set OS parameters.
Set and check OS parameter completed.
Preparing CRON service.
Successfully prepared CRON service.
Preparing SSH service.
Successfully prepared SSH service.
Setting user environmental variables.
Successfully set user environmental variables.
Configuring alarms on the cluster nodes.
Successfully configured alarms on the cluster nodes.
Setting the dynamic link library.
Successfully set the dynamic link library.
Fixing server package owner.
Successfully fixed server package owner.
Create logrotate service.
Successfully create logrotate service.
Setting finish flag.
Successfully set finish flag.
Clean SSH trust for the root permission user.
Successfully cleaned SSH trust for the root permission user.
Preinstallation succeeded.
omm@plat1:/opt/software/gaussdb/script> gs_replace -t install -h plat3
Distributing configuration to remote host.
Successfully distributed configuration to remote host.
Installing.
Checking installation environment on nodes.
Successfully checking installation environment on nodes.
Installing applications on nodes.
Installation is completed.
==============================
Time statistics:
Install replacement nodes: 9s
total: 9somm@plat1:/opt/software/gaussdb/script> gs_replace -t config -h plat3
Check cluster status for replace.
Check the status of ETCD cluster.
Successfully check the status of ETCD cluster.
Successfully check cluster status.
Filter out all valid hosts for replacing.
Distributing configuration to remote host.
Successfully distributed configuration to remote host.
Configuring
Stopping replace instances.
Successfully stopped replace instances.
Configuring replacement instances.
Config replace instances.
Successfully config replace instances.
Config standby DN of new instances.
.......67s
Config standby DN of new instances successfully.
Successfully configured replacement instances.
Configuration succeeded.
==============================
Time statistics:
Config replacement nodes: 95s
total: 95s
omm@plat1:/opt/software/gaussdb/script> gs_replace -t start -h plat3
Starting.
==============================
..2s
Start cm agent on new nodes.
Successfully start cm agent for new nodes.
Starting the cluster.
......6s
Successfully started instance process. Waiting to become Normal.
==============================
Successfully started cluster.
==============================
Time statistics:
Start replacement nodes: 35s
total: 35s
omm@plat4:/opt/software/gaussdb/script> gs_uninstall --delete-data -L
Check preinstall on every node.
Successfully checked preinstall on every node.
Stop cluster.
Check logfile path.
Clean crontab.
Clean crontab successfully.
Kill process for components.
Kill process for components successfully.
Uninstall components
Uninstall components successfully.
Modifying user's environmental variable.
Successfully modified user's environmental variable.
Clean tmp files and logs.
Successfully clean cluster's tmp and logs.
Successful uninstallation
plat1:/opt/software/gaussdb/script # ./gs_preinstall -U omm -G dbgrp -X /opt/software/gaussdb/clusterconfig.xml
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:
Creating SSH trust for the root permission user.
Successfully created SSH trust for the root permission user.
Pass over configuring LVM
Distributing package.
Successfully distributed package.
Are you sure you want to create the user[omm] and create trust for it (yes/no)? yes
Please enter password for cluster user.
Password:
Please enter password for cluster user again.
Password:
Creating [omm] user on all nodes.
Successfully created [omm] user on all nodes.
Installing the tools in the cluster.
Successfully installed the tools in the cluster.
Checking hostname mapping.
Successfully checked hostname mapping.
Creating SSH trust for [omm] user.
Start creating SSH trust for [omm] user.
Successfully created SSH trust for [omm] user.
Checking OS version.
Successfully checked OS version.
Creating cluster's path.
Successfully created cluster's path.
Setting SCTP service.
Successfully set SCTP service.
Set and check OS parameter.
Setting OS parameters.
Successfully set OS parameters.
Set and check OS parameter completed.
Preparing CRON service.
Successfully prepared CRON service.
Preparing SSH service.
Successfully prepared SSH service.
Setting user environmental variables.
Successfully set user environmental variables.
Configuring alarms on the cluster nodes.
Successfully configured alarms on the cluster nodes.
Setting the dynamic link library.
Successfully set the dynamic link library.
Fixing server package owner.
Successfully fixed server package owner.
Create logrotate service.
Successfully create logrotate service.
Setting finish flag.
Successfully set finish flag.
Clean SSH trust for the root permission user.
Successfully cleaned SSH trust for the root permission user.
Preinstallation succeeded.
omm@plat1:/opt/software/gaussdb/script> gs_replace -t warm-standby -X /opt/software/gaussdb/clusterconfig.xml
Checking the cluster configuration differences.
Successfully checked the cluster configuration differences.
Check cluster status for replace.
Check the status of ETCD cluster.
Successfully check the status of ETCD cluster.
Successfully check cluster status.
Checking replace condition.
Successfully checked replace condition.
Check Preinstall Flag.
Creating the backup directory.
Successfully created backup directory.
Changing replace IP.
Changing instance configuration files.
Successfully changed instance configuration files.
Updating cluster database node info.
Successfully update cluster database node info.
Successfully changed replacement IP addresses.
Install GaussDB 100 on plat11.
..............14s
Successfully install GaussDB 100 on warm-standby nodes.
Config GaussDB 100 on plat11.
..................167s
Successfully config GaussDB 100 on warm-standby nodes.
Start GaussDB 100 on plat11.
...........54s
Successfully started warm-standby nodes.
Warm standby is completed.
==============================
Time statistics:
Update cluster configuration file.: 381s
total: 381s
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69959250/viewspace-3120813/ ,如需转载,请注明出处,否则将追究法律责任。