GBase 8a V95版本删除VC的操作手顺

GBase 8a V95版本支持虚拟集群(Virtual Cluster 简称VC)来实现多租户的资源隔离。当某个租户所在VC不再需要时,可以通过删除VC来释放资源,之后再考虑扩容到其它VC。本文介绍删除VC的操作方法。

整体步骤介绍

1、删除VC下所有的数据库对象

包括库、表、视图、存储过程、自定义函数、用户创建event,资源管理配置等;

2、删除nodedatamap中的对应distribution信息

refresh nodedatamap drop [distribution_id]

3、删除分布策略

gcadmin rmdistribution [ID] vc [vc_name]


4、删除VC

gcadmin rmvc [vc_name]


5、卸载集群软件,将vc中的实例节点从freenode中删除

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


节点将被完全删除确认节点信息

6、删除软件后的节点在新集群中重新安装

环境

集群结构

5节点集群,其中4个计算节点分成2个VC,每个VC里2个。复用3个计算节点做调度管理节点。148为备用的自由节点freenode。

IP调度管理VC计算
192.168.56.144Yvc1Y
192.168.56.145vc1Y
192.168.56.146Yvc2Y
192.168.56.147Yvc2Y
192.168.56.148

整体

gbase@suse12node1:~> gcadmin
CLUSTER STATE:         ACTIVE

=================================================================
|             GBASE COORDINATOR CLUSTER INFORMATION             |
=================================================================
|   NodeName   |   IpAddress    | gcware | gcluster | DataState |
-----------------------------------------------------------------
| coordinator1 | 192.168.56.144 |  OPEN  |   OPEN   |     0     |
-----------------------------------------------------------------
| coordinator2 | 192.168.56.146 |  OPEN  |   OPEN   |     0     |
-----------------------------------------------------------------
| coordinator3 | 192.168.56.147 |  OPEN  |   OPEN   |     0     |
-----------------------------------------------------------------
===============================================
|      GBASE VIRTUAL CLUSTER INFORMATION      |
===============================================
|    VcName    | DistributionId |   comment   |
-----------------------------------------------
|     vc1      |       1        | vc1 comment |
-----------------------------------------------
|     vc2      |       2        | vc2 comment |
-----------------------------------------------
===============================================================
|          GBASE CLUSTER FREE DATA NODE INFORMATION           |
===============================================================
| NodeName  |   IpAddress    | gnode | syncserver | DataState |
---------------------------------------------------------------
| FreeNode1 | 192.168.56.148 | OPEN  |    OPEN    |     0     |
---------------------------------------------------------------

2 virtual cluster: vc1, vc2
3 coordinator node
1 free data node

gbase@suse12node1:~> gccli -uroot

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

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

VC1

gbase@suse12node1:~> gcadmin showdistribution vc vc1

                                 Distribution ID: 1 | State: new | Total segment num: 2

             Primary Segment Node IP                   Segment ID                 Duplicate Segment node IP
========================================================================================================================
|                 192.168.56.144                 |         1          |                 192.168.56.145                 |
------------------------------------------------------------------------------------------------------------------------
|                 192.168.56.145                 |         2          |                 192.168.56.144                 |
========================================================================================================================


2 data node
gbase@suse12node1:~> gcadmin showdistribution vc vc1

                                 Distribution ID: 1 | State: new | Total segment num: 2

             Primary Segment Node IP                   Segment ID                 Duplicate Segment node IP
========================================================================================================================
|                 192.168.56.144                 |         1          |                 192.168.56.145                 |
------------------------------------------------------------------------------------------------------------------------
|                 192.168.56.145                 |         2          |                 192.168.56.144                 |
========================================================================================================================


2 data node

VC2

gbase@suse12node1:~> gcadmin showcluster vc vc2
CLUSTER STATE:         ACTIVE
VIRTUAL CLUSTER MODE:  NORMAL

