Introduction to the steps of Redis cluster cluster configuration

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

Redis cluster use
Redis Cluster scheme
1, client fragmentation. such as: take surplus and so on
2, Agent (proxy) fragmentation. By proxy absolute data access, such as: Twemproxy.
3,redis cluster. No Center mode,
4, Codis (Solution for pea pod development)
Redis Cluster reference Documentation: http://redisdoc.com/topic/cluster-tutorial.html
Usually, the Redis cluster needs at least 6 units, three main three from

[Root@yum-down opt]# mkdir ' seq 7001 7008 '
[Root@yum-down opt]# ls
7001 7002 7003 7004 7005 7006 7007 7008 RH
[Root@yum-down opt]# sed ' s/6379/7001/' 6379.conf >> 7001/redis.conf
[Root@yum-down opt]# sed ' s/6379/7002/' 6379.conf >> 7002/redis.conf
[Root@yum-down opt]# sed ' s/6379/7003/' 6379.conf >> 7003/redis.conf
[Root@yum-down opt]# sed ' s/6379/7004/' 6379.conf >> 7004/redis.conf
[Root@yum-down opt]# sed ' s/6379/7005/' 6379.conf >> 7005/redis.conf
[Root@yum-down opt]# sed ' s/6379/7006/' 6379.conf >> 7006/redis.conf
[Root@yum-down opt]# sed ' s/6379/7007/' 6379.conf >> 7007/redis.conf
[Root@yum-down opt]# sed ' s/6379/7008/' 6379.conf >> 7008/redis.conf
[Root@yum-down 7008]# for i in ' seq 7001 7008 ';d o cd/opt/$i &&/usr/local/redis/bin/redis-server redis.conf;done
[Root@yum-down 7008]# netstat-lntp|grep:700*
TCP 0 0 0.0.0.0:7001 0.0.0.0:* LISTEN 2701/redis-server *
TCP 0 0 0.0.0.0:7002 0.0.0.0:* LISTEN 2740/redis-server *
TCP 0 0 0.0.0.0:7003 0.0.0.0:* LISTEN 2742/redis-server *
TCP 0 0 0.0.0.0:7004 0.0.0.0:* LISTEN 2746/redis-server *
TCP 0 0 0.0.0.0:7005 0.0.0.0:* LISTEN 2750/redis-server *
TCP 0 0 0.0.0.0:7006 0.0.0.0:* LISTEN 2754/redis-server *
TCP 0 0 0.0.0.0:7007 0.0.0.0:* LISTEN 2760/redis-server *
TCP 0 0 0.0.0.0:7008 0.0.0.0:* LISTEN 2762/redis-server *
TCP 0 0::: 7001:::* LISTEN 2701/redis-server *
TCP 0 0::: 7002:::* LISTEN 2740/redis-server *
TCP 0 0::: 7003:::* LISTEN 2742/redis-server *
TCP 0 0::: 7004:::* LISTEN 2746/redis-server *
TCP 0 0::: 7005:::* LISTEN 2750/redis-server *
TCP 0 0::: 7006:::* LISTEN 2754/redis-server *
TCP 0 0::: 7007:::* LISTEN 2760/redis-server *
TCP 0 0::: 7008:::* LISTEN 2762/redis-server *
[Root@yum-down 7008]#
Installing Ruby Tools

[Root@yum-down ~]# yum install ruby RubyGems
[Root@yum-down ~]# gem install Redis
Successfully installed redis-3.2.2
1 Gem installed
Installing RI documentation for redis-3.2.2 ...
Installing RDOC documentation for redis-3.2.2 ...
[Root@yum-down ~]#
Copy a Redis-trib script from the source installation directory

[Root@yum-down src]# Cp/usr/local/redis-3.0.7/src/redis-trib.rb/usr/local/bin/redis-trib
Cluster creation: Master-From, the front is the main behind is from

[Root@yum-down src]# Redis-trib Create--replicas 1 10.10.0.250:7001 10.10.0.250:7002 10.10.0.250:7003 10.10.0.250:7004 10.10.0.250:7005 10.10.0.250:7006
Create Master:

>>> Creating cluster
>>> performing hash slots allocation on 6 nodes ...
Using 3 Masters:
10.10.0.250:7001
10.10.0.250:7002
10.10.0.250:7003
Are you sure?

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 10.10.0.250:7001)
M:efff09f4a9fe116bfda3c4d99076b535d8262dde 10.10.0.250:7001 Distribution 0-5460
slots:0-5460 (5461 slots) Master
M:e8bb5fcbccec005aa4c3fc4d1561b54531c586e9 10.10.0.250:7002 5461-10922
slots:5461-10922 (5462 slots) Master
m:f70394b2c10d5beab0c9b91f99be9a714cdd948f 10.10.0.250:7003
slots:10923-16383 (5461 slots) Master
M:5CA874E2E71914CF85CA85063DAA56BCEC4EFDA4 10.10.0.250:7004
Slots: (0 slots) Master
Replicates Efff09f4a9fe116bfda3c4d99076b535d8262dde
m:f67f8a20942831cd0454a3d54d57fb1fe75d0904 10.10.0.250:7005
Slots: (0 slots) Master
Replicates e8bb5fcbccec005aa4c3fc4d1561b54531c586e9
M:0D8C3EF48A4AE8A493699551AB629775180219C0 10.10.0.250:7006
Slots: (0 slots) Master
Replicates f70394b2c10d5beab0c9b91f99be9a714cdd948f
[OK] All nodes agree about slots configuration.
>>> Check for open Slots ...
>>> Check Slots Coverage ...
[OK] All 16384 slots covered. Total number of Allocations
Redis cluster creation. png
View:
7001 from 7004.

