First set up the MySQL master server:
To create a user from the server on the primary server:
1.grant replication Slave on *.* to 192.168.0.1 identified by ' 1234 ';
#4.1 with this, before you can use file.
#grant file on *.* to 192.168.0.1 identified by ' 1234 ';
#后来我又加了super和client Save permission, you can not add it first. and then try again.
Configuration file:/etc/my.cnf
2. On the primary server
Server-id = 1
Log-bin
binlog-do-db= the name of the database you want to back up, and if you back up multiple databases, repeat this option
binlog-ignore-db= database does not need to be backed up, if you back up multiple databases, repeat this option
3. From the server
Log-bin
server-id=2
Master-host= Host
master-user= User Name
master-password= Password
master-port= Port
replicate-do-db= the name of the database you want to back up, and if you back up multiple databases, repeat this option
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Just as simple as the above configuration is OK.
Related commands on the primary server:
Show Master Status
Show slave hosts
Show logs
Show Binlog Events
Purge logs to ' log_name '
Purge logs before ' date '
Reset Master (old version flush Master)
Set sql_log_bin=
Related commands from the server:
Slave start
Slave stop
SLAVE STOP io_thread//This thread writes the log of the master segment to the local
SLAVE Start Io_thread
SLAVE STOP sql_thread//This thread applies logs written to local to the database
SLAVE Start Sql_thread
Reset Slave
SET GLOBAL Sql_slave_skip_counter
Load data from Master
Show slave status (Super,replication CLIENT)
Changes master to master_host=, master_port=,master_user=, master_password=//dynamic Change master information
PURGE Master [before ' date '] Deletes a log that has been synchronized at the master end
#
Something:
To do the experiment is to a long running and very critical database backup, encountered two problems
1. The configuration files for two databases are different.
Even the font is not the same. No language ing
2. Database file inconsistency problem, which was generated later. So no matter how important the primary server is to do from the server when the master server must be
Stop, cuff the stuff to the server.
And then more to see the MySQL log file, very helpful