===============================================
|      GBASE VIRTUAL CLUSTER INFORMATION      |
===============================================
|    VcName    | DistributionId |   comment   |
-----------------------------------------------
|     vc2      |       2        | vc2 comment |
-----------------------------------------------
=========================================================================================================
|                                 VIRTUAL CLUSTER DATA NODE INFORMATION                                 |
=========================================================================================================
| NodeName |                IpAddress                 | DistributionId | gnode | syncserver | DataState |
---------------------------------------------------------------------------------------------------------
|  node1   |              192.168.56.146              |       2        | OPEN  |    OPEN    |     0     |
---------------------------------------------------------------------------------------------------------
|  node2   |              192.168.56.147              |       2        | OPEN  |    OPEN    |     0     |
---------------------------------------------------------------------------------------------------------

2 data node

gbase@suse12node1:~> gcadmin showdistribution vc vc1

                                 Distribution ID: 1 | State: new | Total segment num: 2

             Primary Segment Node IP                   Segment ID                 Duplicate Segment node IP
========================================================================================================================
|                 192.168.56.144                 |         1          |                 192.168.56.145                 |
------------------------------------------------------------------------------------------------------------------------
|                 192.168.56.145                 |         2          |                 192.168.56.144                 |
========================================================================================================================

查看VC2的数据库内对象

此步主要是获得用户库的数据列表,同时确认不再需要备份。

用户库

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

gbase> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| performance_schema |
| gbase              |
| gctmpdb            |
| db2                |
| gclusterdb         |
+--------------------+
6 rows in set (Elapsed: 00:00:00.29)

库内的表

挨个库的查看,确认都不需要了。

gbase> show full tables from db2;
+---------------+------------+
| Tables_in_db2 | Table_type |
+---------------+------------+
| t2            | BASE TABLE |
| v_t2          | VIEW       |
+---------------+------------+
2 rows in set (Elapsed: 00:00:00.00)

查看分布策略使用的表数量

gbase> select count(*) from gbase.table_distribution where data_distribution_id = 2 and vc_id = 'vc00002';
+----------+
| count(*) |
+----------+
|        4 |
+----------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select dbName,tbName from gbase.table_distribution where data_distribution_id = 2 and vc_id = 'vc00002';
+------------+--------------------+
| dbName     | tbName             |
+------------+--------------------+
| gclusterdb | rebalancing_status |
| gclusterdb | dual               |
| db2        | t2                 |
| db2        | v_t2               |
+------------+--------------------+
4 rows in set (Elapsed: 00:00:00.00)

检查存储过程和自定义函数对象

gbase> select count(*) from information_schema.ROUTINES where ROUTINE_VC = 'vc2' and ROUTINE_SCHEMA = 'db2';
+----------+
| count(*) |
+----------+
|        2 |
+----------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select ROUTINE_NAME,ROUTINE_TYPE from information_schema.ROUTINES where ROUTINE_VC = 'vc2' and ROUTINE_SCHEMA = 'db2';
+------------------------------------------------------------------+--------------+
| ROUTINE_NAME                                                     | ROUTINE_TYPE |
+------------------------------------------------------------------+--------------+
| hello                                                            | FUNCTION     |
| hello_world                                                      | PROCEDURE    |
+------------------------------------------------------------------+--------------+
2 rows in set (Elapsed: 00:00:00.00)

删除vc2下所有数据库对象

一旦操作,除非有备份,负责数据库自身无法恢复。

gbase> drop table t2;
Query OK, 0 rows affected (Elapsed: 00:00:00.21)

gbase> drop view v_t2;
Query OK, 0 rows affected (Elapsed: 00:00:00.41)

gbase> drop procedure if exists hello_world;
Query OK, 0 rows affected (Elapsed: 00:00:00.03)

gbase> drop function if exists hello;
Query OK, 0 rows affected, 2 warnings (Elapsed: 00:00:00.02)

gbase> drop database db2;
Query OK, 0 rows affected (Elapsed: 00:00:00.15)

