Master-slave Replication steps
1: Open the main library binlog function
See if 3306 is turned on
grep log-bin/etc/my.cnf
See if it's not the same
2: Make sure the Server-id is different
grep server-id/etc/my.cnf
grep server-id/data/3307/my.cnf
3: User rep for Master library authorized replication
Grant Replication Slave on * * to [e-mail protected] ' 192.168.1.102 ' identified by ' 2017 ';
See if authorization is successful
4: Lock table, view Binlog location point
Lock table to ensure database consistency
Flush table with read lock;
Show master status; Look at the backup point
Show master status;
+------------------+----------+--------------+------------------+
| File | Position | binlog_do_db | binlog_ignore_db |
+------------------+----------+--------------+------------------+
| mysql-bin.000053 | 339 | | |
+------------------+----------+--------------+------------------+
5. New open window export fully prepared
Mysqldump-uroot-p2017-a-B--events-s/tmp/mysql.sock|gzip >/home/chaofu/rep_bak_$ (date +%F). sql.gz
6:unlock Table Release Lock
From library:
1: Make sure the Server-id is different
2: Restore the data from the main library to the library
Gzip-d rep_bak.sql.gz
Mysql-uroot-p-s/data/3307/mysql.sock
3: Find location point, configure Master.info
Change MASTER to
Master_host= ' 192.168.1.102 ',
master_port=3306,
Master_user= ' rep ',
master_password= ' 2017 ',
Master_log_file= ' mysql-bin.000053 ',
master_log_pos=339;
Find/data/3307/data-type-f-name "*.info"
4: Turn on the backup switch
Start slave;
show slave status \g;
Two threads from a library
5: Test
Master-slave replication schematic diagram
This article is from the "9124122" blog, please be sure to keep this source http://9134122.blog.51cto.com/9124122/1983955
MySQL Master-slave replication