redis slave won't sync with master

 ̄綄美尐妖づ 提交于 2019-12-03 09:50:08

I encountered a similar situation today. It seems that for systems that use sysctl, you might have to do:

sysctl vm.overcommit_memory=1

and restart the slave redis server. This link might help.

This issue little tricky,

the reason that the slave can't sync is in the master itself,

pay attention to the Log output : MASTER aborted replication with an error: ERR Unable to perform background save

this is mean that the master can't do background saving due low memory reserve on the master machine,

to solve this issue I Restarted the master redis server , then all the slaves has been sync by themselves.

For me, it was because I had requirepass set, but did not set a masterauth setting.

I've met the same issue, and my reason is both of my servers do not use the same redis version. Let's check your version on both servers:

127.0.0.1:6379> info server
# Server
redis_version:3.2.8

my default settings in redis.conf enabled requirepass,executing " masterauth [passwordOfMaster] "in slave's terminal before "SLAVEOF" will fix this issue.

In my case, it was related to SELINUX, changing it to permissive mode resolved the issue.

I fixed it the following:

sudo -i
service redis-server stop
apt remove --purge redis-server
rm /var/lib/redis/dump.rdb
apt install redis-server
systemctl enable redis-server
service redis-server start

# i have not tried, but it is possible this is enough
service redis-server stop
rm /var/lib/redis/dump.rdb
service redis-server start

I discovered that protected mode was on when I tried to set this up using Redis 5.0.5. When I logged into the putative master on its eth0 interface (as opposed to loopback or UNIX socket) I got this message when I tried to run "INFO":

IP_ADDRESS_REDACTED:6379> info
DENIED Redis is running in protected mode because protected mode is
enabled, no bind address was specified, no authentication password
is requested to clients. In this mode connections are only accepted
from the loopback interface. If you want to connect from external
computers to Redis you may adopt one of the following solutions:
1) Just disable protected mode sending the command 'CONFIG SET 
protected-mode no' from the loopback interface by connecting to Redis
from the same host the server is running, however MAKE SURE Redis is
not publicly accessible from internet if you do so. Use CONFIG REWRITE 
to make this change permanent. 2) Alternatively you can just disable
the protected mode by editing the Redis configuration file, and
setting the protected mode option to 'no', and then restarting the
server. 3) If you started the server manually just for testing,
restart it with the '--protected-mode no' option. 4) Setup a bind
address or an authentication password. NOTE: You only need to do one
of the above things in order for the server to start accepting
connections from the outside.

I followed the instructions and the slave connected immediately.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!