Master-Slave replication principle
- As master server master, each of its changes will be recorded into the binary log binarylog. (The server I/O thread is responsible for reading the master binary log, then writing itself to the relay log and then reading the relay log with its own SQL thread and executing it on its own server.) )
The changes on the master server are synchronized to the slave server.
Environment:
|centos7| Master | Slave |
mysql5.7 | 192.168.41.10 | 192.168.41.20 |
1. Implement master-slave replication based on SSL secure connection
1) Create Ssl/rsa file in main MySQL
Note: Enable MySQL support SSL secure connection is mainly used for MySQL master-slave replication (LAN can be non-SSH connection is clear
replication, but Internet replication recommends an SSL connection)
The operation on master MySQL is completed and regenerated into a copy account: REQUIRE SSL
Mysql>grant replication Slave on . to ' rep ' @ ' 192.168.41.% ' identified by ' 123456 ' require SSL;
Enable binary logs on Master and restart the MySQL service
Vim/etc/my.cnf
Add Log-bin = Mysql-bin
Systemctl Restart Mysqld
Firewall rules 3306/TCP Communication
[Email protected] bin]# firewall-cmd--permanent--add-port=3306/tcp
Success
[Email protected] bin]# Firewall-cmd--reload
Success
2) from the server configuration
Slave's/ETC/MY.CNF
Note: server_id is unique and cannot be duplicated with other MySQL hosts
The master MySQL-generated certificate is given to the slave server in the master host.
Set r permissions for slave Client-key.pem
Continue to configure SSL from: Modify the/etc/my.cnf file to add the following
Restart MYSQLD Service
Systemctl Restart Mysqld
Ss-napt |grep 3306
Go to MySQL to see if SSL is persistent
Then you can try to connect to the master server with SSL from MySQL before configuring master-slave Replication:
The SSL test connection was successful and the login SSL protocol was: Cipher in use is Dhe-rsa-aes256-sha
Finally start configuring master-slave Replicate, login slave mysql
On the change from master to
Start slave \ Boot from the synchronization process:
To view the status from, the following two values must be yes, representing a normal connection from the server to the primary server
Slave_io_running:yes
Slave_sql_running:yes
Test:
Master
Slave
Attention:
Master-slave synchronous slave synchronous Master,master Slave
SSL (secure Sockets Layer Security socket), and its successor Transport Layer Security (Transport layer safety, TLS)
is a security protocol that provides security and data integrity for network communications. Replication is transmitted by default in clear text, by
SSL encryption can greatly improve the security of the data.
Mysql+ssl Master-slave replication