Ubuntu 16.04
Sponsored Link

Redis : Replication Settings2016/09/08

 
Configure Redis Replication. This configuration is general Master-Slave settings.
[1] Change Settings on Master Host.
root@dlp:~#
vi /etc/redis/redis.conf
# line 69: change to own IP or 0.0.0.0

bind
0.0.0.0
# line 382: add follows if you need

# min-slaves-to-write : if number of slave Hosts are online, Master Host accepts write requests

# min-slaves-max-lag : decision time(sec) for online if Slave Hosts return answer within specified time

min-slaves-to-write 1
min-slaves-max-lag 10
root@dlp:~#
systemctl restart redis
[2] Change Settings on Slave Hosts.
root@node01:~#
vi /etc/redis/redis.conf
# line 69: change to own IP or 0.0.0.0

bind
0.0.0.0
# line 211: add Master server's IP and port

slaveof 10.0.0.30 6379
# line 218: add connection password set on Master Host

masterauth password
# line 246: verify parameter (set Slave Hosts read-only)

slave-read-only yes
root@node01:~#
systemctl restart redis
[3] Verify statics on Slave Hosts, then it's OK if "master_link_status:up" is shown.
root@node01:~#
redis-cli info Replication

# Replication
role:slave
master_host:10.0.0.30
master_port:6379
master_link_status:up
master_last_io_seconds_ago:2
master_sync_in_progress:0
slave_repl_offset:99
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

# try to get a Key normally

root@node01:~#
redis-cli get key_on_master

"value_on_master"
Matched Content