• 南大通用数据库-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          |                                                  |
    ========================================================================================================================
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33

    我们可以看到没有副本存在。

    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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    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          |                                                  |
    ========================================================================================================================
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19

    新的分布策略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)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    5、重分布

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

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

    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)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

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

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

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

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

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

    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
    
    • 1
    • 2
    • 3
    • 4
    • 5

    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                                |
    ========================================================================================================================
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
  • 相关阅读:
    如何设置Linux的语言环境
    Leetcode---368周赛
    我已经受够了“系统异常”!
    Java Swing医院就诊预约系统
    R-Car H3系列SOC芯片与R-Car M3 R8A77961JBP0BA区别
    Spring MVC 和 Spring Boot 的区别
    昇思25天学习打卡营第15天|基于 MindSpore 实现 BERT 对话情绪识别
    [附源码]Python计算机毕业设计Django的疫苗接种管理系统
    Dubbo 实战 - Mock 调用
    性能优化之懒加载 - 基于观察者模式和单例模式的实现
  • 原文地址:https://blog.csdn.net/qq_45111959/article/details/126306662