CentOS Master-slave replication

Source: Internet
Author: User


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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.