gs_expand
GaussDB 100提供了gs_expand工具来帮助用户在业务发展和数据量变更的情况下,当前的数据服务需要同时满足可用性和一致性,用户可以使用gs_expand工具快速增加或者删除副本节点,及时根据故障情况部署新副本;也可以使用gs_expand工具增加新的DN组,进行统一管理。
前提条件
- 分布式部署模式下,增加新DN组的前提条件
- 旧集群状态正常。
- 集群主机扩容,要求整个集群处于正常状态且没有被锁定,集群配置文件已经生成,配置的信息正确并且和当前集群状态一致。已按照扩容的集群配置文件执行过前置脚本gs_preinstall。
- 新增主机和旧集群之间通信已经建立,网络正常。
- 数据库安装用户有足够的权限将新的配置文件分发到所有主机的相同目录下。
- 新增加的服务器,需保证和原有集群的服务器时间一致。
- 允许在新增服务器上添加实例,但不允许修改旧服务器信息。
- 扩容节点不能包含ETCD、CN、CM、GTS组件。
- 数据库主DN和CN为READ WRITE状态,即可写入。
- 分布式部署模式下,增删备DN的前提条件
- 集群状态可查,主CM Server状态正常,集群状态非Unavailable,集群中的所有CN处于ONLINE状态。
- 增加节点,数据库安装用户有足够的权限将新的配置文件分发到所有服务器的相同目录下。
- 如果有新增服务器,新增服务器和旧集群之间通信已经建立,网络正常。
- 在已有服务器上增加DN,需要提前手动创建DN的数据目录、日志目录、告警目录或可使用gs_preinstall工具完成环境准备,创建DN的数据目录、日志目录,告警目录。
- 在新增服务器上增加DN,需要在配置文件中新增新服务器的DN信息并使用gs_preinstall工具准备好新主机的环境。
- 一次一个DN group仅允许增加或删除一个DN。
- 删除DN,不允许删除primary DN。
- 新增加的服务器,需保证和原有集群的服务器时间一致。
- 数据库主DN和CN为READ WRITE状态,即可写入。
- 分布式部署模式下,standby降为passive,passive升级standby的前提条件
- 集群状态可查,主CM Server状态正常,集群状态非Unavailable。
- 一次一个DN group仅允许更新一个DN角色。
- passive升级为standby,passive DN必须为ONLINE。
- standby降为passive,必须保证更改角色后该组DN满足paxos的多数派协议。
- 指定要更新的DN角色,必须和当前角色不一致。
- 指定的DN不能是primary DN,只能是standby或者passive DN。
- 该操作仅支持使用ZPaxos内核的数据库集群,不支持使用HA内核的数据库集群。
- 主备部署模式下,增加新DN组的前提条件
- 集群状态可查,且主CM Server状态正常。
- 已按照扩容的集群配置文件执行过前置脚本gs_preinstall。
- 新增服务器和旧集群之间通信已经建立,网络正常。
- 数据库安装用户有足够的权限将新的配置文件分发到所有服务器的相同目录下。
- 新增加的服务器和原有集群的服务器时间一致。
- 允许在新增服务器上添加实例,旧服务器信息不允许修改。
- 扩容服务器不能包含ETCD、CN、CM、GTS组件。
- 主备部署模式下,增加备DN的前提条件
- 集群状态可查,且主CM Server状态正常。
- 要增加DN的DN组中,全部DN状态正常。
- 数据库安装用户有足够的权限将新的配置文件分发到所有服务器的相同目录下。
- 如果有新增服务器,新增服务器和旧集群之间通信已经建立,网络正常。
- 如果有新增服务器,需保证和原有集群的节点时间一致。
- 在已有服务器上增加DN,需要提前手动创建DN的数据目录、日志目录、告警目录或可使用gs_preinstall工具完成环境准备,创建DN的数据目录、日志目录,告警目录。
- 在新增服务器上增加DN,需要在配置文件中新增新服务器的DN信息并使用gs_preinstall工具准备好新主机的环境。
- 每组DN每次仅允许增加一个DN。
- 主备部署模式下,删除备DN的前提条件
- 集群状态可查,且主CM Server状态正常。
- 要删除DN的DN组,需保证DN主状态正常,且满足paxos的多数派协议。
- 要删除DN的DN组,需保证删除DN之后,该组DN仍然满足paxos的多数派协议。
- 删除DN,不允许删除primary DN。
- 每组DN每次仅允许删除一个DN。
- 主备部署模式下,角色变更(standby降为passive,passive升级standby)的前提条件
- 仅支持DN类型为"DN_ZENITH_ZPAXOS"版本的数据库切换角色。
- 集群状态可查,且主CM Server状态正常。
- 执行角色变更的DN所在的group,需保证变更角前满足paxos的多数派协议。
- 执行角色变更的DN所在的group,需保证变更角后仍然满足paxos的多数派协议。
- 指定要更新的DN角色必须和当前角色不一致。
- 指定的DN不能是primary DN,只能是standby或者passive DN。
- passive升级为standby,passive DN必须为ONLINE。
- 每组DN每次仅允许变更一个DN的角色。
注意事项
- 新增服务器的软硬件配置和旧集群一致。CPU的超线程设置需与旧集群保持一致。
- 新增服务器的locale、encoding等需要和旧服务器上保持一致。
- 新的服务器上已经做了路径和用户组规划。
- 在前一次扩容结束后才能再次扩容。例如,扩容过程中由于断电等原因导致扩容未完成时,不允许再次进行扩容。需要先修复结束前一次扩容。
- 在前一次增删节点结束后才能再次执行。例如,增删节点由于断电等原因导致增删节点未完成时,不允许再次进行增删节点,需要先修复结束前一次增删节点。
- 执行增删节点,或者DN由standby降为passive、passive升级standby时,不能执行卸载、集群启停、主备切换、升级操作。
- 执行扩容时,不能执行卸载、集群启停、主备切换、升级操作。
语法
- 集群扩容
gs_expand -t dilatation -X XMLFILE [-l LOGFILE]
说明:
- 如果扩容在启动新集群失败时,此时扩容已经完成,返回用户扩容成功。用户需根据日志信息排查启动失败原因,然后手动启动集群,等待集群状态变为Normal后再进行其它业务操作。
- 扩容过程中已添加自动回滚,若扩容失败后自动回滚未执行,下次执行扩容前会检测上次扩容状态并自行回滚然后再扩容,若失败后不再执行扩容,请使用扩容回滚命令恢复环境。
- 进行过主备切换后,如果当前集群状态中balanced字段为false,再继续执行扩容,集群状态中balanced字段会显示为true,但实际集群DN主备状态并未改变。
- 回滚
gs_expand -t crashclean -X XMLFILE [-l LOGFILE]
- 管理DN节点
gs_expand -t managedn -m MODE [-X CONFIGFILE] [--role=ROLE] [-i INSTANCENAME] [-l LOGFILE]
说明:
- 如果增删节点在启动新集群失败时,此时增删节点已经完成,不再回滚。用户需根据日志信息排查启动失败原因,然后手动启动集群,等待集群状态变为Normal后再进行其它业务操作。
- 增删节点过程中已添加自动回滚,若增删节点失败后自动回滚未执行,下次执行增删节点前会检测上次增删节点状态并自行回滚然后再执行增删节点。若删除节点,清理实例信息,实例目录失败,则需要用户手动排查原因,清理删除DN信息。
- 增加节点会检测新增DN的数据目录是否为空,不为空报错回滚,不会清理数据目录,用户需要手动排查备份可用数据,清空数据目录。
- 显示帮助信息
gs_expand -? | --help
- 显示版本信息
gs_expand -V | --version
参数说明
gs_expand参数可以分为如下几类:
- 通用参数:
- -t
gs_expand命令参数类型。
取值范围:managedn,dilatation,crashclean。
- -X增加节点配置文件路径。
说明:
如果需要修改xml文件名称时,需要将修改后的xml文件分发到集群的其他主机上,且保证xml文件权限和修改名称前相同。
取值范围:clusterconfig.xml的文件路径。
- -m
指定所要进行的操作。
取值范围:
add:增加集群DN。
delete:删除集群DN。
update: 更新standby DN或者passive DN的角色。
- --role
增加的DN实例的角色。
更新的DN实例的角色。
取值范围:standby,passive。
- -i
删除的DN实例名。多个DN实例名以逗号分隔。
更新的DN实例名。多个DN实例名以逗号分隔。
- -l
指定日志文件及存放路径。
默认值:$GAUSSLOG/om/gs_expand-YYYY-MM-DD_hhmmss.log
- -?,--help
显示帮助信息。
- -V,--version
显示版本号信息。
- -t
示例
- 增加standby DN。
- 增加standby DN前需要先执行前置脚本,准备环境。以配置文件“clusterconfig_managedn.xml”为例。
plat1:/opt/software/gaussdb/script #./gs_preinstall -U omm -G dbgrp -X /opt/software/gaussdb/clusterconfig_managedn.xml --alarm-type=1 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. 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. 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 the root permission user. Distributing package. Successfully distributed package. Are you sure you want to create the user[perfadm] and create trust for it (yes/no)? yes Installing the tools in the cluster. Successfully installed the tools in the cluster. Checking hostname mapping. Successfully checked hostname mapping. Creating SSH trust for [perfadm] user. Please enter password for current user[perfadm]. 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. 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 [perfadm] 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. Warning: Installation environment contains some warning messages. Please get more details by "/opt/software/gaussdb/script/gs_checkos -i A -h plat1,plat2,plat3". 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. Preinstallation succeeded.
- 执行增加standby DN。
omm@plat1:~> gs_expand -t managedn -m add --role=standby -X /opt/software/gaussdb/clusterconfig_managedn.xml Check cluster info. Check cluster info successfully. Compare config file. Compare config file successfully. Check cluster status. Cluster is OK. Backing up cluster configuration. Successfully backed up cluster configuration. Add Paxos Members in primary dn. Successfully add Paxos Members in primary dn. Install new instances. Install new instances successfully. Config standby DN of new instances. ..................74s Config standby DN of new instances successfully. Update zhba.conf. Successfully update zhba.conf. Update zpaxos datanode peer parameters. Successfully update zpaxos datanode peer parameters. Begin close cm update node info. Successfully close cm update node info. Update node info for the cluster. Successfully update node info for the cluster. Reload new json to etcd. Reload new json successfully. Begin open cm update node info. Successfully open cm update node info. Starting cluster. Successfully starting the cluster. Manage dn is completed
- 执行删除DB1_2、DB2_5。
omm@plat1:~> gs_expand -t managedn -m delete -i DB1_2,DB2_5 Check cluster info. Check cluster status. Cluster is OK. Backing up cluster configuration. Successfully backed up cluster configuration. Delete Paxos Members in primary dn. Successfully delete Paxos Members in primary dn. Update zpaxos datanode peer parameters. Successfully update zpaxos datanode peer parameters. Begin close cm update node info. Successfully close cm update node info. Update node info for the cluster. Successfully update node info for the cluster. Begin open cm update node info. Successfully open cm update node info. Reload new json to etcd. Reload new json successfully. Clean the deleted dn instances. Successfully clean the deleted dn instances. Manage dn is completed
- 更新实例角色。
- DN备降为passive,以DB1_2为例:
omm@plat1:~> gs_expand -t managedn -m update -i DB1_2 --role=passive Check cluster info. Check cluster status. Check cluster conditions for updating datanode role. Successfully check cluster conditions for updating datanode role. Cluster is OK. Backing up cluster configuration. Successfully backed up cluster configuration. Update datanode member to passive role. Successfully update datanode member to passive role. Update zpaxos datanode peer parameters. Successfully update zpaxos datanode peer parameters. Reload new json to etcd. Reload new json successfully. Manage dn is completed
- passive升级为DN备,以DB1_2为例:
omm@plat1:~> gs_expand -t managedn -m update -i DB1_2 --role=standby Check cluster info. Check cluster status. Check cluster conditions for updating datanode role. Successfully check cluster conditions for updating datanode role. Cluster is OK. Backing up cluster configuration. Successfully backed up cluster configuration. Update datanode member to standby role. Successfully update datanode member to standby role. Update zpaxos datanode peer parameters. Successfully update zpaxos datanode peer parameters. Reload new json to etcd. Reload new json successfully. Manage dn is completed
- 执行扩容。
- 执行扩容前需要先执行前置脚本,准备环境。以配置文件“ClusterConfig_diatation.xml”为例。
plat1:/opt/software/gaussdb/script #./gs_preinstall -U omm -G dbgrp -X /opt/software/gaussdb/ClusterConfig_diatation.xml --alarm-type=1 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. 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. 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 the root permission user. Distributing package. Successfully distributed package. Are you sure you want to create the user[perfadm] and create trust for it (yes/no)? yes Installing the tools in the cluster. Successfully installed the tools in the cluster. Checking hostname mapping. Successfully checked hostname mapping. Creating SSH trust for [perfadm] user. Please enter password for current user[perfadm]. 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. 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 [perfadm] 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. Warning: Installation environment contains some warning messages. Please get more details by "/opt/software/gaussdb/script/gs_checkos -i A -h plat1,plat2,plat3". 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. Preinstallation succeeded.
- 执行扩容:
omm@plat1:~> gs_expand -t dilatation -X /opt/software/gaussdb/ClusterConfig_diatation.xml Check cluster info. Check cluster info successfully. Distribute old cluster configure file. Distribute old cluster configure file successfully. Check cluster status. Cluster is OK. Install new instances. Install new instances successfully. Distribute ETCD keys to new host. Distribute ETCD keys to new host successfully. Initialize new instances. ....................74s Initialize new instances successfully. Build standby database. Config standby DN of new instances. .................46s Config standby DN of new instances successfully. Build standby database successfully. Config applications. Config applications successfully. Begin close cm update node info. Successfully close cm update node info. Update node info for the cluster. Successfully update node info for the cluster. Update zhba.conf. Successfully update zhba.conf. Reload new json to etcd. Reload new json successfully. Begin open cm update node info. Successfully open cm update node info. Starting cluster. Successfully starting the cluster. Starting cluster successfully.
- 执行扩容:
「喜欢文章,快来给作者赞赏墨值吧」【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。评论
- passive升级为DN备,以DB1_2为例:
- DN备降为passive,以DB1_2为例:
- 执行增加standby DN。
- 增加standby DN前需要先执行前置脚本,准备环境。以配置文件“clusterconfig_managedn.xml”为例。