一、测试环境
名称 | 值 |
---|---|
cpu | Intel® Core™ i5-1035G1 CPU @ 1.00GHz |
操作系统 | CentOS Linux release 7.9.2009 (Core) |
内存 | 4G |
逻辑核数 | 3 |
原有节点1-IP | 192.168.142.10 |
缩容节点2-IP | 192.168.142.11 |
数据库版本 | 8.6.2.43-R33 |
二、操作步骤
这里演示的步骤是同时卸载管理和数据节点。
1、查看集群状态
[root@localhost gcinstall]# gcadmin
2、查看集群分布策略
[root@localhost gcinstall]# gcadmin showdistribution
3、修改策略配置文件
我们只留保留节点的信息,缩容节点的信息进行剔除。
[root@localhost gcinstall]# su - gbase
[gbase@localhost gcinstall]$ cat gcChangeInfo.xml
<?xml version="1.0" encoding="utf-8"?>
<servers>
<rack>
<node ip="192.168.142.10"/>
</rack>
</servers>
4、策略重分布
新的策略ID是3。
[gbase@localhost gcinstall]$ gcadmin distribution gcChangeInfo.xml p 1 d 0
[gbase@localhost gcinstall]$ gcadmin showdistribution
5、数据库初始化
[gbase@localhost gcinstall]$ gccli
GBase client 8.6.2.43-R33.132743. Copyright (c) 2004-2022, GBase. All Rights Reserved.
gbase> initnodedatamap;
Query OK, 0 rows affected (Elapsed: 00:00:00.85)
6、实例重分布
gbase> set global gcluster_rebalancing_concurrent_count = 0;
gbase> set global gcluster_reblancing_concurrent_count = 0;
7、查看数据重分布情况
gbase> select * from gclusterdb.rebalancing_status;
8、查看是否有遗漏的表
如果有的话,进行rebalance table 库名.表名。
gbase> select * from gbase.table_distribution where data_distribution_id=2;
9、删除旧的节点数据地图
gbase> refreshnodedatamap drop 2;
10、删掉旧的分布策略
[gbase@localhost gcinstall]$ gcadmin rmdistribution 2
cluster distribution ID [2]
it will be removed now
please ensure this is ok, input y or n: y
gcadmin remove distribution [2] success
11、删除缩容完的数据节点注册信息
里面存放已经缩容完的数据节点信息。
[gbase@localhost gcinstall]$ cat gcChangeInfo.xml
<?xml version="1.0" encoding="utf-8"?>
<servers>
<rack>
<node ip="192.168.142.11"/>
</rack>
</servers>
[gbase@localhost gcinstall]$ gcadmin rmnodes gcChangeInfo.xml
gcadmin remove nodes ...
node [192.168.142.11] had been removed
gcadmin rmnodes success
12、停止所有节点服务
所有节点都要执行。
[root@localhost ~]# service gcware stop
13、卸载缩容节点的数据库服务
coordinateHost 写要卸载的管理节点ip,
dataHost 写要卸载的数据节点ip,
existCoordinateHost写要保留的管理节点ip,
existDataHost写要保留的数据节点ip。
[gbase@localhost gcinstall]$ cat demo.options
installPrefix= /opt
coordinateHost = 192.168.142.11
coordinateHostNodeID = 234,235,237
dataHost = 192.168.142.11
existCoordinateHost = 192.168.142.10
existDataHost = 192.168.142.10
loginUser= root
loginUserPwd = 'qwer1234'
#loginUserPwdFile = loginUserPwd.json
dbaUser = gbase
dbaGroup = gbase
dbaPwd = 'gbase'
rootPwd = 'qwer1234'
#rootPwdFile = rootPwd.json
dbRootPwd = ''
#mcastAddr = 226.94.1.39
mcastPort = 5493
[gbase@localhost gcinstall]$ ./unInstall.py --silent=demo.options
14、各节点启动数据库服务
各节点都要执行。
[root@localhost ~]# service gcware start
15、查看集群是否缩容成功
[gbase@localhost gcinstall]$ gcadmin
CLUSTER STATE: ACTIVE
CLUSTER MODE: NORMAL
=====================================================================
| GBASE COORDINATOR CLUSTER INFORMATION |
=====================================================================
| NodeName | IpAddress |gcware |gcluster |DataState |
---------------------------------------------------------------------
| coordinator1 | 192.168.142.10 | OPEN | OPEN | 0 |
---------------------------------------------------------------------
=================================================================
| GBASE DATA CLUSTER INFORMATION |
=================================================================
|NodeName | IpAddress |gnode |syncserver |DataState |
-----------------------------------------------------------------
| node1 | 192.168.142.10 | OPEN | OPEN | 0 |
-----------------------------------------------------------------
[gbase@localhost gcinstall]$ gcadmin showdistribution
Distribution ID: 3 | State: new | Total segment num: 1
Primary Segment Node IP Segment ID Duplicate Segment node IP
========================================================================================================================
| 192.168.142.10 | 1 | |
========================================================================================================================
1、只缩容数据节点
如果大家只缩容数据节点,在二、13中只写dataHost,不写coordinateHost ,其他的内容和上面的例子不变。
2、只缩容管理节点
(1)查看集群状态
[root@localhost ~]# gcadmin
(2)停止集群
各节点执行
[root@localhost ~]# service gcware stop
(3)修改配置文件
注释dataHost。
coordinateHost 写需要卸载的管理节点IP。
existCoordinateHost 写需要存在的管理节点IP。
existDataHost 写需要存在的数据节点IP
[gbase@localhost gcinstall]$ cat demo.options
installPrefix= /opt
coordinateHost = 192.168.142.11
coordinateHostNodeID = 234,235,237
#dataHost = 192.168.142.11
existCoordinateHost = 192.168.142.10
existDataHost = 192.168.142.10,192.168.142.11
loginUser= root
loginUserPwd = 'qwer1234'
#loginUserPwdFile = loginUserPwd.json
dbaUser = gbase
dbaGroup = gbase
dbaPwd = 'gbase'
rootPwd = 'qwer1234'
#rootPwdFile = rootPwd.json
dbRootPwd = ''
#mcastAddr = 226.94.1.39
mcastPort = 5493
(4)卸载管理节点
[gbase@localhost gcinstall]$ ./unInstall.py --silent=demo.options
(5)启动集群服务
每个节点都执行。
[root@localhost gcinstall]# service gcware start
(6)查看集群状态
管理节点变为一个,卸载成功。
[root@localhost gcinstall]# gcadmin
CLUSTER STATE: ACTIVE
CLUSTER MODE: NORMAL
=====================================================================
| GBASE COORDINATOR CLUSTER INFORMATION |
=====================================================================
| NodeName | IpAddress |gcware |gcluster |DataState |
---------------------------------------------------------------------
| coordinator1 | 192.168.142.10 | OPEN | OPEN | 0 |
---------------------------------------------------------------------
=================================================================
| GBASE DATA CLUSTER INFORMATION |
=================================================================
|NodeName | IpAddress |gnode |syncserver |DataState |
-----------------------------------------------------------------
| node1 | 192.168.142.10 | OPEN | OPEN | 0 |
-----------------------------------------------------------------
| node2 | 192.168.142.11 | OPEN | OPEN | 0 |
-----------------------------------------------------------------