GBase 8a V95合并、加入其它集群功能体验

GBase 8a V95版本支持虚拟集群(VC),每个VC是各自独立的,于是就出现了将已有集群,加入另一个集群的需求,本文简单体验了一下该功能。

环境

2个单节点集群,均无VC,分别安装的。

集群101

[gbase@gbase_rh7_001 ~]$ gcadmin
CLUSTER STATE:         ACTIVE
VIRTUAL CLUSTER MODE:  NORMAL

=============================================================
|           GBASE COORDINATOR CLUSTER INFORMATION           |
=============================================================
|   NodeName   | IpAddress  | gcware | gcluster | DataState |
-------------------------------------------------------------
| coordinator1 | 10.0.2.101 |  OPEN  |   OPEN   |     0     |
-------------------------------------------------------------
=========================================================================================================
|                                    GBASE DATA CLUSTER INFORMATION                                     |
=========================================================================================================
| NodeName |                IpAddress                 | DistributionId | gnode | syncserver | DataState |
---------------------------------------------------------------------------------------------------------
|  node1   |                10.0.2.101                |       8        | OPEN  |    OPEN    |     0     |
---------------------------------------------------------------------------------------------------------

集群102

[gbase@localhost ~]$ gcadmin
CLUSTER STATE:         ACTIVE
VIRTUAL CLUSTER MODE:  NORMAL

=============================================================
|           GBASE COORDINATOR CLUSTER INFORMATION           |
=============================================================
|   NodeName   | IpAddress  | gcware | gcluster | DataState |
-------------------------------------------------------------
| coordinator1 | 10.0.2.102 |  OPEN  |   OPEN   |     0     |
-------------------------------------------------------------
=========================================================================================================
|                                    GBASE DATA CLUSTER INFORMATION                                     |
=========================================================================================================
| NodeName |                IpAddress                 | DistributionId | gnode | syncserver | DataState |
---------------------------------------------------------------------------------------------------------
|  node1   |                10.0.2.102                |       1        | OPEN  |    OPEN    |     0     |
---------------------------------------------------------------------------------------------------------

版本

两套集群完全相同的版本。9.5.2.44.10

gbase> select version();
+--------------------+
| version()          |
+--------------------+
| 9.5.2.44.1045e3118 |
+--------------------+
1 row in set (Elapsed: 00:00:00.00)

数验证据

2个vc都有1个库叫testdb,我们在101的集群testdb库上,建立了一个表

gbase> create table t_101_testdb_tt(id int);
Query OK, 0 rows affected (Elapsed: 00:00:00.08)

gbase> show tables;
+------------------+
| Tables_in_testdb |
+------------------+
| t1               |
| t2               |
| t2_inc           |
| t3_inc           |
| t_101_testdb_tt  |
| t_inc            |
| t_p              |
| t_pid            |
| tidname          |
| tmp2             |
| tmp3             |
| tt               |
| tt2              |
+------------------+
13 rows in set (Elapsed: 00:00:00.00)

在102的testdb库下,也建了一个表。

gbase> create table t_102_testdb_tt(id int);
Query OK, 0 rows affected (Elapsed: 00:00:00.09)

gbase> show tables;
+------------------+
| Tables_in_testdb |
+------------------+
| t1               |
| t2               |
| t2_inc           |
| t3_inc           |
| t_102_testdb_tt  |
| t_inc            |
| t_pid            |
| tidname          |
| tmp2             |
| tmp3             |
| tt               |
| tt2              |
+------------------+
12 rows in set (Elapsed: 00:00:00.00)

测试目标

将102集群的VC(也就是计算资源),合并如101集群集群。

导入前要求和注意事项

由于将导出集群的VC加入到目标集群,所以vc的名字不能和现有目标集群的重复。可以通过命令修改vc名字。

[gbase@localhost ~]$ gcadmin renamevc vcname000001 vcname000002
gcadmin rename vc [vcname000001] to [vcname000002] successful

[gbase@localhost ~]$ 

由于集群统一权限管理,所以被导入集群的一些用户信息,可能会因为重复而丢失。 请导入后,老集群用到的用户名和权限等,及时调整。

编写配置文件

生成配置文件样例

