GBase 8a V9版本虚拟集群(Virtual Cluster 简称VC)安装、创建和使用

本文介绍GBase 8a数据库集群V95版本,虚拟集群(Virtual Cluster 简称VC)的安装,创建和使用。

参考

GBase 8a集群V95新安装注意事项

环境

1管理+1调度+2计算节点集群

10.0.2.101 管理+调度+计算
10.0.2.115 计算

安装

与普通V95安装一样,如下只贴出配置文件和安装结果。

注意如下所有操作都在dbaUser下进行,一般是操作系统gbase用户。

安装准备工作,请参考 GBase 8a集群V95新安装注意事项

配置文件

[gbase@gbase_rh7_001 gcinstall]$ cat demo.options
installPrefix= /opt/gbase
coordinateHost = 10.0.2.101
coordinateHostNodeID = 101
dataHost = 10.0.2.101,10.0.2.115
#existCoordinateHost =10.0.2.101
#existDataHost =10.0.2.101
dbaUser = gbase
dbaGroup = gbase
dbaPwd = 'gbase1234'
rootPwd = ''
#rootPwdFile = rootPwd.json
#updateConf=demo.conf

安装结果

用gcinstall.py安装

./gcinstall.py --silent=demo.options
.........

10.0.2.101              install cluster on host 10.0.2.101 successfully.
10.0.2.115              install cluster on host 10.0.2.115 successfully.
Starting all gcluster nodes...
adding new datanodes to gcware...
[gbase@gbase_rh7_001 gcinstall]$
[gbase@gbase_rh7_001 gcinstall]$
[gbase@gbase_rh7_001 gcinstall]$ gcadmin
CLUSTER STATE:         ACTIVE

=============================================================
|           GBASE COORDINATOR CLUSTER INFORMATION           |
=============================================================
|   NodeName   | IpAddress  | gcware | gcluster | DataState |
-------------------------------------------------------------
| coordinator1 | 10.0.2.101 |  OPEN  |   OPEN   |     0     |
-------------------------------------------------------------
===========================================================
|        GBASE CLUSTER FREE DATA NODE INFORMATION         |
===========================================================
| NodeName  | IpAddress  | gnode | syncserver | DataState |
-----------------------------------------------------------
| FreeNode1 | 10.0.2.101 | OPEN  |    OPEN    |     0     |
-----------------------------------------------------------
| FreeNode2 | 10.0.2.115 | OPEN  |    OPEN    |     0     |
-----------------------------------------------------------

创建VC(createvc)

这部分是虚拟集群(Virtual Cluster)的部分。如果不单独创建,则使用vcname000001的默认vc。

注意:如果你不想使用VC功能,所有节点全是一个VC,和V86版本相容的【兼容模式】,请不要创建VC,直接跳转到后面的创建分布策略章节。与86的方法基本一致。

生成VC配置文件样本

gcadmin命令可以生成配置文件样本。

[gbase@gbase_rh7_001 gcinstall]$ gcadmin createvc e createvc.xml
[gbase@gbase_rh7_001 gcinstall]$ cat createvc.xml
<?xml version='1.0' encoding="utf-8"?>
<servers>

    <rack>
        <node ip="vc data node ip"/>
        <!--- ... -->
        <node ip="vc data node ip"/>
    </rack>

    <vc_name name="virtual cluster name no more than 64 bytes"/>
    <comment message="comment message no more than 60 bytes"/>

</servers>
[gbase@gbase_rh7_001 gcinstall]$

创建VC1

修改配置文件,将第一个计算节点IP 10.0.2.101写入,并编辑VC的名字和注释

[gbase@gbase_rh7_001 gcinstall]$ cat createvc.xml
<?xml version='1.0' encoding="utf-8"?>
<servers>

    <rack>
        <node ip="10.0.2.101"/>
    </rack>

    <vc_name name="vc01"/>
    <comment message="first vc with one node"/>

</servers>

执行createvc命令创建VC

[gbase@gbase_rh7_001 gcinstall]$ gcadmin createvc createvc.xml
parse config file createvc.xml
generate vc id: vc00001
add vc information to cluster
add nodes to vc
gcadmin create vc [vc01] successful

