Destination PostgreSQL#
The extractedreplicant-cli will be referred to as the$REPLICANT_HOME directory in the following steps.
Required permissions#
Make sure that the user being used for replication, has the
CREATE TABLEprivilege on the target catalogs or schemas where you want to replicate the tables to. Use the following command to grant the privileges:GRANTCREATEONDATABASE<catalog_name>TO<replication_user>;Replace the following:
catalog_name: the catalog name in the targetreplication_user: the user being used for replication
In order to store Arcion’s replication metadata, you must ensure one of the following:
- Point to an external metadata database. For more information, seeMetadata configuration.
- Grant the
CREATEDBprivilege to the user being used for replication. This allows the user to create theiodatabase. The user must also possess the privilege to create tables in theiodatabase. Replicant uses thisiodatabase to maintain internal checkpoint and metadata.
The following command assigns the
CREATEDBprivilege to a useralex:ALTERUSER alexCREATEDB;If the user does not have
CREATEDBprivilege, then follow these two steps:- Create a database manually with the name
io:CREATEDATABASE io; - Grant all privileges for the
iodatabase to that user:GRANTALLONDATABASE ioTO alex;
I. Set up connection configuration#
To connect to your PostgreSQL target database, you have these two options:
You can specify your connection details to Replicant with a YAML connection configuration file. You can find a sample connection configuration filecloudsql_postgresql.yaml in the$REPLICANT_HOME/conf/conn directory.
type:POSTGRESQLhost:HOSTNAMEport:PORT_NUMBERdatabase:'DATABASE_NAME'username:'USERNAME'password:'PASSWORD'max-connections:30socket-timeout-s:60max-retries:10retry-wait-duration-ms:1000Replace the following:
HOSTNAME: the hostname of the target PostgreSQL instancePORT_NUMBER: the port numberDATABASE_NAME: the database nameUSERNAME: the username of the user that connects to the PostgreSQL serverPASSWORD: the password associated withUSERNAME
Feel free to change the following parameter values as you need:
max-connections: the maximum number of connections Replicant opens in Cloud SQL instance.max-retries: number of times Replicant retries a failed operation.retry-wait-duration-ms: duration in milliseconds Replicant waits between each retry of a failed operation.socket-timeout-s: the timeout value in seconds specifying socket read operations. A value of0disables socket reads. This parameter is only supported for Arcion self-hosted CLI versions 22.02.12.16 and newer.
Important: Make sure thatmax_connectionsin PostgreSQL exceeds themax-connectionsparameter in the preceding connection configuration file.
II. Configure mapper file (optional)#
If you want to define data mapping from source to your target PostgreSQL, specify the mapping rules in the mapper file. The following is a sample mapper configuration for aMySQL-to-PostgreSQL pipeline:
rules:[tpch, public]:source: - [tpch]For more information on how to define the mapping rules and run Replicant CLI with the mapper file, seeMapper configuration.
III. Set up Applier configuration#
To configure replication mode according to your requirements, specify your configuration in the Applier configuration file. You can find a sample Applier configuration filepostgresql.yaml in the$REPLICANT_HOME/conf/dst directory. For example:
You can configure PostgreSQL for operating in eithersnapshot orrealtime modes.
Configuresnapshot mode#
For operating insnapshot mode, specify your configuration under thesnapshot section of the conifiguration file. For example:
snapshot:threads:16batch-size-rows:5_000txn-size-rows:1_000_000skip-tables-on-failures:falsemap-bit-to-boolean:falsebulk-load:enable:truetype:FILE# FILE or PIPE_traceDBTasks:trueuse-quoted-identifiers:true Additionalsnapshot parameters#
map-bit-to-boolean- Tells Replicant whether to map
bit(1)andvarbit(1)data types from source tobooleanon target.If
true, Replicant mapsbit(1)/varbit(1)data types from source tobooleanon target PostgreSQL. Iffalse, Replicant mapsbit(1)/varbit(1)data types from source tobit(1)/varbit(1)on target PostgreSQL.Default:
false.
For more information about the Applier parameters forsnapshot mode, seeSnapshot mode.
Configurerealtime mode#
If you want to operate inreal time, use therealtime section to specify your configuration. For example:
realtime:threads:8txn-size-rows:10000batch-size-rows:1000skip-tables-on-failures:falseuse-quoted-identifiers:trueFor more information about the configuration parameters forrealtime mode, seeRealtime mode.