1. Prepare two virtual machines a 192.168.174.132 "master" B 192.168.174.133 "from" 2.MySQL version >5.03. Common commands Show Master status;show slave status;show Procudesslist \g; You can see how many clients are currently linked to this library 4. Configuration 4.1. Make sure/etc/my.cnf belongs to the current MySQL, you can copy the auto-generated to/ETC/MY.CNF cp/usr/shara/mysql/my-medium.cnf/etc/ MY.CNF 4.2. Main Library configuration my.cnf server-id=10101 log-bin=mysql-bin binlog-ignore-db=mysql,test innodb_flush_log_at_trx_commit= 1 sync_binlog=1 log_slave-updates Show Master Status View current main library state to add a user from the library GRANT REPLICATION Slave on * * to ' repl ' @ ' 2.2.2.% ' Identified by ' Testpass '; Restart MySQL 4.3 from library configuration my.cnf server-id=20101 Replicate-do-db=demo//data block to be synchronized replicate-do-table=user//table to be synchronized "can add more than one" Master-info-file=master.info Relay-log=relay-relay-bin Relay-log-index=relay-relay-bin.index relay-log-info= Relay-relay-log.info restart MySQL to enter MySQL settings Master library information may need to be closed first slave [stop slave] Change master to master_host= ' 1.1.1.1 ',//main library IP mast Er_user= ' repl ',//the user name assigned in the main library master_password= ' Testpass ',//Assigned password master_log_file= ' mysql-bin.000003 ',//main library Show File master_log_pos=107 in master status; //main Library show master status Open Slave "start slave" restart MySQL view from library info Show slave ensure middle Slave_io_running=yes slave_sql_running=yes out Wrong can view the MySQL error log location by viewing the MySQL bug log position show variables like ' log_error '; If the synchronization fails, you can go through show slave status; View the SQL statement of the error execution. Start slave is then required because an error will automatically stop slave
MySQL master-slave synchronization