Redis cluster configuration

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

Client-side Shard Terminal implementation

Agent Proxy, Access proxy,proxy Specify the Redis save location. Twemproxy

Redis cluster, which can result in some loss of data, no centralized
1. Ability to automatically slice (split) data to multiple nodes
2. The ability to continue processing command requests is still possible when a subset of nodes in the cluster fail or cannot communicate.

Codis Redis cluster solution. Pea pod Open source


Redis Cluster cluster configuration

cd/data/
mkdir ' seq 7001 7008 '

Redis.conf added, port needs to change
‘‘‘
Port 7000
cluster-enabled Yes
Cluster-config-file nodes.conf
Cluster-node-timeout 5000
AppendOnly Yes

‘‘‘
Install Ruby
Yum-y Install ruby RubyGems

Redis management tools for Ruby installation

Gem Install Redis

1 Gem installed
Installing RI documentation for redis-3.3.0 ...
Installing RDOC documentation for redis-3.3.0 ...

Create a cluster
REDIS-TRIB.RB Create--replicas 1 172.16.230.167:7001 172.16.230.167:7002 172.16.230.167:7003 172.16.230.167:7004 172.16.230.167:7005 172.16.230.167:7006

Client connections:

Redis-cli-c-H 172.16.230.167-p 7001
Set name 111
Set NAME1 222
will be written to the non-pass hash slot

Cluster nodes

Cluster info

Add cluster node: The Add-node in the command means that we want Redis-trib to add a node to the cluster, Add-node followed by the IP address and port number of the new node, followed by the IP address and port number of any existing node in the cluster

[Email protected] data]# redis-trib.rb add-node 172.16.230.167:7007 172.16.230.167:7001


>>> Adding node 172.16.230.167:7007 to cluster 172.16.230.167:7001
>>> performing Cluster Check (using node 172.16.230.167:7001)
m:f2a684e0900e7b7eb91bdb77e3b559f47d0f7237 172.16.230.167:7001
slots:0-5460 (5461 slots) Master
1 additional replica (s)
s:37b6f6478ca6425022521d6a5ecf0aeedf12c601 172.16.230.167:7005
Slots: (0 slots) Slave
Replicates 84995c68e3625c91f4c646d71566dffd709e6d01
s:d6d307c91e6ba6fbba7d898f20fd4772a3e42b9c 172.16.230.167:7004
Slots: (0 slots) Slave
Replicates f2a684e0900e7b7eb91bdb77e3b559f47d0f7237
S:458A01EEACE9FD93544645433AD5B12587D94D3B 172.16.230.167:7006
Slots: (0 slots) Slave
Replicates FFE722398240B59F0C993074D35DBE79386C1EC3
M:FFE722398240B59F0C993074D35DBE79386C1EC3 172.16.230.167:7003
slots:10923-16383 (5461 slots) Master
1 additional replica (s)
M:84995C68E3625C91F4C646D71566DFFD709E6D01 172.16.230.167:7002
slots:5461-10922 (5462 slots) Master
1 additional replica (s)
[OK] All nodes agree about slots configuration.
>>> Check for open Slots ...
>>> Check Slots Coverage ...
[OK] All 16384 slots covered.
>>> Send CLUSTER MEET to node 172.16.230.167:7007 to make it join the CLUSTER.
[OK] New node added correctly.

Querying new Nodes
172.16.230.167:7001> cluster Nodes

37b6f6478ca6425022521d6a5ecf0aeedf12c601 172.16.230.167:7005 Slave 84995c68e3625c91f4c646d71566dffd709e6d01 0 1467381076060 5 Connected
d6d307c91e6ba6fbba7d898f20fd4772a3e42b9c 172.16.230.167:7004 Slave f2a684e0900e7b7eb91bdb77e3b559f47d0f7237 0 1467381077061 4 Connected
458a01eeace9fd93544645433ad5b12587d94d3b 172.16.230.167:7006 Slave ffe722398240b59f0c993074d35dbe79386c1ec3 0 1467381073056 6 Connected
FFE722398240B59F0C993074D35DBE79386C1EC3 172.16.230.167:7003 master-0 1467381074057 3 connected 10923-16383

83e5dd37a0825a4adb77d6da4738bf0c88cd6c39 172.16.230.167:7007 master-0 1467381075059 0 connected

84995C68E3625C91F4C646D71566DFFD709E6D01 172.16.230.167:7002 master-0 1467381073556 2 connected 5461-10922
f2a684e0900e7b7eb91bdb77e3b559f47d0f7237 172.16.230.167:7001 myself,master-0 0 1 connected 0-5460


Transform a new node into a node-based method and add 7008 to the cluster
[Email protected] data]# redis-trib.rb add-node 172.16.230.167:7008 172.16.230.167:7001

