Installing a Redis cluster

Source: Internet
Author: User
Tags redis cluster install redis

installing a redis cluster

First step: Install dependent packages

1): Install Redis-cluster dependency: Redis-cluster dependent Library when using a compatibility problem, in Reshard encountered a variety of errors, please install according to the specified version.

(1) Ensure that the system is installed zlib, otherwise Geminstall will report (no such file to load-zlib) #download: Zlib-1.2.6.tar./configure making Make Inst All or yum install Zlib


(1) Install Ruby

Cd/path/ruby./configure-prefix=/usr/local/ruby make do install sudo cp ruby/usr/local/bin or yum install Rub Y

(2) installation

Rubygem:version (1.8.16)
#rubygems -1.8.16.tgz cd/path/gem sudo ruby setup.rb sudo cp bin/gem/usr/local/bin or yum install Rubygem

(3) Installing gem-redis:version (3.0.0)

Geminstall Redis--version 3.0.0 #由于源的原因, may download failed, download it manually down install #download地址: http://rubygems.org/gems/redis/versions/3.0. 0 Geminstall-l/data/soft/redis-3.0.0.gem

Step Two: Install redis-3.2.0

Tar XF redis-3.2.0.tar.gzcd redis-3.2.0makemake install CD SRC/CP redis-server/usr/local/bin CP redis-cli/usr/local/bi NCP Redis-trib.rb/usr/local/bin

Create the directory required by the cluster

[[email protected]/]mkdir-p/redis/{6000..6005}[[email protected]/] #cd/redis/[[email protected] redis]# lltotal 28DRW Xr-xr-x. 2 root root 4096 May 9 03:39 6000drwxr-xr-x. 2 root root 4096 May 9 03:54 6001drwxr-xr-x. 2 root root 4096 May 9 03:39 6002drwxr-xr-x. 2 root root 4096 May 9 03:39 6003drwxr-xr-x. 2 root root 4096 May 9 03:51 6004drwxr-xr-x. 2 root root 4096 May 9 03:39 6005[[email protected] redis]#

Modifying a configuration file redis.conf

Cp/home/lvnian/tools/redis-3.2.0/redis.conf/redisvi/redis/redis.conf

# #修改配置文件中的下面选项

Port 6000daemonize yescluster-enabled yescluster-config-file nodes.confcluster-node-timeout 5000appendonly Yes

# #修改完redis These configuration entries in the. conf configuration file, copy the configuration file to the 6000/6001/6002/6003/6004/6005 directory, respectively.

Cp/redis/redis.conf/redis/6000/cp/redis/redis.conf/redis/6001/cp/redis/redis.conf/redis/6002/cp/redis/redis.c onf/redis/6003/cp/redis/redis.conf/redis/6004/cp/redis/redis.conf/redis/6005/

# #注意: To modify the port parameter in the redis.conf file under the 6000/6001/6002/6003/6004/6005 directory after the copy is complete, change the name of the corresponding folder

Start each instance of Redis

cd /redis/6000redis-server redis.conf & cd /redis/6001redis-server  redis.conf & cd /redis/6002redis-server redis.conf  & cd / Redis/6003redis-server redis.conf  & cd /redis/6004redis-server redis.conf   &cd /redis/6005redis-server redis.conf  &[[email protected]  redis]# netstat -lntp|grep redistcp        0       0 127.0.0.1:6000               0.0.0.0:*                    listen      11046/redis-server   tcp        0      0  127.0.0.1:6001              0.0.0.0:*                    LISTEN       11041/redis-server  tcp        0       0 127.0.0.1:6002               0.0.0.0:*                    listen      11049/redis-server  tcp         0      0 127.0.0.1:6003               0.0.0.0:*                    listen       11052/redis-server  tcp        0       0 127.0.0.1:6004               0.0.0.0:*                    LISTEN      11055/redis-server  tcp         0      0 127.0.0.1:6005               0.0.0.0:*                    LISTEN       11058/redis-server  tcp         0      0 127.0.0.1:16000              0.0.0.0:*                    LISTEN      11046/redis-server  tcp         0      0 127.0.0.1:16001              0.0.0.0:*                    LISTEN       11041/redis-server  tcp        0       0 127.0.0.1:16002              0.0.0.0:*                    listen      11049/redis-server  tcp         0      0 127.0.0.1:16003              0.0.0.0:*                    listen      11052/redis-server   tcp        0      0  127.0.0.1:16004             0.0.0.0:*                     listen      11055/redis-server  tcp         0      0 127.0.0.1:16005              0.0.0.0:*               &nbsP;    listen      11058/redis-server  [[email  protected] redis]#

1 Create cluster command to perform Redis create cluster

CD/HOME/LVNIAN/TOOLS/REDIS-3.2.0/SRC./REDIS-TRIB.RB Create--replicas 1 127.0.0.1:6000 127.0.0.1:6001 127.0.0.1:6002 127.0.0.1:6003 127.0.0.1:6004 127.0.0.1:6005

2 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

Yum Install Ruby

