redis-sentinel模式搭建

一、redis.conf:

daemonize yes
port 6379
dbfilename dump.rdb
dir "/opt/app/redis-sentinel/redis-3.0.3/rdb/redis_6379"
logfile "/opt/app/redis-sentinel/redis-3.0.3/logs/redis_6379.log"
loglevel warning
slaveof 52.22.162.38 6379(注:只有从有该配置、主没有)
requirepass 123123
masterauth 123123

 

二、sentinel.conf:

port 26379
loglevel warning
logfile "/opt/app/redis-sentinel/redis-3.0.3/logs/sentinel_26379.log"
sentinel monitor mymaster 52.22.162.38 6379 2
daemonize yes
sentinel auth-pass mymaster 123123  (注:没有该配置无法完成主备切换)

 

三、启动:

./redis-server /opt/app/redis-sentinel/redis-3.0.3/etc/redis_6379.conf
./redis-server /opt/app/redis-sentinel/redis-3.0.3/etc/redis_6380.conf
./redis-server /opt/app/redis-sentinel/redis-3.0.3/etc/redis_6381.conf
./redis-sentinel /opt/app/redis-sentinel/redis-3.0.3/sentinel-etc/sentinel_26379.conf
./redis-sentinel /opt/app/redis-sentinel/redis-3.0.3/sentinel-etc/sentinel_26380.conf
./redis-sentinel /opt/app/redis-sentinel/redis-3.0.3/sentinel-etc/sentinel_26381.conf

 

 

四、启动redis问题:
1、20060:S 11 Feb 17:56:23.086 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add
'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.


解决:(1)编辑/etc/sysctl.conf ,改vm.overcommit_memory=1,然后sysctl -p 使配置文件生效

2、20914:S 11 Feb 18:05:56.651 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.

解决:编辑/etc/sysctl.conf,添net.core.somaxconn= 1024 然后执行sysctl -p 就可以永久消除这个warning

3、27313:S 11 Feb 19:28:27.098 # Short read or OOM loading DB. Unrecoverable error, aborting now.

解决:删除rdb文件:rm -f /var/lib/redis/dump.rdb     删除pid:rm -f /var/run/redis.pid  重启

 

五、进入客户端

cd src

./redis-cli -p 6379 -a 123123

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值