GBase 8a 虚拟集群

虚拟集群是在一个物理集群中又划分出来一个两个或多个虚拟集群

比如在一个物理集群中包含六个节点 192.168.61.1-6【安装时 demo.options里面配置6个节点】

其中192.168.61.1 , 192.168.61.2 , 192.168.61.3可以划分为一个虚拟集群VC1

       192.168.61.4 , 192.168.61.5 , 192.168.61.6可以划分为一个虚拟集群VC2

VC1和VC2是相互隔离的,同时VC1和VC2都有独自的调度节点和数据节点,所以说,虚拟集群只是在一个大集群中又划分的小集群,仍具有集群的所有特性

安装数据库(执行完gcinstall.py 不要做distribution,提示install sucssful 就好)

GBase 8a 部署(9.5)_GNAIXGNAHZ的博客-CSDN博客

 

配置VC模板

[gbase@8a-01 ~]$ su - gbase
[gbase@8a-01 ~]$ source /home/gbase/.bash_profile
[gbase@8a-01 ~]$ cd /opt/gcinstall/
[gbase@8a-01 gcinstall]$ gcadmin createvc e create_vc1.xml
[gbase@8a-01 gcinstall]$ vi create_vc1.xml
[gbase@8a-01 gcinstall]$ gcadmin createvc e create_vc2.xml
[gbase@8a-01 gcinstall]$ vi create_vc2.xml

create_vc1.xml配置如下:

<?xml version='1.0' encoding="utf-8"?>
<servers>

    <rack>
        <node ip="192.168.61.1"/>
        <node ip="192.168.61.2"/>
        <node ip="192.168.61.3"/>
    </rack>

    <vc_name name="vc1"/>
    <comment message="vc1comments"/>

</servers>

create_vc2.xml配置如下:
<?xml version='1.0' encoding="utf-8"?>
<servers>

    <rack>
        <node ip="192.168.61.4"/>
        <node ip="192.168.61.5"/>
        <node ip="192.168.61.6"/>
    </rack>

    <vc_name name="vc2"/>
    <comment message="vc2comments"/>

</servers>
~  

创建VC

[gbase@8a-01 gcinstall]$ gcadmin createvc create_vc1.xml
[gbase@8a-01 gcinstall]$ gcadmin createvc create_vc2.xml

在VC上创建distribution

[gbase@8a-01 gcinstall]$ cp gcChangeInfo.xml gcChangeInfo_vc1.xml
[gbase@8a-01 gcinstall]$ cp gcChangeInfo.xml gcChangeInfo_vc2.xml
[gbase@8a-01 gcinstall]$ vi gcChangeInfo_vc1.xml
[gbase@8a-01 gcinstall]$ vi gcChangeInfo_vc2.xml
[gbase@8a-01 gcinstall]$ gcadmin distribution gcChangeInfo_vc1.xml p 1 d 1 vc vc1 dba_os_password gba@123   这里写操作系统gbase的密码
[gbase@8a-01 gcinstall]$ gcadmin distribution gcChangeInfo_vc2.xml p 1 d 1 vc vc2 dba_os_password gba@123

gcadmin generate distribution ...

NOTE: node [192.168.61.6] is coordinator node, it shall be data node too
NOTE: node [192.168.61.5] is coordinator node, it shall be data node too
NOTE: node [192.168.61.4] is coordinator node, it shall be data node too
check vc vc2 os password
copy system table to 192.168.61.5
copy system table to 192.168.61.6
copy system table to 192.168.61.4
gcadmin generate distribution successful

 gcChangeInfo_vc1.xml配置如下:

<?xml version="1.0" encoding="utf-8"?>
<servers>
    <rack>
        <node ip="192.168.61.2"/>
    </rack>
    <rack>
        <node ip="192.168.61.1"/>
    </rack>
    <rack>
        <node ip="192.168.61.3"/>
    </rack>
</servers>
~

 gcChangeInfo_vc2.xml配置如下:

 <?xml version="1.0" encoding="utf-8"?>
<servers>
    <rack>
        <node ip="192.168.61.5"/>
    </rack>
    <rack>
        <node ip="192.168.61.4"/>
    </rack>
    <rack>
        <node ip="192.168.61.6"/>
    </rack>
</servers>
~

