How to set up MariaDB Master-Slave replication with SSL on Ubuntu Linux

How to set up MariaDB Master-Slave replication with SSL on Ubuntu Linux

To set up MariaDB Master-Slave replication with SSL on Ubuntu, follow these steps:

  1. On the master server, generate a SSL certificate and key. You can use the openssl command to do this. For example:
refer to‮tual:‬turi.com
openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout server-key.pem -out server-cert.pem

This will generate a self-signed SSL certificate and key that are valid for 365 days.

  1. Copy the SSL certificate and key to the slave server. You can use the scp command to do this. For example:
scp server-key.pem server-cert.pem user@slave:/path/to/destination
  1. On both the master and slave servers, edit the /etc/mysql/mariadb.conf.d/50-server.cnf file and add the following lines to the [mysqld] section:
ssl-ca=/path/to/server-cert.pem
ssl-cert=/path/to/server-cert.pem
ssl-key=/path/to/server-key.pem
  1. Restart the MariaDB server on both the master and slave servers:
sudo service mysql restart
  1. On the master server, create a user for replication:
CREATE USER 'replication'@'%' IDENTIFIED BY 'password';
GRANT REPLICATION SLAVE ON *.* TO 'replication'@'%';

Replace password with a strong password.

  1. On the slave server, create a new database and set it as the default database:
CREATE DATABASE replication;
USE replication;
  1. On the slave server, execute the following command to start the replication process:
CHANGE MASTER TO
  MASTER_HOST='master',
  MASTER_USER='replication',
  MASTER_PASSWORD='password',
  MASTER_SSL=1;

Replace master with the hostname or IP address of the master server.

Created Time:2017-10-29 22:08:38  Author:lautturi