Beckham _redis Advanced Applications-master-slave replication

Source: Internet
Author: User

Redis Advanced Applications-master-slave replication

First, why the need for master-slave replication

Second, the characteristics and process of master-slave replication

Third, configure master-slave replication

Iv. Verifying that master-slave replication is in effect

V. How to view who Master who from and frequently asked questions

First, why the need for master-slave replication

Although Redis runs in memory, processing is faster. However, there are some unavoidable anomalies, such as server outages and so on, in order to improve the usability of the application. Requires a master-slave copy of Redis:

1, share the pressure of access

2, because the master-slave has the same database copy, which can be redundant, when the primary server is abnormal, from the server can be replaced in a timely manner to ensure normal use

second, the characteristics and process of master-slave replication

1. Features:

A, master can have multiple slave

b, multiple slave can be connected to the same master, but also can be connected to other slave

C, master-slave replication does not block master, while synchronizing data, Master can still continue processing client requests

2. Process:

A, slave and master to establish a connection, send Sync Sync command

B, master initiates a background process, saves the database snapshot to a file, and the master master process starts collecting new write commands and caches

C, after the background to complete the save, the file is sent to slave

D, slave Save this file to your hard disk

Third, configure master-slave replication

Prerequisite: Since the test environment is the same machine, the Redis Master service is running on Port 6379, running from the service on port 6378

1. Open the main service profile and set the login password Xiaobei

2. After saving, restart Redis

3. Open the profile from the service, set the information about the main service

(Note: Specify the IP and port of the primary service, and the login password)

4. After saving, restart from service Redis

Iv. Verifying that master-slave replication is in effect

1. Observing the network transmission of the master-slave service

(Note: From the service 6378 can be seen, the master-slave replication network transmission has been successful)

2. Data consistency Verification

2.1, primary and from the beginning of the data are empty

2.2. Set a string with key name,value to Xiaobei in the main service

(Note: As can be seen from the above, the master-slave replication configuration has been successful)

v. How to view who Master who from and frequently asked questions

1, sometimes, when the device is many, and there is no indication of the case, is unable to mark who is the Lord, who is from, then you can use the info command

If this is the master, you will see

Instead, you'll see

2. Frequently Asked Questions

2.1, once set to from the service, it can only be read-only mode

(Note: Modify the name that you just copied, and when you modify it, an error occurs)

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Beckham _redis Advanced Applications-master-slave replication

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.