ITPub博客

首页 > 数据库 > > 替换故障主机-替换主机-换IP

替换故障主机-替换主机-换IP

作者:GaussDB_数据库 时间:2020-01-09 09:02:56 0 删除 编辑

替换主机-换IP的方案相当于集群温备方案,即无需修改新机IP、hostname的情况下,将处于运行状态的主机直接替换为新机。

前提条件

  • 分布式部署模式下替换主机的前提条件:
    • 故障节点不能存在CN实例。
    • 集群中不能存在GTS实例。
    • 集群状态可查,主CM Server状态正常,集群状态不能为Unavailable。
    • 替换前不能锁定集群。
    • 节点替换必须在一个正常主机上执行。
    • 新机器已经准备好。
    • 需保证新物理节点和集群其他节点时间一致。
    • 基于新机器IP的集群配置文件已准备好,与老的集群配置文件相比,仅修改了IP和hostname。
    • 在节点替换(换IP)前,基于新集群配置文件执行前置成功。
    • 在执行过程中不能执行DDL和DML语句。
    • 各节点的系统时间必须同步。
  • 主备部署模式下替换主机的前提条件:
    • 集群状态可查,且主CM Server状态正常。
    • 节点替换必须在一个正常主机上执行。
    • 新机器已经准备好。
    • 需保证新物理节点和集群其他节点时间一致。
    • 集群状态可查,且主CM Server状态正常。
    • 基于新机器IP的集群配置文件已准备好,与老的集群配置文件相比,仅修改了IP和hostname。
    • 在节点替换(换IP)前,基于新集群配置文件执行前置成功。
    • 替换节点期间故障节点上的DN所在的group不能执行DDL和DML操作。
    • 各节点的系统时间必须同步。

注意事项

  • 替换过程中,请勿执行数据增删改等DML操作以及DDL操作,以防数据丢失导致数据不一致。
  • 在前一次替换结束后才能再次执行替换,因此,请不要在一个替换未完成的情况下,交叉执行另外一个替换,或者执行一个新的替换,也不要同时在多个集群主机上执行替换。
  • 执行替换阶段不允许连接数据库执行业务。
  • 进行过主备切换后,如果当前集群状态中balanced字段为false,再继续执行换IP的替换主机操作,集群状态中balanced字段会显示为true,但实际集群DN主备状态并未改变。

操作步骤

  1. 以omm用户身份登录故障节点。

  2. 卸载故障节点上的集群。
    gs_uninstall --delete-data -L

  3. 以omm用户身份登录要使用的新主机。
  1. 检查新主机上的字符集。
    echo $LANG
    en_US.UTF-8

    新主机上的字符集、编码方式等信息,使与其它主机保持一致。

    如果不一致请使用如下方式设置字符集。

    export LANG="en_US.UTF-8"
    在配置文件中将故障主机的配置信息替换成新增主机的配置信息。
  2. vim /opt/software/gaussdb/clusterconfig.xml

    如果进行多节点替换主机(换IP)操作,需要一次性更新XML并进行替换主机操作,不可单独分节点执行。

  3. 以root身份登录集群的任意一台正常主机。
  4. 进入到包路径下,执行如下命令进行替换新主机的前置操作。
    plat1:/opt/software/gaussdb/script # ./gs_preinstall -U omm -G dbgrp  -X /opt/software/gaussdb/clusterconfig.xml
    其中omm为数据库管理员(也是运行集群的操作系统用户),dbgrp为运行集群的操作系统用户的群组名称,/opt/software/gaussdb/clusterconfig.xml为集群配置文件路径。

  5. 切换为运行GaussDB 100的操作系统用户,执行如下命令进行替换主机操作。
    gs_replace -t warm-standby -X /opt/software/gaussdb/clusterconfig.xml
    如果执行过程中出现异常,请根据提示信息排除异常后重新执行该命令。

示例(替换主机-换IP)

  1. 在集群配置文件中将plat2替换为plat11,然后执行如下命令完成前置操作。
    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.
  2. 执行如下命令进行替换主机操作。
    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.
    ..............
    Successfully install GaussDB 100 on warm-standby nodes.
    Config GaussDB 100 on plat11.
    ..............................
    ..............................
    ..............................
    ..............................
    ..............................
    ..............................
    ..............................
    ..............................
    ............................
    Successfully config GaussDB 100 on warm-standby nodes.
    Start GaussDB 100 on plat11.
    ..............................
    ...........................
    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-3161903/ ,如需转载,请注明出处,否则将追究法律责任。

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

注册时间:2020-01-06

  • 博文量
    2907
  • 访问量
    19228