redis主從配置

  • 將上一文章安裝好的redis環境複製一份做爲slave,注意從新生成mac地址 不然沒法鏈接網絡。

  • 查看系統ip並記錄,個人文
redis-master 192.168.129.135
redis-slave1 192.168.129.136
  • 打開slave1服務器的redis配置文件redis.conf,修改端口爲6380,並制定master的ip和端口
# Accept connections on the specified port, default is 6379.
# If port 0 is specified Redis will not listen on a TCP socket.
port 6380
slaveof 192.168.129.135 6379

# TCP listen() backlog.
  • 從新起到從redis服務,啓動完成後可在master和slave分別執行info查看結果

master_link_status:up表示鏈接上,不然爲down。redis

  • 測試,在master上set值,slave上查看

  • 安裝中遇到的問題記錄

1.master上set操做時報錯或slave啓動報錯服務器

5053:S 10 Mar 21:03:19.834 * Connecting to MASTER 192.168.129.135:6379
5053:S 10 Mar 21:03:19.835 * MASTER <-> SLAVE sync started
5053:S 10 Mar 21:03:19.835 * Non blocking connect for SYNC fired the event.
5053:S 10 Mar 21:03:19.835 # Error reply to PING from master: '-MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.'

解決方法:在master上執行config set stop-writes-on-bgsave-error no網絡

2.redis啓動時報錯socket

5053:S 10 Mar 21:12:38.167 * Connecting to MASTER 192.168.129.135:6379
5053:S 10 Mar 21:12:38.167 * MASTER <-> SLAVE sync started
5053:S 10 Mar 21:12:38.167 * Non blocking connect for SYNC fired the event.
5053:S 10 Mar 21:12:38.168 * Master replied to PING, replication can continue...
5053:S 10 Mar 21:12:38.168 * Partial resynchronization not possible (no cached master)
5053:S 10 Mar 21:12:38.168 * Full resync from master: e606a708c45e5fe0ce87c0d11ec246186fa8d668:1158
5053:S 10 Mar 21:12:43.171 # Opening the temp file needed for MASTER <-> SLAVE synchronization: Permission denied

解決方法:緣由是啓動的當前用戶對如下配置中的路徑無寫權限測試

redis.conf中code

3.redis啓動報錯ip

5135:S 10 Mar 21:28:25.447 * Connecting to MASTER 192.168.129.135:6379
5135:S 10 Mar 21:28:25.448 * MASTER <-> SLAVE sync started
5135:S 10 Mar 21:28:25.448 * Non blocking connect for SYNC fired the event.
5135:S 10 Mar 21:28:25.448 * Master replied to PING, replication can continue...
5135:S 10 Mar 21:28:25.448 * Partial resynchronization not possible (no cached master)
5135:S 10 Mar 21:28:25.448 * Full resync from master: e606a708c45e5fe0ce87c0d11ec246186fa8d668:2460
5135:S 10 Mar 21:28:25.541 # I/O error reading bulk count from MASTER: Resource temporarily unavailable

解決辦法:緣由是主從服務之間沒法通信,可以使用telnet進行測試。ci

相關文章
相關標籤/搜索