ITPub博客

首页 > 数据库 > > 数据库管理工具-gs_expand

数据库管理工具-gs_expand

作者:GaussDB_数据库 时间:2020-01-09 18:14:32 0 删除 编辑

GaussDB 100提供了gs_expand工具来帮助用户在业务发展和数据量变更的情况下,增加副本节点、CN节点或DN组,以满足业务需求。

前提条件

  • 集群状态正常(Normal或者Degraded),无异常状态的实例。
  • 集群没有被锁定。
  • 集群配置文件已经生成,并且已按照扩容的集群配置文件执行过前置脚本gs_preinstall。
  • 分布式部署模式下,数据库主DN和CN为READ WRITE状态,即可写入。
  • 需保证新增加的服务器和原有集群的服务器时间一致。
  • 集群用户互信正常。

约束条件

  • 允许在新增服务器和原有服务器上添加新实例,但不允许修改旧服务器原有信息。
  • 仅允许新增DN和CN实例。
  • 主备部署模式下,不允许添加新CN。
  • 扩容过程中,只允许进行DML操作,不允许进行DDL操作。
  • 扩容使用的配置文件不允许更改原配置文件中nodeNames字段取值中主机名的顺序,并且新增节点的主机名需位于原有节点主机名的最后面。
  • 扩容增加的新CN和新DN group中,只存在EXP工具支持导出的元数据。EXP工具支持导出的元数据类型请参考“《开发者指南(分布式)》 > 语法参考 > 功能语法 > EXP”。
  • 在主DN上单独创建过表的集群上,不支持扩容CN。

注意事项

  • 新增服务器的软硬件配置和旧集群一致。CPU的超线程设置需与旧集群保持一致。
  • 新增服务器的locale、encoding等需要和旧服务器上保持一致。
  • 新的服务器上已经做了路径和用户组规划。
  • 在前一次扩容结束后才能再次扩容。例如,扩容过程中由于断电等原因导致扩容未完成时,不允许再次进行扩容。需要先修复结束前一次扩容。
  • 执行扩容时,不能执行卸载、集群启停、主备切换、升级操作。

语法

  • 检测非标准路径的表空间
    gs_expand -t check_tablespace -I INSTANCENAME [-o OUPUTFILE] [-l LOGFILE]
    集群扩容
  • gs_expand -X XMLFILE [--meta-cn=INSTANCENAME] [--meta-dn=INSTANCENAME] [--tablespace-map-file=MAPFILE] [--rollback|--role=passive] [-l LOGFILE]

    • 如果扩容在启动新集群失败时,此时扩容已经完成,返回用户扩容成功。用户需根据日志信息排查启动失败原因,然后手动启动集群,等待集群状态变为Normal后再进行其它业务操作。
    • 扩容过程中已添加自动回滚,若扩容失败后自动回滚未执行,下次执行扩容前会检测上次扩容状态并自行回滚然后再扩容,若失败后不再执行扩容,请使用扩容回滚命令恢复环境。
    • 进行过主备切换后,如果当前集群状态中balanced字段为false,再继续执行扩容,集群状态中balanced字段会显示为true,但实际集群DN主备状态并未改变
  • 显示帮助信息
    gs_expand { -? | --help }
    显示版本信息
  • gs_expand { -V | --version }
    参数说明

gs_expand参数可以分为如下几类:

  • 通用参数
    • -l

      指定日志文件及存放路径。

      默认值:$GAUSSLOG/om/gs_expand.log

    • -?,--help

      显示帮助信息。

    • -V,--version

      显示版本号信息。

  • 检测表空间参数
    • -t

      执行的命令为检测表空间

    • -I

      检测表空间元数据的实例

    • -o

      非标准表空间的datafile输出文件,默认为 $GAUSSTMP/absolute_tablespace.lst

  • 扩容参数:
    • -X
      增加节点配置文件路径。

      如果需要修改xml文件名称时,需要将修改后的xml文件分发到集群的其他主机上,且保证xml文件权限和修改名称前相同。

      取值范围:clusterconfig.xml的文件路径。

    • --meta-cn

      指定导出CN元数据的CN实例

    • --meta-dn

      指定导出DN元数据的DN实例

    • --tablespace-map-file

      替换绝对路径的表空间元数据时,指定替换规则的文件

      • 文件内容需符合 JSON 文件格式,且最高层级内容为字典类型
      • Key 值为新增实例的 "hostname:datadir"
      • Value 为表空间替换拓扑列表,Value 的每一项为一个替换项,数据类型为列表。每个替换项,第一个值为原实例(即导出元数据的实例)中的非标准路径下的表空间路径,第二个值为新实例中对应的表空间路径
    • --rollback

      回滚上一次执行失败的扩容。

