MySQL Hot spare
1 View the MySQL version to ensure that the main library is below equals from the library
2 Main Library configuration:
A need to open the support log function: Log-bin=mysql-bin
B provide server-id:server-id=1
C restart MySQL, after entering, assign copy the account from the library
GRANT REPLICATION SLAVE on * * to ' repuser ' @ ' Backip ' identified by ' repuser ';
D show master status; You can see the current position of the binary log file
E mysqldump--all-databases--single-transaction--master-data > All
Back up the database content, plus the Master-data parameter to see which log file the current backed up data corresponds to in the backed up file position
3 Configuration from the server
A server-id=2//Set database ID The default master server is 1 and can be set casually but cannot be duplicated if there are multiple slave servers.
IP address or domain name of the Master-host=masterip//master server
master-port=3306//port number of the primary database
Master-user=repuser//Synchronizing the database user
Master-password=repuser//Synchronizing the password of the database
MASTER-CONNECT-RETRY=60//If the primary server is found to be disconnected from the server, the time lag for reconnection
B start from the server, and stop Slave:slave stop first;
C Import the Master library data
D mysql> Change MASTER to
Master_host= ' Masterip ',//IP address of the primary server
-master_user= ' repuser ',//users synchronizing the database
-master_password= ' repuser ',//password for synchronizing the database
Master_log_file= ' recorded_log_file_name ',//file name of the primary server binary log
Master_log_pos=recorded_log_position; Where to start the log file
Where the log file name and start location can be found in the first few lines of the file
E slave start; end
Querying the MySQL operations log
1 show binary logs; You can see the position in each Binlog
2 mysqlbinlog binlog_file--no-defaults--start-datetime= ' 2009-12-15 00:00:00 ' |more
MySQL hot standby and query MySQL operation log