一、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