Redis Master-Slave

Source: Internet
Author: User

Redis master-slave replication principle:

By passing this RDB file or aof file to the slave server, the slave server reloads the Rdb file to realize the function of replication!

Copy the words: The master server can have multiple slave servers!!! Not only this from the server can also have from the server, can be made into a star-like structure!

Copy the words will not block the process, the same fork a sub-process to do!

The principle of replication:

When a slave server is established, the server will want to send a sync command from the primary server, and the master server will execute bgsave after receiving the Sync command.

Then save to the Rdb file and then send it to the slave server! Receive the Rdb file and load it into memory!

Delta is not supported at the earliest, and increments are supported after 2.8!

Redis Master-Slave configuration:

The configuration is simple:

I want to put: 192.168.11.241 6379 as a 192.168.11.240 from only need one command

192.168.11.241:6379> slaveof 192.168.11.240 6379ok192.168.11.241:6379> info#  Replicationrole:slavemaster_host:192.168.11.240master_port:6379master_link_status:upmaster_last_io_seconds_ago : 1master_sync_in_progress:0slave_repl_offset:15slave_priority:100slave_read_only:1connected_slaves:0master_ Repl_offset:0repl_backlog_active:0repl_backlog_size:1048576repl_backlog_first_byte_offset:0repl_backlog_ Histlen:0 then go to the top of the master to see:# redis-cli -h 192.168.11.240 192.168.11.240:6379> info#  Replicationrole:masterconnected_slaves:1slave0:ip=192.168.11.241,port=6379,state=online,offset=456,lag=1master _repl_offset:456repl_backlog_active:1repl_backlog_size:1048576repl_backlog_first_byte_offset:2repl_backlog_ histlen:455 wrote an instruction in the Lord: 192.168.11.240:6379> set key hello,worldok on the view from the:192.168.11.241:6379>  get key "Hello,world"     #可以看到主从已经同步从2.61! From is read-only 192.168.11.241:6379> set key1 33033 (error) &NBsp Readonly you can ' t write against a read only slave.192.168.11.241:6379 >  #现实工作场景中, write and read is 1:10 of the ratio, we can set a master much from doing read and write separation!


This article is from the "Ask Heaven" blog, please make sure to keep this source http://79076431.blog.51cto.com/8977042/1755302

Redis Master-Slave

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.