删除nodedatamap

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

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

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

gbase> select count(*) from gbase.nodedatamap where data_distribution_id = 2;
+----------+
| count(*) |
+----------+
|        0 |
+----------+
1 row in set (Elapsed: 00:00:00.02)

删除vc2 distribution分布策略信息

gbase@suse12node1:~> gcadmin showdistribution vc vc2;

                                 Distribution ID: 2 | State: new | Total segment num: 2

             Primary Segment Node IP                   Segment ID                 Duplicate Segment node IP
========================================================================================================================
|                 192.168.56.146                 |         1          |                 192.168.56.147                 |
------------------------------------------------------------------------------------------------------------------------
|                 192.168.56.147                 |         2          |                 192.168.56.146                 |
========================================================================================================================


gbase@suse12node1:~> gcadmin rmdistribution 2 vc vc2;
distribution: id [2] is current distribution
it will be removed now
please ensure this is ok, input [Y,y] or [N,n]: Y
gcadmin remove distribution [2] success

删除vc2

gbase@suse12node1:~> gcadmin rmvc vc2
check cluster mode ...
check vc [vc2] exist ...

vc [vc2] will be removed
please ensure this is ok, input [Y,y] or [N,n]: Y
gcadmin rmvc vc2 successful

查看删除后的结果

删除vc2后vc2节点进入freenode中


gbase@suse12node1:~> gcadmin
CLUSTER STATE:         ACTIVE

=================================================================
|             GBASE COORDINATOR CLUSTER INFORMATION             |
=================================================================
|   NodeName   |   IpAddress    | gcware | gcluster | DataState |
-----------------------------------------------------------------
| coordinator1 | 192.168.56.144 |  OPEN  |   OPEN   |     0     |
-----------------------------------------------------------------
| coordinator2 | 192.168.56.146 |  OPEN  |   OPEN   |     0     |
-----------------------------------------------------------------
| coordinator3 | 192.168.56.147 |  OPEN  |   OPEN   |     0     |
-----------------------------------------------------------------
===============================================
|      GBASE VIRTUAL CLUSTER INFORMATION      |
===============================================
|    VcName    | DistributionId |   comment   |
-----------------------------------------------
|     vc1      |       1        | vc1 comment |
-----------------------------------------------
===============================================================
|          GBASE CLUSTER FREE DATA NODE INFORMATION           |
===============================================================
| NodeName  |   IpAddress    | gnode | syncserver | DataState |
---------------------------------------------------------------
| FreeNode1 | 192.168.56.148 | OPEN  |    OPEN    |     0     |
---------------------------------------------------------------
| FreeNode2 | 192.168.56.146 | OPEN  |    OPEN    |     0     |
---------------------------------------------------------------
| FreeNode3 | 192.168.56.147 | OPEN  |    OPEN    |     0     |
---------------------------------------------------------------

1 virtual cluster: vc1
3 coordinator node
3 free data node

决策是删除节点、备用还是扩容其它VC

freenode可用于扩容其它VC,如果该节点所在服务器硬件确实要回收,则可以继续后面步骤,否则操作到此就算完成了。

从集群移除节点

删除软件将146和147节点从集群中回收回来

编辑xml文件

gbase@suse12node1:/opt/gcinstall> cat gcChangeInfo_rmnodes.xml 
<?xml version="1.0" encoding="utf-8"?>
<servers>
 <rack>
  <node ip="192.168.56.146"/>
  <node ip="192.168.56.147"/>
 </rack>
</servers>

移除节点

gbase@suse12node1:/opt/gcinstall> gcadmin rmnodes gcChangeInfo_rmnodes.xml 
gcadmin remove nodes ...

flush statemachine success

gcadmin rmnodes from cluster success

查看效果

freenodes中已经没有了146和147两个节点


gbase@suse12node1:/opt/gcinstall> gcadmin
CLUSTER STATE:         ACTIVE

