Redis4.0從庫複製報錯"master_link_status:down"處理一例

chenfeng發表於2018-12-28

環境描述:

Redis版本:4.0.2

主庫:192.168.0.190

從庫:192.168.0.191


今天Zabbix告警一直出現redis sync error的資訊,於是登陸redis發現從庫複製狀態一直是master_link_status:down的狀態。


從庫日誌報錯資訊如下:

17365:S 28 Dec 14:45:15.294 * Connecting to MASTER 192.168.0.190:6379

17365:S 28 Dec 14:45:15.294 * MASTER <-> SLAVE sync started

17365:S 28 Dec 14:45:15.294 * Non blocking connect for SYNC fired the event.

17365:S 28 Dec 14:45:15.295 * Master replied to PING, replication can continue...

17365:S 28 Dec 14:45:15.295 * Partial resynchronization not possible (no cached master)

17365:S 28 Dec 14:45:15.341 * Full resync from master: 3987160bba8279fe30b828fb339d1c0c6536a3ab:182474982617073

17365:S 28 Dec 14:45:17.293 # I/O error reading bulk count from MASTER: Resource temporarily unavailable



主庫報錯日誌資訊如下:

25573:M 28 Dec 15:38:53.255 * Background saving started by pid 12067

25573:M 28 Dec 15:38:53.258 # Client id=87019085 addr=192.168.0.191:1440 fd=110 name= age=0 idle=0 flags=S db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=6641 oll=1 omem=19125 events=r cmd=psync scheduled to be closed ASAP for overcoming of output buffer limits.

25573:M 28 Dec 15:38:53.356 # Connection with slave 192.168.0.191:6379 lost.


從主庫日誌中我們可以看出在redis主庫在接到從庫要求重新同步資料的時候先生成一個rdb檔案,再透過psync來做部分同步,可以看到問題就出在這一塊,

持續報錯”psync scheduled to be closed ASAP“,這個原因是由於client-output-buffer-limit值設定的太小從而導致資料傳送失敗。


解決方法:

登陸主庫和從庫修改緩衝區佔用內容大小限制:


127.0.0.1:6379> config set client-output-buffer-limit "slave 8589934592 2147483648 0"

OK

同步到配置檔案:

127.0.0.1:6379> config rewrite

OK

檢視配置檔案內容

# cat redis.conf |grep client-output-buffer-limit  

client-output-buffer-limit normal 0 0 0

client-output-buffer-limit slave 8gb 2gb 0


登陸從庫192.168.0.191,再次觀察主從複製狀態,發現從庫的的複製狀態很快就變成了up:

# redis-cli info replication

# Replication

role:slave

master_host:192.168.0.190

master_port:6379

master_link_status:up


至此,問題處理完畢。


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15498/viewspace-2286846/,如需轉載,請註明出處,否則將追究法律責任。

相關文章