redis+ Master-slave replication + cluster configuration
Redisis aKey-valueStorage System. and thememcachedsimilar, butRedissupported byvaluemore types, mainly:string(String),List(linked list),Set(collection),Zset(Ordered collection) andHash (Hash Type). Redisand thememcached, in order to ensure efficiency, the data is cached in memory. Difference isRedisperiodically writes the updated data to the disk or writes the modified operation to the appended record file, and on this basis implementsMaster-slavemaster-Slave synchronization.
The following is to implement master-slave replication and clustering, clustering is based on the master-slave replication. First three virtual machines are prepared, respectively:
#VM1: ip=172.25.10.8
#VM2: ip=172.25.10.9
#VM3: ip=172.25.10.10
One: Redis installation on three virtual hosts:
#yum install-y gcc gcc-c++ ; Install the build software
#cd redis/
#tar-zxf redis-3.0.2.tar.gz ; unpack a package
#cd redis-3.0.2 ; Enter the extracted directory
compile and install directly
#cd utils/ ; Enter this util Catalogue , execute the following script. Configure and start the program
#./install_server.sh
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/83/88/wKioL1d1Srvy5TrDAAGDs4XdmKU164.png-wh_500x0-wm_3 -wmp_4-s_1037220804.png "title=" screenshot from 2016-06-30 09_53_23.png "alt=" Wkiol1d1srvy5trdaagds4xdmku164.png-wh _50 "/>
#netstat-antlpe | grep redis; can view Redis The port number used is 6379
#redis-cli; Redis use commands for clients
>set No1 1234 key no1 add key value 1234 ;
>get No1; Get No1 the key value;
Start the Redis service on three virtual machines and configure the configuration files on the two slave hosts for master and slave replication;
SLAVE:VM2 VM3
VM2 #vim/etc/redis/redis-6379
Slaveof 172.25.10.8 6379; Add the IP and port number of master.
VM3 #vim/etc/redis/redis-6379/
Slaveof 172.25.10.8 6379
VM2, VM3 respectively restart the Redis service;
#/etc/init.d/redis-6379 Restart
Then verify that you use the command line REDIS-CLI on master to enter the key-value pair (REDIS-CLI--and set No1 1234), and then verify on both slave hosts to get the key value directly (REDIS-CLI--get No1). If you can get a uniform value, this indicates that the master-slave replication synchronization succeeds. Or, on master, verify that: Redis-cli-->info
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M00/83/88/wKioL1d1TYbydHU8AAB8N8Zvgz0428.png-wh_500x0-wm_3 -wmp_4-s_2217544702.png "title=" screenshot from 2016-06-30 09_56_00.png "alt=" Wkiol1d1tybydhu8aab8n8zvgz0428.png-wh _50 "/>
Appears to indicate a successful master-slave copy.
Cluster service configuration, effectively solve single point of failure;
#cd/root/ redis-3.0.2
#vim sentinel.conf
#grep-v ^# sentinel.conf; Modify the configuration as
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M00/83/89/wKiom1d1Tk7yHN34AABknKbZeig506.png-wh_ 500x0-wm_3-wmp_4-s_2247403209.png "title=" screenshot from 2016-06-30 09_54_04.png "alt=" Wkiom1d1tk7yhn34aabknkbzeig506.png-wh_50 "/>
#grep-v ^# sentinel.conf >/etc/sentinel.conf
#scp/etc/sentinel.conf [email protected]:/etc/to transfer the configured files directly to two slave machines,
#scp/etc/sentinel.conf [Email protected]:/etc/
Launch Sentinel process for three virtual hosts;
VM1, VM2, VM3:
# redis-sentinel/etc/sentinel.conf
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M01/83/89/wKiom1d1TwqgwPyaAADiu9Ax_jE961.png-wh_500x0-wm_3 -wmp_4-s_2534129691.png "title=" screenshot from 2016-06-30 09_54_40.png "alt=" Wkiom1d1twqgwpyaaadiu9ax_je961.png-wh _50 "/>
The above graphic appears to indicate that the Sentinel has been started, and if it cannot be started it may be because the Sentinel profile does not give write permission (W).
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M02/83/89/wKiom1d1T4aiUr98AADQfNmSSrM503.png-wh_500x0-wm_3 -wmp_4-s_1116342768.png "title=" screenshot from 2016-06-30 09_55_05.png "alt=" Wkiom1d1t4aiur98aadqfnmssrm503.png-wh _50 "/>
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M01/83/89/wKiom1d1T5XxQlHVAADkgFVw9dI776.png-wh_500x0-wm_3 -wmp_4-s_2116206796.png "title=" screenshot from 2016-06-30 09_55_41.png "alt=" Wkiom1d1t5xxqlhvaadkgfvw9di776.png-wh _50 "/>
Finally verify that master stops, and then the slave takes over.
This article is from the "Foreverlinux" blog, make sure to keep this source http://linuxmin0712.blog.51cto.com/11702588/1794757
redis+ Master-slave replication + cluster configuration