HomeMogDBMogDB StackUqbar

Documentation:v2.0

Supported Versions:

PostgreSQL as a Source Database

Supported Version

Database version: 9.6, 10, 11, 12, 13, 14

Dependency plug-in: decoderbufs, wal2json, pgoutput (recommendation)

Database Configuration

Install plug-in

pgoutput is a built-in plug-in, no need to install, the other two types of plug-ins please refer to:

decoderbufs,

wal2json

Modify the WAL Parameter of the Source Database

Modify the parameter configuration file postgresql.conf of the source database. The parameter file is located in the data/ directory of the database.

Use psql to log in to the PostgreSQL database. Run the following command to query the data directory:

psql -d postgres -U $USER -c 'show data_directory'

Modify the postgresql.conf file in the data/ directory.

# Relace <data_directory> with the actual data directory
vi <data_directory>/postgresql.conf

Find the following parameters in the postgresql.conf file and set them to specified values.

  1. wal_level=logical # use logical (change requires restart)
  2. max_replication_slots = 4 # max number of replication slots (change requires restart)
  3. wal_sender_timeout = 0s # in milliseconds; 0 disables
  4. max_wal_senders = 8 # max number of walsender processes (change requires restart)
  5. shared_preload_libraries = 'decoderbufs' (If the plug-in is wal2json, ignore it)

Modify the HBA Configuration of the Source Database

In the data directory, find the pg_hba.conf configuration file, add the following content to add the replication permission.

Note: mdb_user indicates the user for using the replication function. It needs to be modified based on actual requirement.

# Replace <data_directory> with the actual data directory. 
cat >> <data_directory>/pg_hba.conf <"EOF"

# Add for MDB replication
host  replication  mdb_user   0.0.0.0/0  sha256
EOF

Set User Permission

Create the mdb_user user for logging in to and replicate source PostgreSQL data. The username and password need to be modified based on the actual requirement.

  • The login permission is used for logging in to the database.
  • The replication permission is used for synchronizing incremental data.
  • The superuser permission is used for initializing objects and synchronizing full data.
create user mdb_user with superuser login replication PASSWORD 'Enmo@123';

Enable the REPLICA IDENTITY Mode of the Table

For all tables to be synchronized, enable the REPLICA IDENTITY mode.

Note: The following is the command example.

ALTER TABLE public.customers REPLICA IDENTITY FULL;

Enable Heartbeat Configuration

Sending a heartbeat message enables the connector to send the latest retrieved LSN to the database slot, allowing the database to reclaim disk space used by WAL files that are no longer needed.

To enable the heartbeat configuration, see Channel-related Advanced Parameters. You need to set heartbeatIntervalMs to a positive integer, and run the following command on the source node.

Note: The following is only an example. The table name heartbeat needs to be consistent with the heartbeatTableName value.

CREATE TABLE heartbeat (ts TIMESTAMP WITH TIME ZONE);
INSERT INTO heartbeat (ts) VALUES (NOW());

Character Set Mapping

Source Database Target Database Character Set of the Source Database Character Set of the Target Database
PostgreSQL MogDB BIG5 BIG5
PostgreSQL MogDB EUC_CN EUC_CN
PostgreSQL MogDB EUC_JP EUC_JP
PostgreSQL MogDB EUC_JIS_2004 EUC_JIS_2004
PostgreSQL MogDB EUC_KR EUC_KR
PostgreSQL MogDB EUC_TW EUC_TW
PostgreSQL MogDB GB18030 GB18030
PostgreSQL MogDB GBK GBK
PostgreSQL MogDB Windows936 Windows936
PostgreSQL MogDB ISO_8859_5 ISO_8859_5
PostgreSQL MogDB ISO_8859_6 ISO_8859_6
PostgreSQL MogDB ISO_8859_7 ISO_8859_7
PostgreSQL MogDB ISO_8859_8 ISO_8859_8
PostgreSQL MogDB JOHAB JOHAB
PostgreSQL MogDB KOI8R KOI8R
PostgreSQL MogDB KOI8U KOI8U
PostgreSQL MogDB LATIN1 LATIN1
PostgreSQL MogDB LATIN2 LATIN2
PostgreSQL MogDB LATIN3 LATIN3
PostgreSQL MogDB LATIN4 LATIN4
PostgreSQL MogDB LATIN5 LATIN5
PostgreSQL MogDB LATIN6 LATIN6
PostgreSQL MogDB LATIN7 LATIN7
PostgreSQL MogDB LATIN8 LATIN8
PostgreSQL MogDB LATIN9 LATIN9
PostgreSQL MogDB LATIN10 LATIN10
PostgreSQL MogDB MULE_INTERNAL MULE_INTERNAL
PostgreSQL MogDB SJIS SJIS
PostgreSQL MogDB SHIFT_JIS_2004 SHIFT_JIS_2004
PostgreSQL MogDB SQL_ASCII SQL_ASCII
PostgreSQL MogDB UHC UHC
PostgreSQL MogDB UTF8 UTF8
PostgreSQL MogDB WIN866 WIN866
PostgreSQL MogDB WIN874 WIN874
PostgreSQL MogDB WIN1250 WIN1250
PostgreSQL MogDB WIN1251 WIN1251
PostgreSQL MogDB WIN1252 WIN1252
PostgreSQL MogDB WIN1253 WIN1253
PostgreSQL MogDB WIN1254 WIN1254
PostgreSQL MogDB WIN1255 WIN1255
PostgreSQL MogDB WIN1256 WIN1256
PostgreSQL MogDB WIN1257 WIN1257
PostgreSQL MogDB WIN1258 WIN1258
Copyright © 2011-2025 www.enmotech.com All rights reserved.