Master configuration
Mainly the following configuration
# ~ ~ ~ WARNING ~ ~ ~ If the computer running Redis isdirectly exposed to the# Internet, binding to all the interfaces isdangerous and would expose the# instance to everybody on the internet. so bydefaultWe uncomment the# following bind directive, that would force Redis to listen only into# the IPv4 lookbackInterfaceAddress ( Thismeans Redis would be able to# accept connections only fromclients running into the same computer it# isrunning). # # IF You is sure you want YOUR INSTANCE to LISTEN to all the interfaces# JUST COMMENT the following line.# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Bind127.0.0.1 192.168.1.102
################################## SECURITY #################################### Require clients to issue AUTH <PASSWORD>before processing any other# commands. This might is usefulinchEnvironmentsinchwhich DoNot trust# Others with access to the host running Redis-server.## This should stay commented out forbackward compatibility and because most# people DoNot need auth (e.g. they run their own servers). # # Warning:since Redis isPretty fast an outside user canTryUp to# 150k passwords per second against a good box. This means, should# use a very strong password otherwise it 'll be very easy to Break. #requirepass Master
Slave configuration
#1) Redis Replication isasynchronous, but can configure a master to# stop accepting writesifIt appears to is not connected with at least# a given number of slaves.#2) Redis slaves is able to perform aPartialresynchronization with the# masterifThe replication link isLost fora relatively small amount of# time. Want to configure the replication backlog size (see the next# sections of Thisfile) with a sensible value depending on your needs.#3) Replication isautomatic and does not need user intervention. After a# network partition slaves automaticallyTryTo reconnect to masters# and resynchronize with them. #slaveof192.168.1.102 6379# If The master isPasswordprotected(usingThe"Requirepass"configuration# directive below) it ispossible to tell the slave to authenticate before# starting the replication synchronization process, otherwise the MA Ster will# refuse the slave request. #masterauth Master
################################## SECURITY #################################### Require clients to issue AUTH <PASSWORD>before processing any other# commands. This might is usefulinchEnvironmentsinchwhich DoNot trust# Others with access to the host running Redis-server.## This should stay commented out forbackward compatibility and because most# people DoNot need auth (e.g. they run their own servers). # # Warning:since Redis isPretty fast an outside user canTryUp to# 150k passwords per second against a good box. This means, should# use a very strong password otherwise it 'll be very easy to Break. #requirepass slave
Open Redis's default port 6379 in master or turn off firewall: Systemctl stop Firewalld.service
Firewall-cmd--zone= public--add-port=6379/tcp--permanent
It's best to open the Redis port in slave.
In master requires the IP of the bind master, otherwise in slave may appear the connect refused, the specific reason is not clear, now just began to study redis, learning ....
Restarting the firewall
Firewall-cmd--reload
Redis Master-slave replication configuration