redis10--Master-Slave mode

Source: Internet
Author: User

Redis Master-Slave mode
(1) Introduction
Redis storage data runs in memory and runs faster than a relational database. And it has Sortset/hash
and other unique data types, which are unmatched by other databases.

Redis has increased the deletion of four kinds of operations, and the general database is similar.
What operations consume the most database resources? is the query. Subqueries in queries, multi-table queries, group BY, and order by in a condition
and limit operations will consume a lot of database resources.

Improve the efficiency of the database, in the case of sufficient funds, we can improve the hardware facilities to complete:
Acquisition of multiple servers, each server to perform different data operations, query class operations consume resources, can be divided into several databases to operate, called "Read and write separation technology."

Add, modify, delete are called "Data write", the primary server can be "write" server, and from the server can be as
"Read" server. The primary and slave servers are automatically synchronized through some technologies. This is called "Master-slave Mode".

(2) Creating a Redis-based master-slave mode
We can also build a "master-slave Model" for Reids. Install Redis on multiple servers, and then the primary server is responsible for writing
Operation to read from the server. The master and slave servers can be automatically backed up:

(master server is master, slave server is slave)

We open redis.conf, below you can set which server this redis resides on is the slave server of the primary server:


or become the primary server for the Redis server:


Setup Sample:
Set the slave server for one of the Redis master servers under IP 192.168.39.159


In fact, the read and write permissions from the server can be configured, the configuration location is as follows:


Note that after modifying the Redis configuration file, to kill the existing Redis process and restart the Redis service, you can see

Data from other servers.

(3) Hands-on practice
We use Redis to implement master-slave mode.

First open two terminals in Linux in VMware virtual machines, one is User Jack and the other is NewUser:


Then we jack as host, Redis service runs on port 6379, we set NewUser to slave, set its redis
Run on port 6380 and let it use the slaveof command from the host that belongs to Jack:

Note: When our clients log in, the configuration files used are redis.conf and redis6380.conf, respectively.
Where redis6380.conf content is the same as redis.conf, only the port port number is set differently:


Can look at the information of the two terminals, and found that they are independent of each other, not any one of the slave (that is, two are independent hosts):


Methods for implementing Master-Slave mode with directives:

Reprint Please specify source: http://blog.csdn.net/acmman/article/details/53434134

redis10--Master-Slave mode

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.