=================================================================
|             GBASE COORDINATOR CLUSTER INFORMATION             |
=================================================================
|   NodeName   |   IpAddress    | gcware | gcluster | DataState |
-----------------------------------------------------------------
| coordinator1 | 192.168.56.144 |  OPEN  |   OPEN   |     0     |
-----------------------------------------------------------------
| coordinator2 | 192.168.56.146 |  OPEN  |   OPEN   |     0     |
-----------------------------------------------------------------
| coordinator3 | 192.168.56.147 |  OPEN  |   OPEN   |     0     |
-----------------------------------------------------------------
===============================================
|      GBASE VIRTUAL CLUSTER INFORMATION      |
===============================================
|    VcName    | DistributionId |   comment   |
-----------------------------------------------
|     vc1      |       1        | vc1 comment |
-----------------------------------------------
===============================================================
|          GBASE CLUSTER FREE DATA NODE INFORMATION           |
===============================================================
| NodeName  |   IpAddress    | gnode | syncserver | DataState |
---------------------------------------------------------------
| FreeNode1 | 192.168.56.148 | OPEN  |    OPEN    |     0     |
---------------------------------------------------------------

1 virtual cluster: vc1
3 coordinator node
1 free data node

删除gbase软件

停止146和147节点gbase服务

--------- 192.168.56.146---------
Stopping GCMonit success!
Stopping gcrecover :                                       [  OK  ]
Stopping gcluster :                                        [  OK  ]
Stopping gcware :                                          [  OK  ]
Stopping gbase :                                           [  OK  ]
Stopping syncserver :                                      [  OK  ]
--------- 192.168.56.147---------
Stopping GCMonit success!
Stopping gcrecover :                                       [  OK  ]
Stopping gcluster :                                        [  OK  ]
Stopping gcware :                                          [  OK  ]
Stopping gbase :                                           [  OK  ]
Stopping syncserver :                                      [  OK  ]

卸载配置文件

gbase@suse12node1:/opt/gcinstall> cat demo.options
installPrefix= /opt/mppdata
#coordinateHost = 192.168.56.144,192.168.56.146,192.168.56.147
#coordinateHostNodeID = 144,146,147
dataHost = 192.168.56.146,192.168.56.147
#existCoordinateHost =
#existDataHost =
dbaUser = gbase
dbaGroup = gbase
dbaPwd = 'gbase'
rootPwd = ''
#rootPwdFile = rootPwd.json
characterSet = gbk

卸载146和147上的软件

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

重启集群

卸载成功后执行gcadmin会卡住,需要重启整个集群。

针对具体的集群版本,该步骤是否必须,请和GBase支持人员联系确认。

最终效果

gbase@suse12node1:/opt/gcinstall> gcadmin
CLUSTER STATE:         ACTIVE

=================================================================
|             GBASE COORDINATOR CLUSTER INFORMATION             |
=================================================================
|   NodeName   |   IpAddress    | gcware | gcluster | DataState |
-----------------------------------------------------------------
| coordinator1 | 192.168.56.144 |  OPEN  |   OPEN   |     0     |
-----------------------------------------------------------------
| coordinator2 | 192.168.56.146 |  OPEN  |   OPEN   |     0     |
-----------------------------------------------------------------
| coordinator3 | 192.168.56.147 |  OPEN  |   OPEN   |     0     |
-----------------------------------------------------------------
===============================================
|      GBASE VIRTUAL CLUSTER INFORMATION      |
===============================================
|    VcName    | DistributionId |   comment   |
-----------------------------------------------
|     vc1      |       1        | vc1 comment |
-----------------------------------------------
===============================================================
|          GBASE CLUSTER FREE DATA NODE INFORMATION           |
===============================================================
| NodeName  |   IpAddress    | gnode | syncserver | DataState |
---------------------------------------------------------------
| FreeNode1 | 192.168.56.148 | OPEN  |    OPEN    |     0     |
---------------------------------------------------------------

1 virtual cluster: vc1
3 coordinator node
1 free data node