[gbase@gbase_rh7_001 gcinstall]$ 

创建VC2

相同的方法,将另一个IP修改好配置文件。

[gbase@gbase_rh7_001 gcinstall]$ cat createvc2.xml
<?xml version='1.0' encoding="utf-8"?>
<servers>

    <rack>
        <node ip="10.0.2.115"/>
    </rack>

    <vc_name name="vc02"/>
    <comment message="second vc with one node"/>

</servers>

创建VC

[gbase@gbase_rh7_001 gcinstall]$ gcadmin createvc createvc.xml
parse config file createvc.xml
generate vc id: vc00002
add vc information to cluster
add nodes to vc
gcadmin create vc [vc02] successful

[gbase@gbase_rh7_001 gcinstall]$

创建VC的结果

通过gcadmin命令,可以看到默认只显示了当前的VC信息了。

[gbase@gbase_rh7_001 gcinstall]$ gcadmin
CLUSTER STATE:         ACTIVE

=============================================================
|           GBASE COORDINATOR CLUSTER INFORMATION           |
=============================================================
|   NodeName   | IpAddress  | gcware | gcluster | DataState |
-------------------------------------------------------------
| coordinator1 | 10.0.2.101 |  OPEN  |   OPEN   |     0     |
-------------------------------------------------------------
===========================================================
|            GBASE VIRTUAL CLUSTER INFORMATION            |
===========================================================
|    VcName    | DistributionId |         comment         |
-----------------------------------------------------------
|     vc01     |                | first vc with one node  |
-----------------------------------------------------------
|     vc02     |                | second vc with one node |
-----------------------------------------------------------

2 virtual cluster: vc01, vc02
1 coordinator node
0 free data node

[gbase@gbase_rh7_001 gcinstall]$ 

创建分布策略(distribution)

包括创建分布策略配置文件,和创建2个步骤。

编辑策略配置文件gcChangeInfo.xml

配置文件里包含本VC里,数据节点的主备分布策略。如下是第一个VC的样子。

[gbase@gbase_rh7_001 gcinstall]$ vi gcChangeInfo.xml
[gbase@gbase_rh7_001 gcinstall]$ cat gcChangeInfo.xml
<?xml version="1.0" encoding="utf-8"?>
<servers>
 <rack>
  <node ip="10.0.2.101"/>
 </rack>
</servers>

第二个VC的配置文件

[gbase@gbase_rh7_001 gcinstall]$ cat gcChangeInfo2.xml
<?xml version="1.0" encoding="utf-8"?>
<servers>
 <rack>
  <node ip="10.0.2.115"/>
 </rack>
</servers>
[gbase@gbase_rh7_001 gcinstall]$

创建分布策略(distribution)

注意:如果不使用VC,是和V86相同的兼容模式,则如下参数里,不要执行vc参数。

创建VC1的分布策略

具体参数请参考产品安装手册。其中用户名和密码是【数据库】的用户密码,不是操作系统的。

[gbase@gbase_rh7_001 gcinstall]$ gcadmin distribution gcChangeInfo.xml p 1 d 0 db_user gbase db_pwd gbase20110531 vc vc01
gcadmin generate distribution ...

[warning]: parameter [d num] is 0, the new distribution will has no segment backup
please ensure this is ok, input [Y,y] or [N,n]: y
NOTE: node [10.0.2.101] is coordinator node, it shall be data node too
gcadmin generate distribution successful

[gbase@gbase_rh7_001 gcinstall]$ gcadmin
CLUSTER STATE:         ACTIVE

=============================================================
|           GBASE COORDINATOR CLUSTER INFORMATION           |
=============================================================
|   NodeName   | IpAddress  | gcware | gcluster | DataState |
-------------------------------------------------------------
| coordinator1 | 10.0.2.101 |  OPEN  |   OPEN   |     0     |
-------------------------------------------------------------
===========================================================
|            GBASE VIRTUAL CLUSTER INFORMATION            |
===========================================================
|    VcName    | DistributionId |         comment         |
-----------------------------------------------------------
|     vc01     |       1        | first vc with one node  |
-----------------------------------------------------------
|     vc02     |                | second vc with one node |
-----------------------------------------------------------

