本文内容来自YashanDB官网,原文内容请见 https://doc.yashandb.com/yashandb/23.3/zh/%E5%AE%89%E8%A3%85%...

本文主要介绍当一个单机部署的数据库集群中,一台或多台服务器的IP发生变更时,管理员如何通过yasboot ipchange命令进行数据库层面的IP更换操作,最终使得数据库恢复可用。

下述操作将以一主两备环境中的两台服务器IP发生变更为例进行描述:

服务器名称旧IP角色新IP
服务器1192.168.1.2192.168.1.5
服务器2192.168.1.3192.168.1.6
服务器3192.168.1.4192.168.1.4

IP更换执行的顺序为yasom > yasagent > host,若无需更新某个工具/服务器的IP可跳过,继续更新下一个工具/服务器的IP,但不能乱序操作。

前提条件


执行下述操作前,请确保新IP的环境仍满足YashanDB的各项部署要求,具体见安装前准备

步骤1:进入YashanDB产品安装目录


重部署需要在安装YashanDB时的安装目录下进行,以yashan用户登录服务器并进入install目录:

$ cd /home/yashan/install

Copied!

步骤2:更换yasom IP


  1. 查看主yasom进程所在服务器信息。

查看安装目录下的hosts.toml文件中的如下内容可以获取主yasom进程所在服务器的相关信息:

[om]
  hostid = "host0001"
  [om.config]
    LISTEN_ADDR = "192.168.1.2:1675"

Copied!

根据上述信息,yasom部署于hostid为host0001的服务器上,该服务器的IP为192.168.1.2,需要更换。

  1. 更换主yasom进程的IP。
$ cd /home/yashan/install
$ yasboot ipchange yasom -t hosts.toml -n 192.168.1.5

Copied!

更换完成后,yasom可以正常提供服务。

步骤3:更换yasagent IP


  1. 查看yasagent服务所在服务器信息。

查看安装目录下的hosts.toml文件中的如下内容可以获取yasagent服务所在服务器的相关信息:

[[host]]
  hostid = "host0001"
[host.yasagent]
    [host.yasagent.config]
      LISTEN_ADDR = "192.168.1.2:1676"

[[host]]
  hostid = "host0002"
[host.yasagent]
    [host.yasagent.config]
      LISTEN_ADDR = "192.168.1.3:1676"

[[host]]
  hostid = "host0003"
[host.yasagent]
    [host.yasagent.config]
      LISTEN_ADDR = "192.168.1.4:1676"

Copied!

根据上述信息,hostid为host0001和host0002的服务器上的yasagent使用了旧IP(192.168.1.2和192.168.1.3),需要更换。hostid为host0003服务器上的yasagent无需更换IP,可以正常提供服务。

  1. 执行如下命令,依次更换host0001和host0002服务器上的yasagent的IP。

$ yasboot ipchange yasagent -t hosts.toml -n 192.168.1.5 --host-id host0001


$ yasboot ipchange yasagent -t hosts.toml -n 192.168.1.6 --host-id host0002

Copied!

更换完成后,所有yasagent可以正常提供服务。

步骤4:更换yasdb IP


更换yasdb IP包括对yasdb进程的数据库监听地址和主备复制链路地址的更换,yasdb进程所在的服务器信息与上述yasagent服务所在服务器信息一致。

Note:

更换yasdb IP时,所有yasdb进程将被停止,数据库服务关闭。


$ yasboot ipchange host -t hosts.toml -l 192.168.1.5 -r 192.168.1.5 --host-id host0001


$ yasboot ipchange host -t hosts.toml -l 192.168.1.6 -r 192.168.1.6 --host-id host0002

Copied!

步骤5:启动数据库


执行如下命令启动数据库服务:

$ yasboot cluster start -c yashandb

Copied!

步骤6:检查IP更换结果


执行如下命令查询数据库集群的各项信息,校验IP是否已更换:

$ yasboot cluster status -c yashandb -d

 hostid   | node_type | nodeid | pid    | instance_status | database_status | database_role | listen_address   | data_path
-----------------------------------------------------------------------------------------------------------------------------------
 host0001 | db        | 1-1:1  | 114864 | open            | normal          | standby       | 192.168.1.5:1688 | /data/yashan/yasdb_data/db-1-1
----------+-----------+--------+--------+-----------------+-----------------+---------------+------------------+--------------------
 host0002 | db        | 1-2:2  | 114862 | open            | normal          | standby       | 192.168.1.6:1688 | /data/yashan/yasdb_data/db-1-2
----------+-----------+--------+--------+-----------------+-----------------+---------------+------------------+--------------------
 host0003 | db        | 1-3:3  | 6921   | open            | normal          | primary       | 192.168.1.4:1688 | /data/yashan/yasdb_data/db-1-3
----------+-----------+--------+--------+-----------------+-----------------+---------------+------------------+--------------------

Copied!


YashanDB
1 声望0 粉丝

崖山数据库系统YashanDB是深圳计算科学研究院自主设计研发的新型数据库管理系统,融入原创的有界计算、近似计算、并行可扩展和跨模融合计算理论,可满足金融、政企、能源等关键行业对高性能、高并发及高安全性的...