(for the cluster to work, you need at least3a master node, where we're going to create6aRedisnode, where three primary nodes, three are slave nodes, correspondingRedisnode'sIpand port correspondence are as follows)192.168.1.160:7000
192.168.1.160:7001192.168.1.160:7002192.168.1.160:7003192.168.1.160:7004192.168.1.160:70051 : Download redis . Official website Download 3.0.0 version, before 2.Several versions do not support cluster mode: http://download.redis.io/releases/redis-3.0.0.tar.gz2: Upload server, unzip, compile
TAR-ZXVF redis-3.0.0.tar.gz mv redis-3.0.0.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 # #Modify the following options in the configuration filePort 7000 daemonize Yes cluster-enabled Yes cluster-config-file nodes.conf cluster-node-timeout all appendonly Yes ##finished modifyingRedis.confThese configuration items in the configuration file are copied to the7000/7001/7002/7003/7004/7005directory belowcp/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 # #Note: To modify after the copy is complete7001/7002/7003/7004/7005directory belowredis.confin the filePortparameter, change to the name of the corresponding folder, respectively |
5 : Start these 6 separately a redisExample
cd/usr/local/cluster/7000 redis-server redis.conf cd/usr/local/cluster/7001 redis-server redis.conf cd/usr/local/cl uster/7002 redis-server redis.conf cd/usr/local/cluster/7003 redis-server redis.conf cd/usr/local/cluster/7004 Redi S-server redis.conf cd/usr/local/cluster/7005 redis-server redis.conf # # start using commands to view redis boot conditions PS- Ef|grep Redis as shown indicates successful start |
6 : Performing RedisCreate a cluster command to create a cluster
Cd/usr/local/redis3.0/src./REDIS-TRIB.RB Create--replicas 1 192.168.1.160:7000 192.168.1.160:7001 192.168.1.160:700 2 192.168.1.160:7003 192.168.1.160:7004 192.168.1.160:7005 |
6.1you may get an error when executing the above command, because it is executed.Rubythe script that requiresRubythe EnvironmentError Content:/usr/bin/env:ruby:no such file or directoryso you need to installRubyenvironment, it is recommended to useYum Install Rubyinstallation
6.2and then perform the first6To create a cluster command, you may also get an error, indicating the missingRubyGemscomponents, usingYuminstallationError Content:./redis-trib.rb:24:in ' require ': no suchfile to load--RubyGems (Loaderror) from./redis-trib.rb:24
6.3re-implementation of section6Step command, may also error, prompting cannot loadRedis, because of the lack ofRedisand theRubythe interface, usingGeminstallationError 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.4re-implementation of section6step of the command, normal executioninputYes, and then the configuration is complete. so farRedisThe cluster is built successfully! 7: UsingRedis-clicommand into the cluster environment
Redis-cli-c-P 7000
For more highlights, please pay attention to: http://bbs.superwu.cn attention to Superman academy QR Code: |
Redis3.0 cluster Deployment (CentOS system)