MySQL主從同步從庫(kù)上Slave_IO_Running: Connecting問(wèn)題
成都創(chuàng)新互聯(lián)堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:網(wǎng)站設(shè)計(jì)制作、網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時(shí)代的梅里斯網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!
一.在做主從同步時(shí)遇到的問(wèn)題
數(shù)據(jù)庫(kù)主從問(wèn)題從庫(kù)上Slave_IO_Running: Connecting
在做mysql主從同步的時(shí)候有時(shí)候發(fā)現(xiàn)在從庫(kù)上Slave_IO_Running: Connecting
二.解決辦法通常是5個(gè)問(wèn)題:
1.網(wǎng)絡(luò)不通 #互ping機(jī)器ip,無(wú)丟包率正常訪問(wèn),排除
2.密碼不對(duì) #MySQL重新授權(quán)遠(yuǎn)程用戶登陸賬號(hào),重新設(shè)置密碼,排除
3.pos不正確 #主服務(wù)器,登陸數(shù)據(jù)庫(kù)重新查看起始偏移量show master status,排除
4.ID問(wèn)題
#ID的問(wèn)題,在安裝完mysql數(shù)據(jù)庫(kù)的時(shí)候默認(rèn)他們的server-id=1 但是在做主從同步的時(shí)候需要將ID號(hào)碼設(shè)置不一樣才行,查看數(shù)據(jù)庫(kù)配置文件cat /etc/my.cnf,文件寫的不同,排除
5.防火墻策略
查看防火墻策略,是否放通雙方的服務(wù)端口 iptables -nL,最后發(fā)現(xiàn) 防火墻策略寫了多端口防火墻策略的端口不生效,解決防火墻策略單獨(dú)開放端口,暫停從服務(wù)的io讀取stop slave;重新在從的數(shù)據(jù)庫(kù)寫入以下語(yǔ)句:
mysql> change master to
-> master_host='192.168.137.36',
-> master_user='root',
-> master_password='abc123',
-> master_port=3307,
-> master_log_file='mysql-bin.000001',
-> master_log_pos=848;
Query OK, 0 rows affected, 2 warnings (0.05 sec)
mysql> start slave;
Query OK, 0 rows affected (0.02 sec)
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.137.36
Master_User: root
Master_Port: 3307
Connect_Retry: 60
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 1298
Relay_Log_File: localhost-relay-bin.000002
Relay_Log_Pos: 770
Relay_Master_Log_File: mysql-bin.000001
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: 1298
Relay_Log_Space: 981
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: 0
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: 9
Master_UUID: ad899234-9c81-11e7-99bd-000c29af2bef
Master_Info_File: /data/mysql_data1/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
1 row in set (0.00 sec)
注意:標(biāo)注的倆個(gè)紅色yes為正常。