In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
1. Cluster architecture:
Explanation:
All redis nodes are interconnected with each other (PING-PONG mechanism), and binary protocols are used internally to optimize transmission speed and bandwidth. The fail of a node takes effect only when it is detected by more than half of the nodes in the cluster. The client is directly connected to the redis node and does not require an intermediate proxy layer. The client does not need to connect all the nodes in the cluster, but can connect any available node in the cluster to redis-cluster to map all the physical nodes to the [0-16383] slot, and cluster is responsible for maintenance.
There are 16384 hash slots built into the Redis cluster. When you need to place a key-value in the Redis cluster,
Redis first uses the crc16 algorithm to calculate a result for key, and then calculates the remainder of the result for 16384.
In this way, each key will correspond to a hash slot numbered between 0 and 16383, and redis will map the hash slot to different nodes according to the number of nodes.
Misunderstanding explanation: the cluster here is different from master-slave replication. All the clusters here are mater, and there is a single node gu problem, while master-slave replication only solves the problem of single point of failure.
If you want the cluster mode to have a single point of failure in the afternoon, you need to do master-slave replication for each master.
2.redis-cluster voting fault tolerance
All master in the cluster participate in voting, if more than half of the master nodes communicate with one of the master nodes more than (cluster-node-timeout), the master node is considered to be dead.
Judgment of cluster unavailability status:
If any master of the cluster hangs and there is no slave in the current master, the cluster enters the fail state. It can also be understood as entering the fail state when the [0-16383] slot mapping of the cluster is incomplete. If more than half of the cluster master is down, regardless of whether there is slave or not, the cluster enters the fail state.
The Construction of 3.redis Cluster
Installation of ① ruby
Because the cluster management tool (redis-trib.rb) is written in the ruby scripting language, the environment of ruby is required.
Step 1: install ruby
[root@hdp01 bin2] # yum install ruby
[root@hdp01 bin2] # yum install rubygems
Step 2: upload the redis-3.0.0.gem file to the linux system
Step 3: install ruby and redis interfaces
[root@hdp01 ~] # gem install redis-3.0.0.gem
Step 4: copy the following files in the src directory under the redis-3.0.0 package to redis19/redis-cluster/
Step 5: check to see if the copy is successful
② sets up a cluster:
Here three servers are used to simulate the redis cluster.
Step 1: copy the redis to a machine
[root@hdp01 redis] # scp / xxx/redis-3.0.0-r hostname01:~/apps
Step 2: if there is a persistent file, delete it
[root@hdp01 app] # rm-rf appendonly.aof dump.rdb
Step 3: set cluster parameters
Enable cluster mode:
Step 5: copy the redis service to another machine
[root@hdp01 redis] # scp / xxx/redis-3.0.0-r hostname02:~/apps
[root@hdp01 redis] # scp / xxx/redis-3.0.0-r hostname03:~/apps
Step 7: start three machines
[root@hdp01 redis] # redis-server redis.conf (enabled on all three machines)
Step 9: create a cluster
[root@hdp01 redis-cluster] #. / redis-trib.rb create-replicas 1\
192.168.130.1286379\
192.168.130.129purl 6379\
192.168.130.130R 6379\
> Creating cluster
Connecting to node 192.168.242.137:7001: OK
Connecting to node 192.168.242.137:7002: OK
Connecting to node 192.168.242.137:7003: OK
Connecting to node 192.168.242.137:7004: OK
Connecting to node 192.168.242.137:7005: OK
Connecting to node 192.168.242.137:7006: OK
> Performing hash slots allocation on 6 nodes...
Using 3 masters:
192.168.242.137:7001
192.168.242.137:7002
192.168.242.137:7003
Adding replica 192.168.242.137:7004 to 192.168.242.137:7001
Adding replica 192.168.242.137:7005 to 192.168.242.137:7002
Adding replica 192.168.242.137:7006 to 192.168.242.137:7003
M: 8240cd0fe6d6f842faa42b0174fe7c5ddcf7ae24 192.168.242.137:7001
Slots:0-5460 (5461 slots) master
M: 4f52a974f64343fd9f1ee0388490b3c0647a4db7 192.168.242.137:7002
Slots:5461-10922 (5462 slots) master
M: cb7c5def8f61df2016b38972396a8d1f349208c2 192.168.242.137:7003
Slots:10923-16383 (5461 slots) master
S: 66adf006fed43b3b5e499ce2ff1949a756504a16 192.168.242.137:7004
Replicates 8240cd0fe6d6f842faa42b0174fe7c5ddcf7ae24
S: cbb0c9bc4b27dd85511a7ef2d01bec90e692793b 192.168.242.137:7005
Replicates 4f52a974f64343fd9f1ee0388490b3c0647a4db7
S: a908736eadd1cd06e86fdff8b2749a6f46b38c00 192.168.242.137:7006
Replicates cb7c5def8f61df2016b38972396a8d1f349208c2
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 192.168.242.137)
M: 8240cd0fe6d6f842faa42b0174fe7c5ddcf7ae24 192.168.242.137:7001
Slots:0-5460 (5461 slots) master
M: 4f52a974f64343fd9f1ee0388490b3c0647a4db7 192.168.242.137:7002
Slots:5461-10922 (5462 slots) master
M: cb7c5def8f61df2016b38972396a8d1f349208c2 192.168.242.137:7003
Slots:10923-16383 (5461 slots) master
M: 66adf006fed43b3b5e499ce2ff1949a756504a16 192.168.242.137:7004
Slots: (0 slots) master
Replicates 8240cd0fe6d6f842faa42b0174fe7c5ddcf7ae24
M: cbb0c9bc4b27dd85511a7ef2d01bec90e692793b 192.168.242.137:7005
Slots: (0 slots) master
Replicates 4f52a974f64343fd9f1ee0388490b3c0647a4db7
M: a908736eadd1cd06e86fdff8b2749a6f46b38c00 192.168.242.137:7006
Slots: (0 slots) master
Replicates cb7c5def8f61df2016b38972396a8d1f349208c2
[OK] All nodes agree about slots configuration.
> Check for open slots...
> Check slots coverage...
[OK] All 16384 slots covered.
③ tests whether the cluster is built successfully.
[root@hdp01 7001] #. / redis-cli-h 192.168.130.130murp 6379-c # connect to the cluster
Introduction to related commands:
192.168.130.130R 6379 > cluster info # View cluster information
192.168.130.130R 6379 > cluster nodes # View Cluster Node
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.