Destination Cloud SQL for MySQL#
This page describes how to load data in real time intoGoogle’s Cloud SQL for MySQL, a fully managed service for MySQL relational database.
The following steps refer to the extractedArcion self-hosted CLI download as the$REPLICANT_HOME directory.
Prerequisites#
Pay attention to the following before configuring Cloud SQL for MySQL as the target system:
To replicate tables into the catalogs or schemas you need, make sure that the specified user possesses the
CREATE TABLEandCREATE TEMPORARY TABLEprivileges on those catalogs and schemas.If you want Replicant to create catalogs or schemas for you on the target Cloud SQL for MySQL system, then you must grant
CREATE DATABASEorCREATE SCHEMAprivileges respectively to the user.If the user does not have
CREATE DATABASEprivilege, the follow these steps:- Create a database manually with name
io_blitzz. - Grant all privileges for the
io_blitzzdatabase to that user.
Replicant uses this
io_blitzzdatabase to maintain internal checkpoints and metadata.- Create a database manually with name
I. Set up connection configuration#
Specify your connection details to Replicant with a connection configuration file. You can find a sample connection configuration filecloudsql_mysql.yaml in the$REPLICANT_HOME/conf/conn directory.
Specify the connection details in the following manner:
type:CLOUDSQL_MYSQLhost:CLOUDSQL_MYSQL_IPport:PORT_NUMBERusername:'USERNAME'password:'PASSWORD'max-connections:30max-retries:10retry-wait-duration-ms:1000Replace the following:
CLOUDSQL_MYSQL_IP: the IP address of the Cloud SQL for MySQL instancePORT_NUMBER: the port numberUSERNAME: the usernamePASSWORD: 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 instancemax-retries: number of times Replicant retries a failed operationretry-wait-duration-ms: duration in milliseconds Replicant waits between each retry of a failed operation.
The following shows a sample connnection configuration:
type:CLOUDSQL_MYSQLhost:12.34.456.78port:57565username:"replicant"password:"Replicant#123"max-connections:30max-retries:10retry-wait-duration-ms:1000II. Configure mapper file (optional)#
If you want to define data mapping from your source to Cloud SQL for MySQL, specify the mapping rules in the mapper file. For more information on how to define the mapping rules and run Replicant CLI with the mapper file, seeMapper configuration.
For example, the following sample applies to a MySQL-to-Cloud SQL for MySQL pipeline:
rules:[tpch]:source: -tpchtables:DST_PART:source:[tpch, PART]:DST_ORDERS:source:[tpch, ORDERS]:III. Configure metadata (optional)#
To ensure fault tolerance and resilience in replication, Arcion Replicant needs to maintain a number of metadata tables. Replicant uses a metadata configuration file to handle metadata-related operations. For more information, seeMetadata configuration.
The following shows a sample metadata configuration:
type:MYSQLconnection:host:localhostport:53585username:'replicant'password:'Replicant#123'max-connections:30catalog:io_replicateIV. 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 filecloudsql_mysql.yaml in the$REPLICANT_HOME/conf/dst directory.
Configuresnapshot mode#
For operating insnapshot mode, specify your configuration under thesnapshot section of the configuration file. For example:
snapshot:threads:32batch-size-rows:10_000txn-size-rows:1_000_000bulk-load:enable:truetype:FILEskip-tables-on-failures:true_traceDBTasks:truehandle-failed-opers:trueuse-upsert-based-recovery:falsefk-cycle-resolution-method:REMOVE_FK# BLOCK_TABLES to break cycle or REMOVE_FK(default) to remove constraintuser-role:init-user-roles:trueTip: If you want to use bulk loading, make sure to setthelocal_infiledatabase flag toonin Cloud SQL for MySQL.
For more information about the Applier parameters forsnapshot mode, seeSnapshot mode.
Configure real-time replication#
For operating inrealtime mode orfull mode, specify your configuration under therealtime section of the conifiguration file. For example:
realtime:threads:32batch-size-rows:10_000txn-size-rows:1_00_000replay-replace-as-upsert:falseskip-tables-on-failures:falsehandle-failed-opers:true# Transactional mode config# realtime:# threads: 1# batch-size-rows: 1000# replay-consistency: GLOBAL# txn-group-count: 100# _oper-queue-size-rows: 20000# skip-upto-cursors: #last failed cursorFor more information about the configuration parameters forrealtime mode, seeRealtime mode.