南大通用数据库-Gbase-8a-学习-08-集群节点添加数据副本

一、测试环境

名称
cpuIntel® Core™ i5-1035G1 CPU @ 1.00GHz
操作系统CentOS Linux release 7.9.2009 (Core)
内存4G
逻辑核数3
节点1-IP192.168.142.10
节点2-IP192.168.142.11
数据库版本8.6.2.43-R33.132743

二、操作步骤

1、查看集群状态

[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: 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;
Query OK, 0 rows affected, 1 warning (Elapsed: 00:00:00.76)

5、重分布

重分布支持instance, database、table三种等级。

gbase> rebalance instance;
Query OK, 1 row affected (Elapsed: 00:00:00.25)

6、查看重分布完成度

gbase> select * from  gclusterdb.rebalancing_status;
+------------------------------+------------+-------------------+----------+----------------------------+----------------------------+-----------+------------+----------+-----------------------+-----------------+
| index_name                   | db_name    | table_name        | tmptable | start_time                 | end_time                   | status    | percentage | priority | host                  | distribution_id |
+------------------------------+------------+-------------------+----------+----------------------------+----------------------------+-----------+------------+----------+-----------------------+-----------------+
| gclusterdb.audit_log_express | gclusterdb | audit_log_express |          | 2022-08-12 16:47:08.211000 | 2022-08-12 16:47:09.130000 | COMPLETED |        100 |        5 | ::ffff:192.168.142.10 |               5 |
| czg.czg                      | czg        | czg               |          | 2022-08-12 16:47:08.207000 | 2022-08-12 16:47:09.162000 | COMPLETED |        100 |        5 | ::ffff:192.168.142.10 |               5 |
+------------------------------+------------+-------------------+----------+----------------------------+----------------------------+-----------+------------+----------+-----------------------+-----------------+
2 rows in set (Elapsed: 00:00:00.01)

7、查看是否有表使用老的策略

gbase> select * from gbase.table_distribution where data_distribution_id=4;
Empty set (Elapsed: 00:00:00.00)

如果有的话,请使用rebalance table 库名.表名,重新分布表。

8、删除老的刷新节点数据地图

gbase> refreshnodedatamap drop 4;
Query OK, 0 rows affected (Elapsed: 00:00:00.85)

9、删除老的分布策略

[gbase@localhost gcinstall]$ gcadmin rmdistribution 4
cluster distribution ID [4]
it will be removed now
please ensure this is ok, input y or n: y
gcadmin remove distribution [4] success

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                                |
========================================================================================================================
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值