南大通用GBase 8a查看某张表当前主副本可用状态、是否存在event

GBase 8a提供了show datacopymap功能来查询指定的表,在所有的计算节点上是否有不可用的情况,比如节点离线或服务不可用,某些分片有dmlevent,ddlevent,dmlstorageevent等情况。分片状态正常为0,如果不是0,则表示该主机的该分片,当前不可用,22表示服务离线,包括主机离线;32表示dmlstorageevent,16表示有ddlevent, 2表示有dmlevent。总之,只要不是0,后续的访问就不该继续使用该分片。

参考

语法

show datacopymap [DBNAME.]tableName

其中DBNAME是库名,tablename是表名。

样例

正常状态(0)

dp_state的数值为0,代表该节点,该分片为正常状态。

gbase> show nodes;
+------------+------------+-------+--------------+----------------+--------+-----------+
| Id         | ip         | name  | primary part | duplicate part | status | datastate |
+------------+------------+-------+--------------+----------------+--------+-----------+
| 3389128714 | 10.0.2.202 | node2 | n1           | n2             | online |         0 |
| 3372351498 | 10.0.2.201 | node1 | n2           | n1             | online |         0 |
+------------+------------+-------+--------------+----------------+--------+-----------+
2 rows in set (Elapsed: 00:00:00.00)

gbase> show datacopymap testdb.t3;
+---------+------------+----------+
| dp_name | node_id    | dp_state |
+---------+------------+----------+
| n1      | 3389128714 |        0 |
| n1      | 3372351498 |        0 |
| n2      | 3372351498 |        0 |
| n2      | 3389128714 |        0 |
+---------+------------+----------+
4 rows in set (Elapsed: 00:00:00.00)

[gbase@rh6-1 ~]$ gcadmin
CLUSTER STATE:  ACTIVE
CLUSTER MODE:   NORMAL

=================================================================
|             GBASE COORDINATOR CLUSTER INFORMATION             |
=================================================================
|   NodeName   |     IpAddress     |gcware |gcluster |DataState |
-----------------------------------------------------------------
| coordinator1 |    10.0.2.201     | OPEN  |  OPEN   |    0     |
-----------------------------------------------------------------
=============================================================
|              GBASE DATA CLUSTER INFORMATION               |
=============================================================
|NodeName |     IpAddress     |gnode |syncserver |DataState |
-------------------------------------------------------------
|  node1  |    10.0.2.201     | OPEN |   OPEN    |    0     |
-------------------------------------------------------------
|  node2  |    10.0.2.202     | OPEN |   OPEN    |    0     |
-------------------------------------------------------------

服务离线状态(4/22)

202节点数据库服务停了。经测试,OFFLINE 也是这个结果。

gbase> show datacopymap testdb.t3;
+---------+------------+----------+
| dp_name | node_id    | dp_state |
+---------+------------+----------+
| n1      | 3389128714 |       22 |
| n1      | 3372351498 |        0 |
| n2      | 3372351498 |        0 |
| n2      | 3389128714 |       22 |
+---------+------------+----------+
4 rows in set (Elapsed: 00:00:00.01)


[gbase@rh6-1 ~]$ gcadmin
CLUSTER STATE:  ACTIVE
CLUSTER MODE:   NORMAL

=================================================================
|             GBASE COORDINATOR CLUSTER INFORMATION             |
=================================================================
|   NodeName   |     IpAddress     |gcware |gcluster |DataState |
-----------------------------------------------------------------
| coordinator1 |    10.0.2.201     | OPEN  |  OPEN   |    0     |
-----------------------------------------------------------------
=============================================================
|              GBASE DATA CLUSTER INFORMATION               |
=============================================================
|NodeName |     IpAddress     |gnode |syncserver |DataState |
-------------------------------------------------------------
|  node1  |    10.0.2.201     | OPEN |   OPEN    |    0     |
-------------------------------------------------------------
|  node2  |    10.0.2.202     |CLOSE |   CLOSE   |    0     |
-------------------------------------------------------------

数据不一致dmlevent(2)

服务正常,但表存在dmlevent.

gbase> show datacopymap testdb.t3;
+---------+------------+----------+
| dp_name | node_id    | dp_state |
+---------+------------+----------+
| n1      | 3389128714 |        2 |
| n1      | 3372351498 |        0 |
| n2      | 3372351498 |        0 |
| n2      | 3389128714 |        0 |
+---------+------------+----------+
4 rows in set (Elapsed: 00:00:00.01)

[gbase@rh6-1 ~]$ gcadmin
CLUSTER STATE:  ACTIVE
CLUSTER MODE:   NORMAL

