Install based on Redhat Linux
Front: Yum installed (because you need to install software like Ruby, it's easy to install using Yum Install, see http://eip.teamshub.com/t/3111540 for installing Yum)
1, put "redis-3.0.5.tar.gz" into the Home/redis directory;
2. Decompression
TAR-ZXVF redis-3.0.5.tar.gz
3, into the directory to compile
CD redis-3.0.5
Make
4. Create the directory required by the cluster
Mkdir-p/home/redis/redis-3.0.5/cluster-test
Cd/home/redis/redis-3.0.5/cluster-test
mkdir 7000
mkdir 7001
mkdir 7002
mkdir 7003
mkdir 7004
mkdir 7005
5. Modify the configuration file redis.conf
cd/home/redis/redis-3.0.5/cluster-test/7000
VI redis.conf
# #编辑文件中的内容为下面内容:
Port 7000
Daemonize Yes #这个可有可无 to see what it is. Configuration Items
cluster-enabled Yes
Cluster-config-file nodes.conf
Cluster-node-timeout 5000
AppendOnly Yes
6. Copy the 7000 redis.conf configuration files to the 7001/7002/7003/7004/7005 directory, respectively.
cp/home/redis/redis-3.0.5/cluster-test/7000/redis.conf/home/redis/redis-3.0.5/cluster-test/7001
cp/home/redis/redis-3.0.5/cluster-test/7000/redis.conf/home/redis/redis-3.0.5/cluster-test/7002
cp/home/redis/redis-3.0.5/cluster-test/7000/redis.conf/home/redis/redis-3.0.5/cluster-test/7003
cp/home/redis/redis-3.0.5/cluster-test/7000/redis.conf/home/redis/redis-3.0.5/cluster-test/7004
cp/home/redis/redis-3.0.5/cluster-test/7000/redis.conf/home/redis/redis-3.0.5/cluster-test/7005
7. To modify the port parameter in the redis.conf file under the 7001/7002/7003/7004/7005 directory after the previous copy is complete, change the name of the corresponding folder
8. Write a Redis startup script, such as 7000
cd/home/redis/redis-3.0.5/cluster-test/7000
VI start7000.sh
# #在start7000. SH Edit the following and save:
cd/home/redis/redis-3.0.5/cluster-test/7000
Nohup/home/redis/redis-3.0.5/src/redis-server redis.conf > Redis7000.log 2>&1 &
#编辑保存好后, modify permissions to execute
chmod 777 start7000.sh
9, copy the start7000.sh script, respectively, to the 7001/7002/7003/7004/7005 directory below
cp/home/redis/redis-3.0.5/cluster-test/7000/start7000.sh/home/redis/redis-3.0.5/cluster-test/7001/start7001.sh
cp/home/redis/redis-3.0.5/cluster-test/7000/start7000.sh/home/redis/redis-3.0.5/cluster-test/7002/start7002.sh
cp/home/redis/redis-3.0.5/cluster-test/7000/start7000.sh/home/redis/redis-3.0.5/cluster-test/7003/start7003.sh
cp/home/redis/redis-3.0.5/cluster-test/7000/start7000.sh/home/redis/redis-3.0.5/cluster-test/7004/start7004.sh
cp/home/redis/redis-3.0.5/cluster-test/7000/start7000.sh/home/redis/redis-3.0.5/cluster-test/7005/start7005.sh
10. To modify the port parameter in the start700x.sh file under the 7001/7002/7003/7004/7005 directory after the previous copy is complete, change the name of the corresponding folder
11, the distribution starts the start700x.sh under the respective path, after starting, can view the process
[Email protected] 7005]$ Ps-ef|grep 700
Redis 6063 1 0 22:56? 00:00:06/home/redis/redis-3.0.5/src/redis-server *:7000 [cluster]
Redis 28766 1 0 23:50 pts/2 00:00:00/home/redis/redis-3.0.5/src/redis-server *:7001 [cluster]
Redis 28795 1 0 23:52 pts/2 00:00:00/home/redis/redis-3.0.5/src/redis-server *:7002 [cluster]
Redis 28800 1 2 23:53 pts/2 00:00:00/home/redis/redis-3.0.5/src/redis-server *:7003 [cluster]
Redis 28817 1 0 23:53 pts/2 00:00:00/home/redis/redis-3.0.5/src/redis-server *:7004 [cluster]
Redis 28823 1 0 23:53 pts/2 00:00:00/home/redis/redis-3.0.5/src/redis-server *:7005 [cluster]
Redis 28831 28500 0 23:53 pts/2 00:00:00 grep 700
If the startup is encountered because Ulimit Nofile set too small to start, you can change the root user Ulimit, to Redis users set Nofile
Vim/etc/security/limits.conf
Add the following two lines
Redis Soft Nofile 10240
Redis Hard Nofile 20480
12. Upgrade Ruby, install Gem
Installing GEMS requires a ruby version of 1.8.7 or more, if Ruby version is low or not installed, first you upgrade your Ruby
[Email protected] ~]# ruby-v
Bash:ruby:command not found
[[email protected] ~]# Yum install Ruby
To check the ruby version:
[Email protected] ~]# ruby-v
Ruby 1.8.7 (2013-06-27 patchlevel 374) [I386-linux]
Check if the RubyGems is installed:
[Email protected] ~]# Rpm-qa|grep Ruby
ruby-1.8.7.374-4.el6_6.i686
ruby-libs-1.8.7.374-4.el6_6.i686
If there is no RubyGems, install
[email protected] ~]# Yum install RubyGems
13. Installing the Redis Ruby interface via gem
[[Email protected] ~]# gem install Redis
14. Create cluster command to perform REDIS create cluster
Usage notes for creating a cluster using REDIS-TRIB.RB:
Create sub-command construction #redis-TRIB.RB
#--replicas specifies several slave nodes for each master node in the Redis cluster
#节点角色由顺序决定, first master is slave.
To create a command:
/HOME/REDIS/REDIS-3.0.5/SRC/REDIS-TRIB.RB Create--replicas 1 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005
[[email protected] src]$/home/redis/redis-3.0.5/src/redis-trib.rb create--replicas 1 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005
>>> Creating Cluster
Connecting to Node 127.0.0.1:7000:ok
Connecting to Node 127.0.0.1:7001:ok
Connecting to Node 127.0.0.1:7002:ok
Connecting to Node 127.0.0.1:7003:ok
Connecting to Node 127.0.0.1:7004:ok
Connecting to Node 127.0.0.1:7005:ok
>>> performing hash slots allocation on 6 nodes ...
Using 3 Masters:
127.0.0.1:7000
127.0.0.1:7001
127.0.0.1:7002
Adding replica 127.0.0.1:7003 to 127.0.0.1:7000
Adding replica 127.0.0.1:7004 to 127.0.0.1:7001
Adding replica 127.0.0.1:7005 to 127.0.0.1:7002
M:240ded0272e5d6827a9d99f83304a38ba656ddad 127.0.0.1:7000
slots:0-5460 (5461 slots) Master
m:d8640ddab8d45f26d34082490cce6a567e612192 127.0.0.1:7001
slots:5461-10922 (5462 slots) Master
M:f1a4a0983c595dcab49e8b8258538929525632e8 127.0.0.1:7002
slots:10923-16383 (5461 slots) Master
S:feb6af7fbdd9a68712c8017b447222aac596a5ee 127.0.0.1:7003
Replicates 240ded0272e5d6827a9d99f83304a38ba656ddad
S:441F2FD0FB4B5FBE66929AF699A20E3E989449FB 127.0.0.1:7004
Replicates d8640ddab8d45f26d34082490cce6a567e612192
s:cc16895d326c29bc159ddf6ca10dcfa04762d984 127.0.0.1:7005
Replicates F1a4a0983c595dcab49e8b8258538929525632e8
Can I Set the above configuration? (Type ' yes ' to accept): Yes
>>> Nodes Configuration Updated
>>> Assign a different config epoch to each node
>>> sending CLUSTER MEET messages to join the CLUSTER
Waiting for the cluster to join:
>>> performing Cluster Check (using node 127.0.0.1:7000)
M:240ded0272e5d6827a9d99f83304a38ba656ddad 127.0.0.1:7000
slots:0-5460 (5461 slots) Master
m:d8640ddab8d45f26d34082490cce6a567e612192 127.0.0.1:7001
slots:5461-10922 (5462 slots) Master
M:f1a4a0983c595dcab49e8b8258538929525632e8 127.0.0.1:7002
slots:10923-16383 (5461 slots) Master
M:feb6af7fbdd9a68712c8017b447222aac596a5ee 127.0.0.1:7003
Slots: (0 slots) Master
Replicates 240ded0272e5d6827a9d99f83304a38ba656ddad
M:441F2FD0FB4B5FBE66929AF699A20E3E989449FB 127.0.0.1:7004
Slots: (0 slots) Master
Replicates d8640ddab8d45f26d34082490cce6a567e612192
m:cc16895d326c29bc159ddf6ca10dcfa04762d984 127.0.0.1:7005
Slots: (0 slots) Master
Replicates F1a4a0983c595dcab49e8b8258538929525632e8
[OK] All nodes agree about slots configuration.
>>> Check for open Slots ...
>>> Check Slots Coverage ...
[OK] All 16384 slots covered.
The default is the first three nodes 7000 7001 7002 is the primary, and the last 3 nodes 7003 7004 7005 are from
If redistribution is required, after all nodes are stopped, the following files are removed:
RM appendonly.aof Dump.rdb nodes.conf Redis7005.log
Delete and then rerun the REDIS-TRIB.RB Create command to add the constituent cluster.
15. Monitoring Cluster Status command
/HOME/REDIS/REDIS-3.0.5/SRC/REDIS-TRIB.RB Check 127.0.0.1:7000
[Email protected] 7000]$/home/redis/redis-3.0.5/src/redis-trib.rb check 127.0.0.1:7000
Connecting to Node 127.0.0.1:7000:ok
Connecting to Node 127.0.0.1:7003:ok
Connecting to Node 127.0.0.1:7002:ok
Connecting to Node 127.0.0.1:7005:ok
Connecting to Node 127.0.0.1:7001:ok
Connecting to Node 127.0.0.1:7004:ok
>>> performing Cluster Check (using node 127.0.0.1:7000)
M:240ded0272e5d6827a9d99f83304a38ba656ddad 127.0.0.1:7000
slots:0-5460 (5461 slots) Master
1 additional replica (s)
S:feb6af7fbdd9a68712c8017b447222aac596a5ee 127.0.0.1:7003
Slots: (0 slots) Slave
Replicates 240ded0272e5d6827a9d99f83304a38ba656ddad
M:f1a4a0983c595dcab49e8b8258538929525632e8 127.0.0.1:7002
slots:10923-16383 (5461 slots) Master
1 additional replica (s)
s:cc16895d326c29bc159ddf6ca10dcfa04762d984 127.0.0.1:7005
Slots: (0 slots) Slave
Replicates F1a4a0983c595dcab49e8b8258538929525632e8
m:d8640ddab8d45f26d34082490cce6a567e612192 127.0.0.1:7001
slots:5461-10922 (5462 slots) Master
1 additional replica (s)
S:441F2FD0FB4B5FBE66929AF699A20E3E989449FB 127.0.0.1:7004
Slots: (0 slots) Slave
Replicates d8640ddab8d45f26d34082490cce6a567e612192
[OK] All nodes agree about slots configuration.
>>> Check for open Slots ...
>>> Check Slots Coverage ...
[OK] All 16384 slots covered.
16. Testing
Using the REDIS-CLI command to enter a clustered environment
/home/redis/redis-3.0.5/src/redis-cli-c-P 7000
In addition, when 7000 is killed, 7003 becomes the primary node;
Redis3.0.5 Installing cluster instance sharing