Redis 3.0 cluster cluster

References:

Mr. Wu Shuicheng's <<Redis cluster installation (Redis3+CentOS)>> see the attachment

Redis official cluster guide: http://redis.io/topics/cluster-tutorial
Redis official cluster specification: http://redis.io/topics/cluster-spec
Redis cluster guide (Chinese translation, for reference): http: //redisdoc.com/topic/cluster-tutorial.html
Redis Cluster Specification (Chinese translation, for reference): http://redisdoc.com/topic/cluster-spec.html

Practice: Combine your own practice

 

1. Introduction to Redis Cluster

Redis cluster is a centerless distributed redis storage architecture, which can share data among multiple nodes, which solves the problems of high availability and scalability of redis. Redis cluster provides the following two benefits

(1) Automatically split the data into multiple nodes

(2) When a node in the cluster fails, redis can continue to process client requests.

A Redis cluster contains 16384 hash slots, and every data in the database belongs to one of these 16384 hash slots. The cluster uses the formula CRC16(key) % 16384 to calculate which slot the key key belongs to. Each node in the cluster is responsible for processing a portion of the hash slots. Each node in the cluster has 1 to N replicas, one of which is the master node and the rest are slave nodes. If the master node goes offline, the cluster will set a slave node of the master node as the new one Master node, continue to work. This way the cluster will not fail due to a master node going offline

For detailed content, please refer to: http://www.cnblogs.com/wjoyxt/p/4242184.html http://blog.csdn.net/a67474506/article/details/50435498

 

2. Installation configuration

1. Environment introduction

Redis cluster installation (Redis3.0.3 + CentOS 6.6 _x64) To make the Redis3.0 cluster work normally, at least 3 Master nodes are required. To achieve high availability, each Master node must be equipped with at least 1 Slave node. According to the above characteristics and requirements, carry out the following cluster implementation planning:
use 6 servers (physical machines or virtual machines) to deploy 3 Master + 3 Slaves;

My environment settings:

machine: virtual machine

O S:   CentOS 6.6 _x64

IP:

192.168.1.121:7111  192.168.1.121:7112  192.168.1.121:7113

192.168.1.122:7114  192.168.1.124:7116  192.168.1.123:7115

 

2. Redis installation configuration

Redis introduction, installation and cluster introduction

 

3. Installation of Redis cluster

3.1 Reference for the remaining content: Redis cluster installation (Redis3+CentOS)

 

3.2. Summary of problems during installation

(1) redis-trib create --replicas 1 192.168.1.107:7114 192.168.1.108:7115 192.168.1.109:7116 192.168.1.104:7111 192.168.1.105:7112 192.168.1.106:7113

Note: (1) Retry if it does not satisfy the changeable position (2) When there is a pseudo node, when the master and slave are in one, there will be problems with the machine; because the master and slave of the node are not controllable

 

(2) Error: [ERR] Node 172.168.63.202:7001 is not empty. Either the nodealready knows other nodes (check with CLUSTER NODES) or contains some key
1) Backup aof, rdb, nodes.conf under each node locally File deletion;
2) 172.168.63.201:7001> flushdb #Clear the current database (can be omitted)
3) Execute the script after that, and execute successfully;
reference: http://blog.csdn.net/vtopqx/article/details/50235737

 

4. Redis cluster high availability test

 

5. Expansion test of Redis cluster

5.1 Comply with the file <<Scalability test of redis cluster>>

 

5.2 The following is a summary of my own practice and problems

1. Add a new node to the cluster: execute it on the new node machine

/usr/local/src/redis3.0/src/redis-trib.rb add-node 192.168.1.111:7117 192.168.1.121:7111

 

2. Allocate a hash slot for the new node:

You only need to specify the address of one of the nodes in the cluster, and redis-trib will automatically find the other nodes in the cluster. At present, redis-trib can only complete the resharding work with the assistance of the administrator. The command is as follows:

# /usr/local/src/redis3.0/src/redis-trib.rb reshard 192.168.1.121:7111

 

3. After the move is completed, check whether the node is normal

/usr/local/src/redis3.0/src/redis-trib.rb check 192.168.1.121:7111

 

4. Add slave node

#/usr/local/src/redis3.0/src/redis-trib.rb add-node 192.168.1.111:7118 192.168.1.121:7111

 

5. Redis-cli connects to the new node shell, enter the command: cluster replicate corresponds to the node-id of the master

127.0.0.1:7118>cluster replicate ab31611b3424990e2b9bbe73135cb4cb0ace394f

ab31611b3424990e2b9bbe73135cb4cb0ace394f nodeId of bit 7117

 

6. Delete a slave node

# cd /usr/local/src/redis-3.0.3/src/

# ./redis-trib.rb del-node 172.21.10.203:7118 7f868a38a90acfdf40121613bfed1a089b7db028

 

delete a master node

Before deleting the master node, first use reshard to remove all the slots of the master, and then delete the current node (currently only

Delete the slot of the master and migrate it to a node), the operation is similar to the allocation of the slot, and the specific Source node can be specified.

# /usr/local/src/redis-3.0.3/src/redis-trib.rb reshard 172.21.10.203:7117

 

After confirming that all slots of the Master node have been emptied, you can delete the node (the command is the same as deleting the slave node):

# cd /usr/local/src/redis-3.0.3/src/

# ./redis-trib.rb del-node 172.21.10.203:7117 93c4477e5d23db7fc17fc4c15ec72595b52d25e7

