redis sentinel: use Spring-data-redis to operate Redis Sentinel

Sentinel[ˈsentɪnl] Sentinel
http://blog.csdn.net/peterwanghao/article/details/44980085
One. Sentinel mechanism:
Redis Sentinel is a cluster management tool officially provided by Redis, using one or more sentinel and Redis master/slave (Master/Slave) can form a cluster, can detect whether the master instance is alive, and when the master instance fails, the slave will be promoted to the master, and after the old master rejoins the sentinel cluster, it will be reconfigured as The slave of the new master. This means that a Redis sentinel based HA cluster is able to manage itself.
Sentinel in Redis will scan nodes in real time. If a node that is down is found, it will perform failover, master selection, etc. Let's take a look at the specific process.
2. Environment configuration:
This article is based on redis-2.8.19 and jedis2.4.2 versions, and clusters are available above 3.0.
Start two redis on one machine, one as master and one as slave.
Master port: 6379
Slave1 port: 6380

	    
<dependency>
	<groupId>org.springframework.data</groupId>  
	<artifactId>spring-data-redis</artifactId>  
	<version>1.4.1.RELEASE</version>  
</dependency>
<!--redis client-->
<dependency>
	<groupId>redis.clients</groupId>
	<artifactId>jedis</artifactId>
	<version>2.6.2</version>
</dependency>

The above configuration is also used when
http://572327713.iteye.com/blog/2358403
senssion is shared across domains.

Spring-Data-Redis provides a basic generic RedisTemplate for developers to quickly use code to complete basic crud work. The StringRedisTemplate provides the implementation of the most commonly used String types. In practice, it can be considered to completely omit the design of the dao layer, and directly inject the corresponding template instance into the service layer.

3. Sentinel configuration:


redis master-slave:
Master:
redis.conf
      port 6379
Slave1:
redis.conf
      port 6380
      slaveof 192.168.92.130 6379 For



additional configuration of redis, see
http://572327713.iteye.com/admin/blogs/2346196

sentinel cluster :

sentinel.conf
      port 26379
      sentinel monitor mymaster 192.168.0.100 6379 2

sentinel.conf
      port 26380
      sentinel monitor mymaster 192.168.0.100 6379 2

sentinel.conf
      port 26381
      sentinel monitor mymaster 192.168.0.100 6379 2

run start redis:
$ redis-server /usr/local/redis/sentinel/redis-6379/redis.conf


For the redis-sentinel program, you can start the Sentinel system with the following command:
[root@centos64 sentinel-26379]# redis-sentinel sentinel.conf

For the redis-server program, you can start a Redis server running in Sentinel mode with the following command:
[root@centos64 sentinel-26379]# redis-server sentinel.conf --sentinel


Encounter problems:
WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.

Execute echo 511 > /proc/sys/net/core/somaxconn


other projects may use redis keepalive
redis+keepalive+LVS

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326364125&siteId=291194637