Redis's master-slave replication configuration

Source: Internet
Author: User

This document is based on Nginx+tomcat+redis (session basis) to do the operation, this operation is not introduced, can refer to: http://francis905.blog.51cto.com/3048056/1720693


Principle part:

Redis's master-slave replication feature is very powerful, a master can have multiple slave, and a slave can have more than slave, so continue to form a powerful multi-level server cluster architecture. Here are some of the features of Redis master-slave replication:

1.master can have multiple slave

2. In addition to multiple slave connected to the same master, slave can also connect other slave to form a graphic structure

3. Master-slave replication does not block primary. This means that when one or more slave and master synchronize data for the first time, master can continue to process requests from the client. Conversely, slave will block requests that cannot process the client when the data is first synchronized.

4. Master-slave replication can be used to improve the scalability of the system, we can use multiple slave dedicated to client read requests, such as the sort operation can be handled using slave. can also be used to do simple data redundancy

5. You can disable data persistence in master, just comment out all the save configurations in the master configuration file and configure data persistence on slave only.


The following describes the process of master-slave replication

When the slave server is set up, slave will establish a connection to master and then send the Sync command. Whether the connection was first synchronized or after a disconnected connection, master initiates a background process, saves the database snapshot to a file, and the master master process starts collecting new write commands and caches them. After the background process finishes writing the file, master sends the file to Slave,slave to save the file to disk, and then loads it into the memory recovery database snapshot to slave. The master then forwards the cached command to slave. and subsequent master commands are sent to the slave by the connection that was started to be established. Commands that synchronize data from master to slave and commands sent from the client use the same protocol format. Slave can automatically reestablish a connection when master and slave are disconnected. If master receives multiple slave simultaneous connection commands at the same time, it will only use the START process to write database mirroring and then send it to all slave.


Operating section: s1:192.168.3.13 tomcat7+redis2.6 (Redis-master)

s2:192.168.3.12 tomcat7+redis2.6 (Redis-slave)

In other words, Redis-master is your tomcat configuration file context.xml with host= "192.168.1.11" code.

1.11 The server on which this IP resides is master


First, master-slave replication


The master-slave configuration is very simple, only need to operate on the slave,

vim/etc/redis/6379.conf//Modify configuration file Some may be in/usr/local/redis/etc/redis.conf

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/77/48/wKioL1ZmdzeAvNn3AADghyl8d6U274.png "title=" 222. PNG "alt=" Wkiol1zmdzeavnn3aadghyl8d6u274.png "/>

#在slave上添加master的IP地址 Port can be as much from the same reason

If you are configuring a master-slave relationship on a machine, you also need to modify the default port number from the server, as well as the redis.conf.


Restart Redis to see

Slave

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/77/49/wKiom1ZmeDLRqcdaAADG28p80Jc641.png "title=" 1.png " alt= "Wkiom1zmedlrqcdaaadg28p80jc641.png"/>

Test:

Mater

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/77/4A/wKiom1Zme9KC44ZOAAAkVLiOwbg050.png "title=" 11111111111111111111.png "alt=" Wkiom1zme9kc44zoaaakvliowbg050.png "/>

Slaver:

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/77/4A/wKiom1Zme-jAwvehAAAdlFobhF0115.png "title=" 2222222222222222.png "alt=" Wkiom1zme-jawvehaaadlfobhf0115.png "/>






This article is from the "Rookie Growth Road" blog, please be sure to keep this source http://francis905.blog.51cto.com/3048056/1720737

Redis's master-slave replication configuration

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.