南大通用GBase 8a 扩容重分布报错ERROR 1707 (HY000): gcluster command error: table can't be rebalanced when only one distribution rule.

GBase 8a数据库集群支持在线扩容,用户根据新的硬件情况,创建新的主备策略后,必须要初始化分布规则,initnodedatamap,如果忘记初始化直接rebalance 操作,则会报这个错误,因为系统元数据里,只有1份分布规则。

报错样例

gbase> rebalance instance;
ERROR 1707 (HY000): gcluster command error: table can't be rebalanced when only one distribution rule.
gbase>

原因

创建完成新的distribution 后,没有初始化分布规则nodedatamap。

[gbase@gbase_rh7_001 gcinstall]$ gcadmin distribution gcChangeInfo.xml vc vc1 p 1 d 0
gcadmin generate distribution ...

[warning]: parameter [d num] is 0, the new distribution will has no segment backup
please ensure this is ok, input [Y,y] or [N,n]: y
gcadmin generate distribution successful

[gbase@gbase_rh7_001 gcinstall]$ gcadmin showdistribution vc vc1

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

             Primary Segment Node IP                   Segment ID                 Duplicate Segment node IP
========================================================================================================================
|                   10.0.2.101                   |         1          |                                                |
========================================================================================================================

                                 Distribution ID: 1 | State: old | Total segment num: 1

             Primary Segment Node IP                   Segment ID                 Duplicate Segment node IP
========================================================================================================================
|                   10.0.2.101                   |         1          |                                                |
========================================================================================================================
[gbase@gbase_rh7_001 gcinstall]$ 

直接重分布,报错

[gbase@gbase_rh7_001 gcinstall]$ gccli

GBase client 9.5.2.36.125743. Copyright (c) 2004-2021, GBase.  All Rights Reserved.

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

gbase> rebalance instance;
ERROR 1707 (HY000): gcluster command error: table can't be rebalanced when only one distribution rule.
gbase>

解决方案

先初始化分布规则,再重分布。

[gbase@gbase_rh7_001 gcinstall]$ gccli

GBase client 9.5.2.36.125743. Copyright (c) 2004-2021, GBase.  All Rights Reserved.

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

gbase> rebalance instance;
ERROR 1707 (HY000): gcluster command error: table can't be rebalanced when only one distribution rule.
gbase> initnodedatamap;
Query OK, 0 rows affected, 10 warnings (Elapsed: 00:00:01.20)

gbase> rebalance instance;
Query OK, 70 rows affected (Elapsed: 00:00:00.51)

gbase>