一、测试环境
名称 | 值 |
---|---|
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.132743 |
二、操作步骤
1、查看集群状态
[gbase@localhost gcinstall]$ gcadmin
[gbase@localhost gcinstall]$ gcadmin showdistribution
Distribution ID: 4 | State: new | Total segment num: 2
Primary Segment Node IP Segment ID Duplicate Segment node IP
========================================================================================================================
| 192.168.142.11 | 1 | |
------------------------------------------------------------------------------------------------------------------------
| 192.168.142.10 | 2 | |
=========================================================================================
2、设置分布策略
[gbase@localhost gcinstall]$ cat gcChangeInfo.xml
<?xml version="1.0" encoding="utf-8"?>
<servers>
<rack>
<node ip="192.168.142.11"/>
<node ip="192.168.142.10"/>
</rack>
</servers>
[gbase@localhost gcinstall]$ gcadmin distribution gcChangeInfo.xml p 1 d 1
gcadmin generate distribution ...
gcadmin generate distribution successful
3、查看分布情况
[gbase@localhost gcinstall]$ gcadmin showdistribution
Distribution ID: 5 | State: new | Total segment num: 2
Primary Segment Node IP Segment ID Duplicate Segment node IP
========================================================================================================================
| 192.168.142.11 | 1 | 192.168.142.10 |
------------------------------------------------------------------------------------------------------------------------
| 192.168.142.10 | 2 | 192.168.142.11 |
========================================================================================================================
Distribution ID: 4 | State: old | Total segment num: 2
Primary Segment Node IP Segment ID Duplicate Segment node IP
========================================================================================================================
| 192.168.142.11 | 1 | |
------------------------------------------------------------------------------------------------------------------------
| 192.168.142.10 | 2 | |
========================================================================================================================
新的分布策略ID:5
老的分布策略ID:4
4、数据库初始化
[gbase@localhost gcinstall]$ gccli
GBase client 8.6.2.43-R33.132743. Copyright (c) 2004-2022, GBase. All Rights Reserved.
gbase> initnodedatamap;
5、重分布
重分布支持instance, database、table三种等级。
gbase> rebalance instance;
6、查看重分布完成度
gbase> select * from gclusterdb.rebalancing_status;
7、查看是否有表使用老的策略
gbase> select * from gbase.table_distribution where data_distribution_id=4;
如果有的话,请使用rebalance table 库名.表名,重新分布表。
8、删除老的刷新节点数据地图
gbase> refreshnodedatamap drop 4;
9、删除老的分布策略
[gbase@localhost gcinstall]$ gcadmin rmdistribution 4
10、查看是否成功
各节点状态正常,分布策略是最新的,有副本信息,说明我们添加数据副本成功啦
[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 |
---------------------------------------------------------------------
| coordinator2 | 192.168.142.11 | 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 |
-----------------------------------------------------------------
[gbase@localhost gcinstall]$ gcadmin showdistribution
Distribution ID: 5 | State: new | Total segment num: 2
Primary Segment Node IP Segment ID Duplicate Segment node IP
========================================================================================================================
| 192.168.142.11 | 1 | 192.168.142.10 |
------------------------------------------------------------------------------------------------------------------------
| 192.168.142.10 | 2 | 192.168.142.11 |
========================================================================================================================
。