master配置文件以下:node
1 bind 127.0.0.1 2 port 6379 3 tcp-backlog 511 4 timeout 0 5 tcp-keepalive 0 6 loglevel notice 7 logfile "" 8 databases 16 9 save 900 1 10 save 300 10 11 save 60 10000 12 stop-writes-on-bgsave-error yes 13 rdbcompression yes 14 rdbchecksum yes 15 dbfilename dump.rdb 16 dir ./ 17 slave-serve-stale-data yes 18 slave-read-only yes 19 repl-diskless-sync no 20 repl-diskless-sync-delay 5 21 repl-disable-tcp-nodelay no 22 slave-priority 100 23 appendonly no 24 appendfilename "appendonly.aof" 25 appendfsync everysec 26 no-appendfsync-on-rewrite no 27 auto-aof-rewrite-percentage 100 28 auto-aof-rewrite-min-size 64mb 29 aof-load-truncated yes 30 lua-time-limit 5000 31 slowlog-log-slower-than 10000 32 slowlog-max-len 128 33 latency-monitor-threshold 0 34 notify-keyspace-events "" 35 hash-max-ziplist-entries 512 36 hash-max-ziplist-value 64 37 list-max-ziplist-size -2 38 list-compress-depth 0 39 set-max-intset-entries 512 40 zset-max-ziplist-entries 128 41 zset-max-ziplist-value 64 42 hll-sparse-max-bytes 3000 43 activerehashing yes 44 client-output-buffer-limit normal 0 0 0 45 client-output-buffer-limit slave 256mb 64mb 60 46 client-output-buffer-limit pubsub 32mb 8mb 60 47 hz 10 48 aof-rewrite-incremental-fsync yes
slave配置文件以下:redis
1 ################################## INCLUDES ################################### 2 # include .\path\to\local.conf 3 # include c:\path\to\other.conf 4 ################################## NETWORK ##################################### 5 bind 127.0.0.1 6 protected-mode yes 7 port 6380 8 tcp-backlog 511 9 timeout 0 10 tcp-keepalive 0 11 ################################# GENERAL ##################################### 12 loglevel notice 13 logfile "" 14 databases 16 15 ################################ SNAPSHOTTING ################################ 16 save 900 1 17 save 300 10 18 save 60 10000 19 stop-writes-on-bgsave-error yes 20 rdbcompression yes 21 rdbchecksum yes 22 dbfilename dump.rdb 23 dir ./ 24 ################################# REPLICATION ################################# 25 slaveof 127.0.0.1 6379 26 # masterauth <master-password> 27 slave-serve-stale-data yes 28 slave-read-only yes 29 repl-diskless-sync no 30 repl-diskless-sync-delay 5 31 repl-ping-slave-period 10 32 repl-timeout 60 33 repl-disable-tcp-nodelay no 34 repl-backlog-size 1mb 35 repl-backlog-ttl 3600 36 slave-priority 100 37 min-slaves-to-write 3 38 min-slaves-max-lag 10 39 ################################## SECURITY ################################### 40 # rename-command CONFIG "" 41 ################################### LIMITS #################################### 42 # maxclients 10000 43 # persistence-available [(yes)|no] 44 # maxmemory <bytes> 45 # maxmemory-policy noeviction 46 # maxmemory-samples 5 47 ############################## APPEND ONLY MODE ############################### 48 appendonly no 49 appendfilename "appendonly.aof" 50 # appendfsync always 51 appendfsync everysec 52 # appendfsync no 53 no-appendfsync-on-rewrite no 54 auto-aof-rewrite-percentage 100 55 auto-aof-rewrite-min-size 64mb 56 aof-load-truncated yes 57 ################################ LUA SCRIPTING ############################### 58 lua-time-limit 5000 59 ################################ REDIS CLUSTER ############################### 60 cluster-enabled no 61 # cluster-config-file nodes-6379.conf 62 # cluster-node-timeout 15000 63 # cluster-slave-validity-factor 10 64 # cluster-migration-barrier 1 65 # cluster-require-full-coverage yes 66 ################################## SLOW LOG ################################### 67 slowlog-log-slower-than 10000 68 ################################ LATENCY MONITOR ############################## 69 latency-monitor-threshold 0 70 ############################# EVENT NOTIFICATION ############################## 71 # notify-keyspace-events Elg 72 # notify-keyspace-events Ex 73 notify-keyspace-events "" 74 ############################### ADVANCED CONFIG ############################### 75 hash-max-ziplist-entries 512 76 hash-max-ziplist-value 64 77 list-max-ziplist-size -2 78 list-compress-depth 0 79 set-max-intset-entries 512 80 zset-max-ziplist-entries 128 81 zset-max-ziplist-value 64 82 hll-sparse-max-bytes 3000 83 activerehashing yes 84 client-output-buffer-limit normal 0 0 0 85 client-output-buffer-limit slave 256mb 64mb 60 86 client-output-buffer-limit pubsub 32mb 8mb 60 87 hz 10 88 aof-rewrite-incremental-fsync yes
結果能夠分別進入6379和6380的redis客戶端進行查看:命令爲 info Replicationapp
若是看到此處的role分別爲master 和salve則說明如今已經基本配置成功了less
另附幾點聲明:異步