GBase 8s HAC Cluster Setup Guide (1)

Cong Li - Jul 18 - - Dev Community

In enterprise applications, database stability and availability are crucial. GBase 8s, a high-performance database system, offers HAC (High Availability Cluster) functionality to ensure business continuity and data security. This guide details how to install and configure GBase 8s on both primary and secondary nodes, laying a solid foundation for setting up an HAC cluster.

1. Installing GBase 8s Database

First, we need to install the GBase 8s database on both the primary and secondary nodes. You can use silent installation (./ids_install -i silent -DLICENSE_ACCEPTED=TRUE -DUSER_INSTALL_DIR=/opt/gbase) or use ./ids_install to choose whether to initialize the instance. Note that the silent installation will leave the database uninitialized. The primary node must initialize the instance, while the secondary node should not initialize the instance.

2. Modifying Primary Node Configuration Files and sqlhosts File

After initializing the instance on the primary node, we need to modify the onconfig file. The SERVERNUM and DBSERVERNAME can remain unchanged (as long as they are different from the secondary node). The remaining three parameters are set to default values after initialization and need to be modified. The DRAUTO parameter controls failover behavior. When DRAUTO is set to 0, there will be no automatic failover; the secondary node will remain in read-only mode if the primary node fails. When set to 1, automatic failover will occur, and the HAC secondary node will switch to a standard server. When set to 2, automatic failover will convert the HAC secondary node to the primary node upon primary server failure or network loss. DRAUTO set to 3 indicates control by a connection manager.

After modifying the onconfig file, update the sqlhosts file to include the secondary node information, as shown below:

[gbasedbt@prim gbase_dbs]$ cat /opt/gbase/etc/sqlhosts.prim 
prim onsoctcp 192.168.16.128 13000
hac  onsoctcp 192.168.16.129 13000
Enter fullscreen mode Exit fullscreen mode

Restart the primary node to apply the changes.

3. Synchronizing Secondary Node Configuration Files and Environment Variables

After modifying the primary node's configuration and sqlhosts files, transfer the environment variables, sqlhosts file, and onconfig file to the secondary node, and make secondary modifications. For clarity, rename the files from prim to hac.

[gbasedbt@hac ~]$ scp 192.168.16.128:/opt/gbase/etc/onconfig.prim /opt/gbase/etc/
[gbasedbt@hac ~]$ scp 192.168.16.128:/opt/gbase/etc/sqlhosts.prim /opt/gbase/etc/
[gbasedbt@hac ~]$ scp 192.168.16.128:/home/gbasedbt/profile.prim /home/gbasedbt/
[gbasedbt@hac ~]$ mv profile.prim     profile.hac
[gbasedbt@hac etc]$ mv onconfig.prim  onconfig.hac
[gbasedbt@hac etc]$ mv sqlhosts.prim  sqlhosts.hac
Enter fullscreen mode Exit fullscreen mode

Modify the onconfig file, especially SERVERNUM, DBSERVERNAME, and HA_ALIAS, to ensure they are different from the primary node. Next, update the profile file, changing instances of prim to hac.

[gbasedbt@hac ~]$ cat profile.hac 
export GBASEDBTSERVER=hac
export GBASEDBTDIR=/opt/gbase
export GBASEDBTSQLHOSTS=/opt/gbase/etc/sqlhosts.hac
export ONCONFIG=onconfig.hac
export PATH=/opt/gbase/bin:$PATH
export PATH=/opt/gbase/sbin:$PATH
export DB_LOCALE=zh_CN.utf8
export CLIENT_LOCALE=zh_CN.utf8
export GL_USEGLU=1
Enter fullscreen mode Exit fullscreen mode

The sqlhosts file remains identical to the primary node, so no changes are necessary. Source the environment variables and check the database service status, which should be in a shutdown state on the secondary node.

[gbasedbt@hac ~]$ source profile.hac
[gbasedbt@hac ~]$ gstat -
Your evaluation license will expire on 2025-07-06 00:00:00
shared memory not initialized for GBASEDBTSERVER 'hac'
Enter fullscreen mode Exit fullscreen mode

4. Creating Chunks on the Secondary Node

First, check the dbspace storage paths on the primary node and create corresponding directories on the secondary node.

[gbasedbt@prim gbase_dbs]$ ll  # Primary Node
total 8527872
-rw-rw---- 1 gbasedbt gbasedbt  104857600  Nov 13 14:28 datadbs1_1
-rw-rw---- 1 gbasedbt gbasedbt 3481272320  Nov 13 16:28 llogdbs
-rw-rw---- 1 gbasedbt gbasedbt 3481272320  Nov 13 16:28 plogdbs
-rw-rw---- 1 gbasedbt gbasedbt  209715200  Nov 13 16:28 rootdbs
-rw-rw---- 1 gbasedbt gbasedbt  727711744  Nov 13 14:28 sbspace1
-rw-rw---- 1 gbasedbt gbasedbt  727711744  Nov 13 14:38 tmpdbs1
[gbasedbt@prim gbase_dbs]$ pwd
/opt/gbase/gbase_dbs
Enter fullscreen mode Exit fullscreen mode

On the secondary node, create the gbase_dbs directory and the same chunk files as the primary node. Set the permissions to 660.

[gbasedbt@hac ~]$ cd /opt/gbase/  # Secondary Node
[gbasedbt@hac gbase]$ mkdir gbase_dbs
[gbasedbt@hac gbase]$ cd gbase_dbs/
[gbasedbt@hac gbase_dbs]$ touch datadbs1_1 llogdbs plogdbs rootdbs sbspace1 tmpdbs1
[gbasedbt@hac gbase_dbs]$ chmod 660 *
[gbasedbt@hac gbase_dbs]$ ll
total 0
-rw-rw---- 1 gbasedbt gbasedbt 0  Nov 13 14:34 datadbs1_1
-rw-rw---- 1 gbasedbt gbasedbt 0  Nov 13 14:34 llogdbs
-rw-rw---- 1 gbasedbt gbasedbt 0  Nov 13 14:34 plogdbs
-rw-rw---- 1 gbasedbt gbasedbt 0  Nov 13 14:34 rootdbs
-rw-rw---- 1 gbasedbt gbasedbt 0  Nov 13 14:34 sbspace1
-rw-rw---- 1 gbasedbt gbasedbt 0  Nov 13 14:34 tmpdbs1
Enter fullscreen mode Exit fullscreen mode

With these steps, the installation, initialization, and configuration file modifications are complete.

Following these steps, we have prepared the GBase 8s HAC cluster setup.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player