博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
redis sentinel模式集群
阅读量:7202 次
发布时间:2019-06-29

本文共 2178 字,大约阅读时间需要 7 分钟。

一、环境搭建准备(3台机器)

服务器三台:

127.0.0.1

127.0.0.2

127.0.0.3

将redis-3.2.9.tar.gz压缩包分别上传到各自机器上

二、安装

1、解压redis安装包:tar -zxvf redis-3.2.9.tar.gz

2、编译:

  cd redis-3.2.9

  make

3、安装:

  make install PREFIX=/usr/local/redis

最后,查看Redis是否安装成功,进入/usr/local/redis

使用ll命令,可以看到bin文件夹,说明Redis已经安装成功。

三、主从模式配置

在/usr/local/redis/ 中新建redis.conf配置文件:

bind 0.0.0.0protected-mode noport 6379logfile "/root/redis/redis.log"     #数据文件pidfile "redis.pid"masterauth "123456789"       #密码requirepass "123456789"tcp-backlog 511timeout 0tcp-keepalive 300daemonize yes supervised nologlevel noticedatabases 16save 900 1save 300 10save 60 10000stop-writes-on-bgsave-error yesrdbcompression yesrdbchecksum yesdir "/home/oas/cluster2"slave-serve-stale-data yesslave-read-only yesrepl-diskless-sync norepl-diskless-sync-delay 5repl-disable-tcp-nodelay noslave-priority 100appendonly noappendfilename "appendonly.aof"appendfsync everysecno-appendfsync-on-rewrite noauto-aof-rewrite-percentage 100auto-aof-rewrite-min-size 64mbaof-load-truncated yeslua-time-limit 5000slowlog-log-slower-than 10000slowlog-max-len 128latency-monitor-threshold 0notify-keyspace-events ""hash-max-ziplist-entries 512hash-max-ziplist-value 64list-max-ziplist-size -2list-compress-depth 0set-max-intset-entries 512zset-max-ziplist-entries 128zset-max-ziplist-value 64hll-sparse-max-bytes 3000activerehashing yesclient-output-buffer-limit normal 0 0 0client-output-buffer-limit slave 256mb 64mb 60client-output-buffer-limit pubsub 32mb 8mb 60hz 10aof-rewrite-incremental-fsync yes

使用如下命令启动redis服务:

  redis-server  /usr/local/redis/redis.conf

动态改变主从关系,成为127.0.0.1的slave:    

登录127.0.0.2机器:redis-cli -h 127.0.0.2 -p 6379127.0.0.2:6379> slaveof 127.0.0.1 6379登录127.0.0.3机器:redis-cli -h 127.0.0.3 -p 6379127.0.0.3:6379> slaveof 127.0.0.1 6379

设置完成后开通防火墙端口:

登录127.0.0.1机器:redis-cli -h 127.0.0.1 -p 6379127.0.0.2:6379> info    #查看主从关系

四、sentinel模式集群管理配置

到/usr/local/redis/ 中创建sentinel.conf文件:

port 26379daemonize yeslogfile "sentinel.log"dir "/root/redis"protected-mode nosentinel monitor mymaster 127.0.0.1 6379 1sentinel auth-pass mymaster 123456789

使用如下命令启动sentinel模式:

  redis-sentinel sentinel.conf

 

转载于:https://www.cnblogs.com/Tang-Yuan/p/10184702.html

你可能感兴趣的文章
网球入门(一)网球打墙练习(转载)
查看>>
MyBatis(二)最简易的增、删、改、查
查看>>
jsapi4加载的首个图层的范围被默认作为地图范围,且不能修改的解决
查看>>
基于模式识别的的内窥镜肿瘤检测
查看>>
安装VMware tools (虚拟机:VMware 10.0.3 系统:centos 6.5)
查看>>
大家一起和snailren学java-(六)复用类
查看>>
Day20 Django的使用_基础
查看>>
Mac-OSX的Python3.5虚拟环境下安装Opencv
查看>>
windows ce 4.2/5.0/6.0/windows mobile设备直接连接PC端的SQLserver
查看>>
浏览器的工作流程
查看>>
低版本IE(ie8)环境如何支持html5新标签
查看>>
初玩Linux部署项目
查看>>
django 模板中定义临时列表
查看>>
linux协议栈skb操作函数
查看>>
python3 函数
查看>>
在ROS中使用QT界面
查看>>
4、重新编译内核
查看>>
C#-对象序列化和反序列化
查看>>
消息队列-推/拉模式学习 & ActiveMQ及JMS学习
查看>>
模拟退火算法
查看>>