1. From the pull redis image repository docker
docker pull redis
2. Create redis-6379-data, redis-6380-data, redis-6381-data under / home respectively
3. Copy /etc/redis/redis.conf under / home
4. Copy redis.conf is redis-6379.conf, redis-6380.conf, redis.6381.con and wherein the configuration changes are different logfile specified file
port 6380 logfile "redis-6380.log" dir /data appendonly yes appendfilename appendonly.aof slaveof 127.0.0.1 6379
5.docker start three redis
docker run -tdi -v /home/data:/data /home/redis-6379.conf:/usr/local/ect/redis/redis.conf -p 6379:6379 redis
docker run -tdi -v /home/data:/data /home/redis-6380.conf:/usr/local/ect/redis/redis.conf -p 6380:6380 redis
docker run -tdi -v /home/data:/data /home/redis-6381.conf:/usr/local/ect/redis/redis.conf -p 6381:6381 redis
6. Create a good redis are connected to the server via redis-cli, whether with a good test from the master
7. Configure redis-sentinelm, create three sentinel file, as follows
port 26379 dir "/data" logfile "sentinel-26379.log" sentinel monitor mymaster 127.0.0.1 6379 2 sentinel down-after-milliseconds mymaster 10000 sentinel failover-timeout mymaster 60000
Only modify the log file name
8. Start sentinel by three docker
docker run -dit -v /home/sentinel-26379.conf:/usr/local/etc/redis/sentinel.conf -p 26379:26379 redis redis-sentinel /usr/local/etc/redis/sentinel.conf
docker run -dit -v /home/sentinel-26380.conf:/usr/local/etc/redis/sentinel.conf -p 26380:26380 redis redis-sentinel /usr/local/etc/redis/sentinel.conf
docker run -dit -v /home/sentinel-26381.conf:/usr/local/etc/redis/sentinel.conf -p 26381:26381 redis redis-sentinel /usr/local/etc/redis/sentinel.conf
9. Stop the master node redis
containerid docker stop master node
10 connected to the slave node, the master view from the state
redis-cli -p 6380 info replication
11. Wait tens of seconds, it will automatically become the master node from
Sentinel uses the principle mode of voting and decision mechanisms heartbeat mechanism.