Environment:
CentOS7.4
CA host One
MySQL host two
Database: MariaDB-5.5 First, prepare the certificate file
1. Generate a CA self-signed certificate
mkdir /etc/my.cnf.d/sslcd /etc/my.cnf.d/sslopenssl genrsa 2048 > cakey.pemchmod 600 cakey.pemopenssl req -new -x509 -key cakey.pem -days 3650 -out cacert.pem
2. Generate Master private key and certificate request
openssl req -newkey rsa:2048 -days 365 -nodes -keyout master.key > master.csr
3. Issue a certificate to master
openssl x509 -req -in master.csr -CA cacert.pem -CAkey cakey.pem -set_serial 01 > master.crt
4. Generate slave private key and certificate request
openssl req -newkey rsa:2048 -days 365 -nodes -keyout slave.key > slave.csr
5. Issuing certificates to Slave
openssl x509 -req -in slave.csr -CA cacert.pem -CAkey cakey.pem -set_serial 02 > slave.crt
6. Distribute the certificate files to master and slave separately
Master:
Slave:
Second, the main library configuration
#修改/etc/my.cnf
#添加ssl等配置信息
Create a copy user from the library and allow only encrypted connections over SSL:
mysql> grant replication slave on *.* to ‘repluser‘@‘192.168.1.%‘ identified by ‘mysql‘ require ssl;
Third, from the library configuration
#修改/etc/my.cnf
#添加ssl等配置信息
To configure the connection main Library information:
change master to master_host=‘192.168.1.2‘,master_user=‘repluser‘,master_password=‘mysql‘,master_log_file=‘mariadb-bin.000001‘,master_log_pos=245,master_ssl=1;start slave;show slave status\G
Iv. test master/Slave synchronization
MySQL master-slave replication uses SSL encryption