纯 data 节点缩容
集群环境描述:
Coordinator 节点: 172.168.83.11, 172.168.83.12, 172.168.83.13, 172.168.83.15
Data 节点:
vc1: 172.168.83.11, 172.168.83.12, 172.168.83.15, 172.168.83.16
Vc2: 172.168.83.13, 172.168.83.14
待缩容的 data 节点 IP: 172.168.83.16
创建新的 distribution
步骤 1:将安装目录下的 gcChangeInfo.xml 复制到 gcS_vc1.xml 文件,然后去掉待
缩容的节点 IP。
修改后的 gcS_vc1.xml 文件参考如下:
$cp gcChangeInfo.xml gcS_vc1.xml $cat gcS_vc1.xml
步骤 2:执行创建 distribution 的命令。
$ gcadmin distribution gcS_vc1.xml p 1 d 1 vc vc1
gcadmin generate distribution ... gcadmin generate distribution successful 完成后的集群信息如下: $ gcadmin showdistribution vc vc1 Distribution ID: 4 | State: new | Total segment num: 3 Primary Segment Node IP Segment ID Duplicate Segment node IP ============================================================================== | 172.168.83.11 | 1 | 172.168.83.12 | ------------------------------------------------------------------------------ | 172.168.83.12 | 2 | 172.168.83.15 | ------------------------------------------------------------------------------ | 172.168.83.15 | 3 | 172.168.83.11 | ============================================================================== Distribution ID: 3 | State: old | Total segment num: 4 Primary Segment Node IP Segment ID Duplicate Segment node IP ============================================================================== | 172.168.83.11 | 1 | 172.168.83.12 | ------------------------------------------------------------------------------ | 172.168.83.12 | 2 | 172.168.83.15 | ------------------------------------------------------------------------------ | 172.168.83.15 | 3 | 172.168.83.16 | ------------------------------------------------------------------------------ | 172.168.83.16 | 4 | 172.168.83.11 | ==============================================================================
初始化 hashmap 并进行数据重分布
步骤 1:初始化 hashmap:
$ gccli -uroot Gbase client 9.5.3.17.117651. Copyright (c) 2004-2020, Gbase. All Rights Reserved. gbase> use vc vc1; Query OK, 0 rows affected (Elapsed: 00:00:00.00) gbase> initnodedatamap; Query OK, 0 rows affected, 5 warnings (Elapsed: 00:00:01.45)
步骤 2:执行数据重分布:
gbase> show variables like '%rebalanc%'; +-------------------------------------------------------+-----------+ | Variable_name | Value | +-------------------------------------------------------+-----------+ | _t_gcluster_rebalance_mirror_node | 0 | | gcluster_load_rebalance_seed | 5 | | gcluster_rebalancing_concurrent_count | 5 | | gcluster_rebalancing_ignore_mirror | OFF | | gcluster_rebalancing_immediate_recover_internal_table | OFF | | gcluster_rebalancing_parallel_degree | 4 | | gcluster_rebalancing_random_table_quick_mode | 1 | | gcluster_rebalancing_step | 100000000 | | gcluster_rebalancing_update_status_on_drop_table | ON | +-------------------------------------------------------+-----------+ 9 rows in set (Elapsed: 00:00:00.24) gbase> rebalance instance; Query OK, 2 rows affected (Elapsed: 00:00:01.45) 查看 rebalance 状态: gbase> select index_name, status, percentage from gclusterdb.rebalancing_status; +------------+-----------+------------+ | index_name | status | percentage | +------------+-----------+------------+ | demo.t | COMPLETED | 100 | | demo.tt | COMPLETED | 100 | +------------+-----------+------------+ 2 rows in set (Elapsed: 00:00:00.04) gbase> quit Bye
删除旧的 distribution
步骤 1:确认当前的 distribution id,在当前示例中新的 Distribution ID 为 4,旧的Distribution ID 为 3:
$ gcadmin showdistribution vc vc1
Distribution ID: 4 | State: new | Total segment num: 3 Primary Segment Node IP Segment ID Duplicate Segment node IP ============================================================================== | 172.168.83.11 | 1 | 172.168.83.12 | ------------------------------------------------------------------------------ | 172.168.83.12 | 2 | 172.168.83.15 | ------------------------------------------------------------------------------ | 172.168.83.15 | 3 | 172.168.83.11 | ============================================================================== Distribution ID: 3 | State: old | Total segment num: 4 Primary Segment Node IP Segment ID Duplicate Segment node IP ============================================================================== | 172.168.83.11 | 1 | 172.168.83.12 | ------------------------------------------------------------------------------ | 172.168.83.12 | 2 | 172.168.83.15 | ------------------------------------------------------------------------------ | 172.168.83.15 | 3 | 172.168.83.16 | ------------------------------------------------------------------------------ | 172.168.83.16 | 4 | 172.168.83.11 | ==============================================================================
步骤 2:确认当前集群中没有使用旧的 Distribution ID 的表
gbase> select index_name,tbname,data_distribution_id,vc_id from gbase.table_distribution; +------------------------------+------------------+---------------------+---------+ | index_name |tbname |data_distribution_id | vc_id | +------------------------------+------------------+---------------------+---------+ | gclusterdb.rebalancing_status|rebalancing_status| 4 | vc00001 | | gclusterdb.dual |dual | 4 | vc00001 | | demo.t |t | 4 | vc00001 | | demo.tt |tt | 4 | vc00001 | +------------------------------+------------------+---------------------+---------+
步骤 3:删除旧的 distribution:
$ gcadmin rmdistribution 3 vc vc1 cluster distribution ID [3] it will be removed now please ensure this is ok, input [Y,y] or [N,n]: y select count(*) from gbase.nodedatamap where data_distribution_id=3 result is not 0 refreshnodedatamap drop 3 success gcadmin remove distribution [3] success $ gcadmin showdistribution vc vc1 Distribution ID: 4 | State: new | Total segment num: 3 Primary Segment Node IP Segment ID Duplicate Segment node IP ================================================================== | 172.168.83.11 | 1 | 172.168.83.12 | ------------------------------------------------------------------ | 172.168.83.12 | 2 | 172.168.83.15 | ------------------------------------------------------------------ | 172.168.83.15 | 3 | 172.168.83.11 | ------------------------------------------------------------------ $ gcadmin showcluster vc vc1 CLUSTER STATE: ACTIVE VIRTUAL CLUSTER MODE: NORMAL ============================================= | Gbase VIRTUAL CLUSTER INFORMATION | ============================================= | VcName | DistributionId | comment | --------------------------------------------- | vc1 | 4 | | --------------------------------------------- =================================================================== | VIRTUAL CLUSTER DATA NODE INFORMATION | =================================================================== |NodeName| IpAddress |DistributionId| gnode|syncserver|DataState| ------------------------------------------------------------------- | node1 |172.168.83.11| 4 | OPEN | OPEN | 0 | ------------------------------------------------------------------- | node2 |172.168.83.12| 4 | OPEN | OPEN | 0 | ------------------------------------------------------------------- | node3 |172.168.83.15| 4 | OPEN | OPEN | 0 | ------------------------------------------------------------------- | node4 |172.168.83.16| | OPEN | OPEN | 0 | ------------------------------------------------------------------- 4 data node
从集群中删除缩容节点
步骤 1:将 gcChangeInfo.xml 文件复制为 gcRm_vc1.xml 文件,并修改其中对应 nodeip内容为待修改节点 IP:
$ cp gcChangeInfo.xml gcRm_vc1.xml $ vi gcRm_vc1.xml $ cat gcRm_vc1.xml
步骤 2:将缩容节点从对应 vc 中删除, 变为 freenode。
$ gcadmin rmnodes gcRm_vc1.xml vc1 gcadmin remove nodes ... flush statemachine success gcadmin rmnodes from vc [vc1] success $ gcadmin CLUSTER STATE: ACTIVE ================================================================ | Gbase COORDINATOR CLUSTER INFORMATION | ================================================================ | NodeName | IpAddress | gcware | gcluster | DataState | ---------------------------------------------------------------- | coordinator1 | 172.168.83.11 | OPEN | OPEN | 0 | ---------------------------------------------------------------- | coordinator2 | 172.168.83.12 | OPEN | OPEN | 0 | ---------------------------------------------------------------- | coordinator3 | 172.168.83.13 | OPEN | OPEN | 0 | ---------------------------------------------------------------- | coordinator4 | 172.168.83.15 | OPEN | OPEN | 0 | ---------------------------------------------------------------- ============================================= | Gbase VIRTUAL CLUSTER INFORMATION | ============================================= | VcName | DistributionId | comment | --------------------------------------------- | vc1 | 4 | | --------------------------------------------- | vc2 | 2 | | --------------------------------------------- ============================================================== | Gbase CLUSTER FREE DATA NODE INFORMATION | ============================================================== | NodeName | IpAddress | gnode | syncserver | DataState | -------------------------------------------------------------- | FreeNode1 | 172.168.83.16 | OPEN | OPEN | 0 | --------------------------------------------------------------
卸载缩容节点(可选)
若缩容后该节点不再需要可以彻底从集群中移除该节点并卸载该节点, 也可以一直作为 freenode 待以后使用。
从集群中彻底移除并卸载缩容掉的节点步骤如下:
步骤 1:确定 gcRm_vc1.xml 文件内容为待卸载节点 IP:
$ cat gcRm_vc1.xml
步骤 2:将待卸载 IP 从集群中移除
$ gcadmin rmnodes gcRm_vc1.xml gcadmin remove nodes ... flush statemachine success gcadmin rmnodes from cluster success
步骤 3:修改卸载配置文件 demoUn.options
1) 拷贝 demo.options 文件为 demoUn.options,修改 demoUn.options 如下;
2) 设置 dataHost 参数为要卸载的节点的 IP;
3) 注释 coordinateHost 和 coordinateHostNodeID 参数;
4) 修改 existCoordinateHost 参数为缩容后保留的 Coordinator 节点的 IP;
5) 修改 existDataHost 参数为缩容后保留的所有 data 节点的 IP。
$ cat demoUn.options installPrefix= /opt #coordinateHost = #coordinateHostNodeID = dataHost = 172.168.83.16 existCoordinateHost =172.168.83.11,172.168.83.12,172.168.83.13,172.168.83.15 existDataHost =172.168.83.11,172.168.83.12,172.168.83.13,172.168.83.14,172.168.83.15 existGcwareHost=172.168.83.11,172.168.83.12,172.168.83.13,172.168.83.15 #gcwareHost = #gcwareHostNodeID = dbaUser = gbase dbaGroup = gbase dbaPwd = 'gbasedba' rootPwd = '111111' #rootPwdFile = rootPwd.json #characterSet = utf8 #sshPort = 10022
步骤 4:到所有需要卸载的数据节点上去停止集群服务
$ gcluster_services all stop
步骤 5:执行卸载。
$ ./unInstall.py --silent=demoUn.options These GCluster nodes will be uninstalled. CoordinateHost: DataHost: 172.168.83.16 Are you sure to uninstall GCluster ([Y,y]/[N,n])? y 172.168.83.16 unInstall 172.168.83.16 successfully.
纯 coordinator 节点缩容
集群环境描述:
Coordinator 节点: 172.168.83.11, 172.168.83.12, 172.168.83.13, 172.168.83.15
Data 节点:
vc1: 172.168.83.11, 172.168.83.12
vc2: 172.168.83.13, 172.168.83.14
缩容 coordinator 节点 IP:172.168.83.15
准备配置文件
步骤 1:修改 demo.options 文件:
1) 设置 coordinateHost 参数为要卸载的节点的 IP;
2) 设置 coordinateHostNodeID 参数为要卸载的节点设置的 ID;
3) 修改 existCoordinateHost 参数为缩容后保留的 Coordinator 节点的 IP;
4) 修改 existDataHost 参数为缩容后保留的所有 data 节点的 IP。
修改后的 demo.options 参考如下:
$ cat demo.options installPrefix= /opt coordinateHost = 172.168.83.15 coordinateHostNodeID =15 #dataHost = 172.168.83.15 existCoordinateHost =172.168.83.11,172.168.83.12,172.168.83.13 existDataHost =172.168.83.11,172.168.83.12,172.168.83.13,172.168.83.14 existGcwareHost=172.168.83.11,172.168.83.12,172.168.83.13,172.168.83.15#gcwareHost = #gcwareHostNodeID = dbaUser = gbase dbaGroup = gbase dbaPwd = 'gbasedba' rootPwd = '111111' #rootPwdFile = rootPwd.json
停止所有节点的集群服务
在所有节点执行集群服务停止命令。
$ gcluster_services all stop Stopping gcrecover : [ OK ] Stopping gcluster : [ OK ] Stopping gbase : [ OK ] Stopping syncserver : [ OK ] $ gcware_services all stop Stopping GCWareMonit success! Stopping gcware : [ OK ]
卸载节点
步骤 1:执行卸载。
$ ./unInstall.py --silent=demo.options These GCluster nodes will be uninstalled. CoordinateHost: 172.168.83.15 DataHost: Are you sure to uninstall GCluster ([Y,y]/[N,n])? y 172.168.83.15 unInstall 172.168.83.15 successfully. Update all coordinator gcware conf. 172.168.83.11 update gcware conf successfully. 172.168.83.12 update gcware conf successfully. 172.168.83.13 update gcware conf successfully
启动所有节点的集群服务
步骤 1:在所有节点执行集群服务启动命令。
$ gcluster_services all start Starting gbase : [ OK ] Starting syncserver : [ OK ] Starting gcluster : [ OK ] Starting gcrecover : [ OK ] $ gcware_services all start Starting gcware : [ OK ] Starting GCWareMonit success! 安装后状态信息如下: $ gcadmin CLUSTER STATE: ACTIVE ================================================================ | Gbase COORDINATOR CLUSTER INFORMATION | ================================================================ | NodeName | IpAddress | gcware | gcluster | DataState | ---------------------------------------------------------------- | coordinator1 | 172.168.83.11 | OPEN | OPEN | 0 | ---------------------------------------------------------------- | coordinator2 | 172.168.83.12 | OPEN | OPEN | 0 | ---------------------------------------------------------------- | coordinator3 | 172.168.83.13 | OPEN | OPEN | 0 | ---------------------------------------------------------------- ============================================================== | Gbase CLUSTER FREE DATA NODE INFORMATION | ============================================================== | NodeName | IpAddress | gnode | syncserver | DataState | -------------------------------------------------------------- | FreeNode1 | 172.168.83.11 | OPEN | OPEN | 0 | -------------------------------------------------------------- | FreeNode2 | 172.168.83.12 | OPEN | OPEN | 0 | --------------------------------------------------------------| FreeNode3 | 172.168.83.13 | OPEN | OPEN | 0 | -------------------------------------------------------------- | FreeNode4 | 172.168.83.14 | OPEN | OPEN | 0 | -------------------------------------------------------------- 0 virtual cluster 3 coordinator node 4 free data node



