To set up MariaDB Master-Slave replication with SSL on Ubuntu, follow these steps:
openssl
command to do this. For example: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.
scp
command to do this. For example:scp server-key.pem server-cert.pem user@slave:/path/to/destination
/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
sudo service mysql restart
CREATE USER 'replication'@'%' IDENTIFIED BY 'password'; GRANT REPLICATION SLAVE ON *.* TO 'replication'@'%';
Replace password
with a strong password.
CREATE DATABASE replication; USE replication;
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.