Master-slave replication settings for Mysql in LINUX
Source: Internet
Author: User
For two servers, the intranet IP address of A is 192.168.1.111, the intranet IP address of B is 192.168.1.222, A is the master, and B is the Mysql (1) vim/etc/mysql/my configured for Slave1. cnf remove server_id1 and log_bin/var/log/mysql/mysql-bin.log in the [mysqld] Segment # two servers, A's intranet IP address is 192.168.1.111, B's intranet IP address is 192.168.1.222, A as the master, B as the Slave
1. configure Mysql of
(1) vim/etc/ Mysql/My. cnf
Remove the # Comment for server_id = 1 and log_bin =/var/log/mysql/mysql-bin.log in the [mysqld] segment
Binlog-do-db = s3 s3 is the name of the database to be synchronized. if this row does not exist, all data is synchronized, and binlog_ignore_db = mysql. The name of the database to ignore synchronization is mysql. if there are multiple data to be synchronized or ignored, configure multiple rows and save and exit.
(2) create a copy account (name: repl, allow remote connection, password: 123456 ):
Grant replication slave, RELOAD, SUPER, NO *. * TO repl @ '%' identified by '123 ';
Flush privileges;
(3) restart the mysql service or directly reboot the machine.
(4) enter mysql, and then use show master status \ G to view the status of the binary log. The result is similar to the following:
+ ------------------ + ---------- + -------------- + ------------------ + | File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+ ------------------ + ---------- + -------------- + ------------------ +
| Mysql-bin.000003 | 1376 | s3 |
+ ------------------ + ---------- + -------------- + ------------------ +
2. configure Mysql of B
(1) vim/etc/mysql/my. cnf
Remove the # comment of server_id = 1 and log_bin =/var/log/mysql/mysql-bin.log in the [mysqld] segment and change server_id to 2, which is different from the master machine. Add the following content:
Binlog_do_db = s3
Log-slave-updates
Save and exit
(2) restart the mysql service
(3) go to mysql and run
Change master TOMASTER_HOST = '192. 168.1.111 ', MASTER_USER = 'repl', Master_Port = 192, MASTER_PASSWORD = '000000', MASTER_LOG_FILE = 'MySQL-bin.000003', MASTER_LOG_POS = 3306;
Slave start;
Note that in the above CHANGE statement, MASTER_LOG_FILE and MASTER_LOG_POS are the results of the show masterstatus command mentioned in 1.4 above, specifying the binary file name and the location where synchronization starts.
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