And we can use the same way to upgrade it to 2.6.16.
Start the redid server like this.
>./redis-server redis.conf
>./redis-cli
>info
It will give out a lot of information to prove that our installation is right.
2. Understanding of Redis Change the database as we like
redis 127.0.0.1:6379[1]> select 1
OK
redis 127.0.0.1:6379[1]> select 0
OK
Data Expiration
>set name "sillycat"
>ttl name
>exists name
>expire name 5
Check Suffix Command
>set name "karl"
>setnx name "bcd"
>get name
"Karl"
Java Mapping Spring Example
org.springframework.data.redis.connection.jedis.JedisConnectionFactory
3. Use Cases
Cache, Messaging, Counting
4. HA Solutions
Replication http://redis.io/topics/replication
Persistence http://redis.io/topics/persistence
HA http://redis.io/topics/sentinel
Here is the Codes Repo. https://github.com/antirez/redis
Build my own latest Redis
>git clone https://github.com/antirez/redis.git
>cd redis
>make
>make test
Sometimes, it has error and fail test cases, try more times.
4.1 Replication
Slave Redis servers to be exact copies of master servers.
Configration
slaveof 192.168.10.115 6379
4.2 Persistence
…snip…
4.3 Sentinel
Get the latest unstable branch and compile that, from the same src directory
>cp redis-sentinel /Users/carl/tool/redis-latest/
>cd ..
>cp sentinel.conf /Users/carl/tool/redis-latest/
Command to start
>./redis-sentinel sentinel.conf
Or alternatively
>./redis-server sentinel.conf --sentinel
>./redis-cli -p 26379 sentinel masters
SDOWN and ODOWN
SDOWN - subjectively down, sentinel think one Redis instance not working.
ODOWN - objectively down, a lot of sentinel instance think Redis master instance down.
How to Set up Master-Slave
Configuration
>vi redis-0/redis.conf
port 6379
>vi redis-1/redis.conf
port 6479
slaveof 127.0.0.1 6379
Then I have 1 master of Redis instance on 6379, 1 slave of Redis instance on 6479.
1 Sentinel on 26379, 1 sentinel on 26479.
Once the master is down on 6379, the slave will take the place to be master.
Information
>./redis-cli -h 127.0.0.1 -p 26379 info Sentinel
# Sentinel
sentinel_masters:1
sentinel_tilt:0
sentinel_running_scripts:0
sentinel_scripts_queue_length:0
master0:name=mymaster,status=ok,address=127.0.0.1:6479,slaves=1,sentinels=2
>./redis-cli -h 127.0.0.1 -p 6479
redis>info
Useful Book http://www.redisbook.com/en/latest/ http://www.wzxue.com/redis%E6%A0%B8%E5%BF%83%E8%A7%A3%E8%AF%BB-%E9%9B%86%E7%BE%A4%E7%AE%A1%E7%90%86%E5%B7%A5%E5%85%B7redis-sentinel/