First, the main service mater Configuration
1. The main service will need to create an account from the server
1) into the mysq L
执行? create user 'slave'@'ip' identified by '123456';
ps:create user 'slave'@'122.11.112.3' identified by '123456';
For creating user slave, password is 123456
2) for slave account permissions
Implementation of grant replication slave on * * to 'username' @ 'Host' identified by 'password';
? ps:?grant replication slave on *.* to 'slave'@'122.11.112.3' identified by '123456';
? Flush privileges; // take effect
2. Configure /etc/my.cnf
Exit mysql, execute vi? Etc / my.cnf? Add the following configuration
?? Server-id = 2? // server-id can not be repeated
?? Log-bin = mysql-bin // log
?? Binlog-do-db = vrs // specify which database instance of mysql binlog log (VRS)
?
? ? binlog-ignore-db=information_schema
? ? binlog-ignore-db=cluster
? ? binlog-ignore-db=mysql
Restart MySQL, Service mysqld restart
3) Verify
Enter mysql execution show master status;
ps:
+------------------+----------+--------------+------------------+-------------------+
| File ? ? ? ? ? ? | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000001 | ? ? ?120 | slave ? ? ? ?| ? ? ? ? ? ? ? ? ?| ? ? ? ? ? ? ? ? ? |
+------------------+----------+--------------+------------------+-------------------+
slave is to back up the library????;
Second, the configuration from the server Slave
- /etc/my.cnf? configuration? execute vi / etc / my.cnf?? add the following configuration
????? Server-id = 3 // server-id can not be repeated
????? Log-bin = mysql-bin // log
????? Binlog-do-db = slave?? // specify the binlog mysql db which logging
????? Replicate-do-db = slave?? // parameter in the slave configuration, specify which library you want to copy slave
? ? ? ? ? log-slave-updates
? ? ? ? ? slave-skip-errors=all
? ? ? ? ? slave-net-timeout=60
?
? ? ? ? ? binlog-ignore-db=information_schema
? ? ? ? ? binlog-ignore-db=cluster
? ? ? ? ? binlog-ignore-db=mysql
? ? ? ? ? replicate-ignore-db=mysql
Configuration is complete restart mysql
? 2. Open configuration from the library
Enter from mysql
mysql -uroot -p123456
stop slave; // stop
CHANGE MASTER TO
MASTER_HOST='122.11.112.3',
MASTER_USER='slave',
MASTER_PASSWORD='123456',
MASTER_LOG_FILE = 'mysql-bin.000001', // file with the master status
MASTER_LOG_POS = 120; // same master status file location pos?
start slave; // start
3. Verify
Execute in mysql show slave status \ G?;
You will get a list of configurations,
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
If these two options is not all Yes, it shows a step ahead of you to configure wrong.
If correct you can create a table or add fields, data in the main service to be verified.