“Redis is an open source (BSD licensed), in-memory data structure store, used as database, cache and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs and geospatial indexes with radius queries. Redis has built-in replication, Lua scripting, LRU eviction, transactions and different levels of on-disk persistence, and provides high availability via Redis Sentinel and automatic partitioning with Redis Cluster.”
I have installed redis on CentOS 7 and CentOS 6 without any issues, they specifically make it without any external dependencies so it is very lightweight.
cd /opt wget http://download.redis.io/releases/redis-3.0.7.tar.gz tar -xzvf redis-3.0.7.tar.gz cd redis-3.0.7/ make make test make install
Best practices state that there should be a Minimum 3 masters, but recommend a slave for each master for a complete HA environement.
I configured each node as a cluster node, this is somewhat of a new feature for Redis 3.0+, where before one could only setup master to slave replication, and then implement client side sharding to deal with fail-over and partitioning of data.
$ vim /opt/redis-3.0.7/redis.conf port 6379 bind 10.0.0.[R1] 127.0.0.1 cluster-enabled yes cluster-config-file nodes-6379.conf cluster-node-timeout 5000 appendonly yes
setup for clustering http://redis.io/topics/cluster-tutorial
$ redis-server /opt/redis-3.0.7/redix.conf $ ps fax | grep redis -> redis-server 10.0.0.[R1]:6379 [cluster]
Should do this on every master, but only really needed on 1 machine to execute redis-trib.rb to properly setup clusters
$ yum install ruby $ gem install redis $ /opt/redis-3.0.7/src/redis-trib.rb create 10.0.0.[R1]:6379 10.0.0.[R2]:6379 10.0.0.[R3]:6379
to create cluster nodes, no data can already be on the nodes and all nodes must up and be running
redis-trib.rb will not start if less than 3 masters, in production should also configure a number of slaves for failover
If there is already data
redis-cli -c -h 10.0.0.[R1] -p 6379 FLUSHALL CLUSTER RESET Quit rm /opt/redis-3.0.7/nodes-6379.conf
$ redis-cli -c -h 10.0.0.[R3] -p 6379 set foo bar get foo "bar"
$ redis-cli -c -h 10.0.0.[R2] -p 6379 get foo "bar"
Add additional master, the example below is with multiple masters running on the same host, but just by changing IP/port you can connect a new master to any existing master in the redis cluster
./redis-trib.rb add-node 10.0.0.[R1]:6379 10.0.0.[R4]:6379
Add slave node example
./redis-trib.rb add-node --slave 10.0.0.[R2]:6379 [10.0.0.[Rs2]:6379
./redis-trib del-node 127.0.0.1:6379 `<node-id>`