CentOS Installation redis3.0.0 Cluster

Source: Internet
Author: User
Tags download redis redis cluster install redis

Here 6 Redis nodes are created, of which three are primary and three are slave nodes.

Redis and Port correspondence:

127.0.0.1:7000
127.0.0.1:7001

127.0.0.1:7002

From:

127.0.0.1:7003
127.0.0.1:7004
127.0.0.1:7005

Steps:
1, download Redis. Download 3.0.0 version, the previous version does not support cluster mode

: http://download.redis.io/releases/redis-3.0.0.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 for the cluster and copy the Redis
Mkdir-p/usr/local/cluster
Mkdir-p/usr/local/cluster/7000
Mkdir-p/usr/local/cluster/7001
Mkdir-p/usr/local/cluster/7002
Mkdir-p/usr/local/cluster/7003
Mkdir-p/usr/local/cluster/7004
Mkdir-p/usr/local/cluster/7005
cp-rf/usr/local/redis3.0/*/usr/local/cluster/7000/
cp-rf/usr/local/redis3.0/*/usr/local/cluster/7001/
cp-rf/usr/local/redis3.0/*/usr/local/cluster/7002/
cp-rf/usr/local/redis3.0/*/usr/local/cluster/7003/
cp-rf/usr/local/redis3.0/*/usr/local/cluster/7004/
cp-rf/usr/local/redis3.0/*/usr/local/cluster/7005/


4: Modify configuration file redis.conf

Vi/usr/local/cluster/7000/redis.conf

# #修改配置文件中的下面选项
Port 7000
Daemonize Yes
cluster-enabled Yes
Cluster-config-file nodes.conf
Cluster-node-timeout 5000
AppendOnly Yes


#同样再对其它配置文件进行修改
Vi/usr/local/cluster/7001/redis.conf
Vi/usr/local/cluster/7002/redis.conf
Vi/usr/local/cluster/7003/redis.conf
Vi/usr/local/cluster/7004/redis.conf
Vi/usr/local/cluster/7005/redis.conf
# #注意: Different directories Configure ports in different redis.conf


5: Start 6 Redis

Cd/usr/local/cluster/7000/src
Redis-server. /redis.conf
Cd/usr/local/cluster/7001/src
Redis-server. /redis.conf
Cd/usr/local/cluster/7002/src
Redis-server. /redis.conf
Cd/usr/local/cluster/7003/src
Redis-server. /redis.conf
Cd/usr/local/cluster/7004/src
Redis-server. /redis.conf
Cd/usr/local/cluster/7005/src
Redis-server. /redis.conf

# #启动之后使用命令查看redis的启动情况ps-ef|grep Redis


6. Create a Redis 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 Execution of the above command will be error, because is the execution of the script, need to
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


Yum Install Ruby


6.2 And then perform the next step of the Create Cluster command, will also error, indicating the missing RubyGems component
Error content:
./redis-trib.rb:24:in ' require ': No such file to load--rubygems (Loaderror)
From./redis-trib.rb:24
Yum Install RubyGems


6.3 Execute step of the command again, will also error, indicating that Redis cannot be loaded because the interface is missing Redis
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
This may not install because the GEM server cannot be connected:
[@zw_22_90 src]# gem install Redis--version 3.0.0
Error:could not find a valid gem ' redis ' (= 3.0.0) in any repository
Error:while Executing gem ... (Gem::remotefetcher::fetcherror)


Manual download and installation required:
wget Https://rubygems.global.ssl.fastly.net/gems/redis-3.2.1.gem
Gem Install-l./redis-3.2.1.gem


6.4 Execute Step command again, normal execution
Enter Yes, and the configuration is complete.
[@zw_22_90 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:7,004 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:2022f24d581b4a7c3342e3245c32927cbd5ec16d 127.0.0.1:7000
slots:0-5460 (5461 slots) Master
M:37B7008F80F8C21A698DA8CB1F1B32DB8C0C415C 127.0.0.1:7001
slots:5461-10922 (5462 slots) Master
M:AC6DC5FA96E856B34C1BA4C3814394E4EBB698DD 127.0.0.1:7002
slots:10923-16383 (5461 slots) Master
s:b5b76d70bbb0dbf3e7df8a38f1259e95e2054721 127.0.0.1:7003
Replicates 2022f24d581b4a7c3342e3245c32927cbd5ec16d
S:6881F8FEF9C25DA486F320EBF2EAD39C1502DB4C 127.0.0.1:7004
Replicates 37b7008f80f8c21a698da8cb1f1b32db8c0c415c
S:f090526d32cced97731eef2a2e1722a7bac7d9ea 127.0.0.1:7005
Replicates AC6DC5FA96E856B34C1BA4C3814394E4EBB698DD
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:2022f24d581b4a7c3342e3245c32927cbd5ec16d 127.0.0.1:7000
slots:0-5460 (5461 slots) Master
M:37B7008F80F8C21A698DA8CB1F1B32DB8C0C415C 127.0.0.1:7001
slots:5461-10922 (5462 slots) Master
M:AC6DC5FA96E856B34C1BA4C3814394E4EBB698DD 127.0.0.1:7002
slots:10923-16383 (5461 slots) Master
m:b5b76d70bbb0dbf3e7df8a38f1259e95e2054721 127.0.0.1:7003
Slots: (0 slots) Master
Replicates 2022f24d581b4a7c3342e3245c32927cbd5ec16d
M:6881F8FEF9C25DA486F320EBF2EAD39C1502DB4C 127.0.0.1:7004
Slots: (0 slots) Master
Replicates 37b7008f80f8c21a698da8cb1f1b32db8c0c415c
M:f090526d32cced97731eef2a2e1722a7bac7d9ea 127.0.0.1:7005
Slots: (0 slots) Master
Replicates AC6DC5FA96E856B34C1BA4C3814394E4EBB698DD
[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!


7,REDIS-CLI command into the cluster environment
[@zw_22_90 src]# redis-cli-c-P 7000

127.0.0.1:7000> quit;



Reference: http://blog.csdn.net/xu470438000/article/details/42971091, and the details were modified and partially supplemented.

CentOS Installation redis3.0.0 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.