这里只是总结一下安装步骤
如果要了解redis集群高可用的原理,推荐仔细看一遍配置文件示例http://download.redis.io/redis-stable/redis.conf,源码包里也有,里面的注释都是干货,看完会非常有帮助。
1、安装
tar xf
redis-2.8.18.tar.gz
make
mkdir /usr/local/redis-bin #创建redis安装目录
#复制编译出来的bin文件到安装目录
cp src/redis-* /usr/local/redis-bin
#复制默认配置文件到安装目录
cp redis.conf /usr/local/redis-bin
cp sentinel.conf /usr/local/redis-bin
2、配置(redis服务一主一从,故障选举服务三台)
vi redis.conf #配置redis,两台
daemonize yes #redis在后台执行
logfile "/usr/local/redis-bin/redis.log" #redis日志输出
slaveof 192.168.166.131 6379 #slave节点需要配置主master节点的信息
#redis要求的,kernel参数修改,重启生效
vim /etc/sysctl.conf
vm.overcommit_memory = 1
net.core.somaxconn = 511
vi sentinel.conf #配置故障选举服务,三台
添加:
daemonize yes
logfile "/usr/local/redis-bin/sentinel.log"
修改
sentinel monitor mymaster 192.168.166.131 6379 2
3、起动关闭
redis
起动:/usr/local/redis-bin/redis-server /usr/local/redis-bin/redis.conf
关闭:/usr/local/redis-bin/redis-cli shutdown
sentinel
起动:/usr/local/redis-bin/redis-sentinel /usr/local/redis-bin/sentinel.conf
关闭:/usr/local/redis-bin/redis-cli -p 26379 shutdown