#CN扩缩容
对于分布式部署中的CN组,YashanDB支持对CN节点进行扩缩容,扩容期间集群无法正常使用,会阻塞DDL,还会拦截yasboot的一些命令;详细命令参数可查阅yasboot。
具体yasboot拦截命令如下所示。
$ yasboot cluster restart
$ yasboot group restart
$ yasboot node restart
$ yasboot group add/remove
$ yasboot node add/remove
# CN节点扩容
支持对CN节点进行在线扩容。
Warn:
在扩缩容过程中请不要通过yasboot命令对节点进行强制重启/停止节点的操作,否则可能会造成扩缩容失败后无法执行node remove --clean命令。如果不可避免地造成了这种情况,可以通过对扩容失败/缩容失败的节点进行强制操作(如yasboot node stop -f)后,通过node remove --node-ids的方式删除失败的节点。
Step1:生成配置文件
情况1:在新增主机上增加CN节点,会生成hosts_add.toml和yashandb_add.toml两个配置文件。
$ yasboot config node gen -c yashandb -u yashan -p password --ip ip1,ip2...ipn --port 22 --install-path /var/database/yashan -g 2 --node 2
情况2:在已有主机上增加CN节点,会生成yashandb_add.toml配置文件。
$ yasboot config node gen -c yashandb --host-id host0001,host0002 -g 2 --node 2
Step2:部署新主机
如果是在已有主机上增加CN节点,则跳过该步骤。
$ yasboot host add -c yashandb -i yashandb-23.1.0.2-linux-x86_64.tar.gz -t hosts_add.toml
type | uuid | name | hostid | index | status | return_code | progress | cost
-------------------------------------------------------------------------------------------------
task | b5328fe3dbf4a2be | HostAdd | - | yashandb | SUCCESS | 0 | 100 | 9
------+------------------+---------+--------+----------+---------+-------------+----------+------
task completed, status: SUCCESS
Step3:扩容
$ yasboot node add -c yashandb -t yashandb_add.toml
type | uuid | name | hostid | index | status | return_code | progress | cost
-------------------------------------------------------------------------------------------------
task | faac17066f99af00 | NodeAdd | - | yashandb | SUCCESS | 0 | 100 | 3
------+------------------+---------+--------+----------+---------+-------------+----------+------
task completed, status: SUCCESS
任务显示成功并不代表着扩容任务成功,因为仍有后台任务在完成数据的同步等操作。
可以通过task list命令查看和扩容相关的任务是否都成功。
Note:
扩缩容无法并行执行。
Step 4:查看扩容相关的任务
$ yasboot task list -c yashandb --search type=NodeAdd
uuid | name | type | index | hostid | status | ret_code | progress | created_at | cost
---------------------------------------------------------------------------------------------------------------------------
ddb43ad43a9ee01e | AddCNAlterHA | NodeAdd | yashandb.cng1 | - | SUCCESS | 0 | 0 | 2023-08-17 10:20:33 | -
------------------+--------------+---------+---------+--------+---------+----------+----------+---------------------+------
faac17066f99af00 | NodeAdd | NodeAdd | yashandb.cng1 | - | SUCCESS | 0 | 100 | 2023-08-17 10:20:33 | 10
# 删除CN节点
如某个CN节点发生故障导致无法启用。工具执行手动缩容,删除该故障节点。
通过yasboot node remove命令删除一个CN节点。
示例
$ yasboot node remove -c yashandb -n 2-2 --purge
Note:
仅在CN节点处于不在线状态时可进行缩容;如果想对在线的CN节点缩容,需要先停止该节点。