1. Primary server RPM installation MySQL
2. Copy a server called slave (from the server), for a while
3. On the master server, modify the my.cnf file to find Server-id, under it
Plus binlog-do-db = Houdunwang
4. On the master server, go to MySQL, create the Houdunwang database,
Just build a table and insert some data.
5. Open the slave server, set the IP, guaranteed to be able to surf the internet
6. Open the main server, go to MySQL, add MySQL account
Grant Replication Slave on * * to ' slave ' @ ' 192.168.1.250 ' identified by ' admin888 ';
Refresh the authorization form to make the account effective immediately
Flush privileges;
See if the user has added
Select User,host from Mysql.user;
Lock all tables of the master server
Flush tables with read lock;
Exit MySQL first, and then export the SQL
Mysqldump-uroot-p Houdunwang>houdunwang.sql
Copy the SQL files from the master server to the home directory from the server
SCP Houdunwang.sql [Email protected]:~
7. Open from server, edit/etc/my.cnf, change Server-id to 2
Restart MySQL, go to MySQL,
Set up the Houdunwang library,
Exit MySQL, perform an import operation
Mysql-uroot-p Houdunwang
8. In the main server MySQL, hit the following command to view the Bin-log status
Show master status;
9. On the MySQL from the server
Change Master to master_host= ' 192.168.21.109 ', master_user= ' slave ', master_password= ' admin888 ', master_log_file= ' Mysql-bin.000005 ', master_log_pos=725;
10. Turn on sync from server MySQL
Start slave
11. Unlock the table of the master server and operate in MySQL on the master server
Unlock tables;
CentOS Master-slave replication