[gbase@gbase_rh7_001 ~]$ gcadmin importvc  e example_vc.xml
gcadmin importvc vc ...
gcadmin importvc vc generate example file:[example_vc.xml] successful

配置文件说明

[gbase@gbase_rh7_001 ~]$ cat example_vc.xml
<?xml version='1.0' encoding="utf-8"?>
<import_vc_parameter>

    <vc_name name="vc name to be imported"/>

    <coordinator_ip ip_list="the imported vc coordinator ip list, splitting by comma"/>
    <gcware_port port="the imported vc coordinator gcware client port, default config is 5919"/>
    <coordinator_os_dba_user_name os_user_name="the imported cluster coordinator os dba user name"/>
    <coordinator_os_dba_password os_password="the imported cluster coordinator os dba user password, write "" if no password"/>

    <imported_vc_db_user_name db_user_name="the imported vc database user name"/>
    <imported_vc_db_password db_password="the imported vc database password, write "" if no password"/>

    <importing_os_dba_user_name os_user_name="the importing cluster coordinator os dba user name"/>
    <importing_os_dba_password os_password="the importing cluster coordinator os dba user password, write "" if no password"/>

    <importing_db_user_name db_user_name="the importing cluster database user name"/>
    <importing_db_password db_password="the importing cluster database password, write "" if no password"/>

    <import_vc_timeout timeout="import vc timeout, unit is minute"/>

中文解释一下

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

    <vc_name name="被导入的VC的名字,默认是vcname000001"/>

    <coordinator_ip ip_list="被导入虚拟集群gcluster调度节点IP列表,逗号分割"/>
    <gcware_port port="被导入集群gcware客户都的端口,默认是5919"/>
    <coordinator_os_dba_user_name os_user_name="被导入集群操作系统用户的用户名"/>
    <coordinator_os_dba_password os_password="被导入集群操作系统用户的密码,无密码的话这里保持空串就行"/>

    <imported_vc_db_user_name db_user_name="被导入集群的数据库用户名"/>
    <imported_vc_db_password db_password="被导入集群的数据库密码,无密码保持空串"/>

    <importing_os_dba_user_name os_user_name="当前执行导入操作的目标集群的操作系统用户名"/>
    <importing_os_dba_password os_password="当前执行导入操作的目标集群的操作系统密码,无密码保持空串"/>

    <importing_db_user_name db_user_name="当前执行导入操作的目标集群的数据库用户名"/>
    <importing_db_password db_password="当前执行导入操作的目标集群的数据库密码,无密码保持空串"/>

    <import_vc_timeout timeout="超时时间,单位是分钟"/>

修改后的配置文件

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

    <vc_name name="vcname000002"/>

    <coordinator_ip ip_list="10.0.2.102"/>
    <gcware_port port="5919"/>
    <coordinator_os_dba_user_name os_user_name="gbase"/>
    <coordinator_os_dba_password os_password="gbase1234"/>

    <imported_vc_db_user_name db_user_name="root"/>
    <imported_vc_db_password db_password=""/>

    <importing_os_dba_user_name os_user_name="gbase"/>
    <importing_os_dba_password os_password="gbase1234"/>

    <importing_db_user_name db_user_name="root"/>
    <importing_db_password db_password=""/>

    <import_vc_timeout timeout="15"/>

</import_vc_parameter>

导入集群操作

导入很顺利,里面的细节就不展开了。

[gbase@gbase_rh7_001 ~]$ gcadmin importvc example_vc.xml
gcadmin importvc vc ...
gcadmin importvc vc parse config file
gcadmin importvc vc [vcname000002] check parameters
gcadmin importvc vc [vcname000002] has 1 distribution
get importing cluster coordinator information and check os password
clear importing and imported cluster coordinator nodes
drop temporary database
gcadmin importvc disable vc [vcname000002] resource plan
gcadmin importvc vc [vcname000002] switch to readonly mode
gcadmin importvc vc [vcname000002] wait write process
gcadmin importvc create importvc directory at all coordinator nodes
gcadmin importvc get vc [vcname000002] databases and tables information, may be consume some times, please wait a moment ...
gcadmin importvc get vc [vcname000002] information
gcadmin importvc switch importing cluster every vc mode to readonly
gcadmin importvc write vc [vcname000002] information to current cluster
gcadmin importvc get vc [vcname000002] nodedatamap
gcadmin importvc insert nodedatamap, may be consume some times, please wait a moment ...
gcadmin importvc create gclusterdb
gcadmin importvc [vcname000002] backup table id, may be consume some times, please wait a moment ...
gcadmin importvc [vcname000002] backup table id done
gcadmin importvc [vcname000002] modify table id, may be consume some times, please wait a moment ...
gcadmin importvc [vcname000002] modify table id done
gcadmin importvc [vcname000002] build metadata packet, may be consume some times, please wait a moment ...
gcadmin importvc [vcname000002] build metadata packet done
gcadmin importvc [vcname000002] copy metadata packet
gcadmin importvc [vcname000002] copy metadata packet done
gcadmin importvc [vcname000002] extract metadata packet
gcadmin importvc [vcname000002] extract metadata packet done