2 virtual cluster: vc01, vc02
1 coordinator node
0 free data node

[gbase@gbase_rh7_001 gcinstall]$ 

创建VC2的分布策略

[gbase@gbase_rh7_001 gcinstall]$ gcadmin distribution gcChangeInfo2.xml p 1 d 0 db_user gbase db_pwd gbase20110531 vc vc02
gcadmin generate distribution ...

[warning]: parameter [d num] is 0, the new distribution will has no segment backup
please ensure this is ok, input [Y,y] or [N,n]: y
gcadmin generate distribution successful

[gbase@gbase_rh7_001 gcinstall]$ gcadmin
CLUSTER STATE:         ACTIVE

=============================================================
|           GBASE COORDINATOR CLUSTER INFORMATION           |
=============================================================
|   NodeName   | IpAddress  | gcware | gcluster | DataState |
-------------------------------------------------------------
| coordinator1 | 10.0.2.101 |  OPEN  |   OPEN   |     0     |
-------------------------------------------------------------
===========================================================
|            GBASE VIRTUAL CLUSTER INFORMATION            |
===========================================================
|    VcName    | DistributionId |         comment         |
-----------------------------------------------------------
|     vc01     |       1        | first vc with one node  |
-----------------------------------------------------------
|     vc02     |       2        | second vc with one node |
-----------------------------------------------------------

2 virtual cluster: vc01, vc02
1 coordinator node
0 free data node

[gbase@gbase_rh7_001 gcinstall]$

初始化

登录数据库,选择VC,然后初始化initnodedatamap;

[gbase@gbase_rh7_001 gcinstall]$ gccli

GBase client 9.5.2.26.121440. Copyright (c) 2004-2021, GBase.  All Rights Reserved.

gbase> show vcs;
+---------+------+---------+
| id      | name | default |
+---------+------+---------+
| vc00001 | vc01 |         |
| vc00002 | vc02 |         |
+---------+------+---------+
2 rows in set (Elapsed: 00:00:00.00)

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

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

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

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

gbase>

查看虚拟集群信息

通过 showcluster vc vcName 方法获得指定VC的情况。其它功能也都需要指定vc。

[gbase@gbase_rh7_001 gcinstall]$ gcadmin showcluster vc vc01
CLUSTER STATE:         ACTIVE
VIRTUAL CLUSTER MODE:  NORMAL

==========================================================
|           GBASE VIRTUAL CLUSTER INFORMATION            |
==========================================================
|    VcName    | DistributionId |        comment         |
----------------------------------------------------------
|     vc01     |       1        | first vc with one node |
----------------------------------------------------------
=========================================================================================================
|                                 VIRTUAL CLUSTER DATA NODE INFORMATION                                 |
=========================================================================================================
| NodeName |                IpAddress                 | DistributionId | gnode | syncserver | DataState |
---------------------------------------------------------------------------------------------------------
|  node1   |                10.0.2.101                |       1        | OPEN  |    OPEN    |     0     |
---------------------------------------------------------------------------------------------------------

1 data node

[gbase@gbase_rh7_001 gcinstall]$ gcadmin showcluster vc vc02
CLUSTER STATE:         ACTIVE
VIRTUAL CLUSTER MODE:  NORMAL

===========================================================
|            GBASE VIRTUAL CLUSTER INFORMATION            |
===========================================================
|    VcName    | DistributionId |         comment         |
-----------------------------------------------------------
|     vc02     |       2        | second vc with one node |
-----------------------------------------------------------
=========================================================================================================
|                                 VIRTUAL CLUSTER DATA NODE INFORMATION                                 |
=========================================================================================================
| NodeName |                IpAddress                 | DistributionId | gnode | syncserver | DataState |
---------------------------------------------------------------------------------------------------------
|  node1   |                10.0.2.115                |       2        | OPEN  |    OPEN    |     0     |
---------------------------------------------------------------------------------------------------------

1 data node

[gbase@gbase_rh7_001 gcinstall]$

总结

虚拟集群,只针对计算节点,不同的计算节点唯一属于某个虚拟集群,不能共享,来达到物理级别的资源隔离。

管理和调度集群是共享的,对外服务也是相同的。

不同的用户,可以指定默认的vc。