redis slave won't sync with master

2020-06-07 06:20发布

The redis slave won't sync with the master.

Connectivity:

I can connect to the master when I issue

HOST_NAME=fakehost
redis-cli -h $HOST_NAME

and check the master status using a command like INFO, so connectivity is not an issue.

Settings:

From the slave box, I issued

SLAVEOF $HOST_NAME 6379

And received an OK.

When I issue the INFO command on the slave, I get

# Replication
role:slave
master_host:<removed>
master_port:6379
master_link_status:down
master_last_io_seconds_ago:-1
master_sync_in_progress:0
master_link_down_since_seconds:1379450797
slave_priority:100
slave_read_only:1
connected_slaves:0

On the master box, I issue info and get

# Replication
role:master
connected_slaves:0

So obviously I'm not connected.

Logs

[11225] 17 Sep 14:31:33.225 * Connecting to MASTER...
[11225] 17 Sep 14:31:33.226 * MASTER <-> SLAVE sync started
[11225] 17 Sep 14:31:33.226 * Non blocking connect for SYNC fired the event.
[11225] 17 Sep 14:31:33.226 * Master replied to PING, replication can continue...
[11225] 17 Sep 14:31:33.227 # MASTER aborted replication with an error: ERR Unable to perform background save

Tests

Test that dump.rdb is created on BGSAVE

BGSAVE
> OK

Test that dump.rdb is created on SAVE

SAVE
> OK

Thanks in advance.

8条回答
劫难
2楼-- · 2020-06-07 06:53

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
查看更多
Bombasti
3楼-- · 2020-06-07 06:56

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.

查看更多
太酷不给撩
4楼-- · 2020-06-07 07:05

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

查看更多
Juvenile、少年°
5楼-- · 2020-06-07 07:07

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

查看更多
三岁会撩人
6楼-- · 2020-06-07 07:07

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
查看更多
Explosion°爆炸
7楼-- · 2020-06-07 07:09

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.

查看更多
登录 后发表回答