References:

Mr. Wu Shuicheng's <<Redis cluster installation (Redis3+CentOS)>> see the attachment

Redis official cluster guide: http://redis.io/topics/cluster-tutorial
Redis official cluster specification: http://redis.io/topics/cluster-spec
Redis cluster guide (Chinese translation, for reference): http: //redisdoc.com/topic/cluster-tutorial.html
Redis Cluster Specification (Chinese translation, for reference): http://redisdoc.com/topic/cluster-spec.html

Practice: Combine your own practice

 

1. Introduction to Redis Cluster

Redis cluster is a centerless distributed redis storage architecture, which can share data among multiple nodes, which solves the problems of high availability and scalability of redis. Redis cluster provides the following two benefits

(1) Automatically split the data into multiple nodes

(2) When a node in the cluster fails, redis can continue to process client requests.

A Redis cluster contains 16384 hash slots, and every data in the database belongs to one of these 16384 hash slots. The cluster uses the formula CRC16(key) % 16384 to calculate which slot the key key belongs to. Each node in the cluster is responsible for processing a portion of the hash slots. Each node in the cluster has 1 to N replicas, one of which is the master node and the rest are slave nodes. If the master node goes offline, the cluster will set a slave node of the master node as the new one Master node, continue to work. This way the cluster will not fail due to a master node going offline

For detailed content, please refer to: http://www.cnblogs.com/wjoyxt/p/4242184.html http://blog.csdn.net/a67474506/article/details/50435498

 

2. Installation configuration

1. Environment introduction

Redis cluster installation (Redis3.0.3 + CentOS 6.6 _x64) To make the Redis3.0 cluster work normally, at least 3 Master nodes are required. To achieve high availability, each Master node must be equipped with at least 1 Slave node. According to the above characteristics and requirements, carry out the following cluster implementation planning:
use 6 servers (physical machines or virtual machines) to deploy 3 Master + 3 Slaves;

My environment settings:

machine: virtual machine

O S:   CentOS 6.6 _x64

IP:

192.168.1.121:7111  192.168.1.121:7112  192.168.1.121:7113

192.168.1.122:7114  192.168.1.124:7116  192.168.1.123:7115

 

2. Redis installation configuration

Redis introduction, installation and cluster introduction

 

3. Installation of Redis cluster

3.1 Reference for the remaining content: Redis cluster installation (Redis3+CentOS)

 

3.2. Summary of problems during installation

(1) redis-trib create --replicas 1 192.168.1.107:7114 192.168.1.108:7115 192.168.1.109:7116 192.168.1.104:7111 192.168.1.105:7112 192.168.1.106:7113

Note: (1) Retry if it does not satisfy the changeable position (2) When there is a pseudo node, when the master and slave are in one, there will be problems with the machine; because the master and slave of the node are not controllable

 

(2) Error: [ERR] Node 172.168.63.202:7001 is not empty. Either the nodealready knows other nodes (check with CLUSTER NODES) or contains some key
1) Backup aof, rdb, nodes.conf under each node locally File deletion;
2) 172.168.63.201:7001> flushdb #Clear the current database (can be omitted)
3) Execute the script after that, and execute successfully;
reference: http://blog.csdn.net/vtopqx/article/details/50235737

 

4. Redis cluster high availability test

 

5. Expansion test of Redis cluster

5.1 Comply with the file <<Scalability test of redis cluster>>

 

5.2 The following is a summary of my own practice and problems

1. Add a new node to the cluster: execute it on the new node machine

/usr/local/src/redis3.0/src/redis-trib.rb add-node 192.168.1.111:7117 192.168.1.121:7111

 

2. Allocate a hash slot for the new node:

You only need to specify the address of one of the nodes in the cluster, and redis-trib will automatically find the other nodes in the cluster. At present, redis-trib can only complete the resharding work with the assistance of the administrator. The command is as follows:

# /usr/local/src/redis3.0/src/redis-trib.rb reshard 192.168.1.121:7111

 

3. After the move is completed, check whether the node is normal

/usr/local/src/redis3.0/src/redis-trib.rb check 192.168.1.121:7111

 

4. Add slave node

#/usr/local/src/redis3.0/src/redis-trib.rb add-node 192.168.1.111:7118 192.168.1.121:7111

 

5. Redis-cli connects to the new node shell, enter the command: cluster replicate corresponds to the node-id of the master

127.0.0.1:7118>cluster replicate ab31611b3424990e2b9bbe73135cb4cb0ace394f

ab31611b3424990e2b9bbe73135cb4cb0ace394f nodeId of bit 7117

 

6. Delete a slave node

# cd /usr/local/src/redis-3.0.3/src/

# ./redis-trib.rb del-node 172.21.10.203:7118 7f868a38a90acfdf40121613bfed1a089b7db028

 

delete a master node

Before deleting the master node, first use reshard to remove all the slots of the master, and then delete the current node (currently only

Delete the slot of the master and migrate it to a node), the operation is similar to the allocation of the slot, and the specific Source node can be specified.

# /usr/local/src/redis-3.0.3/src/redis-trib.rb reshard 172.21.10.203:7117

 

After confirming that all slots of the Master node have been emptied, you can delete the node (the command is the same as deleting the slave node):

# cd /usr/local/src/redis-3.0.3/src/

# ./redis-trib.rb del-node 172.21.10.203:7117 93c4477e5d23db7fc17fc4c15ec72595b52d25e7

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326266309&siteId=291194637