=================================================================
|             GBASE COORDINATOR CLUSTER INFORMATION             |
=================================================================
|   NodeName   |     IpAddress     |gcware |gcluster |DataState |
-----------------------------------------------------------------
| coordinator1 |    10.0.2.201     | OPEN  |  OPEN   |    0     |
-----------------------------------------------------------------
=============================================================
|              GBASE DATA CLUSTER INFORMATION               |
=============================================================
|NodeName |     IpAddress     |gnode |syncserver |DataState |
-------------------------------------------------------------
|  node1  |    10.0.2.201     | OPEN |   OPEN    |    0     |
-------------------------------------------------------------
|  node2  |    10.0.2.202     | OPEN |   OPEN    |    1     |
-------------------------------------------------------------
[gbase@rh6-1 ~]$ gcadmin showdmlevent
Event count:1
Event ID:    21
ObjectName: testdb.t3

Fail Data Copy:
------------------------------------------------------
SegName: n1     SCN: 4456452    NodeIP: 10.0.2.202      FAILURE

服务离线且有dmlevent(6)

gbase> show datacopymap enc.tr;
+---------+------------+----------+
| dp_name | node_id    | dp_state |
+---------+------------+----------+
| NULL    | 3372351498 |        0 |
| NULL    | 3389128714 |        0 |
| NULL    | 3405905930 |        6 |
+---------+------------+----------+
3 rows in set (Elapsed: 00:00:00.00)
[gbase@localhost ~]$ gcadmin
CLUSTER STATE:  ACTIVE
CLUSTER MODE:   NORMAL

=================================================================
|             GBASE COORDINATOR CLUSTER INFORMATION             |
=================================================================
|   NodeName   |     IpAddress     |gcware |gcluster |DataState |
-----------------------------------------------------------------
| coordinator1 |    10.0.2.201     | OPEN  |  OPEN   |    0     |
-----------------------------------------------------------------
| coordinator2 |    10.0.2.202     | OPEN  |  OPEN   |    0     |
-----------------------------------------------------------------
| coordinator3 |    10.0.2.203     | OPEN  |  OPEN   |    0     |
-----------------------------------------------------------------
=============================================================
|              GBASE DATA CLUSTER INFORMATION               |
=============================================================
|NodeName |     IpAddress     |gnode |syncserver |DataState |
-------------------------------------------------------------
|  node1  |    10.0.2.201     | OPEN |   OPEN    |    0     |
-------------------------------------------------------------
|  node2  |    10.0.2.202     | OPEN |   OPEN    |    0     |
-------------------------------------------------------------
|  node3  |    10.0.2.203     |CLOSE |   OPEN    |    1     |
-------------------------------------------------------------
[gbase@localhost ~]$ gcadmin showdmlevent
Event count:1
Event ID:    11
ObjectName: enc.tr

Fail Data Copy:
------------------------------------------------------
SCN: 655387     NodeIP: 10.0.2.203      FAILURE

表结构不一致DDL(16)

服务正常,但表有ddlevent.

gbase> show datacopymap testdb.t4;
+---------+------------+----------+
| dp_name | node_id    | dp_state |
+---------+------------+----------+
| n1      | 3389128714 |       16 |
| n1      | 3372351498 |        0 |
| n2      | 3372351498 |        0 |
| n2      | 3389128714 |       16 |
+---------+------------+----------+
4 rows in set (Elapsed: 00:00:00.00)

gbase> ^CAborted
[gbase@rh6-1 ~]$ gcadmin
CLUSTER STATE:  ACTIVE
CLUSTER MODE:   NORMAL

=================================================================
|             GBASE COORDINATOR CLUSTER INFORMATION             |
=================================================================
|   NodeName   |     IpAddress     |gcware |gcluster |DataState |
-----------------------------------------------------------------
| coordinator1 |    10.0.2.201     | OPEN  |  OPEN   |    0     |
-----------------------------------------------------------------
=============================================================
|              GBASE DATA CLUSTER INFORMATION               |
=============================================================
|NodeName |     IpAddress     |gnode |syncserver |DataState |
-------------------------------------------------------------
|  node1  |    10.0.2.201     | OPEN |   OPEN    |    0     |
-------------------------------------------------------------
|  node2  |    10.0.2.202     | OPEN |   OPEN    |    1     |
-------------------------------------------------------------
[gbase@rh6-1 ~]$ gcadmin showddlevent
Event count:1
Event ID:    719712
ObjectName: testdb.t4
Fail Node Copy:
------------------------------------------------------

Fail Data Copy:
------------------------------------------------------
SegName: n1     NodeIP: 10.0.2.202      FAILURE
SegName: n2     NodeIP: 10.0.2.202      FAILURE

总结

只要节点数据状态不是0, 那就一定是有故障,包括服务,数据,表结构等方面。