Redis 5: Configure master-slave Replication

Source: Internet
Author: User
Tags redis cluster

Redis master-slave replication is actually very simple, and even easier than MySQL configuration, because basically no operation is required on the master server.

We open different ports on the same server for testing (the installation part is not mentioned. The previous articles include ::)

 

1. Start the master server (default port 6379)

/Etc/init. d/redis_6379 start

2. enable the first slave server

Redis-server -- Port 6380 -- slaveof 127.0.0.1 6379

This command needs to be performed in the src directory under your redis installation directory. It is strange that it is named make-install and an error will be reported when an existing service is started.

First, set the slave server port to 6380, enable the slave server function, and point the port to 6379.

3. Enable the second slave server

Redis-server -- Port 6381 -- slaveof 127.0.0.1 6380

 

========================================================== ======================================

In this way, our server group forms the relationship between the master and slave;

In fact, you can also set the port number of the master replication server of the second slave server to 6379, which becomes the relationship between one master and two slaves.

========================================================== ======================================

We set

Check the two slave servers:

It should be noted that once it is set as a slave server, you cannot perform write or modify operations, and only read operations are allowed.

This also indirectly facilitates the read/write Splitting Operation after we use the redis cluster;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.