1 主从配置
以单机172.17.0.133为例
Redis master配置
编辑/etc/redis/6380.conf
1 2 3 4 5 6 7 8
| bind 172.17.0.133 port 6380 pidfile /var/run/redis_6380.pid logfile /var/log/redis_6380.log dir /var/lib/redis/6380 maxmemory-policy noeviction appendonly yes appendfsync everysec
|
创建数据目录
1 2
| cd /var/lib/redis sudo mkdir 6380
|
Redis slave配置
编辑/etc/redis/6381.conf
1 2 3 4 5 6 7 8 9
| bind 172.17.0.133 port 6381 pidfile /var/run/redis_6381.pid logfile /var/log/redis_6381.log dir /var/lib/redis/6381 slaveof 172.17.0.133 6380 maxmemory-policy noeviction appendonly yes appendfsync everysec
|
创建数据目录
1 2
| cd /var/lib/redis sudo mkdir 6381
|
2 启动redis
1 2
| redis-server /etc/redis/6380.conf redis-server /etc/redis/6381.conf
|
3 配置哨兵Sentinel
在/etc/redis 中创建 sentinel_26380.conf
1 2 3 4 5 6 7 8
| bind 172.17.0.133 port 26380 daemonize yes logfile /var/log/redis-sentinel.log sentinel monitor mymaster 172.17.0.133 6380 2 sentinel down-after-milliseconds mymaster 30000 sentinel parallel-syncs mymaster 1 sentinel failover-timeout mymaster 180000
|
复制并创建另外两个配置文件
- sentinel_26381.conf
- sentinel_26382.conf
4 启动sentinel
1 2 3
| redis-sentinel /etc/redis/sentinel_26380.conf redis-sentinel /etc/redis/sentinel_26381.conf redis-sentinel /etc/redis/sentinel_26382.conf
|