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