Skip to main content

openGauss Database Integration Guide

HAP Server uses MySQL as its default relational database. Since v6.2.0, it also supports openGauss (free and open source). For environments with domestic technology requirements, you can use this database instead of MySQL.

Follow these integration steps:

  1. Install openGauss 6.0.0 or later using the Installation Guide, in standalone or primary-standby mode (Enterprise or Minimal Edition).

    For HAP standalone deployments or simplified clusters, choose standalone mode. For standard or professional clusters, choose primary-standby mode.

  2. After deploying openGauss, download the HAP database initialization scripts and upload them to the openGauss environment.

  3. Initialize the data

    Connect to openGauss using gsql, which is included with the deployment.

    Run the initialization scripts (adjust the IP address, port, username and SQL file paths for your environment). Enter the password when prompted.

    gsql -h 127.0.0.1 -p 5432 -U omm -f /usr/local/init_opengauss/1_Database_g.sql -d postgres
    gsql -h 127.0.0.1 -p 5432 -U omm -f /usr/local/init_opengauss/1_Database_s.sql -d mdproject
    gsql -h 127.0.0.1 -p 5432 -U omm -f /usr/local/init_opengauss/1_Database_s.sql -d mdapplication
    gsql -h 127.0.0.1 -p 5432 -U omm -f /usr/local/init_opengauss/1_Database_s.sql -d mdcalendar
    gsql -h 127.0.0.1 -p 5432 -U omm -f /usr/local/init_opengauss/1_Database_s.sql -d mdstructure
    gsql -h 127.0.0.1 -p 5432 -U omm -f /usr/local/init_opengauss/1_Database_s.sql -d mdlog
    gsql -h 127.0.0.1 -p 5432 -U omm -f /usr/local/init_opengauss/2_MDProject.sql -d mdproject
    gsql -h 127.0.0.1 -p 5432 -U omm -f /usr/local/init_opengauss/3_MDStructure.sql -d mdstructure
    gsql -h 127.0.0.1 -p 5432 -U omm -f /usr/local/init_opengauss/4_MDApplication.sql -d mdapplication
    gsql -h 127.0.0.1 -p 5432 -U omm -f /usr/local/init_opengauss/5_MDCalendar.sql -d mdcalendar
    gsql -h 127.0.0.1 -p 5432 -U omm -f /usr/local/init_opengauss/6_MDLog.sql -d mdlog
    gsql -h 127.0.0.1 -p 5432 -U omm -f /usr/local/init_opengauss/7_Data_MDProject.sql -d mdproject
    gsql -h 127.0.0.1 -p 5432 -U omm -f /usr/local/init_opengauss/8_Data_MDApplication.sql -d mdapplication
  4. Initialize HAP services

    Before initializing services, add the following environment variables (replace connection parameter values with actual values):

    ENV_RDB_TYPE: "9"
    ENV_RDB_URI_MDPROJECT: "Host=127.0.0.1;Port=5432;Username=gaussdb;Password=******;Database=mdproject;No Reset On Close=true"
    ENV_RDB_URI_MDLOG: "Host=127.0.0.1;Port=5432;Username=gaussdb;Password=******;Database=mdlog;No Reset On Close=true"
    ENV_RDB_URI_MDSTRUCTURE: "Host=127.0.0.1;Port=5432;Username=gaussdb;Password=******;Database=mdstructure;No Reset On Close=true"
    ENV_RDB_URI_MDCALENDAR: "Host=127.0.0.1;Port=5432;Username=gaussdb;Password=******;Database=mdcalendar;No Reset On Close=true"
    ENV_RDB_URI_MDAPPLICATION: "Host=127.0.0.1;Port=5432;Username=gaussdb;Password=******;Database=mdapplication;No Reset On Close=true"
    ENV_STANDALONE_DISABLE_SERVICES: "mysql"
  5. Complete the remaining system initialization steps.