Outbound Parallel Replication from Distributed Transactions to MariaDB Xpand

Overview

MariaDB SkySQL customers can configure outbound parallel replication from a Distributed Transactions service that uses MariaDB Xpand 6 to MariaDB Xpand.

For additional information about the stored procedures used to configure replication with Distributed Transactions services, see "SkySQL Replication Helper Procedures for Distributed Transactions".

Use Cases

  • Offsite replica for Disaster Recovery (DR)

  • Dedicated replica for reporting workloads

Compatibility

  • Distributed Transactions, with MariaDB Xpand 6

Requirements

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

  • The external replica server must use the same character set and collation as the SkySQL service.

  • The external replica server must use MariaDB Xpand 6.

Create User Account for Replication

On the SkySQL service, create a user account to use for replication.

A replication user account can be created by calling the sky.install_repl_users() stored procedure:

CALL sky.install_repl_users();

Get User Account Credentials for Replication

On the SkySQL service, get the credentials for the user account created in the last step.

The credentials can be obtained by calling the sky.get_replica_creds() stored procedure:

CALL sky.get_replica_creds();
+-------------------------------+----------------------------------+
| PRIMARY_USER                  | PRIMARY_PASSWORD                 |
+-------------------------------+----------------------------------+
| skysql_replication            | <password>                       |
+-------------------------------+----------------------------------+

Check User Account

On the SkySQL service, confirm that the new user has sufficient privileges by executing SHOW GRANTS:

SHOW GRANTS FOR 'skysql_replication'@'%';
+-----------------------------------------------------------------------+
| Grants for skysql_replication@%                                       |
+-----------------------------------------------------------------------+
| GRANT REPLICATION SLAVE ON *.* TO 'skysql_replication'@'%'            |
+-----------------------------------------------------------------------+

Add External Replica to Allowlist

On the SkySQL Customer Portal, add the IP address of the external replica server to the SkySQL service's allowlist.

Create Binary Log

On the SkySQL service, create a binary log.

A binary log can be created by calling the sky.create_binlog() stored procedure. The stype parameter should be set to xpand:

CALL sky.create_binlog('xpand', 'xpand-bin');

Obtain Binary Log File and Position

On the SkySQL service, obtain the binary log file and position.

The binary log file and position can be obtained by calling the sky.binlog_status_parallel() stored procedure:

CALL sky.binlog_status_parallel();
+-----------+----------+--------------+------------------+
| File      | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+-----------+----------+--------------+------------------+
| xpand-bin |        0 |              |                  |
+-----------+----------+--------------+------------------+

Configure Replication

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

Replication can be configured using the CREATE SLAVE statement:

CREATE SLAVE 'default'
   MASTER_HOST='FULLY_QUALIFIED_DOMAIN_NAME',
   MASTER_PORT=TCP_PORT,
   MASTER_USER='skysql_replication',
   MASTER_PASSWORD='my_password',
   MASTER_SSL=1,
   PARALLEL_LOG='xpand-bin',
   PARALLEL_POS=0,
   SLICES=6,
   BATCH_SIZE_MS=5000;
  • 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

Start Replication

On the external replica server, start replication.

Replication can be started using the START SLAVE statement:

START SLAVE;

Check Replication Status

On the external replica server, check replication status.

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

SHOW SLAVE STATUS\G
*************************** 1. row ***************************
             Slave_Name: default
           Slave_Status: Running
            Master_Host: my-service.mdb0002147.db.skysql.net
            Master_Port: 5001
            Master_User: skysql_replication
        Master_Log_File: xpand-bin
          Slave_Enabled: Enabled
           Log_File_Seq: 1
           Log_File_Pos: 4
             Last_Error: no error
      Connection_Status: Connected
   Relay_Log_Bytes_Read: 0
Relay_Log_Current_Bytes: 0
  Seconds_Behind_Master: NULL