Redis simple local one master and two slaves to build study notes

Simple local one-master-two-slave construction of Redis

1. Create a myredis directory under the root directory and enter the directory

image-20211014214114849

image-20211014214124725

2. Copy /etc/redic.conf to /myredis/redis.conf

image-20211014214222061

3. Create three configuration files, named redis6379.conf, redis6380.conf, and redis6381.conf respectively, and import the common configuration file redis.conf through include, and modify the corresponding configuration information at the same time

First create and modify the contents of the redis6379.conf configuration file through vi

image-20211014214736262

Enter the following content and save and exit, which means importing redis.conf, modifying pidfile, the port number is 6379, and modifying the file name of the persistent RDB

image-20211014214809319

In the same way, create redis6380.conf and make the same modification

image-20211014214953963

Continue to configure redis6381.conf

image-20211014215050330

image-20211014215130319

4. Start three services

[External link picture transfer failed, the source site may have an anti-theft link mechanism, it is recommended to save the picture and upload it directly (img-TVoiTvzq-1634220414889)(/Users/sundaohan/Library/Application Support/typora-user-images/image-20211014215242074 .png)]

5. Check whether the service is opened successfully

image-20211014215318875

6. Open three terminals and open the clients of the three services respectively

image-20211014215620764

image-20211014215630300

image-20211014215704640

7. Configure 6379 as the master, and the others as slaves

Execute on 6380 and 6381: slaveof 127.0.0.1 6379 The command format is: slaveof [ip] [port]

image-20211014215843242

image-20211014215852327

8. Check whether the configuration is successful

View information through the command info replication on the three terminals

image-20211014220032926

image-20211014220101419

image-20211014220128045

9. Test effect

Write operation in the host

image-20211014220338340

View from the slave

image-20211014220409982

image-20211014220422877

If the write operation is performed in the slave, an error will be reported

image-20211014220454852

Guess you like

Origin blog.csdn.net/weixin_42195126/article/details/120773880