Note: The environment is the primary library single instance, from the library multiple instances.
The main library opens Logbin, confirming that the server ID is different from the library
[Email protected] backup]# egrep "Log-bin|server-id"/etc/my.cnf
Server-id= 1
Log-bin=mysql-bin
[Email protected] backup]# egrep "Log-bin|server-id"/data/3306/my.cnf
#log-bin =/data/3306/mysql-bin
Server-id = 06
2. Master repository user for access from library
[[email protected] backup]# mysql-uroot-p111111-e "Grant replication Slave on * * to ' rep ' @ '% ' identified by ' 111111 '; fl Ush privileges; "
[[email protected] backup]# MYSQL-UROOT-P111111-E "show grants for rep"
+-------------------------------------------------------------------------------------------------------------- --+
| Grants for [email protected]% |
+-------------------------------------------------------------------------------------------------------------- --+
| GRANT REPLICATION SLAVE on * * to ' rep ' @ '% ' identified by PASSWORD ' *FD571203974BA9AFE270FE62151AE967ECA5E0AA ' |
3. Primary Library Backup
Mysqldump-uroot-p111111-a-B--events-master-data=1-x >/backup/db.sql
#备注: Official Recommendation: Lock table view (flush table with read Lock:show master status;show master logs;)---> Backup---> Unlock (unlock tables):
4. Import from library (data SCP has been sent over)
Mysql-uroot-p111111-s/data/3306/mysql.sock </backup/db.sql
5. Change Master,start slave from the library.
Change Master to master_host= ' 192.168.199.21 ', master_port=3306, master_user= ' rep ', master_password= ' 111111 ', master_ Log_file= ' mysql-bin.000025 ', master_log_pos=107;
Start slave;
show slave status \g;
1. Row ***************************
Slave_io_state:waiting for Master to send event
master_host:192.168.199.21
Master_user:rep
master_port:3306
Connect_retry:60
master_log_file:mysql-bin.000025
read_master_log_pos:107
relay_log_file:relay-bin.000002
relay_log_pos:253
relay_master_log_file:mysql-bin.000025
Slave_io_running:yes
Slave_sql_running:yes
....
ERROR:
No query specified
MySQL master slave 1 (2015-11)