1. 程式人生 > >Windows下Redis主從配置出現Writing to master:Unknow error

Windows下Redis主從配置出現Writing to master:Unknow error

nec redis主從 comm 當我 nds slave log 系統 shake

異常:Sending command to master in replication handshake: -Writing to master: Unknown error;

解決結論:

  從數據庫的slaveof所寫的ip地址要和 主數據庫的bind第一個參數相同;

解決過程:

一、當我在一臺操作系統為win10的64位電腦上進行redis主從配置時,出現以上錯誤,死活連接不上,當時配置如下;

  1、(master)配置redis.windows.conf

    (1)bind 127.0.0.1 172.16.XX.XX(本臺電腦ip)

    (2)port 6379

  2、(slave1)配置redis.windows6380.conf

    (1)bind 127.0.0.1 172.16.XX.XX(本臺電腦ip)

    (2)port 6380

    (3)slaveof 172.16.XX.XX(本臺電腦ip) 6379

  3、(slave2)配置redis.windows6381.conf

    (1)bind 127.0.0.1 172.16.XX.XX(本臺電腦ip)

    (2)port 6381

    (3)slaveof 172.16.XX.XX(本臺電腦ip) 6379

  4、然後先後啟動

    redis.server.exe redis.windows.conf

    redis.server.exe redis.windows6380.conf

    redis.server.exe redis.windows6381.conf

  5、報以上異常

    其中有一句錯誤是:Connecting to MASTER 172.16.xx.xx:6379

二、找出錯誤原因

  1、根據錯誤信息可以看出,從數據庫配置是沒問題的,它就是連接了咱寫好的主數據庫的ip和端口

  2、那問題就出在主數據庫;

    (1)ip地址是對的;

    (2)我嘗試過關閉所有的防火墻,依然連不上;

  3、後來我想了是不是bind的原因

    我把兩個從數據庫的slaveof 從172.16.xx.xx 6379 改成了 127.0.0.1 6379後,就連上了!

    我認為,從數據庫的slaveof要和主數據庫的bind第一個參數相同!

  4、證實想法

    (1)我把主數據庫的bind改成172.16.xx.xx

    (2)兩個從數據庫的slaveof 改成 172.16.xx.xx 6379

    (3)連接成功;

三、用兩臺windows系統的電腦進行redis主從配置

  0、關了防火墻

  1、主數據庫

    (1)bind 0.0.0.0

  2、從數據庫

    (2)slaveof 主數據庫的ip 端口

  3、連接成功

Windows下Redis主從配置出現Writing to master:Unknow error