现有master@172.20.0.2和slave@172.20.0.3,并且已经通过mysqldump将数据同步至从库slave中. 现在在从服务器slave上配置复制链路
mysql> change master to master_host='master',master_user='repl',master_password='123456',master_auto_position=1;
Query OK,0 rows affected,2 warnings (0.06 sec)
启动复制
mysql> start slave;
启动成功后查看slave的状态
mysql> show slave statusG
*************************** 1. row ***************************
Slave_IO_State: Queueing master event to the relay log
Master_Host: master
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000002
Read_Master_Log_Pos: 12793692
Relay_Log_File: relay-bin.000002
Relay_Log_Pos: 1027
Relay_Master_Log_File: mysql-bin.000002
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 814
Relay_Log_Space: 12794106
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 5096
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 101
Master_UUID: a9fd4765-ec70-11e6-b543-0242ac140002
Master_Info_File: mysql.slave_master_info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Reading event from the relay log
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set: a9fd4765-ec70-11e6-b543-0242ac140002:1-39
Executed_Gtid_Set: a9fd4765-ec70-11e6-b543-0242ac140002:1-4
Auto_Position: 1
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
1 row in set (0.00 sec)
当Slave_IO_Running,Slave_SQL_Running为YES,
且Slave_SQL_Running_State 为Slave has read all relay log; waiting for more updates时表示成功构建复制链路
6、总结
优点
- 因为不用手工设置日志偏移量,可以很方便地进行故障转移
- 如果启用log_slave_updates那么从库不会丢失主库上的任何修改
缺点
- 对执行的SQL有一定限制
- 仅支持MySQL 5.6之后的版本,而且不建议使用早期5.6版本
(编辑:鹤壁站长网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|