如何确认nodedatamap系统表是否损坏?

warning: 这篇文章距离上次修改已过1648天,其中的内容可能已经有所变动。

nodedatamap系统表用于计算一致性hash,数据hash分布时要访问此表。该表存储于每个节点gcluster和gnode的gclusterdb数据库和gbase数据库下。此表是安装集群后,通过initnodedatamap命令初始化的。
表中记录数为65536行。表结构如下:

CREATE TABLE "nodedatamap" (
  "hashkey" int(11) DEFAULT NULL,
  "nodeid" int(11) DEFAULT NULL
) ENGINE=EXPRESS DEFAULT CHARSET=utf8 TABLESPACE='sys_tablespace' 

可以利用crc32函数查询判断数据hash分布后落在哪个节点,如:

select nodeid from nodedatamap where hashkey = crc32('13184647638')%65536;

可以使用以下SQL判断表是否损坏,如SQL执行报错,则说明表已经损坏

select count(*) from gclusterdb.nodedatamap;
select distinct nodeid from gclusterdb.nodedatamap;
select * from gclusterdb.nodedatamap;

如果确认nodedatamap表损坏,可以执行以下命令重新初始化此表:refreshnodedatamap
执行前需确保gcluster没有其它操作。

最后修改于:2020年10月28日 12:06

添加新评论