简介:
实现reids master slave 模式添加哨兵(sentinel)监控,当主机down掉后备机承担主机身份进行生产工作。
实施:
1.先依照spring redis 整合http://see-you-again.iteye.com/admin/blogs/2323435完成非哨兵监控模式下的配置。
2.修改pom文件如下:
<?xml version="1.0" encoding="UTF-8"?> <!--suppress ALL --> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <context:property-placeholder location="classpath:redis.properties" /> <bean id="poolConfig" class="redis.clients.jedis.JedisPoolConfig" p:maxIdle="${redis.maxIdle}" p:maxTotal="${redis.maxActive}" p:maxWaitMillis="${redis.maxWait}" p:testOnBorrow="${redis.testOnBorrow}"> </bean> <!-- 不使用哨兵 <bean id="jedisConnFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory" p:usePool="true" p:hostName="127.0.0.1" p:port="7000" p:timeout="200" p:password="" p:poolConfig-ref="poolConfig"/> --> <bean id="jedisConnFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"> <constructor-arg name="sentinelConfig" ref="redisSentinelConfiguration"></constructor-arg> <constructor-arg name="poolConfig" ref="poolConfig"></constructor-arg> </bean> <bean id="redisSentinelConfiguration" class="org.springframework.data.redis.connection.RedisSentinelConfiguration"> <property name="master"> <bean class="org.springframework.data.redis.connection.RedisNode"> <property name="name" value="mymaster"></property> </bean> </property> <property name="sentinels"> <set> <!-- 注意这里配置的是哨兵信息,而非redis服务信息--> <bean class="org.springframework.data.redis.connection.RedisNode"> <constructor-arg index="0" value="127.0.0.1" /> <constructor-arg index="1" value="5001" /> </bean> <bean class="org.springframework.data.redis.connection.RedisNode"> <constructor-arg index="0" value="127.0.0.1" /> <constructor-arg index="1" value="5002" /> </bean> <bean class="org.springframework.data.redis.connection.RedisNode"> <constructor-arg index="0" value="127.0.0.1" /> <constructor-arg index="1" value="5003" /> </bean> </set> </property> </bean> <bean id="redisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate" > <property name="connectionFactory" ref="jedisConnFactory" /> <property name="enableTransactionSupport" value="true" /> </bean> <bean id="userDao" class="com.test.redis.UserDao" > <constructor-arg name="redisTemplate" ref="redisTemplate"/> </bean> <bean id="redisDao" class="com.test.redis.RedisDao" > <constructor-arg name="redisTemplate" ref="redisTemplate"/> </bean> </beans>
相关推荐
Redis Sentinel(哨兵)部署.pdf Redis Sentinel(哨兵)部署.pdf Redis Sentinel(哨兵)部署.pdf
spring + redis + sentinel 配置文件,同学们可以下载使用,有问题请指教。
SpringRedis哨兵配置,包括RedisTemplete、CacheManger
spring整合redis哨兵模式,内含redis连接池,哨兵模式,json序列化,redis crud封装
二、Redis sentinel的工作机制 三、案例:构建Redis sentinel集群 四、案例:Keepalived+Haproxy+Redis实现高可用
redis4.0.6哨兵模式部署,含有安装包redis-4.0.6.tar.gz,有redis存储乱码问题得解决方案。
Redis Sentinel 主从部署 使用Python脚本获取Redis主从节点信息
spring集成springmvc,mybatis,redis,redis采用sentinel哨兵模式 高可用,并基于注解使用redis缓存
redis-sentinel 基于 phpredis 扩展的 redis-sentinel 客户端
示例:$sentinel = new \Jenner\RedisSentinel\Sentinel(); $sentinel->connect('127.0.0.1', 6379); $address = $sentinel->getMasterAddrByName('mymaster'); $redis = new Redis(); $redis->connect($...
docker-compose 形式部署 redis 1主2从3哨兵 redis 多节点高可用 redis 主从哨兵 redis 集群高可用 redis 哨兵 redis 高可用
redis+sentinel+tomcat部署Linux详细步骤,带安装包,自动脚本。redis+sentinel+tomcat部署Linux详细步骤,带安装包,自动脚本。redis+sentinel+tomcat部署Linux详细步骤,带安装包,自动脚本。
Windos系统的Redis sentinel集群。 启动命令:D:\redis-2.8.18.rar\redis-2.8.18>redis-server.exe sentinel.conf --sentinel
此脚本文件用于zabbix监控redis哨兵时收集redis sentinel监控信息。
redis主从配置+sentinel哨兵模式 redis主从配置+sentinel哨兵模式
Windows环境下,搭建Redis哨兵模式【一主二从三哨兵】所需要的配置文件。
redis-sentinel哨兵集群搭建并整合springboot完美解决方案
Redis 是一个开源的 key-value 存储系统,由于出众的性能,大部分互联网企业都用来做服务器端缓存。Redis 支持单实例模式,集群主从模式、哨兵模式等部署
redis sentinel部署(Windows下实现).rar
Spring整合Redis的哨兵及RedisTemplate,并且实现了redis的事务处理