????Redis???????????????KEY-VALUE(???????)??????洢??????????????????????Redis?????????????????Redis????????????????
?????????
????http://redis.io/download (????Redis????????????http://antirez.com/latest/0??????????????)
?????????
??????redis-2.8.19.tar.gz????????????????£????????/usr/local????
????????
????????/usr/local/redis-2.8.19?????
????#make
??????????gcc: Command not found?????????????gcc
????#yum install gcc
??????????zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory???????????deps??????У?
????#make hiredis
????#make jemalloc
????#make linenoise
????#make lua
???????????????????make???ɡ?
?????????
????make??????????src??????redis-server?????????????У?
????#src/redis-server
??????
????#src/redis-server &//??&??????????????Redis????????
????????
????#ps aux|grep redis//???????????????
??????
????#telnet localhost 6379//???Redis
????????????
????#src/redis-cli//????Redis??????????
?????????????????????Redis????(1)keys *???????????????е?key??(2)set foo bar???????foo?????bar??(3)get foo??????foo?????
????????
????#src/redis-cli shutdown
?????????
?????????????ó?????????????????к?????????????????????Redis??????????????????????????Redis?????????????????Redis?????????????????????/usr/local/redis-2.8.19/redis.conf????е?logfile?????/var/log/redis.log???????????????
???????????src/redis-cli CONFIG GET *??????????????????????????ERR Wrong number of arguments for CONFIG GET
??????????????Щ???????????????Redis????????????????????????????????
????#src/redis-server redis.conf &//???????·???????redis.conf
????????????????????????????????
????HA?????
?????????????Redis???????Replication????????????????????redisha1(153.65.171.99)???????master??redisha2(153.65.170.156)???????????????slave?????????redis.conf??
????slaveof 153.65.171.99 6379
???????????redisha1??slave??????????????????????redisha1?????set foo bar2????redisha2?????get foo????????bar2??Redis?????????????
????????????????????Replication?????slave??redisha2?????read-only????????????????redisha2?????set????д?????????set?????????(error) READONLY You can't write against a read only slave??
??????????Replication??????ζ?????′???????????redisha1崻???????????ζ??????Redis???Ч??????????????μ?redisha2?????read-only??slave??
??????????????????????????????????Redis Replication???е????л?????????????????????Redis Sentinel?????????sentinel??????????????????????????????????????????????????Sentinel??redisha3(153.65.171.168)??redisha4(153.65.170.145)???????????redisha1??redisha2?????????????redis-2.8.19??????????????????????redis.conf???У?????????sentinel.conf??
????sentinel monitor test 153.65.171.99   6379   2
?????????????????????153.65.171.99??????????Redis????????????????????test(?????mymaster????????????????????????????????mymaster???????????????)??6379????99??Redis?????????
???????2???????????quorum???????????Redis?????????????ж??sentinel???????????????????sentinel崵?????redis???????С????sentinel?????????“??”?????????sentinel??????redis???崵????????????????????????????????е?sentinel????е?n??sentinel???????????redis?????崵???????????????????????n???????quorum?????????
???????Sentinel??
??????redisha3??redisha4???????/usr/local/redis-2.8.19??????У?
????#src/redis-server sentinel.conf --sentinel
?????????
???????redisha1???redis?????????sentinel??????У?
????+switch-master test 153.65.171.99 6379 153.65.170.156 6379
?????????????redisha1(153.65.171.99)??master???????????redisha2(153.65.170.156)???е????
??????????????redisha2??redis.conf?е?slaveof??????????????????????master???
???????redisha1???redis??redisha1????slave????????redis???У???????sentinel??????п?????
????+convert-to-slave slave 153.65.171.99:6379 153.65.171.99 6379 @ test 153.65.170.156 6379
??????redisha1?е?redis.conf????????л?????????slaveof?????????????master??redisha2??
??????????????????????????redis????????????slave???????е???????2.6?汾??????е??
???????redisha4???sentinel??redisha3??????????
????+sdown sentinel 153.65.170.145:26379 153.65.170.145 26379 @ test 153.65.170.156 6379
??????????????redisha2??????????master????sentinel??????????????л???????quorum???????й?????????????а????2????????????????????
????SDOWN?? ODOWN??
??????sentinel??????У??????????????????????
????Subjectively Down condition (SDOWN) ????????redis??????????????sentinel?ж??redis??????????
????Objectively Down condition (ODOWN) ????ж??redis?????????quorum?????????????n?????????n??sentinel????redis????????????ODOWN????
????????????????
????#redis-cli -h {IP} -p 26379 info Sentinel//??sentinel?????
????#redis-cli -h {IP} -p 6379 info Replication//??replication?????
????#redis-cli -h {IP} -p 26379 sentinel slaves test//??????slave???????test??sentinel.conf???????master?????