Introduction: MySQL supports one-way, asynchronous replication, in which one server acts as a master and one or more other servers act as slaves. The Master writes the update to a binary log file and maintains an index of the log file to track the log loop.
First, MySQL dual-machine synchronous replication
MySQL supports one-way, asynchronous replication, one server acts as the master during replication, and one or more other servers act as slaves. The Master writes the update to a binary log file and maintains an index of the log file to track the log loop. When a slave connects to the Master, it notifies the Master of the location of the last successful update that Slave read in the log. Slave receives any updates that have occurred since then, then blocks and waits for the Master to notify the next update.
Two MySQL databases are installed on hosts located in different places. The two servers are active and standby. When one of the nodes fails, the other node can take over the application on the server. The data of the nodes is consistent in real time, and the synchronization function of MySQL is used to achieve synchronous replication of the two machines.
Second, the configuration specification
configure dual-machine mutual standby on two nodes as needed, the relevant information is as follows:
Third, the environment confirms
operation The system selects the CentOS 6.4 x86_64 version, and the MySQL version is 5.6.23. Follow the steps below to confirm the environment of the two nodes:
3.1. Kernel and Release
Note: If you have used yum upgrade, the system will automatically upgrade the latest source version.
3.3. Firewall and enforce configuration
Note: SELINUX=disabled in /etc/selinux/config can be modified, but it is not recommended to stop the firewall
3.4. Confirm MySQL
four, MySQL two-node synchronization settings
4.1. Create a log file and authorize
touch /var/lib/mysql/mysql-bin on two nodes respectively. Log
chmod 755 /var/lib/mysql/mysql-bin. Log
chown -R mysql:mysql /var/lib/mysql/mysql-bin. Log
4.2. Edit /usr/my. Cnf
--Run on two nodes respectively vi /usr/my. Cnf
server-id=1 --where usdb6 is set to 1, but usdb7 must change it to 2
binlog-ignore-db=information_schema,mysql,performance_schema[123 ]auto-increment-increment=2auto-increment-offset=1--where usdb6 is set to 1, but usdb7 must change it to 24.3. Restart MySQL4.4. Authorization of the account master nodegrant replication slave on *. * to 'slave'@'220.127.116.11' identified by 'oracle';slave nodegrant replication slave on *. * to 'slave'@'18.104.22.168' identified by 'oracle';
This article was written by the author of the cutting-edge technology, and the views represent only the author and do not represent the OFweek position. If you have any infringement or other problems, please contact us.