Summary: In a Redis cluster, several Redis servers are assigned to replicate another Redis server, so the server to be replicated is defined as the master server, while the server to replicate the master server is called the slave server. This mode is called the master-slave replication mode. Multiple copies of data can be provided to achieve high availability and read/write separation (the master node is responsible for writing data, and the slave node is responsible for reading data. The master node synchronizes data to the slave node to ensure data consistency

By default, redis is installed and running properly

Conf file to ect, copy the redis.conf file to redis6380, redis6381. I’ll name redis. Conf slave.conf.

2. Modify the slave.conf configuration

# Change the port number to6380.6381
port 6380/6381Configure the primary IP address and port slaveof for host-based replication127.0. 01.  6379# set whether the secondary node is read-only replica-read-only yesCopy the code

3. Enable the slave service

/usr/local/etc/redis6380 /redis server slave.confCopy the code

4. Start the slave service

$ redis-cli -h 127.0. 01. -p 6380
Copy the code