MySQL Replication
MySQL replication refers to the transfer of DDL and DML operations on the main library to the library from the binary log, keeping the master and the data from the library in sync
MySQL Master-slave Architecture: Advantages: Can cut the library when failure, read and write separation, perform other business from the library such as backup.
1:master-slave Master-Slave synchronization
2:master-slave-slave ... Cascade
3:master-master Mutual Primary Preparation
"Master-Slave Synchronization" Master-slave
Note: The main library is required to open log-bin; set Server-id
#mysqldump-uroot-p--all-databases--master-data=2--routines--events--quick>
--master-data=2 indicates that the export data needs to be recorded at the time the Binlog location of the main library--routines represents the export stored procedure--events represents the export event--quick means that the server does not send the result set one at a time, but sends it in batches. Reduced pressure Note: The--master-data is the lock library by default, ensuring data consistency, that is, the consistency of the exported data and the Binlog location. For the InnoDB engine, you can increase the--single-transaction unlock library and use the INNODB Transaction feature to ensure consistent data
#创建同步账号
#grant replication Slave, replication client on * * to [email protected] '% ' identified by ' Gechong ';
#确定主库同步点
You can perform the SHOW master STATUS on master; You can also view the file you just exported
#从库同步数据
#mysql-uroot-p < Master_data_20140920.sql
#从库CHANGE
#CHANGE MASTER to master_log_file= ' mysql.000002 ', master_log_pos=525, master_host= ' 10.1.29.10 ', master_port=3306, Master_user= ' replication ', master_password= ' Gechong ';
#查看从库状态
#SHOW SLAVE STATUS \g
If both slave_io_running and slave_sql_running are yes, the Master-slave is built successfully.
Master-slave master-Slave synchronization of MySQL master-slave architecture