Redis Cluster Deployment Documentation (CENTOS6 system )
(To make the cluster work at least 3 primary nodes, here we will create 6 redis nodes, of which three are the primary node, three are slave nodes, the corresponding redis node IP and port correspondence is as follows)
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
1: Download redis. Download 3.0.0 version, previous 2. Several versions do not support cluster mode
: https://github.com/antirez/redis/archive/3.0.0-rc2.tar.gz
2: Upload server, unzip, compile
|
TAR-ZXVF redis-3.0.0-rc2.tar.gz
MV Redis-3.0.0-rc2.tar.gz redis3.0
cd/usr/local/redis3.0
Make
Make install |
3: Create the directory required by the cluster
|
Mkdir-p/usr.local/cluster
Cd/usr.local/cluster
mkdir 7000
mkdir 7001
mkdir 7002
mkdir 7003
mkdir 7004
mkdir 7005
|
4: Modify configuration file redis.conf
|
Cp/usr/local/redis3.0/redis.conf/usr.local/cluster
VI redis.conf
# #修改配置文件中的下面选项
Port 7000
Daemonize Yes
cluster-enabled Yes
Cluster-config-file nodes.conf
Cluster-node-timeout 5000
AppendOnly Yes
# #修改完These configuration entries in the redis.conf configuration file, copy the configuration file to the 7000/7001/7002/7003/7004/7005 directory , respectively.
cp/usr/local/cluster/redis.conf/usr/local/cluster/7000
cp/usr/local/cluster/redis.conf/usr/local/cluster/7001
cp/usr/local/cluster/redis.conf/usr/local/cluster/7002
cp/usr/local/cluster/redis.conf/usr/local/cluster/7003
cp/usr/local/cluster/redis.conf/usr/local/cluster/7004
cp/usr/local/cluster/redis.conf/usr/local/cluster/7005
# #注意: To modify the Port parameter in the redis.conf file under the 7001/7002/7003/7004/7005 directory after the copy is complete, change the name of the corresponding folder
|
5: Start each of these 6 Redis instances separately
|
cd/usr/local/cluster/7000
Redis-server redis.conf
cd/usr/local/cluster/7001
Redis-server redis.conf
cd/usr/local/cluster/7002
Redis-server redis.conf
cd/usr/local/cluster/7003
Redis-server redis.conf
cd/usr/local/cluster/7004
Redis-server redis.conf
cd/usr/local/cluster/7005
Redis-server redis.conf
# #启动之后使用命令查看redis boot situation ps-ef|grep Redis
If the display indicates a successful start
|
6: Execute redis create cluster command to create cluster
|
Cd/usr/local/redis3.0/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 |
6.1 error occurs when executing the above command, because it is the Ruby script that is executed and requires the environment of Ruby
Error content:/usr/bin/env:ruby:no such file or directory
So you need to install Ruby's environment, it is recommended to use yum install ruby installation
6.2 Then perform step 6 to create the cluster command, also error, hint missing rubygems component, use Yum to install
Error content:
./redis-trib.rb:24:in ' require ': No such file to load--rubygems (Loaderror)
From./redis-trib.rb:24
6.3 Execute Step 6 command again, also error, prompt cannot load Redis because of missing Redis and Ruby interface, using gem to install
Error content:
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in ' Gem_original_require ': No such file to load--Redis ( Loaderror)
From/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in ' require '
From./redis-trib.rb:25
6.4 Execute Step 6 command again, normal execution
Enter Yes, and the configuration is complete.
This is where the Redis cluster is built successfully!
7: Use the redis-cli command to enter the cluster environment
Redis cluster Installation Detailed steps