一、集群服务管理
- ① 查看集群状态
[gbase@node173 ~]$gcadmin
CLUSTER STATE: ACTIVE
VIRTUAL CLUSTER MODE: NORMAL
===============================================================
| GBASE COORDINATOR CLUSTER INFORMATION |
===============================================================
| NodeName | IpAddress | gcware | gcluster | DataState |
---------------------------------------------------------------
| coordinator1 | 172.16.9.173 | OPEN | OPEN | 0 |
---------------------------------------------------------------
| coordinator2 | 172.16.9.174 | OPEN | OPEN | 0 |
---------------------------------------------------------------
| coordinator3 | 172.16.9.175 | OPEN | OPEN | 0 |
---------------------------------------------------------------
============================================================================
| GBASE DATA CLUSTER INFORMATION |
============================================================================
| NodeName | IpAddress | DistributionId | gnode | syncserver | DataState |
----------------------------------------------------------------------------
| node1 | 172.16.9.173 | 1 | OPEN | OPEN | 0 |
----------------------------------------------------------------------------
| node2 | 172.16.9.174 | 1 | OPEN | OPEN | 0 |
----------------------------------------------------------------------------
| node3 | 172.16.9.175 | 1 | OPEN | OPEN | 0 |
----------------------------------------------------------------------------
- ② 查看集群服务
[gbase@node173 ~]$gcluster_services all info
gcware is running
gcluster is running
gcrecover is running
gbase is running
syncserver is running
③ 停止集群服务
[gbase@node173 ~]$ gcluster_services all stop
Stopping GCMonit success!
Stopping gcrecover : [ OK ]
Stopping gcluster : [ OK ]
Stopping gcware : [ OK ]
Stopping gbase : [ OK ]
Stopping syncserver : [ OK ]
在另一个节点上使用gcadmin查看集群状态
[gbase@node174 ~]$ gcadmin
CLUSTER STATE: ACTIVE
VIRTUAL CLUSTER MODE: NORMAL
===============================================================
| GBASE COORDINATOR CLUSTER INFORMATION |
===============================================================
| NodeName | IpAddress | gcware | gcluster | DataState |
---------------------------------------------------------------
| coordinator1 | 172.16.9.173 | CLOSE | CLOSE | 0 |
---------------------------------------------------------------
| coordinator2 | 172.16.9.174 | OPEN | OPEN | 0 |
---------------------------------------------------------------
| coordinator3 | 172.16.9.175 | OPEN | OPEN | 0 |
---------------------------------------------------------------
============================================================================
| GBASE DATA CLUSTER INFORMATION |
============================================================================
| NodeName | IpAddress | DistributionId | gnode | syncserver | DataState |
----------------------------------------------------------------------------
| node1 | 172.16.9.173 | 1 | CLOSE | CLOSE | 0 |
----------------------------------------------------------------------------
| node2 | 172.16.9.174 | 1 | OPEN | OPEN | 0 |
----------------------------------------------------------------------------
| node3 | 172.16.9.175 | 1 | OPEN | OPEN | 0 |
----------------------------------------------------------------------------
开启管理节点所有集群服务
[gbase@node173 ~]$ gcluster_services all start
Starting gcware : [ OK ]
Starting gcluster : [ OK ]
Starting gcrecover : [ OK ]
Starting gbase : [ OK ]
Starting syncserver : [ OK ]
Starting GCMonit success!
集群状态恢复正常。
CLUSTER STATE: ACTIVE
VIRTUAL CLUSTER MODE: NORMAL
===============================================================
| GBASE COORDINATOR CLUSTER INFORMATION |
===============================================================
| NodeName | IpAddress | gcware | gcluster | DataState |
---------------------------------------------------------------
| coordinator1 | 172.16.9.173 | OPEN | OPEN | 0 |
---------------------------------------------------------------
| coordinator2 | 172.16.9.174 | OPEN | OPEN | 0 |
---------------------------------------------------------------
| coordinator3 | 172.16.9.175 | OPEN | OPEN | 0 |
---------------------------------------------------------------
============================================================================
| GBASE DATA CLUSTER INFORMATION |
============================================================================
| NodeName | IpAddress | DistributionId | gnode | syncserver | DataState |
----------------------------------------------------------------------------
| node1 | 172.16.9.173 | 1 | OPEN | OPEN | 0 |
----------------------------------------------------------------------------
| node2 | 172.16.9.174 | 1 | OPEN | OPEN | 0 |
---------------------------------------------------------------------------------------------------------
| node3 | 172.16.9.175 | 1 | OPEN | OPEN | 0 |
----------------------------------------------------------------------------
关闭数据节点集群服务
[gbase@node175 ~]$ gcluster_services all stop
Stopping GCMonit success!
Stopping gbase : [ OK ]
Stopping syncserver : [ OK ]
CLUSTER STATE: ACTIVE
VIRTUAL CLUSTER MODE: NORMAL
===============================================================
| GBASE COORDINATOR CLUSTER INFORMATION |
===============================================================
| NodeName | IpAddress | gcware | gcluster | DataState |
---------------------------------------------------------------
| coordinator1 | 172.16.9.173 | OPEN | OPEN | 0 |
---------------------------------------------------------------
| coordinator2 | 172.16.9.174 | OPEN | OPEN | 0 |
---------------------------------------------------------------
| coordinator3 | 172.16.9.175 | CLOSE | CLOSE | 0 |
---------------------------------------------------------------
============================================================================
| GBASE DATA CLUSTER INFORMATION |
============================================================================
| NodeName | IpAddress | DistributionId | gnode | syncserver | DataState |
----------------------------------------------------------------------------
| node1 | 172.16.9.173 | 1 | OPEN | OPEN | 0 |
----------------------------------------------------------------------------
| node2 | 172.16.9.174 | 1 | OPEN | OPEN | 0 |
----------------------------------------------------------------------------
| node3 | 172.16.9.175 | 1 | CLOSE | CLOSE | 0 |
----------------------------------------------------------------------------
注:仔细查看每次gcadmin显示出的集群状态
④ 恢复一个服务进程
[gbase@node175 ~]$ gcluster_services gbase start
Starting gbase : [ OK ]
CLUSTER STATE: ACTIVE
VIRTUAL CLUSTER MODE: NORMAL
===============================================================
| GBASE COORDINATOR CLUSTER INFORMATION |
===============================================================
| NodeName | IpAddress | gcware | gcluster | DataState |
---------------------------------------------------------------
| coordinator1 | 172.16.9.173 | OPEN | OPEN | 0 |
---------------------------------------------------------------
| coordinator2 | 172.16.9.174 | OPEN | OPEN | 0 |
---------------------------------------------------------------
| coordinator3 | 172.16.9.175 | CLOSE | CLOSE | 0 |
---------------------------------------------------------------
=========================================================================================================
| GBASE DATA CLUSTER INFORMATION |
=========================================================================================================
| NodeName | IpAddress | DistributionId | gnode | syncserver | DataState |
---------------------------------------------------------------------------------------------------------
| node1 | 172.16.9.173 | 1 | OPEN | OPEN | 0 |
---------------------------------------------------------------------------------------------------------
| node2 | 172.16.9.174 | 1 | OPEN | OPEN | 0 |
---------------------------------------------------------------------------------------------------------
| node3 | 172.16.9.175 | 1 | OPEN | CLOSE | 0 |
---------------------------------------------------------------------------------------------------------
⑤ 恢复另一个服务进程
[gbase@node175 ~]$ gcluster_services syncserver start
Starting gbase : [ OK ]
CLUSTER STATE: ACTIVE
VIRTUAL CLUSTER MODE: NORMAL
===============================================================
| GBASE COORDINATOR CLUSTER INFORMATION |
===============================================================
| NodeName | IpAddress | gcware | gcluster | DataState |
---------------------------------------------------------------
| coordinator1 | 172.16.9.173 | OPEN | OPEN | 0 |
---------------------------------------------------------------
| coordinator2 | 172.16.9.174 | OPEN | OPEN | 0 |
---------------------------------------------------------------
| coordinator3 | 172.16.9.175 | CLOSE | CLOSE | 0 |
---------------------------------------------------------------
=========================================================================================================
| GBASE DATA CLUSTER INFORMATION |
=========================================================================================================
| NodeName | IpAddress | DistributionId | gnode | syncserver | DataState |
---------------------------------------------------------------------------------------------------------
| node1 | 172.16.9.173 | 1 | OPEN | OPEN | 0 |
---------------------------------------------------------------------------------------------------------
| node2 | 172.16.9.174 | 1 | OPEN | OPEN | 0 |
---------------------------------------------------------------------------------------------------------
| node3 | 172.16.9.175 | 1 | OPEN | OPEN | 0 |
---------------------------------------------------------------------------------------------------------
注:此时并没有恢复GCMonit进程。所以,进程异常关闭,不会自动拉起。
再此操作syncserver进程关闭:
[gbase@node175 ~]$ gcluster_services syncserver stop
CLUSTER STATE: ACTIVE
VIRTUAL CLUSTER MODE: NORMAL
===============================================================
| GBASE COORDINATOR CLUSTER INFORMATION |
===============================================================
| NodeName | IpAddress | gcware | gcluster | DataState |
---------------------------------------------------------------
| coordinator1 | 172.16.9.173 | OPEN | OPEN | 0 |
---------------------------------------------------------------
| coordinator2 | 172.16.9.174 | OPEN | OPEN | 0 |
---------------------------------------------------------------
| coordinator3 | 172.16.9.175 | CLOSE | CLOSE | 0 |
---------------------------------------------------------------
=========================================================================================================
| GBASE DATA CLUSTER INFORMATION |
=========================================================================================================
| NodeName | IpAddress | DistributionId | gnode | syncserver | DataState |
---------------------------------------------------------------------------------------------------------
| node1 | 172.16.9.173 | 1 | OPEN | OPEN | 0 |
---------------------------------------------------------------------------------------------------------
| node2 | 172.16.9.174 | 1 | OPEN | OPEN | 0 |
---------------------------------------------------------------------------------------------------------
| node3 | 172.16.9.175 | 1 | OPEN | CLOSE | 0 |
---------------------------------------------------------------------------------------------------------
⑥开启gcmonit 工具
[gbase@node175 ~]$ gcmonit --start
Starting gcmonit success!
Starting syncserver : [ OK ]
Starting gcmmonit success!
CLUSTER STATE: ACTIVE
VIRTUAL CLUSTER MODE: NORMAL
===============================================================
| GBASE COORDINATOR CLUSTER INFORMATION |
===============================================================
| NodeName | IpAddress | gcware | gcluster | DataState |
---------------------------------------------------------------
| coordinator1 | 172.16.9.173 | OPEN | OPEN | 0 |
---------------------------------------------------------------
| coordinator2 | 172.16.9.174 | OPEN | OPEN | 0 |
---------------------------------------------------------------
| coordinator3 | 172.16.9.175 | OPEN | OPEN | 0 |
---------------------------------------------------------------
=========================================================================================================
| GBASE DATA CLUSTER INFORMATION |
=========================================================================================================
| NodeName | IpAddress | DistributionId | gnode | syncserver | DataState |
---------------------------------------------------------------------------------------------------------
| node1 | 172.16.9.173 | 1 | OPEN | OPEN | 0 |
---------------------------------------------------------------------------------------------------------
| node2 | 172.16.9.174 | 1 | OPEN | OPEN | 0 |
---------------------------------------------------------------------------------------------------------
| node3 | 172.16.9.175 | 1 | OPEN | OPEN | 0 |
---------------------------------------------------------------------------------------------------------
注:GCMonit开启后,异常关闭的进程会自动拉起。
二、集群模式
① 修改管理节点 173 集群模式为只读
[gbase@node173 ~]$ gcadmin switchmode readonly
========== switch cluster mode...
switch pre mode: [NORMAL]
switch mode to [READONLY]
switch after mode: [READONLY]
[gbase@node173 ~]$ gcadmin
CLUSTER STATE: ACTIVE
VIRTUAL CLUSTER MODE: READONLY
===============================================================
| GBASE COORDINATOR CLUSTER INFORMATION |
===============================================================
| NodeName | IpAddress | gcware | gcluster | DataState |
---------------------------------------------------------------
| coordinator1 | 172.16.9.173 | OPEN | OPEN | 0 |
---------------------------------------------------------------
| coordinator2 | 172.16.9.174 | OPEN | OPEN | 0 |
---------------------------------------------------------------
| coordinator3 | 172.16.9.175 | OPEN | OPEN | 0 |
---------------------------------------------------------------
============================================================================
| GBASE DATA CLUSTER INFORMATION |
============================================================================
| NodeName | IpAddress | DistributionId | gnode | syncserver | DataState |
----------------------------------------------------------------------------
| node1 | 172.16.9.173 | 1 | OPEN | OPEN | 0 |
----------------------------------------------------------------------------
| node2 | 172.16.9.174 | 1 | OPEN | OPEN | 0 |
----------------------------------------------------------------------------
| node3 | 172.16.9.175 | 1 | OPEN | OPEN | 0 |
----------------------------------------------------------------------------
②此时尝试对数据库写操作
[gbase@node173 ~]$ gccli
GBase client 9.5.2.35.125594. Copyright (c) 2004-2021, GBase. All Rights Reserved.
gbase> create database testdb;
由于集群处于readonly模式,该SQL的执行被阻塞。
③在管理节点 174 切换集群模式为normal:
[gbase@node174 ~]$ gcadmin switchmode normal
========== switch cluster mode...
switch pre mode: [READONLY]
switch mode to [NORMAL]
switch after mode: [NORMAL]
等待大约 5 分钟,173 阻塞的SQL命令会继续执行,无需人为干预。其执行结果如下:
Query OK, 1 row affected (Elapsed: 00:05:00.16)
④验证testdb库创建是否成功:
gbase> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| performance_schema |
| gbase |
| gctmpdb |
| gclusterdb |
| testdb |
+--------------------+
6 rows in set (Elapsed: 00:00:00.01)
⑤修改集群模式为recovery
[gbase@node173 ~]$ gcadmin switchmode recovery
========== switch cluster mode...
switch pre mode: [NORMAL]
switch mode to [RECOVERY]
switch after mode: [RECOVERY]
[gbase@node173 ~]$ gcadmin
CLUSTER STATE: ACTIVE
VIRTUAL CLUSTER MODE: RECOVERY
===============================================================
| GBASE COORDINATOR CLUSTER INFORMATION |
===============================================================
| NodeName | IpAddress | gcware | gcluster | DataState |
---------------------------------------------------------------
| coordinator1 | 172.16.9.173 | OPEN | OPEN | 0 |
---------------------------------------------------------------
| coordinator2 | 172.16.9.174 | OPEN | OPEN | 0 |
---------------------------------------------------------------
| coordinator3 | 172.16.9.175 | OPEN | OPEN | 0 |
---------------------------------------------------------------
============================================================================
| GBASE DATA CLUSTER INFORMATION |
============================================================================
| NodeName | IpAddress | DistributionId | gnode | syncserver | DataState |
----------------------------------------------------------------------------
| node1 | 172.16.9.173 | 1 | OPEN | OPEN | 0 |
----------------------------------------------------------------------------
| node2 | 172.16.9.174 | 1 | OPEN | OPEN | 0 |
----------------------------------------------------------------------------
| node3 | 172.16.9.175 | 1 | OPEN | OPEN | 0 |
----------------------------------------------------------------------------
[gbase@node173 ~]$ gccli
GBase client 9.5.2.35.125594. Copyright (c) 2004-2021, GBase. All Rights Reserved.
gbase>use testdb;
gbase>select database();
ERROR 1707 (HY000): gcluster command error: (GBA-02CO-0002) Currently,gcluster is at recovery mode,current operation isn't allowed.
[gbase@node173 ~]$ gcadmin switchmode normal
========== switch cluster mode...
switch pre mode: [RECOVERY]
switch mode to [NORMAL]
switch after mode: [NORMAL]
[gbase@node173 ~]$ gcadmin
CLUSTER STATE: ACTIVE
VIRTUAL CLUSTER MODE: NORMAL
===============================================================
| GBASE COORDINATOR CLUSTER INFORMATION |
===============================================================
| NodeName | IpAddress | gcware | gcluster | DataState |
---------------------------------------------------------------
| coordinator1 | 172.16.9.173 | OPEN | OPEN | 0 |
---------------------------------------------------------------
| coordinator2 | 172.16.9.174 | OPEN | OPEN | 0 |
---------------------------------------------------------------
| coordinator3 | 172.16.9.175 | OPEN | OPEN | 0 |
---------------------------------------------------------------
=========================================================================================================
| GBASE DATA CLUSTER INFORMATION |
=========================================================================================================
| NodeName | IpAddress | DistributionId | gnode | syncserver | DataState |
---------------------------------------------------------------------------------------------------------
| node1 | 172.16.9.173 | 1 | OPEN | OPEN | 0 |
---------------------------------------------------------------------------------------------------------
| node2 | 172.16.9.174 | 1 | OPEN | OPEN | 0 |
---------------------------------------------------------------------------------------------------------
| node3 | 172.16.9.175 | 1 | OPEN | OPEN | 0 |
---------------------------------------------------------------------------------------------------------
[gbase@node173 ~]$ gccli
GBase client 9.5.2.35.125594. Copyright (c) 2004-2021, GBase. All Rights Reserved.
gbase>use testdb;
gbase>select database();
+------------+
| database() |
+------------+
| testdb |
+------------+
1 row in set (Elapsed: 00:00:00.00)
三、集群日志
- 关闭一个节点的所有集群服务
[gbase@node175 ~]$gcluster_services all stop
Stopping GCMonit success!
Stopping gbase : [ OK ]
Stopping syncserver : [ OK ]
在管理节点查看集群状态
CLUSTER STATE: ACTIVE
VIRTUAL CLUSTER MODE: NORMAL
===============================================================
| GBASE COORDINATOR CLUSTER INFORMATION |
===============================================================
| NodeName | IpAddress | gcware | gcluster | DataState |
---------------------------------------------------------------
| coordinator1 | 172.16.9.173 | OPEN | OPEN | 0 |
---------------------------------------------------------------
| coordinator2 | 172.16.9.174 | OPEN | OPEN | 0 |
---------------------------------------------------------------
| coordinator3 | 172.16.9.175 | CLOSE | CLOSE | 0 |
---------------------------------------------------------------
=========================================================================================================
| GBASE DATA CLUSTER INFORMATION |
=========================================================================================================
| NodeName | IpAddress | DistributionId | gnode | syncserver | DataState |
---------------------------------------------------------------------------------------------------------
| node1 | 172.16.9.173 | 1 | OPEN | OPEN | 0 |
---------------------------------------------------------------------------------------------------------
| node2 | 172.16.9.174 | 1 | OPEN | OPEN | 0 |
---------------------------------------------------------------------------------------------------------
| node3 | 172.16.9.175 | 1 | CLOSE | CLOSE | 0 |
---------------------------------------------------------------------------------------------------------
①DDLevent日志
- 删除用户库:
gbase>drop database testdb;
Query OK, 0 rows affected (Elapsed: 00:00:00.11)
- 查看集群状态:
CLUSTER STATE: ACTIVE
VIRTUAL CLUSTER MODE: NORMAL
===============================================================
| GBASE COORDINATOR CLUSTER INFORMATION |
===============================================================
| NodeName | IpAddress | gcware | gcluster | DataState |
---------------------------------------------------------------
| coordinator1 | 172.16.9.173 | OPEN | OPEN | 0 |
---------------------------------------------------------------
| coordinator2 | 172.16.9.174 | OPEN | OPEN | 0 |
---------------------------------------------------------------
| coordinator3 | 172.16.9.175 | CLOSE | CLOSE | 1 |
---------------------------------------------------------------
============================================================================
| GBASE DATA CLUSTER INFORMATION |
============================================================================
| NodeName | IpAddress | DistributionId | gnode | syncserver | DataState |
----------------------------------------------------------------------------
| node1 | 172.16.9.173 | 1 | OPEN | OPEN | 0 |
----------------------------------------------------------------------------
| node2 | 172.16.9.174 | 1 | OPEN | OPEN | 0 |
----------------------------------------------------------------------------
| node3 | 172.16.9.175 | 1 | CLOSE | CLOSE | 1 |
----------------------------------------------------------------------------
- 查看DDLevent日志:
[gbase@node174 ~]$ gcadminshowddlevent
Vc event count:1
Event ID: 2
ObjectName: testdb
Fail Node Copy:
------------------------------------------------------
Fail Data Copy:
------------------------------------------------------
NodeIP: 172.16.9.175 FAILURE
- 创建一个新库:
gbase>create database testdb1;
- 在新库内创建一张新表:
gbase>create table student( sno varchar(20),sname varchar(20),ssex varchar(3),sage int(4),sdept varchar(20));
- 插入数据:
gbase> insert into student values (‘200215121’,‘liyong’,‘F’,20,‘CS’); - 查看DDLevent日志:
[gbase@node174 ~]$gcadmin showddlevent
Vc event count:4
Event ID: 2
ObjectName: testdb
Fail Node Copy:
------------------------------------------------------
NodeID: 3037270188 NodeIP:172.16.9.175 FAILURE
Fail Data Copy:
------------------------------------------------------
NodeIP: 172.16.9.175 FAILURE
Event ID: 3
ObjectName: testdb1
Fail Node Copy:
------------------------------------------------------
NodeID: 3037270188 NodeIP:172.16.9.175 FAILURE
Fail Data Copy:
------------------------------------------------------
NodeIP: 172.16.9.175 FAILURE
Event ID: 5
ObjectName: testdb1.student
Fail Node Copy:
------------------------------------------------------
NodeID: 3037270188 NodeIP:172.16.9.175 FAILURE
Fail Data Copy:
------------------------------------------------------
SegName: n1 NodeIP: 172.16.9.175 FAILURE
SegName: n5 NodeIP: 172.16.9.175 FAILURE
SegName: n4 NodeIP: 172.16.9.175 FAILURE
SegName: n7 NodeIP: 172.16.9.175 FAILURE
Event ID: 6
ObjectName: testdb1.student
Fail Node Copy:
------------------------------------------------------
NodeID: 3037270188 NodeIP:172.16.9.175 FAILURE
Fail Data Copy:
------------------------------------------------------
SegName: n1 NodeIP: 172.16.9.175 FAILURE
SegName: n5 NodeIP: 172.16.9.175 FAILURE
SegName: n4 NodeIP: 172.16.9.175 FAILURE
SegName: n7 NodeIP: 172.16.9.175 FAILURE
② DMLevent日志
[gbase@node174 ~]$ gcadmin showdmlevent;
Vc event count:1
Event ID: 2
ObjectName: testdb1.student
Fail Data Copy:
------------------------------------------------------
SegName: n1 SCN: 4103 NodeIP: 172.16.9.175 FAILURE
③ 恢复故障节点
[gbase@node175 ~]$ gcluster_services all start
Starting gcware : [ OK ]
Starting gcluster : [ OK ]
Starting gcrecover : [ OK ]
Starting gbase : [ OK ]
Starting syncserver : [ OK ]
Starting GCMonit success!
注:系统自动进行数据同步,略等一段时间,DataState状态由“1”转变为“0”。
CLUSTER STATE: ACTIVE
VIRTUAL CLUSTER MODE: NORMAL
===============================================================
| GBASE COORDINATOR CLUSTER INFORMATION |
===============================================================
| NodeName | IpAddress | gcware | gcluster | DataState |
---------------------------------------------------------------
| coordinator1 | 172.16.9.173 | OPEN | OPEN | 0 |
---------------------------------------------------------------
| coordinator2 | 172.16.9.174 | OPEN | OPEN | 0 |
---------------------------------------------------------------
| coordinator3 | 172.16.9.175 | OPEN | OPEN | 0 |
---------------------------------------------------------------
============================================================================
| GBASE DATA CLUSTER INFORMATION |
============================================================================
| NodeName | IpAddress | DistributionId | gnode | syncserver | DataState |
----------------------------------------------------------------------------
| node1 | 172.16.9.173 | 1 | OPEN | OPEN | 0 |
----------------------------------------------------------------------------
| node2 | 172.16.9.174 | 1 | OPEN | OPEN | 0 |
----------------------------------------------------------------------------
| node3 | 172.16.9.175 | 1 | OPEN | OPEN | 0 |
----------------------------------------------------------------------------
[gbase@node174 ~]$ gcadmin showddlevent;
Vc event count:0
[gbase@node174 ~]$ gcadmin showdmlevent;
Vc event count:0