The transparent gateway (GateWay) of GBase 8a connects two clusters at the SQL level through dblink syntax. As IPv4 networks migrate to IPv6, there is a transition period where one cluster is still on IPv4 and the other has moved to IPv6. This post covers the caveats of reaching an IPv4 cluster from an IPv6 cluster with dblink in the China-domestically developed GBase 8a MPP database from GBASE. IPv4 and IPv6 cannot talk to each other directly, so the gateway has to relay traffic — the service must be able to reach the IPs of both clusters.
Environment
Transparent gateway
GBase8a_MPP_Cluster_Gateway_8.5.1.2_build4.19 — use this version or newer.
IPv4 cluster
The original cluster, with no IPv6 address configured yet.
[root@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 |
-----------------------------------------------------------------
| coordinator2 | 10.0.2.202 | 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 |
-------------------------------------------------------------
[root@rh6-1 ~]#
[root@rh6-1 ~]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 08:00:27:30:04:2F
inet addr:10.0.2.201 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe30:42f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1282485 errors:0 dropped:0 overruns:0 frame:0
TX packets:2060190 errors:0 dropped:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:389154896 (371.1 MiB) TX bytes:234663549 (223.7 MiB)
[root@rh6-1 ~]#
IPv6 cluster
The cluster migrated from IPv4 to IPv6, holding both IPv4 and IPv6 addresses.
[gbase@rh6-3 ~]$ gcadmin
CLUSTER STATE: ACTIVE
CLUSTER MODE: NORMAL
=========================================================
| GBASE COORDINATOR CLUSTER INFORMATION |
=========================================================
| NodeName | IpAddress |gcware |gcluster |DataState |
---------------------------------------------------------
| coordinator1 | 2001::203 | OPEN | OPEN | 0 |
---------------------------------------------------------
=====================================================
| GBASE DATA CLUSTER INFORMATION |
=====================================================
|NodeName | IpAddress |gnode |syncserver |DataState |
-----------------------------------------------------
| node1 | 2001::203 | OPEN | OPEN | 0 |
-----------------------------------------------------
[gbase@rh6-3 ~]$
[gbase@rh6-3 ~]$ ifconfig eth0
eth0 Link encap:Ethernet HWaddr 08:00:27:30:D4:0B
inet addr:10.0.2.203 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: 2001::203/64 Scope:Global
inet6 addr: fe80::a00:27ff:fe30:d40b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:168459 errors:0 dropped:0 overruns:0 frame:0
TX packets:118510 errors:0 dropped:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:161721591 (154.2 MiB) TX bytes:9698462 (9.2 MiB)
[gbase@rh6-3 ~]$
Gateway configuration
The gateway must be installed on the IPv6 cluster. Installed on the IPv4 side it would only hold an IPv4 address and could never reach an IPv6 address; on the IPv6 side its nodes carry IPv4 addresses as well. See the gateway documentation for the full parameter reference.
Data source cluster configuration
Following the manual, put one file per data source under GateWay/conf/datasource/. The filename is the name used by dblink, so pick something easy to tell apart — here it is ipv4_201. The content is a standard database connection config; dataSource_dbtype supports gcluster and oracle.
[gbase@rh6-3 ~]$ cat /opt/GBase8a_MPP_Cluster_Gateway_8.5.1.2_build4.19/conf/dataSource/ipv4_201.properties
[ipv6201]
dataSource_IP=10.0.2.201
dataSource_port=5258
dataSource_dbname=testdb
dataSource_dbtype=gcluster
dataSource_user=gbase
dataSource_pwd=XXXXXXXX
[gbase@rh6-3 ~]$
Target cluster configuration
There is only one such file. For security reasons the username must match the login user — root in this example.
[gbase@rh6-3 ~]$ cat /opt/GBase8a_MPP_Cluster_Gateway_8.5.1.2_build4.19/conf/gcluster/gbase8a_gcluster.properties
[gc1]
gcluster_IP=2001::203
gcluster_port=5258
gcluster_user=root
gcluster_pwd=root1234
gcluster_encode=utf-8
If there are several login users or several IPs, configure one section per pair; the match is made on IP and username. V95 may add a vc (dataSource_vc=vc1), but a user with a default vc is still recommended.
[gc1]
gcluster_IP=2001::203
gcluster_port=5258
gcluster_user=root
gcluster_pwd=XXXXXX
gcluster_encode=utf-8
[gc2]
gcluster_IP=2001::203
gcluster_port=5258
gcluster_user=gbase
gcluster_pwd=XXXXX
gcluster_encode=utf-8
[gc3]
gcluster_IP=2001::213
gcluster_port=5258
gcluster_user=root
gcluster_pwd=root1234
gcluster_encode=utf-8
Because the gateway relays traffic, it may need to reach a data node of the target cluster, so every data-node IP has to be listed in the config file with port 5050:
[gn1]
gcluster_IP=2001::222
gcluster_port=5050
gcluster_user=root
gcluster_pwd=root1234
gcluster_encode=utf-8
Starting the gateway
Switch to /opt/GBase8a_MPP_Cluster_Gateway_8.5.1.2_build4.19/ and start it:
cd /opt/GBase8a_MPP_Cluster_Gateway_8.5.1.2_build4.19/
sh gt.sh
Check for a java process with ps -ef|grep ga to confirm startup. Logs are under the logs directory.
Target IPv6 cluster configuration
Add the following parameters to the config file of every management node and restart the services.
Note: gcluster_dblink_direct_data_exchange and _t_gcluster_dblink_insert_select_optimization only apply when the two clusters cannot reach each other directly. If unsure, leave these two unset first and verify that dblink works. With them enabled, performance is worse because traffic is forwarded through the gateway instead of flowing directly between the clusters.
[gbase@rh6-3 ~]$ grep dblink /opt/gbase/gcluster/config/gbase_8a_gcluster.cnf
gcluster_dblink_direct_data_exchange=0
gbase_dblink_gateway_ip=10.0.2.203
gbase_dblink_gateway_port=9898
_t_gcluster_dblink_insert_select_optimization=0
[gbase@rh6-3 ~]$
Check the resulting parameter state:
gbase> show variables like '%dblink%';
+--------------------------------------------------+------------+
| Variable_name | Value |
+--------------------------------------------------+------------+
| _t_gcluster_dblink_clear_syntax_constraints | 0 |
| _t_gcluster_dblink_generate_interim_table_policy | 1 |
| _t_gcluster_dblink_insert_select_optimization | 0 |
| gbase_dblink_gateway_ip | 10.0.2.203 |
| gbase_dblink_gateway_port | 9898 |
| gbase_dblink_server_ip | |
| gbase_dblink_standby_gateway_ip | |
| gbase_dblink_standby_gateway_port | 0 |
| gcluster_dblink_direct_data_exchange | 0 |
| gcluster_dblink_optimize | 0 |
| gcluster_dblink_orcl_case_sensitive | 0 |
| gcluster_ipv4_dblink_insert | 1 |
+--------------------------------------------------+------------+
12 rows in set (Elapsed: 00:00:00.00)
Using dblink
Creating a dblink
gbase> create database link ipv4201 connect to '' identified by '' using 'ipv4_201';
Query OK, 0 rows affected (Elapsed: 00:00:00.00)
SELECT
gbase> select * from d@ipv4201;
+---------------------+
| d |
+---------------------+
| 2023-05-17 17:01:24 |
+---------------------+
1 row in set (Elapsed: 00:00:00.05)
INSERT ... SELECT from a dblink
gbase> truncate table d;
Query OK, 3 rows affected (Elapsed: 00:00:00.33)
gbase> insert into d select * from d@ipv4201;
Query OK, 1 row affected (Elapsed: 00:00:01.17)
Records: 1 Duplicates: 0 Warnings: 0
gbase>
CREATE TABLE AS SELECT from a dblink
gbase> create table d2 as select * from d@ipv4201;
Query OK, 2 rows affected (Elapsed: 00:00:00.89)
gbase> select * from d2;
+---------------------+
| d |
+---------------------+
| 2023-05-24 06:56:39 |
| 2023-05-17 17:01:24 |
+---------------------+
2 rows in set (Elapsed: 00:00:00.01)
JOINs between two dblink tables are supported
gbase> select * from d@ipv4201 a ,d@ipv4201 b;
+---------------------+---------------------+
| d | d |
+---------------------+---------------------+
| 2023-05-24 06:56:39 | 2023-05-24 06:56:39 |
| 2023-05-17 17:01:24 | 2023-05-24 06:56:39 |
| 2023-05-24 06:56:39 | 2023-05-17 17:01:24 |
| 2023-05-17 17:01:24 | 2023-05-17 17:01:24 |
+---------------------+---------------------+
4 rows in set (Elapsed: 00:00:00.16)
JOINs between a dblink table and a local table are not supported
gbase> select * from d left join d@ipv4201 b on d.d=b.d;
ERROR 1149 (42000): (GBA-02SC-1001) DBLink table join with (normal table || from sub query) is forbidden
gbase>
Inspecting db_links metadata
gbase> select * from gbase.db_links;
+--------+---------+-------------+----------+----------+----------+---------------------+
| owner | db_link | dblink_priv | username | password | host | created |
+--------+---------+-------------+----------+----------+----------+---------------------+
| public | ipv4201 | PUBLIC | | NULL | ipv4_201 | 2023-05-17 17:00:12 |
+--------+---------+-------------+----------+----------+----------+---------------------+
1 row in set (Elapsed: 00:00:00.00)
Dropping a dblink
gbase> drop database link ipv4201;
Query OK, 0 rows affected (Elapsed: 00:00:00.09)
Sending SQL to the dblink data source
Only some DDL and DML are supported; SELECT, CALL and similar statements are not, and large objects are not supported yet.
- insert values
- insert select
- delete
- update
- truncate
- merge
- create
- drop
gbase> passthrough link ipv4201 using 'insert into d values( now())';
Query OK, 1 row affected (Elapsed: 00:00:00.26)
gbase> passthrough link ipv4201 using 'select * from d';
ERROR 1105 (HY000): SQL command is not supported: select * from d
gbase>
Direct INSERT into the dblink data source
The version tested here does not support it yet:
gbase> insert into d@ipv4201 values (now());
ERROR 1235 (42000): This version of GBase doesn't yet support 'insert into remote table'
gbase>
Caveats
Because IPv6 and IPv4 do not interoperate directly, a relay is mandatory: a machine configured with both address families, reachable from both sides, has to serve as the gateway.
Data source config is usually straightforward — just watch the filename. The target side is trickier: older gateway versions used one file per source, while newer ones merge them, which is easy to mix up.
- Use the IPv6 address for an IPv6 cluster, not its IPv4 one; otherwise the IP + username pair will not match.
- Keep IPv6 addresses in one complete, consistent format across the cluster.
2001::200and2001::0200are different strings when compared literally. - The username must match the login user. Business systems rarely use the two admin accounts
rootor gbase, so expect a business account instead. - Port 5258 is enough unless the cluster uses a non-default port.
Going forward, pin the address format and the login user before the first dblink query on a gbase cluster: most failed connections come from a mismatched IP + username pair in the gateway config, not from the gbase database itself.
Top comments (0)