gcadmin importvc remove vc [vcname000002] from coordinator 10.0.2.102
gcadmin importvc restore importing cluster every vc mode

gcadmin import vc [vcname000002] successful
[gbase@gbase_rh7_001 ~]$

导入后的效果

集群gcadmin输出

可以看到调度节点依然是101;虚拟集群出现了,有2个。

[gbase@gbase_rh7_001 ~]$ 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  |
---------------------------------------------
| vcname000001 |       8        |           |
---------------------------------------------
| vcname000002 |       9        |           |
---------------------------------------------

2 virtual cluster: vcname000001, vcname000002
1 coordinator node
0 free data node

[gbase@gbase_rh7_001 ~]$

查看2个集群的构成

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

=============================================
|     GBASE VIRTUAL CLUSTER INFORMATION     |
=============================================
|    VcName    | DistributionId |  comment  |
---------------------------------------------
| vcname000001 |       8        |           |
---------------------------------------------
=========================================================================================================
|                                 VIRTUAL CLUSTER DATA NODE INFORMATION                                 |
=========================================================================================================
| NodeName |                IpAddress                 | DistributionId | gnode | syncserver | DataState |
---------------------------------------------------------------------------------------------------------
|  node1   |                10.0.2.101                |       8        | OPEN  |    OPEN    |     0     |
---------------------------------------------------------------------------------------------------------

1 data node

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

=============================================
|     GBASE VIRTUAL CLUSTER INFORMATION     |
=============================================
|    VcName    | DistributionId |  comment  |
---------------------------------------------
| vcname000002 |       9        |           |
---------------------------------------------
=========================================================================================================
|                                 VIRTUAL CLUSTER DATA NODE INFORMATION                                 |
=========================================================================================================
| NodeName |                IpAddress                 | DistributionId | gnode | syncserver | DataState |
---------------------------------------------------------------------------------------------------------
|  node1   |                10.0.2.102                |       9        | OPEN  |    OPEN    |     0     |
---------------------------------------------------------------------------------------------------------

1 data node

[gbase@gbase_rh7_001 ~]$

查看验证用的数据

[gbase@gbase_rh7_001 ~]$ gccli vcname000001.testdb

GBase client 9.5.2.44.1045e3118. Copyright (c) 2004-2022, GBase.  All Rights Reserved.

gbase> show tables;
+------------------+
| Tables_in_testdb |
+------------------+
| t1               |
| t2               |
| t2_inc           |
| t3_inc           |
| t_101_testdb_tt  |
| t_inc            |
| t_p              |
| t_pid            |
| tidname          |
| tmp2             |
| tmp3             |
| tt               |
| tt2              |
+------------------+
13 rows in set (Elapsed: 00:00:00.00)

gbase> ^CAborted
[gbase@gbase_rh7_001 ~]$ gccli vcname000002.testdb

GBase client 9.5.2.44.1045e3118. Copyright (c) 2004-2022, GBase.  All Rights Reserved.

gbase> show tables;
+------------------+
| Tables_in_testdb |
+------------------+
| t1               |
| t2               |
| t2_inc           |
| t3_inc           |
| t_102_testdb_tt  |
| t_inc            |
| t_pid            |
| tidname          |
| tmp2             |
| tmp3             |
| tt               |
| tt2              |
+------------------+
12 rows in set (Elapsed: 00:00:00.00)

关于不同用户,自动使用默认VC的事情,请参考 GBase 8a V95设置更改数据库用户默认VC的方法