集群初始化

[gbase@8a-01 gcinstall]$ gccli -uroot -p
Enter password:

GBase client 9.5.3.27.14_patch.1b41b5c1. Copyright (c) 2004-2022, 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 (Elapsed: 00:00:01.68)

gbase> use vc vc2;
Query OK, 0 rows affected (Elapsed: 00:00:00.01)

gbase> initnodedatamap;
Query OK, 0 rows affected (Elapsed: 00:00:00.29)

 检查

[gbase@8a-01 gcinstall]$ gcadmin showcluster vc vc1
[gbase@8a-01 gcinstall]$ gcadmin showcluster vc vc2
[gbase@8a-01 gcinstall]$ gcadmin showdistribution vc vc1
[gbase@8a-01 gcinstall]$ gcadmin showdistribution vc vc2
[gbase@8a-01 gcinstall]$ gccli -uroot -p
gbase> show vcs;

镜像集群

镜像集群可以理解为两个VC之间的集群同步,将VC2设置为VC1的镜像集群后,VC1表中新增的数据 在VC2中都可以看到

[gbase@bogon gcinstall]$ gcadmin showdistribution node vc vc1
                                      Distribution ID: 1 | State: new | Total segment num: 3

====================================================================================================================================
|  nodes   |             192.168.61.4              |             192.168.61.3              |             192.168.61.5              |
------------------------------------------------------------------------------------------------------------------------------------
| primary  |                  1                    |                  2                    |                  3                    |
| segments |                                       |                                       |                                       |
------------------------------------------------------------------------------------------------------------------------------------
|duplicate |                  3                    |                  1                    |                  2                    |
|segments 1|                                       |                                       |                                       |
====================================================================================================================================
[gbase@bogon gcinstall]$ gcadmin showdistribution node vc vc2
                                      Distribution ID: 2 | State: new | Total segment num: 2

============================================================================================
|  nodes   |             192.168.61.7              |             192.168.61.6              |
--------------------------------------------------------------------------------------------
| primary  |                  1                    |                  2                    |
| segments |                                       |                                       |
--------------------------------------------------------------------------------------------
|duplicate |                  2                    |                  1                    |
|segments 1|                                       |                                       |
============================================================================================
gbase> select distinct(res.r), count(res.r) from (select count(*) r from  gbase.nodedatamap t where t.data_distribution_id in (1,2) group by t.hashkey, t.nodeid) res group by res.r;
+---+--------------+
| r | count(res.r) |
+---+--------------+
| 1 |        87384 |
| 2 |        21844 |
+---+--------------+
2 rows in set (Elapsed: 00:00:00.13)


gbase> use vc vc1;
Query OK, 0 rows affected (Elapsed: 00:00:00.00)

gbase> create database zhangxiang;
Query OK, 1 row affected (Elapsed: 00:00:00.14)

gbase> use vc vc2;
Query OK, 0 rows affected (Elapsed: 00:00:00.00)

gbase> create database zhangxiang;
Query OK, 1 row affected (Elapsed: 00:00:00.03)

gbase> ALTER DATABASE VC1.zhangxiang CREATE MIRROR TO VC2;
Query OK, 1 row affected (Elapsed: 00:00:00.02)

gbase> show mirror databases;
+--------------------+-----+-----------+
| Database           | VC  | MIRROR_VC |
+--------------------+-----+-----------+
| information_schema |     |           |
| performance_schema |     |           |
| gbase              |     |           |
| gctmpdb            |     |           |
| gclusterdb         | vc1 |           |
| zhangxiang         | vc1 |           |
+--------------------+-----+-----------+
6 rows in set (Elapsed: 00:00:00.00)

gbase> alter database vc1.zhangxiang set default mirror=vc2;
Query OK, 1 row affected (Elapsed: 00:00:00.03)

gbase> show mirror databases;
+--------------------+-----+-----------+
| Database           | VC  | MIRROR_VC |
+--------------------+-----+-----------+
| information_schema |     |           |
| performance_schema |     |           |
| gbase              |     |           |
| gctmpdb            |     |           |
| gclusterdb         | vc1 |           |
| zhangxiang         | vc1 | vc2       |
+--------------------+-----+-----------+
6 rows in set (Elapsed: 00:00:00.00)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值