Redis Cluster Deployment documentation (UBUNTU15.10 System)

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

Redis Cluster Deployment documentation (UBUNTU15.10 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
: http://download.redis.io/releases/redis-3.0.7.tar.gz
2: Upload server, unzip, compile

tar -zxvf redis-3.0. 7. Tar . GZ MV redis-3.0. 7 /usr/local/redis3. 0  /usr/local/redis3. 0  Make

After that, the Redis-server redis-client and other files are generated in SRC.


3: Create the directory required by the cluster

mkdir -p/usr/local//usr/local/clustermkdir7000mkdir  7001mkdir7002mkdir7003mkdir7004mkdir  7005

4: Modify configuration file redis.conf
Cp/usr/local/redis3.0/redis.conf/usr/local/cluster
VI redis.conf
# #修改配置文件中的下面选项

Pidfile/var/run/redis. 7000  7000  #个性化daemonize yescluster-enabled Yescluster-config-file nodes. 7000 . conf #个性化cluster  the  "appendonly.7000.aof" #个性化

# #修改完redis These configuration entries in the. 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/7000CP /usr/local/cluster/ redis.conf/usr/local/cluster/7001cp /usr/local/cluster/redis.conf/usr/local/cluster/7002  cp /usr/local/cluster/redis.conf/usr/local/cluster/7003CP /usr/local/cluster/ redis.conf/usr/local/cluster/7004cp /usr/local/cluster/redis.conf/usr/local/cluster/  7005

# #注意: After the copy is complete, change the label personalization parameters in the redis.conf file under the 7001/7002/7003/7004/7005 directory to the name of the corresponding folder.


5: Launch each of these 6 Redis instances
vi/usr/local/cluster/redis-start.sh
To add the following

 #!/bin/sh /usr/local/redis3. 0 /src/redis-server/usr/local/cluster/7000 /redis.conf &/usr/local/redis3. 0 /src/redis-server/usr/local/cluster/7001 /redis.conf &/usr/local/redis3. 0 /src/redis-server/usr/local/cluster/7002 /redis.conf &/usr/local/redis3. 0 /src/redis-server/usr/local/cluster/7003 /redis.conf &/usr/local/redis3. 0 /src/redis-server/usr/local/cluster/7004 /redis.conf &/usr/local/redis3. 0 /src/redis-server/usr/local/cluster/7005 /redis.conf & 

And then

chmod +x/usr/local/cluster/redis-start/usr/local/cluster/redis-start

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


6: Execute redis Create cluster command to create cluster
Install Ruby because./REDIS-TRIB.RB is a ruby-executed script that requires a ruby environment
sudo apt-get install Ruby

In order to perform redis-trib.rb need to install gem Redis sudo gem install Redis There may be problems with the Great Firewall
You can go to https://rubygems.org/gems/redis/versions/3.2.2 to download the latest version.
Then use the command sudo gem install Redis-3.2.2.gem

 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  

The following output indicates success.

>>>Creating Cluster>>> performing hash slots allocation on6nodes ... Using3Masters:127.0.0.1:7000127.0.0.1:7001127.0.0.1:7002Adding Replica127.0.0.1:7003To127.0.0.1:7000Adding Replica127.0.0.1:7004To127.0.0.1:7001Adding Replica127.0.0.1:7005To127.0.0.1:7002m:1cdc6971ddbcf64427a9499e19b048afa55aff08127.0.0.1:7000Slots:0-5460(5461slots) masterm:a355b2ccb1fdf413652a14cec722076af958a079127.0.0.1:7001Slots:5461-10922(5462slots) Masterm:0bc286b514d36e7195142ff0d55a87542048b5a9127.0.0.1:7002Slots:10923-16383(5461slots) Masters:a3b7c85fe957917bd383b181de3f1a3f31df8a05127.0.0.1:7003replicates 1cdc6971ddbcf64427a9499e19b048afa55aff08s:9f0f4045497a72b64783fd9c2387f38b7e3bda6c127.0.0.1:7004replicates a355b2ccb1fdf413652a14cec722076af958a079s:f4b371c4e1d0fddfbe1552e540ddd36a5a00200b127.0.0.1:7005replicates 0bc286b514d36e7195142ff0d55a87542048b5a9can 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 toJoinThe clusterwaiting forThe cluster toJoin...>>> performing Cluster Check (using node127.0.0.1:7000) m:1cdc6971ddbcf64427a9499e19b048afa55aff08127.0.0.1:7000Slots:0-5460(5461slots) masterm:a355b2ccb1fdf413652a14cec722076af958a079127.0.0.1:7001Slots:5461-10922(5462slots) Masterm:0bc286b514d36e7195142ff0d55a87542048b5a9127.0.0.1:7002Slots:10923-16383(5461slots) Masterm:a3b7c85fe957917bd383b181de3f1a3f31df8a05127.0.0.1:7003Slots: (0slots) Master replicates 1cdc6971ddbcf64427a9499e19b048afa55aff08m:9f0f4045497a72b64783fd9c2387f38b7e3bda6c 127.0.0.1:7004Slots: (0slots) Master replicates a355b2ccb1fdf413652a14cec722076af958a079m:f4b371c4e1d0fddfbe1552e540ddd36a5a00200b 127.0.0.1:7005Slots: (0slots) Master replicates 0bc286b514d36e7195142ff0d55a87542048b5a9[ok] All nodes agree about slots configuration.>>> Check forOpen Slots ...>>>Check Slots Coverage ... [OK] All16384Slots covered.

So the Redis-cluster cluster will start


7. View the current status of the cluster:

$ redis-cli-c-P7000127.0.0.1:7000> ClusterInfocluster_state:okcluster_slots_assigned:16384CLUSTER_SLOTS_OK:16384Cluster_slots_pfail:0Cluster_slots_fail:0Cluster_known_nodes:6cluster_size:3Cluster_current_epoch:0cluster_stats_messages_sent:8770cluster_stats_messages_received:8770


8, test value: After each operation may jump to another inside. That's the redirected to slot ...

127.0.0.1:7002>set Foo Barok127.0.0.1:7000>Set Hello Worldok127.0.0.1:7000>get foo-Redirected to slot [12182] located at127.0.0.1:7002"Bar"127.0.0.1:7002>Get Hello-Redirected to slot [866] located at127.0.0.1:7000" World"127.0.0.1:7000>Get name-Redirected to slot [5798] located at127.0.0.1:7001(nil)127.0.0.1:7001>127.0.0.1:7002>Get name-Redirected to slot [5798] located at127.0.0.1:7001(nil)127.0.0.1:7001>

Redis Cluster Deployment documentation (UBUNTU15.10 System)

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.