Redis High Availability cluster scheme and emergency maintenance skills

Source: Internet
Author: User
Tags redis haproxy

Prerequisite: Now has the master-slave structure, the main library is not configured to persist, from the library configuration aof. (The main library is used to back up and write services and to provide read services from the library)

Scene: Which God's library suddenly down, what to do?

Method: Connect from the library, do the save operation. A copy of the latest Dump.rdb file from the library will be saved in the data directory from the library. Copy the Dump.rdb file to the main library's data directory. and restart the main library.

Because of that, I thought of the cluster scheme, but Redis officially did not have MySQL-like master-

Master Mode ~ In this case, we can only find a way to ourselves ~

The principle of realization ~

When Master and Slave are working properly, Master is responsible for reading, Slave is responsible for synchronization;

When Master hangs out, the Slave is normal, the Slave takes over the service, and the master and slave copy function is turned off;

Then loop it in turn.

In this way, any one of the two Redis servers will continue to be serviced by another, not on the site

To a perceptible effect, without losing data.

You can also achieve

When Master returns to normal, it synchronizes data from slave, synchronizes data, turns off the master-slave copy function, restores

Master, while Slave waits for master to synchronize data to complete, restore slave identity.

High Availability aspects

The need to separate the read and write, the writing, pointing to a vip~ that two main keepalived with a script to judge.

Read, as far as possible with haproxy to shunt, so, even if a from down words, Haproxy will automatically remove the ~

Redis Installation ~

wget http://redis.googlecode.com/files/redis-2.2.13.tar.gz    
tar-zxf redis-2.2.13.tar.gz    
cd redis-2.2.13 Make make    
install

Installation of keepalived ~

TAR-XZVF keepalived-1.1.20.tar.gz    
        
cd keepalived-1.1.20    
        
./configure--prefix=/usr/local/webserver/ Keepalived make make    
        
install    
        
cp/usr/local/webserver/keepalived/sbin/keepalived/usr/sbin    
        
CP/ Usr/local/webserver/keepalived/etc/sysconfig/keepalived/etc/sysconfig    
        
cp/usr/local/webserver/keepalived/ ETC/RC.D/INIT.D/KEEPALIVED/ETC/INIT.D    
        
mkdir/etc/keepalived    
        
cp/usr/local/webserver/keepalived/etc/ Keepalived/keepalived.conf/etc/keepalived

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.