This article uses the version of redis2.8.24;
1. Test environment
master:192.168.136.130 6379slave1:192.168.136.130 6479slave2:192.168.136.130 6579master-sentinel:192.168.136.1 26579 26379slave1-sentinel:192.168.136.130 26479slave2-sentinel:192.168.136.130
2. Download and install
Address: Http://www.redis.io
#安装tar zxf redis-2.8.24.tar.gzcd redis-2.8.24make && make install# may need to install other underlying software prior to installation; Yum install-y gcc MAKC
3. Configuring the test environment
Cd/usr/localmkdir redis_clustermkdir Redis_cluster/master_6379mkdir Redis_cluster/slave_6479mkdir redis_cluster/ slave_6579
Configure Redis
1) Master
Cp-f/usr/local/src/redis-2.8.24/redis.conf/usr/local/redis_cluster/master_6379/redis.confcp-f/usr/local/src/ Redis-2.8.24/sentinel.conf/usr/local/redis_cluster/master_6379/6379_sentinel.conf
Master_6379/redis.conf modified to read as follows:
Daemonize Yes Port 6379 requirepass 123456 masterauth 123456 appendonly no Save "" Slave-read-only Yes
6379_sentinel.conf modified as follows:
Port 26379 Sentinel Monitor MyMaster 192.168.136.130 6379 2 Sentinel auth-pass mymaster 123456 Sentinel Down-after-mill Iseconds MyMaster 30000 Sentinel Parallel-syncs mymaster 1 Sentinel failover-timeout MyMaster 900000
2) slave1
Cp-f/usr/local/src/redis-2.8.24/redis.conf/usr/local/redis_cluster/slave_6479/redis.confcp-f/usr/local/src/ Redis-2.8.24/sentinel.conf/usr/local/redis_cluster/slave_6479/6479_sentinel.conf
Slave_6479/redis.conf modified as follows:
Daemonize Yes Port 6479 requirepass 123456 masterauth 123456 appendonly no Save "" Slave-read-only Yes Slav EOF 192.168.136.130 6379
6479_sentinel.conf modified as follows:
Port 26479 Sentinel Monitor MyMaster 192.168.136.130 6379 2 Sentinel auth-pass mymaster 123456 Sentinel Down-after-mill Iseconds MyMaster 30000 Sentinel Parallel-syncs mymaster 1 Sentinel failover-timeout MyMaster 900000
3) Slave2
Cp-f/usr/local/src/redis-2.8.24/redis.conf/usr/local/redis_cluster/slave_6579/redis.confcp-f/usr/local/src/ Redis-2.8.24/sentinel.conf/usr/local/redis_cluster/slave_6579/6579_sentinel.conf
Slave_6579/redis.conf modified as follows:
Daemonize Yes Port 6579 requirepass 123456 masterauth 123456 appendonly no Save "" Slave-read-only Yes Slav EOF 192.168.136.130 6379
6479_sentinel.conf modified as follows:
Port 26579 Sentinel Monitor MyMaster 192.168.136.130 6379 2 Sentinel auth-pass mymaster 123456 Sentinel Down-after-mill Iseconds MyMaster 30000 Sentinel Parallel-syncs mymaster 1 Sentinel failover-timeout MyMaster 900000
4. Start the cluster
Note : When you first build your sentinel environment, you must first start master.
#启动master和master-sentinel:redis-server/usr/local/redis_cluster/master_6379/redis.conf redis-sentinel/usr/local/ Redis_cluster/master_6379/6379_sentinel.conf
Cloning sessions, starting slave1 and Slave1-sentinel:
Redis-server/usr/local/redis_cluster/slave_6479/redis.conf redis-sentinel/usr/local/redis_cluster/slave_6479/ 6479_sentinel.conf
Cloning sessions, starting slave2 and Slave2_sentinel:
Redis-server/usr/local/redis_cluster/slave_6579/redis.conf redis-sentinel/usr/local/redis_cluster/slave_6579/ 6579_sentinel.conf
To view the status of master:
Redis-cli-h 192.168.136.130-p 6379 #查看集群状态info replication
5. Testing
1) Master Outage
Result: After Master is down, Sentinel cluster will select one in the slave cluster as master to continue serving;
2) Master Recovery
Results: When the previous master returned to normal, the Redis cluster was added and the class was slave;
3) Slave Downtime
Results: Slave had no effect on master;
This article refer to http://blog.csdn.net/wtyvhreal/article/details/46517483
This article from the "Shallow faint" blog, please be sure to keep this source http://cuixiang.blog.51cto.com/8204722/1770521
Redis Sentinel Cluster configuration