3 then perform step 1 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:24yum Install RubyGems

4 Repeat step 1 command, also error, indicating that Rediscannot be loadedbecause of the lack of 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:25gem Install Redis

5. Repeat Step 1 of the order, normal execution

[[email protected] src]# ./redis-trib.rb create --replicas1 127.0.0.1:6000   127.0.0.1:6001  127.0.0.1:6002 127.0.0.1:6003127.0.0.1:6004  127.0.0.1:6005> >> creating cluster>>> performing hash slots allocation on  6nodes ... using 3 masters:127.0.0.1:6000127.0.0.1:6001127.0.0.1:6002adding replica 127.0.0.1:6003  to 127.0.0.1:6000Adding replica 127.0.0.1:6004 to 127.0.0.1:6001Adding  replica 127.0.0.1:6005 to 127.0.0.1:6002m:  d968e771065b571e832b32b793ae235269ae7c6c127.0.0.1:6000  slots:0-5460  (5461 slots)   masterm: 7d8a4d617f2ada37f0efbdc1ce23accd9930a853127.0.0.1:6001  slots:5461-10922  (5462  slots)  masterm: 75a450d2d95eb5849aa33f50b1c6c6fac701aebf127.0.0.1:6002  slots :10923-16383  (5461 slots)  MASTERS: 2EC788DD51b6fee6fae76b1fa7c009bcfd1bafff127.0.0.1:6003    replicatesd968e771065b571e832b32b793ae235269ae7c6cs: cc2ce728ad7a8dee323dcd6ec5c0f21927bef71a127.0.0.1 :6004   replicates7d8a4d617f2ada37f0efbdc1ce23accd9930a853s:  6668aae6f3ce06cf4269977f82163876630abec8127.0.0.1:6005    Replicates75a450d2d95eb5849aa33f50b1c6c6fac701aebfcan i set the above configuration?   (type  ' yes '  toaccept): yes>>> nodes configuration updated>> > assign a different config epoch toeach node11046:m 09 may  03:39:21.630 # configepoch set to 1via cluster set-config-epoch11041: m 09 may 03:39:21.630 # configepoch set to 2via cluster  Set-config-epoch11049:m 09 may 03:39:21.631 # configepoch set to 3via  cluster set-config-epoch11052:m 09 may 03:39:21.631 # configepoch set to 4via  cluster set-config-epoch11055:m 09 may 03:39:21.631 # configepoch set  to 5via cluster set-config-epoch11058:m 09 may 03:39:21.632 #  configepoch set to 6via cluster set-config-epoch>>> sending  cluster meet messages to jointhe cluster11046:m 09 may 03:39:21.660  # IP address for thisnode updated to 127.0.0.111049:M 09  may 03:39:21.736 # ip address for thisnode updated to  127.0.0.111055:m 09 may 03:39:21.736 # ip address for thisnode  Updated to 127.0.0.111041:m 09 may 03:39:21.736 # ip address for  thisnode updated to 127.0.0.111058:m 09 may 03:39:21.736 # ip address for thisnode  Updated to 127.0.0.111052:m 09 may 03:39:21.736 # ip address for  thisnode updated to 127.0.0.1waiting for the cluster to join ... 11052:s 09 may 03:39:25.655 # cluster statechanged: ok11055:s 09  may 03:39:25.656 # cluster statechanged: ok11058:s 09 may 03:39:25.657  # Cluster statechanged: ok>>> Performing Cluster Check  ( using node127.0.0.1:6000) m: d968e771065b571e832b32b793ae235269ae7c6c127.0.0.1:6000  slots :0-5460  (5461 slots)  masterM: 7d8a4d617f2ada37f0efbdc1ce23accd9930a853127.0.0.1:6001   slots:5461-10922  (5462 slots)  masterM:  75a450d2d95eb5849aa33f50b1c6c6fac701aebf127.0.0.1:6002  slots:10923-16383  (5461 slots)  masterm: 2ec788dd51b6fee6fae76b1fa7c009bcfd1bafff127.0.0.1 :6003   slots:  (0slots)  master    replicatesd968e771065b571e832b32b793ae235269ae7c6cm: cc2ce728ad7a8dee323dcd6ec5c0f21927bef71a127.0.0.1 :6004   slots:  (0slots)  master    replicates7d8a4d617f2ada37f0efbdc1ce23accd9930a853m: 6668aae6f3ce06cf4269977f82163876630abec8127.0.0.1 :6005   slots:  (0slots)  master    Replicates75a450d2d95eb5849aa33f50b1c6c6fac701aebf[ok] all nodes agree about slots  configuration.>>> check for open slots...>>> check slots  coverage ... [Ok] all 16384 slots covered.

This is where the Redis cluster is built successfully!

Use redis-cli command into the cluster environment

[Email protected] redis-3.2.0]# redis-cli-c-P 6000127.0.0.1:6000>


This article is from the "Struggle Bar" blog, please be sure to keep this source http://lvnian.blog.51cto.com/7155281/1771438

Installing a Redis cluster

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.