redis master配置了密碼進行主從同步

1.若是master不設置密碼,那麼直接在slave服務器配置slaveof便可 配置以下redis

#slaveof ip 端口
slaveof  221.224.85.186 6379 

配置好咱們看下redis的日誌 看是否同步成功服務器

5014:S 25 Jan 10:53:53.667 * Connecting to MASTER 221.224.85.186:6379
5014:S 25 Jan 10:53:53.667 * MASTER <-> SLAVE sync started
5014:S 25 Jan 10:53:53.700 * Non blocking connect for SYNC fired the event.
5014:S 25 Jan 10:53:53.734 * Master replied to PING, replication can continue...
5014:S 25 Jan 10:53:53.832 * Partial resynchronization not possible (no cached master)
5014:S 25 Jan 10:53:53.867 * Full resync from master: 4d6221e370675f397c396c9222b1b60bfcea1efb:1
5014:S 25 Jan 10:53:53.985 * MASTER <-> SLAVE sync: receiving 844 bytes from master
5014:S 25 Jan 10:53:53.985 * MASTER <-> SLAVE sync: Flushing old data
5014:S 25 Jan 10:53:53.985 * MASTER <-> SLAVE sync: Loading DB in memory
5014:S 25 Jan 10:53:53.985 * MASTER <-> SLAVE sync: Finished with success
5014:S 25 Jan 10:53:53.667 * Connecting to MASTER 221.224.85.186:6379
這句是從上面slave服務器日誌裏面獲取的,咱們能夠看到鏈接的master的服務器的ip是221.224.85.186

MASTER <-> SLAVE sync: Finished with success
看到輸出的語句是success表示同步成功.

2.master設置密碼的狀況下同步數據,其實很簡單,咱們只要讓slave能連上master就能夠了,咱們在slave的配置文件中加一句話便可。
masterauth 123456

 OK。ui

 否則可能會出現一下錯誤spa

 

4939:S 25 Jan 09:53:20.450 # MASTER aborted replication with an error: NOAUTH Authentication required.
4939:S 25 Jan 09:53:21.291 * Connecting to MASTER 120.27.137.142:6379
4939:S 25 Jan 09:53:21.292 * MASTER <-> SLAVE sync started
4939:S 25 Jan 09:53:21.317 * Non blocking connect for SYNC fired the event.
4939:S 25 Jan 09:53:21.342 * Master replied to PING, replication can continue...
4939:S 25 Jan 09:53:21.368 * (Non critical) Master does not understand REPLCONF listening-port: -NOAUTH Authentication required.
4939:S 25 Jan 09:53:21.393 * (Non critical) Master does not understand REPLCONF capa: -NOAUTH Authentication required.
4939:S 25 Jan 09:53:21.393 * Partial resynchronization not possible (no cached master)
4939:S 25 Jan 09:53:21.419 # Unexpected reply to PSYNC from master: -NOAUTH Authentication required.
4939:S 25 Jan 09:53:21.419 * Retrying with SYNC...
4939:S 25 Jan 09:53:21.444 # MASTER aborted replication with an error: NOAUTH Authentication required.
相關文章
相關標籤/搜索