Enter into the terminal of the newly added cluster
[[email protected] data]# redis-cli-c-H 172.16.230.167-p 7008

172.16.230.167:7008> CLUSTER nodes
84995c68e3625c91f4c646d71566dffd709e6d01 172.16.230.167:7002 master-0 1467381351640 2 connected 5461-10922
37b6f6478ca6425022521d6a5ecf0aeedf12c601 172.16.230.167:7005 Slave 84995C68E3625C91F4C646D71566DFFD709E6D01 0 1467381350638 2 connected
f2a684e0900e7b7eb91bdb77e3b559f47d0f7237 172.16.230.167:7001 master-0 1467381352142 1 connected 0-5460
83e5dd37a0825a4adb77d6da4738bf0c88cd6c39 172.16.230.167:7007 master-0 1467381352641 0 connected
458a01eeace9fd93544645433ad5b12587d94d3b 172.16.230.167:7006 slave FFE722398240B59F0C993074D35DBE79386C1EC3 0 1467381349636 3 Connected
FFE722398240B59F0C993074D35DBE79386C1EC3 172.16.230.167:7003 master-0 1467381348635 3 connected 10923-16383
d6d307c91e6ba6fbba7d898f20fd4772a3e42b9c 172.16.230.167:7004 Slave f2a684e0900e7b7eb91bdb77e3b559f47d0f7237 0 1467381348135 1 Connected
6b52de99a37444a2f7cb04a65ed4239446dee048 172.16.230.167:7008 myself,master-0 0 7 Connected

172.16.230.167:7008> CLUSTER REPLICATE 83e5dd37a0825a4adb77d6da4738bf0c88cd6c39

Where the command provides 83e5dd37a0825a4adb77d6da4738bf0c88cd6c39 is the node ID of the primary node 172.16.230.167:7007

172.16.230.167:7008> CLUSTER Nodes
84995C68E3625C91F4C646D71566DFFD709E6D01 172.16.230.167:7002 master-0 1467381552990 2 connected 5461-10922
37b6f6478ca6425022521d6a5ecf0aeedf12c601 172.16.230.167:7005 Slave 84995c68e3625c91f4c646d71566dffd709e6d01 0 1467381554995 2 Connected
f2a684e0900e7b7eb91bdb77e3b559f47d0f7237 172.16.230.167:7001 master-0 1467381553992 1 Connected 0-5460
83e5dd37a0825a4adb77d6da4738bf0c88cd6c39 172.16.230.167:7007 master-0 1467381555997 0 connected
458a01eeace9fd93544645433ad5b12587d94d3b 172.16.230.167:7006 Slave ffe722398240b59f0c993074d35dbe79386c1ec3 0 1467381550487 3 Connected
FFE722398240B59F0C993074D35DBE79386C1EC3 172.16.230.167:7003 master-0 1467381550988 3 connected 10923-16383
d6d307c91e6ba6fbba7d898f20fd4772a3e42b9c 172.16.230.167:7004 Slave f2a684e0900e7b7eb91bdb77e3b559f47d0f7237 0 1467381549986 1 connected
6b52de99a37444a2f7cb04a65ed4239446dee048 172.16.230.167:7008 Myself,slave 83E5DD37A0825A4ADB77D6DA4738BF0C88CD6C39 0 0 7 connected


Re-sharding the cluster: mainly re-sharding the 172.16.230.167:7007 cluster nodes

[Email protected] ~]# redis-trib.rb reshard 172.16.230.167:7007

>>> performing Cluster Check (using node 172.16.230.167:7007)
M:83e5dd37a0825a4adb77d6da4738bf0c88cd6c39 172.16.230.167:7007
Slots: (0 slots) Master
1 additional replica (s)
s:d6d307c91e6ba6fbba7d898f20fd4772a3e42b9c 172.16.230.167:7004
Slots: (0 slots) Slave
Replicates f2a684e0900e7b7eb91bdb77e3b559f47d0f7237
s:6b52de99a37444a2f7cb04a65ed4239446dee048 172.16.230.167:7008
Slots: (0 slots) Slave
Replicates 83e5dd37a0825a4adb77d6da4738bf0c88cd6c39
M:84995C68E3625C91F4C646D71566DFFD709E6D01 172.16.230.167:7002
slots:5461-10922 (5462 slots) Master
1 additional replica (s)
s:37b6f6478ca6425022521d6a5ecf0aeedf12c601 172.16.230.167:7005
Slots: (0 slots) Slave
Replicates 84995c68e3625c91f4c646d71566dffd709e6d01
m:f2a684e0900e7b7eb91bdb77e3b559f47d0f7237 172.16.230.167:7001
slots:0-5460 (5461 slots) Master
1 additional replica (s)
S:458A01EEACE9FD93544645433AD5B12587D94D3B 172.16.230.167:7006
Slots: (0 slots) Slave
Replicates FFE722398240B59F0C993074D35DBE79386C1EC3
M:FFE722398240B59F0C993074D35DBE79386C1EC3 172.16.230.167:7003
slots:10923-16383 (5461 slots) Master
1 additional replica (s)
[OK] All nodes agree about slots configuration.
>>> Check for open Slots ...
>>> Check Slots Coverage ...
[OK] All 16384 slots covered.
How many slots does want to move (from 1 to 16384)? ###### #分片大小
What is the receiving node ID? 83e5dd37a0825a4adb77d6da4738bf0c88cd6c39 #分配到那个集群节点的master上172.16.230.167:7007
Please enter the source node IDs.
The Type ' All ' is the nodes as source nodes for the hash slots.
Type ' Done ' once your entered all the source nodes IDs.
Source node #1: All #所有

