Redis 5 : Replication2019/11/29 |
Configure Redis Replication. This configuration is general Master-Replica settings.
|
|
[1] | Change Settings on Master Host. |
[root@www ~]#
vi /etc/redis.conf # line 69: change to own IP address or [0.0.0.0] bind 0.0.0.0
# line 136: change (run as daemon) daemonize yes
# line 459: add follows if 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-replicas-to-write 2
min-replicas-max-lag 10 # line 508: authentication password
requirepass password
systemctl restart redis
|
[2] | Change Settings on Replica Host. |
[root@node01 ~]#
vi /etc/redis.conf # line 69: change to own IP address or [0.0.0.0] bind 0.0.0.0
# line 136: change (run as daemon) daemonize yes
# line 287: add Master Host IP address and port
replicaof 10.0.0.31 6379
# line 294: add authentication password set on Master Host
masterauth password
# line 324: verify parameter (set Slave Hosts read-only) replica-read-only yes systemctl restart redis
|
[3] | On all Nodes, If Firewalld is running, allow service. |
[root@www ~]# firewall-cmd --add-service=redis --permanent success [root@www ~]# firewall-cmd --reload success |
[4] | Verify statics on Replica Hosts, then it's OK if [master_link_status:up] is shown. |
[root@node01 ~]# redis-cli 127.0.0.1:6379> auth password OK # show statics 127.0.0.1:6379> info Replication # Replication role:slave master_host:10.0.0.31 master_port:6379 master_link_status:up master_last_io_seconds_ago:6 master_sync_in_progress:0 slave_repl_offset:134 slave_priority:100 slave_read_only:1 connected_slaves:0 master_replid:44a90666ab73ef6ec5d755ed4b8f87062309679f master_replid2:0000000000000000000000000000000000000000 master_repl_offset:134 second_repl_offset:-1 repl_backlog_active:1 repl_backlog_size:1048576 repl_backlog_first_byte_offset:15 repl_backlog_histlen:120 # verify to get keys set on Master Host 127.0.0.1:6379> get key_on_master "value_on_master" |
Sponsored Link |