[Root@yum-down ~]# redis-cli-c-H 10.10.0.250-p 7001
10.10.0.250:7001> Info
# Replication
Role:master
Connected_slaves:1
Slave0:ip=10.10.0.250,port=7004,state=online,offset=743,lag=1
master_repl_offset:743
Repl_backlog_active:1
repl_backlog_size:1048576
Repl_backlog_first_byte_offset:2
repl_backlog_histlen:742

10.10.0.250:7001>
After the set one is transferred to the other Redis (according to the algorithm redirected)

10.10.0.250:7001> Set Key1 Test
-> redirected to slot [9189] located at 10.10.0.250:7002
Ok
10.10.0.250:7002>
View Status:

10.10.0.250:7002> cluster Nodes
5CA874E2E71914CF85CA85063DAA56BCEC4EFDA4 10.10.0.250:7004 Slave Efff09f4a9fe116bfda3c4d99076b535d8262dde 0 1456659010020 4 Connected
f67f8a20942831cd0454a3d54d57fb1fe75d0904 10.10.0.250:7005 Slave e8bb5fcbccec005aa4c3fc4d1561b54531c586e9 0 1456659011029 5 Connected
f70394b2c10d5beab0c9b91f99be9a714cdd948f 10.10.0.250:7003 master-0 1456659011030 3 connected 10923-16383
0d8c3ef48a4ae8a493699551ab629775180219c0 10.10.0.250:7006 Slave f70394b2c10d5beab0c9b91f99be9a714cdd948f 0 1456659009515 6 Connected
Efff09f4a9fe116bfda3c4d99076b535d8262dde 10.10.0.250:7001 master-0 1456659010526 1 Connected 0-5460
E8bb5fcbccec005aa4c3fc4d1561b54531c586e9 10.10.0.250:7002 myself,master-0 0 2 connected 5461-10922
10.10.0.250:7002> Cluster Info
Cluster_state:ok
cluster_slots_assigned:16384
cluster_slots_ok:16384
cluster_slots_pfail:0
cluster_slots_fail:0
Cluster_known_nodes:6
Cluster_size:3
Cluster_current_epoch:6
Cluster_my_epoch:2
cluster_stats_messages_sent:3238
cluster_stats_messages_received:3238
10.10.0.250:7002>
Add new node: 10.10.0.250:7007,7004 as from node, new node mainly

[Root@yum-down ~]# redis-trib add-node 10.10.0.250:7007 10.10.0.250:7004
View

10.10.0.250:7002> cluster nodes
5ca874e2e71914cf85ca85063daa56bcec4efda4 10.10.0.250:7004 Slave Efff09f4a9fe116bfda3c4d99076b535d8262dde 0 1456659211846 4 connected
f67f8a20942831cd0454a3d54d57fb1fe75d0904 10.10.0.250:7005 slave e8bb5fcbccec005aa4c3fc4d1561b54531c586e9 0 1456659210839 5 Connected
29610d96ef7c5d001e22c1bea370ba6f39f62068 10.10.0.250:7007 master-0 1456659210131 0 Connected
f70394b2c10d5beab0c9b91f99be9a714cdd948f 10.10.0.250:7003 master-0 1456659210838 3 connected 10923-16383
0d8c3ef48a4ae8a493699551ab629775180219c0 10.10.0.250:7006 Slave f70394b2c10d5beab0c9b91f99be9a714cdd948f 0 1456659211846 6 connected
Efff09f4a9fe116bfda3c4d99076b535d8262dde 10.10.0.250:7001 master-0 1456659210333 1 Connected 0-5460
E8bb5fcbccec005aa4c3fc4d1561b54531c586e9 10.10.0.250:7002 myself,master-0 0 2 connected 5461-10922
After adding 7007, re-fragmentation

[Root@yum-down ~]# redis-trib Reshard 10.10.0.250:7007
How many slots does you want to move (from 1 to 16384)? 1000 slot position of allocating size
What is the receiving node ID? 29610d96ef7c5d001e22c1bea370ba6f39f62068, 7007ID
Source node #1: All can
Do your want to proceed with the proposed Reshard plan (yes/no)? Yes
In adding 7008 as 7007 from the node:
First add 7008

[Root@yum-down ~]# redis-trib add-node 10.10.0.250:7008 10.10.0.250:7004
Then connect to add a 7007 cluster replicate ID in 7008

[Root@yum-down ~]# redis-cli-c-H 10.10.0.250-p 7008
10.10.0.250:7008> Cluster Replicate 29610d96ef7c5d001e22c1bea370ba6f39f62068
Ok
10.10.0.250:7008>
In view:

0.10.0.250:7008> cluster Nodes
29610d96ef7c5d001e22c1bea370ba6f39f62068 10.10.0.250:7007 master-0 1456659930448 7 connected 0-665 5461-6128 10923-11588
613063078b7b128c269996369fc2838736520a2c 10.10.0.250:7008 Myself,slave 29610d96ef7c5d001e22c1bea370ba6f39f62068 0 0 0 connected
10.10.0.250:7008>
Online Add from the time you need master Bgsava

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.