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 # #修改完redis These configuration entries in the. conf configuration file, copy the configuration file to the 7000/7001/7002/7003/7004/7005 directory below 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的启动情况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 the 6th step of the Create 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 Repeat the 6th step of the command, will also error, indicating that the Redis can not be loaded because of the lack of Redis and Ruby interface, using GEM installation
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
Gem Install Redis--version 3.0.0 |
Note: If the gem install Redis--version 3.0.0 fails, you need to modify the source of the gem
Gem Sources--remove https://rubygems.org/
Gem Sources-a https://ruby.taobao.org/
6.4 Execute the 6th step 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 under CentOS