Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mysql+ssl master-slave replication

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Principle of master-slave replication

As the primary server Master, it records every change in its binary log Binarylog. (from the server master binary log O thread is responsible for reading the relay log, then writing it to its own relay log, and then reading the relay log with its own sql thread and executing it on its own server. )

At this point, 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 a SSL/RSA file in the main mysql

Note: enable mysql to support ssl secure connection is mainly used for mysql master-slave replication (LAN can be either ssh connection or plaintext

Replication, but ssl connection is recommended for internet replication)

After the operation on the main mysql is completed, a copy account is generated: REQUIRE SSL

Mysql > grant replication slave on. To 'rep'@'192.168.41.%' identified by' 123456 'require ssl

Enable binary logging and restart the mysql service on master

Vim / etc/my.cnf

Add log-bin = mysql-bin

Systemctl restart mysqld

Firewall rules 3306/tcp communication

[root@localhost bin] # firewall-cmd-permanent-add-port=3306/tcp

Success

[root@localhost bin] # firewall-cmd-- reload

Success

2) configure from the server

/ etc/my.cnf of slave

Note: server_id should be unique and cannot be duplicated with other mysql hosts

In the master host, the certificate generated by the master mysql is given to the slave server

Set r permissions for slave client-key.pem

Continue to configure SSL on the slave: modify the / etc/my.cnf file to add the following

Restart the mysqld service

Systemctl restart mysqld

Ss-napt | grep 3306

Go to mysql to check whether ssl is persisted

Try connecting to the master server with SSL on the slave mysql before configuring master-slave replication:

SSL test connection is successful, and the SSL protocol logged in is: Cipher in use is DHE-RSA-AES256-SHA

Finally, configure the master-slave replicate and log in to slave mysql

Change master to from the top

Start slave\ starts the slave synchronization process:

To view the status of the slave, the following two values must be yes, which means that the slave server can connect to the master server normally.

Slave_IO_Running:Yes

Slave_SQL_Running:Yes

Test:

Master:

Slave:

Note:

Master-slave synchronization slave synchronization master,master Asynchronous slave

SSL (Secure Sockets Layer secure Sockets layer) and its successors Transport layer Security (Transport Layer Security, TLS)

It is a security protocol that provides security and data integrity for network communication. Replication is transmitted by default in clear text, through the

SSL encryption can greatly improve the security of data.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report