共计 4103 个字符,预计需要花费 11 分钟才能阅读完成。
都是在本地虚拟机作为例子
如果是生产环境修改对应的 ip 即可
1、master 配置 /home/redis/redis-5.0.8/redis.conf
bind 127.0.0.1 | |
port 6379 | |
tcp-backlog 511 | |
timeout 0 | |
tcp-keepalive 300 | |
daemonize no | |
supervised no | |
pidfile /var/run/redis_6379.pid | |
loglevel notice | |
logfile "6379.log" | |
databases 16 | |
always-show-logo yes | |
save 900 1 | |
save 300 10 | |
save 60 10000 | |
rdbcompression yes | |
dbfilename dump.rdb | |
dir /usr/local/redis/redis-6379/ | |
replica-serve-stale-data yes | |
replica-read-only yes | |
repl-diskless-sync no | |
repl-diskless-sync-delay 5 | |
lazyfree-lazy-eviction no | |
lazyfree-lazy-expire no | |
lazyfree-lazy-server-del no | |
replica-lazy-flush no | |
appendonly no | |
no-appendfsync-on-rewrite no | |
aof-load-truncated yes | |
aof-use-rdb-preamble yes | |
lua-time-limit 5000 | |
slowlog-max-len 128 | |
latency-monitor-threshold 0 | |
list-max-ziplist-size -2 | |
list-compress-depth 0 | |
zset-max-ziplist-entries 128 | |
zset-max-ziplist-value 64 | |
hll-sparse-max-bytes 3000 | |
stream-node-max-bytes 4096 | |
stream-node-max-entries 100 | |
activerehashing yes | |
client-output-buffer-limit normal 0 0 0 | |
client-output-buffer-limit replica 256mb 64mb 60 | |
client-output-buffer-limit pubsub 32mb 8mb 60 | |
hz 10 | |
dynamic-hz yes | |
aof-rewrite-incremental-fsync yes | |
rdb-save-incremental-fsync yes |
slave-6380
bind 127.0.0.1 | |
port 6380 | |
tcp-backlog 511 | |
timeout 0 | |
tcp-keepalive 300 | |
daemonize no | |
supervised no | |
pidfile /var/run/redis_6380.pid | |
loglevel notice | |
logfile "6380.log" | |
databases 16 | |
always-show-logo yes | |
save 900 1 | |
save 300 10 | |
save 60 10000 | |
rdbcompression yes | |
dbfilename dump.rdb | |
dir /usr/local/redis/redis-6380/ | |
replica-serve-stale-data yes | |
replica-read-only yes | |
repl-diskless-sync no | |
repl-diskless-sync-delay 5 | |
lazyfree-lazy-eviction no | |
lazyfree-lazy-expire no | |
lazyfree-lazy-server-del no | |
replica-lazy-flush no | |
appendonly no | |
no-appendfsync-on-rewrite no | |
aof-load-truncated yes | |
aof-use-rdb-preamble yes | |
lua-time-limit 5000 | |
slowlog-max-len 128 | |
latency-monitor-threshold 0 | |
list-max-ziplist-size -2 | |
list-compress-depth 0 | |
zset-max-ziplist-entries 128 | |
zset-max-ziplist-value 64 | |
hll-sparse-max-bytes 3000 | |
stream-node-max-bytes 4096 | |
stream-node-max-entries 100 | |
activerehashing yes | |
client-output-buffer-limit normal 0 0 0 | |
client-output-buffer-limit replica 256mb 64mb 60 | |
client-output-buffer-limit pubsub 32mb 8mb 60 | |
hz 10 | |
dynamic-hz yes | |
aof-rewrite-incremental-fsync yes | |
rdb-save-incremental-fsync yes | |
# | |
replicaof 127.0.0.1 6379 |
slave-6381
bind 127.0.0.1 | |
port 6381 | |
tcp-backlog 511 | |
timeout 0 | |
tcp-keepalive 300 | |
daemonize no | |
supervised no | |
pidfile /var/run/redis_6381.pid | |
loglevel notice | |
logfile "6381.log" | |
databases 16 | |
always-show-logo yes | |
save 900 1 | |
save 300 10 | |
save 60 10000 | |
rdbcompression yes | |
dbfilename dump.rdb | |
dir /usr/local/redis/redis-6381/ | |
replica-serve-stale-data yes | |
replica-read-only yes | |
repl-diskless-sync no | |
repl-diskless-sync-delay 5 | |
lazyfree-lazy-eviction no | |
lazyfree-lazy-expire no | |
lazyfree-lazy-server-del no | |
replica-lazy-flush no | |
appendonly no | |
no-appendfsync-on-rewrite no | |
aof-load-truncated yes | |
aof-use-rdb-preamble yes | |
lua-time-limit 5000 | |
slowlog-max-len 128 | |
latency-monitor-threshold 0 | |
list-max-ziplist-size -2 | |
list-compress-depth 0 | |
zset-max-ziplist-entries 128 | |
zset-max-ziplist-value 64 | |
hll-sparse-max-bytes 3000 | |
stream-node-max-bytes 4096 | |
stream-node-max-entries 100 | |
activerehashing yes | |
client-output-buffer-limit normal 0 0 0 | |
client-output-buffer-limit replica 256mb 64mb 60 | |
client-output-buffer-limit pubsub 32mb 8mb 60 | |
hz 10 | |
dynamic-hz yes | |
aof-rewrite-incremental-fsync yes | |
rdb-save-incremental-fsync yes | |
# | |
replicaof 127.0.0.1 6379 |
哨兵集群配置
哨兵 1 sentinel-26379.conf
port 26379 | |
bind 127.0.0.1 192.168.43.33 | |
daemonize yes | |
dir "/usr/local/redis/6379" | |
logfile "26379.log" | |
protected-mode no | |
sentinel monitor mymaster 192.168.43.33 6379 2 | |
sentinel parallel-syncs mymaster 1 | |
sentinel failover-timeout mymaster 15000 |
哨兵 2 sentinel-26380.conf
port 26380 | |
bind 127.0.0.1 192.168.43.33 | |
daemonize yes | |
dir "/usr/local/redis/6380" | |
logfile "26380.log" | |
protected-mode no | |
sentinel monitor mymaster 192.168.43.33 6379 2 | |
sentinel parallel-syncs mymaster 1 | |
sentinel failover-timeout mymaster 15000 |
哨兵 3 sentinel-26381.conf
port 26381 | |
bind 127.0.0.1 192.168.43.33 | |
daemonize yes | |
dir "/usr/local/redis/6381" | |
logfile "26381.log" | |
protected-mode no | |
sentinel monitor mymaster 192.168.43.33 6379 2 | |
sentinel parallel-syncs mymaster 1 | |
sentinel failover-timeout mymaster 15000 |
启动主库
redis-server /home/redis/redis-5.0.8/redis.conf
启动 salve-6380
redis-server /home/redis/redis-5.0.8/redis-6380.conf
启动 salve-6381
redis-server /home/redis/redis-5.0.8/redis-6381.conf
启动哨兵 26379
redis-sentinel sentinel-26379.conf
启动哨兵 26380
redis-sentinel sentinel-26380.conf
启动哨兵 26381
redis-sentinel sentinel-26381.conf
正文完