installationRuby
1) sudo apt-get install ruby
2) sudo apt-get install ruby-full rubygems
3) sudo gem install Redis ( This command takes longer to wait )
Create a node folder
1. cd/usr/local/
2. sudo mkdir cluster
3. sudo mkdir 7000 7001 7002 7003 7004 7005
Modifying a configuration fileRedis.conf
1. cd/deploy/redis-3.0.0/-------------Redis installation Folder
2. sudo cp redis.conf/usr/local/cluster/
3. Cd/usr/local/cluster
4. sudo vim redis.conf
5. Modify the following items:
a) Port 7000
b) cluster-enabled Yes
c) cluster-config-file nodes.conf
d) cluster-node-timeout
e) appendonly Yes
CopyRedis.confto the Node folder
1. sudo cp redis.conf 7000
2. sudo cp redis.conf 7001
3. sudo cp redis.conf 7002
4. sudo cp redis.conf 7003
5. sudo cp redis.conf 7004
6. sudo cp redis.conf 7005
7. Modify the ports in the configuration file under each node folder to correspond to folders
Start each node, be sure to go to each node folder to start
1. CD 7000
2. sudo redis-server redis.conf
3. CD.. /7001
4. sudo redis-server redis.conf
5. CD.. /7002
6. sudo redis-server redis.conf
7. CD.. /7003
8. sudo redis-server redis.conf
9. CD.. /7004
Ten. sudo redis-server redis.conf
One . CD. /7005
sudo redis-server redis.conf
Build a cluster
1. cd/deploy/redis-3.0.0/src
2. ./REDIS-TRIB.RB Create--replicas 1 192.168.1.149:7000 192.168.1.149:7001 192.168.1.149:7002 192.168.1.149:7003 192.168.1.149:7004 192.168.1.149:7005
Add116one of the nodes
1. Create the one of the nodes Port 7000
2. cd/deploy/redis-3.0.0/src
3. ./redis-trib.rb add-node 192.168.1.116:7000 192.168.1.149:7000--------------- will be the the node is added to the 149 on the cluster
Test
1. Login Redis
a) redis-cli–c–p 7000–h 192.168.1.149
2. Add Data
a) set Key1 val1
3. Get Data
a) get Key1
4. Exit
a) quit
5. log in to other nodes, such as 192.168.1.116:700
6. Get Key1 data to see if it is correct
Note the point:
1. building a cluster at least 6 a node: 3 Master node, 3 a Slave node
2. This machine IP : 192.168.1.149
3. To View all nodes:
a) redis-cli-p 7000-h 192.168.1.116 cluster nodes\
REDIS3 Cluster Construction