Do you want to proceed with the proposed Reshard plan (yes/no)? Yes

Detecting data consistency with CONSISTENCY-TEST.RB
Download
git clone https://github.com/antirez/redis-rb-cluster.git

[Email protected] redis-rb-cluster]# Ruby consistency-test.rb 172.16.230.167 7001
G-R (0 err) | W (0 Err) |
1453 R (0 err) | 1453 W (0 err) |
2708 R (0 err) | 2708 W (0 err) |
4010 R (0 err) | 4010 W (0 err) |
5309 R (0 err) | 5309 W (0 err) |
6613 R (0 err) | 6613 W (0 err) |
7915 R (0 err) | 7915 W (0 err) |
9214 R (0 err) | 9214 W (0 err) |
10517 R (0 err) | 10517 W (0 err) |
11817 R (0 err) | 11817 W (0 err) |
13121 R (0 err) | 13121 W (0 err) |
14422 R (0 err) | 14422 W (0 err) |
15724 R (0 err) | 15724 W (0 err) |
17012 R (0 err) | 17012 W (0 err) |
18312 R (0 err) | 18312 W (0 err) |
19628 R (0 err) | 19628 W (0 err) |
20949 R (0 err) | 20949 W (0 err) |
22255 R (0 err) | 22255 W (0 err) |
23294 R (0 err) | 23294 W (0 err) |
24542 R (0 err) | 24542 W (0 err) |
25852 R (0 err) | 25852 W (0 err) |


Fail-over Test

To view the master node:
[Email protected] ~]# redis-cli-c-H 172.16.230.167-p 7001 cluster Nodes | grep Master
FFE722398240B59F0C993074D35DBE79386C1EC3 172.16.230.167:7003 master-0 1467383421007 3 connected 11256-16383
83e5dd37a0825a4adb77d6da4738bf0c88cd6c39 172.16.230.167:7007 master-0 1467383423010 8 connected 0-332 5461-5794 10923-11255
84995C68E3625C91F4C646D71566DFFD709E6D01 172.16.230.167:7002 master-0 1467383426014 2 connected 5795-10922
f2a684e0900e7b7eb91bdb77e3b559f47d0f7237 172.16.230.167:7001 myself,master-0 0 1 connected 333-5460

Using debug Segfault to crash the master node
Redis-cli-c-H 172.16.230.167-p 7001 Debug Segfault

[Email protected] ~]# redis-cli-c-H 172.16.230.167-p 7002 cluster Nodes | grep Master
84995C68E3625C91F4C646D71566DFFD709E6D01 172.16.230.167:7002 myself,master-0 0 2 connected 5795-10922
d6d307c91e6ba6fbba7d898f20fd4772a3e42b9c 172.16.230.167:7004 master-0 1467383553156 9 Connected 333-5460
83e5dd37a0825a4adb77d6da4738bf0c88cd6c39 172.16.230.167:7007 master-0 1467383556161 8 connected 0-332 5461-5794 10923-11255
FFE722398240B59F0C993074D35DBE79386C1EC3 172.16.230.167:7003 master-0 1467383553657 3 connected 11256-16383
f2a684e0900e7b7eb91bdb77e3b559f47d0f7237 172.16.230.167:7001 master,fail-1467383513361 1467383506054 1 disconnected

Cluster Management
Yum-y Install httpd php Php-redis

git clone https://github.com/erikdubbelboer/phpRedisAdmin.git
CD Phpredisadmin
git clone https://github.com/nrk/predis.git Vendor

###################################

Codis Cluster

The Codis consists of four parts:

Codis Proxy (Codis-proxy)
Codis Dashboard (Codis-config)
Codis Redis (Codis-server)
Zookeeper/etcd


Install Go
Yum-y Install Golang

mkdir/data/gopath/

Export Gopath=/data/gopath
Export PATH USER LOGNAME MAIL HOSTNAME histsize Histcontrol Gopath

Redis cluster configuration

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.