Replicating Data From MariaDB Cloud to External Database

MariaDB Cloud customers can configure outbound replication from a Replicated Transactions service to a compatible MariaDB Server running elsewhere - could be your data center, self-managed MariaDB DB on the cloud or even other managed services like AWS RDS.

MariaDB Cloud uses stored procedures to configure replication to other MariaDB or MySQL database servers.

For additional information about the stored procedures used to configure replication with Replicated Transactions services, see MariaDB Cloud Replication Helper Procedures for Replicated Transactions.

Requirements

To configure outbound replication from your Replicated Transactions service in MariaDB Cloud to an external replica server using MariaDB Server, the following requirements must be met:

  • The external replica server must use a supported version of MariaDB Server, and the external replica server must use a version in the same or newer release series as the version used by the MariaDB Cloud service.

  • When the MariaDB Cloud service uses ES 10.6, the following versions are supported for the external replica server:

    • MariaDB Server 10.6

Creating a User for Outbound Replication

With the default database admin user provided, create an external_replication user as seen below.

CREATE USER 'external_replication'@'hostname' IDENTIFIED BY 'bigs3cret';
GRANT REPLICATION SLAVE ON *.* TO 'external_replication’@'hostname';

Check User Account

On the MariaDB Cloud service, confirm that the new user has sufficient privileges by executing

SHOW GRANTS FOR 'external_replication'@'%';
+------------------------------------------------------------------------------------------------------------------------------------------------+
| Grants for external_replication@%                                                                                                              |
+------------------------------------------------------------------------------------------------------------------------------------------------+
| GRANT REPLICATION SLAVE, SLAVE MONITOR ON *.* TO `external_replication`@`%` IDENTIFIED BY PASSWORD '*CCD3A959D6A004B9C3807B728BC2E55B67E10518' |
+------------------------------------------------------------------------------------------------------------------------------------------------+

Add External Replica to Allowlist

On the MariaDB Cloud Customer Portal, add the IP address of the external replica server to the MariaDB Cloud service's allowlist - Click ‘Manage’→ ‘Manage Allowlist’ to add the IP address to the allowed list.

If your ‘external replica server’ is also running on MariaDB Cloud (say, for DR), you can find the outbound IP address from the ‘Details’ tab (Select on the Service name on the dashboard, then click ‘Details’).

Obtain GTID Position

On the MariaDB Cloud service, obtain the GTID position from which to start replication.

When you want to start replication from the most recent transaction, the current GTID position can be obtained by querying the value of the 'gtid_current_pos:

Configure GTID Position

On the external replica server, configure the GTID position from which to start replication.

The GTID position can be configured by setting the gtid_slave_pos:

Configure Replication

On the external replica server, configure replication using the connection parameters for your MariaDB Cloud service.

Replication can be configured using the CHANGE MASTER TO statement:

  • Replace FULLY_QUALIFIED_DOMAIN_NAME with the Fully Qualified Domain Name of your service

  • Replace TCP_PORT with the read-write or read-only port of your service

  • Replace ~/PATH_TO_PEM_FILE with the path to the certificate authority chain (.pem) file

Start Replication

On the external replica server, start replication.

Replication can be started using the START REPLICA statement:

Finally, Check Replication Status

On the external replica server, check replication status.

Replication status can be checked using the SHOW REPLICA STATUS statement:

Last updated

Was this helpful?