A mirror cluster in the China-domestically developed GBase 8a MPP database from GBASE is normally built with the same topology on both sides — the same node count and the same distribution strategy. For a real-time backup scenario, a handful of high-spec machines with large disks can serve as the mirror instead. This post records a lab test of that layout and the two conditions that make it work.
Test environment
A 3-node cluster. The first two nodes belong to vc1, set to p 1 (one primary fragment per node); the third node is vc2, set to p 2 d 0 (two primary fragments per node).
Two prerequisites for mirroring the two virtual clusters:
- The number of primary fragments is the same — 2 on each side, replicas excluded.
- The hashmap is the same:
vc2is initialized withinitnodedatamap from vc1.
Cluster overview
[gbase@gbase_rh7_001 gcinstall_9.5.2.45.5]$ gcadmin CLUSTER STATE: ACTIVE ============================================================= | GBASE COORDINATOR CLUSTER INFORMATION | ============================================================= | NodeName | IpAddress | gcware | gcluster | DataState | ------------------------------------------------------------- | coordinator1 | 10.0.2.101 | OPEN | OPEN | 0 | ------------------------------------------------------------- ============================================= | GBASE VIRTUAL CLUSTER INFORMATION | ============================================= | VcName | DistributionId | comment | --------------------------------------------- | vc1 | 1 | vc_101 | --------------------------------------------- | vc2 | 2 | vc_102 | --------------------------------------------- 2 virtual cluster: vc1, vc2 1 coordinator node 0 free data node vc1
Two machines, one primary fragment per machine.
[gbase@gbase_rh7_001 gcinstall_9.5.2.45.5]$ gcadmin showcluster vc vc1 CLUSTER STATE: ACTIVE VIRTUAL CLUSTER MODE: NORMAL ============================================= | GBASE VIRTUAL CLUSTER INFORMATION | ============================================= | VcName | DistributionId | comment | --------------------------------------------- | vc1 | 1 | vc_101 | --------------------------------------------- ========================================================================================================= | VIRTUAL CLUSTER DATA NODE INFORMATION | ========================================================================================================= | NodeName | IpAddress | DistributionId | gnode | syncserver | DataState | --------------------------------------------------------------------------------------------------------- | node1 | 10.0.2.101 | 1 | OPEN | OPEN | 0 | --------------------------------------------------------------------------------------------------------- | node2 | 10.0.2.102 | 1 | OPEN | OPEN | 0 | --------------------------------------------------------------------------------------------------------- 2 data node [gbase@gbase_rh7_001 gcinstall_9.5.2.45.5]$ gcadmin showdistribution vc vc1 Distribution ID: 1 | State: new | Total segment num: 2 Primary Segment Node IP Segment ID Duplicate Segment node IP ======================================================================================================================== | 10.0.2.101 | 1 | 10.0.2.102 | ------------------------------------------------------------------------------------------------------------------------ | 10.0.2.102 | 2 | 10.0.2.101 | ======================================================================================================================== [gbase@gbase_rh7_001 gcinstall_9.5.2.45.5]$ vc2
One machine with two primary fragments.
[gbase@gbase_rh7_001 gcinstall_9.5.2.45.5]$ gcadmin showcluster vc vc2 CLUSTER STATE: ACTIVE VIRTUAL CLUSTER MODE: NORMAL ============================================= | GBASE VIRTUAL CLUSTER INFORMATION | ============================================= | VcName | DistributionId | comment | --------------------------------------------- | vc2 | 2 | vc_102 | --------------------------------------------- ========================================================================================================================= | VIRTUAL CLUSTER DATA NODE INFORMATION | ========================================================================================================================= | NodeName | IpAddress | DistributionId | gnode | syncserver | DataState | --------------------------------------------------------------------------------------------------------- | node1 | 10.0.2.115 | 2 | OPEN | OPEN | 0 | --------------------------------------------------------------------------------------------------------- 1 data node [gbase@gbase_rh7_001 gcinstall_9.5.2.45.5]$ gcadmin showdistribution vc vc2 Distribution ID: 2 | State: new | Total segment num: 2 Primary Segment Node IP Segment ID Duplicate Segment node IP ======================================================================================================================== | 10.0.2.115 | 1 | | ------------------------------------------------------------------------------------------------------------------------ | 10.0.2.115 | 2 | | ======================================================================================================================== [gbase@gbase_rh7_001 gcinstall_9.5.2.45.5]$ Creating the mirror database
Initialize the hashmap on vc1, copy it into vc2, then set vc2 as the default mirror for the database:
gbase> use vc vc1; Query OK, 0 rows affected (Elapsed: 00:00:00.00) gbase> initnodedatamap; Query OK, 1 row affected (Elapsed: 00:00:00.51) gbase> use vc vc2; Query OK, 0 rows affected (Elapsed: 00:00:00.00) gbase> initnodedatamap from vc1; Query OK, 1 row affected, 1 warning (Elapsed: 00:00:00.36) gbase> show warnings; +---------+------+----------------------------------------------------------+ | Level | Code | Message | +---------+------+----------------------------------------------------------+ | Warning | 1042 | It is risky that some suffix is not in the backup state. | +---------+------+----------------------------------------------------------+ 1 row in set (Elapsed: 00:00:00.00) gbase> create database vc1.testdb; Query OK, 1 row affected (Elapsed: 00:00:00.01) gbase> create database vc2.testdb; Query OK, 1 row affected (Elapsed: 00:00:00.00) gbase> alter database vc1.testdb set default mirror=vc2; Query OK, 1 row affected (Elapsed: 00:00:00.00) gbase> show mirror databases; +--------------------+-----+-----------+ | Database | VC | MIRROR_VC | +--------------------+-----+-----------+ | information_schema | | | | performance_schema | | | | gbase | | | | gctmpdb | | | | gclusterdb | vc2 | | | testdb | vc2 | vc1 | +--------------------+-----+-----------+ 6 rows in set (Elapsed: 00:00:00.00) Testing a mirrored table
Create a table on vc1 and read it back from both sides. Note the typo vc1.testd.t1 in the first select — the error message is kept as printed:
gbase> use vc vc1; Query OK, 0 rows affected (Elapsed: 00:00:00.00) gbase> use testdb; Query OK, 0 rows affected (Elapsed: 00:00:00.00) gbase> create table t1(id int,name varchar(100)); Query OK, 0 rows affected (Elapsed: 00:00:00.21) gbase> insert into t1 values(1,'From vc1'); Query OK, 1 row affected (Elapsed: 00:00:00.13) gbase> select * from vc1.testd.t1; ERROR 1146 (42S02): Table 'vc1.testd.t1' doesn't exist gbase> select * from vc1.testdb.t1; +------+----------+ | id | name | +------+----------+ | 1 | From vc1 | +------+----------+ 1 row in set (Elapsed: 00:00:00.01) gbase> select * from vc2.testdb.t1; +------+----------+ | id | name | +------+----------+ | 1 | From vc1 | +------+----------+ 1 row in set (Elapsed: 00:00:00.01) gbase> ^CAborted What the mirror actually depends on
Mirroring depends on the primary fragment count — both sides must have the same number — and on the hashmap: the data_distribution_id rows in each side's nodedatamap table must be equal in count and identical in content.
In the tested version, the number of distributions is not strictly checked. Creating a distribution without running initnodedatamap does not break mirroring, but once initnodedatamap has run, the two nodedatamap tables differ and creating the mirror fails. The following query checks it by counting hashkey,nodeid groups:
select distinct(res.r), count(res.r) from (select count(*) r from gbase.nodedatamap t where t.data_distribution_id in (1,2) group by t.hashkey, t.nodeid) res group by res.r; +---+--------------+ | r | count(res.r) | +---+--------------+ | 2 | 65536 | +---+--------------+ 1 row in set (Elapsed: 00:00:00.42) The id in the query is the distribution number currently used by the mirror VC, visible in gcadmin showdistribution vc VCNAME.
Going forward, keep the primary fragment count and the nodedatamap in sync on a gbase cluster before enabling a mirror: fewer, larger nodes work for backup only as long as both sides resolve the same hashmap, and a gbase database will reject the mirror as soon as one side's map diverges.

