Redis simple master-slave replication

Two ubuntu cloud servers, redis master and slave servers, respectively, the ip addresses are:
123.207.96.138 (master)
139.199.167.251 (slave)


Install redis, here I recommend setting a password for redis. I read an article before, because redis did not set a password, which caused the redis server to be hacked.
First modify the redis.conf configuration file:
set all hosts to be accessible:
bind 127.0.0.1 to bind 0.0.0.0

Set password:
requiredpass: **** #(password)

On 139.199.167.251 (set on slave server):
slaveof 123.207.96.138 6379
masterpass **** #(master server password)

It's that simple, but a series of problems can arise. The two most common problems are memory constraints. When copying data from the master server to the slave server, if the amount of data is large, problems may occur. This is one to consider.
The second is that the master-slave redis server version does not match. I have this problem!
I configured the above configuration at the beginning, but tested on redis-cli:
info replication
shows the following:
127.0.0.1:6379> info replication
# Replication
role:slave
master_host:123.207.96.138
master_port:6379
master_link_status:down
master_last_io_seconds_ago:5
master_sync_in_progress: 0
slave_repl_offset:336
slave_priority:100
slave_read_only:1
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0

master_link_status:down indicates that the connection between the master and slave servers is broken. At this time, you must look at the redis configuration file! ! !
redis.log:
5414:S 27 Apr 10:00:57.490 # Can't handle RDB format version 8
5414:S 27 Apr 10:00:57.490 # Failed trying to load the MASTER synchronization DB from disk

I probably looked at it, this should be the redis version is not right, check it and it is true! After reinstalling redis, the version is the same, and the problem is solved!
If there is a problem with redis, you must look at the log file.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324945476&siteId=291194637