示例

  • 执行扩容(增加新CN、新DN组、原DN组的新DN及新节点)。
    1. 检测指定CN实例的表空间的元数据
      omm@plat1:~> gs_expand -t check_tablespace -I cn_401 
      Check tablespace data files.
      Get instance named cn_401.
      Successfully got instance.
      Export metadata from cn_401.
      Successfully export metadata.
      Get the standard paths of tablespace.
      Successfully got the non-standard tablespace paths.
      Write the non-standard paths into output file.
      Successfully wrote the non-standard paths.
      Successfully check tablespace data files.
      The non-standard path tablespace are:
      /opt/huawei/gaussdb_tbs/yy_test001cn
      /opt/huawei/gaussdb_tbs/zz_test001cn
    2. 检测指定DN实例的表空间的元数据
      omm@plat1:~> gs_expand -t check_tablespace -I DB1_1 
      Check tablespace data files.
      Get instance named DB1_1.
      Successfully got instance.
      Export metadata from DB1_1.
      Successfully export metadata.
      Get the standard paths of tablespace.
      Successfully got the non-standard tablespace paths.
      Write the non-standard paths into output file.
      Successfully wrote the non-standard paths.
      Successfully check tablespace data files.
      The non-standard path tablespace are:
      /opt/huawei/gaussdb_tbs/bb_test001dn
      /opt/huawei/gaussdb_tbs/cc_test001dn


    3. 创建表空间替换文件
      {
      "plat4:/opt/huawei/gaussdb/sdc/data/data_dn4": [
      [
      "/opt/huawei/gaussdb_tbs/bb_test001dn",
      "/opt/huawei/gaussdb_tbs/test/bb_test001dn"
      ],
      [
      "/opt/huawei/gaussdb_tbs/cc_test001dn",
      "/opt/huawei/gaussdb_tbs/test/cc_test001dn"
      ]
      ],
      "plat4:/opt/huawei/gaussdb/sdc/data/data_cn": [
      [
      "/opt/huawei/gaussdb_tbs/yy_test001cn",
      "/opt/huawei/gaussdb_tbs/test/yy_test001cn"
      ],
      [
      "/opt/huawei/gaussdb_tbs/zz_test001cn",
      "/opt/huawei/gaussdb_tbs/test/zz_test001cn"
      ]
      ]
      }
    4. 执行扩容前需要先执行前置脚本,准备环境。以配置文件“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.
    5. 执行扩容(无非标准路径表空间)。
      omm@plat1:~> gs_expand -X /opt/software/gaussdb/ClusterConfig_diatation.xml
      Check ssh trust.
      Successfully check ssh trust.
      Check time consistency.
      Successfully check time consistency.
      Get cluster status.
      Successfully get cluster status.
      Check cluster open status.
      Successfully check cluster open status.
      Compare config file.
      Compare config file successfully.
      Get new instances.
      Successfully get new instances.
      Backing up cluster configuration.
      Successfully backed up cluster configuration.
      Distribute ETCD keys to new host.
      Distribute ETCD keys to new host successfully.
      Close the CM heartbeat about CN.
      Install new hosts.
      Install new hosts successfully.
      Initialize new instances.
      ...........71s
      Initialize new instances successfully.
      Build standby database.
      Config standby DN of new instances.
      ..............74s
      Config standby DN of new instances successfully.
      Build standby database successfully.
      Config applications.
      Config applications successfully.
      .Export metadata from original instance.
      Successfully export metadata from original instance.
      Import metadata into new instances.
      Successfully import metadata into new instances.
      Update zhba.conf.
      Successfully update zhba.conf.
      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.
      Starting cluster successfully.
      Open the CM heartbeat about CN.
      Expand is completed.
    6. 执行扩容(有非标准表空间):
      omm@plat1:~> gs_expand -X /opt/software/gaussdb/ClusterConfig_diatation.xml --meta-dn=DB1_1 --meta-cn=cn_401 --tablespace-map-file=/home/omm/replace_tbs.json
      Check ssh trust.
      Successfully check ssh trust.
      Check time consistency.
      Successfully check time consistency.
      Get cluster status.
      Successfully get cluster status.
      Check cluster open status.
      Successfully check cluster open status.
      Compare config file.
      Compare config file successfully.
      Get new instances.
      Successfully get new instances.
      Export metadata from cn_401.
      Successfully export metadata.
      Check tablespace map info about cn_401.
      Successfully checked tablespace map info about cn_401.
      Export metadata from DB1_1.
      Successfully export metadata.
      Check tablespace map info about DB1_1.
      Successfully checked tablespace map info about DB1_1.
      Distribute tablespace map file to remote hosts.
      Check the replace paths of tablespace on remote nodes.
      Backing up cluster configuration.
      Successfully backed up cluster configuration.
      Distribute ETCD keys to new host.
      Distribute ETCD keys to new host successfully.
      Close the CM heartbeat about CN.
      Install new hosts.
      Install new hosts successfully.
      Initialize new instances.
      ..........70s
      Initialize new instances successfully.
      Build standby database.
      Config standby DN of new instances.
      ...123s
      Config standby DN of new instances successfully.
      Build standby database successfully.
      Config applications.
      Config applications successfully.
      Import metadata into new instances.
      Successfully import metadata into new instances.
      Update zhba.conf.
      Successfully update zhba.conf.
      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.
      Starting cluster successfully.
      Open the CM heartbeat about CN.
      Expand is completed.

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69959250/viewspace-3135346/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2020-01-06

  • 博文量
    2907
  • 访问量
    19202