首页 > 其他 > 详细

redis主从配置

时间:2017-11-03 12:21:42      阅读:281      评论:0      收藏:0      [点我收藏+]

机器ip:192.168.233.8
主redis:
./src/redis-server ./redis.conf

从redis:
./src/redis-server ./redis.conf
修改 redis.conf 文件:
port 6380
slaveof 192.168.233.8 6379

哨兵:
./src/redis-sentinel ./sentinel.conf
修改 sentinel.conf 文件:
sentinel monitor mymaster 192.168.233.8 6379 1

这样配置后,应用程序先询问哨兵,获取主redis信息,然后连接redis。

@Configuration
public class Config {
    @Bean
    public RedisConnectionFactory jedisConnectionFactory() {
      RedisSentinelConfiguration sentinelConfig =
              new RedisSentinelConfiguration().master("mymaster").sentinel("192.168.233.8", 26379);
      // .sentinel("127.0.0.1", 26380);
      return new JedisConnectionFactory(sentinelConfig);
    }
}

 

redis主从配置

原文:http://www.cnblogs.com/allenwas3/p/7777308.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!