当前位置:网站首页>Redis cluster deployment based on redis6.2.4
Redis cluster deployment based on redis6.2.4
2022-07-25 16:57:00 【wwzroom】
be based on redis6.2.4 Of redis cluster Deploy
Experimental framework 
1. Modify profile enable cluster function
1. Modify hostname
hostnamectl set-hostname node1.magedu.org;exit
hostnamectl set-hostname node2.magedu.org;exit
hostnamectl set-hostname node3.magedu.org;exit
hostnamectl set-hostname node4.magedu.org;exit
hostnamectl set-hostname node5.magedu.org;exit
hostnamectl set-hostname node6.magedu.org;exit
2. install redis6.2.4
Script to achieve one click installation : See https://blog.csdn.net/aa896517050/article/details/125955201
3. Modify the configuration file ( All nodes )
sed -i.bak -e '/masterauth/a masterauth 123456' -e '/# cluster-enabled yes/a cluster-enabled yes' -e '/# cluster-config-file nodes-6379.conf/a cluster-config-file nodes-6379.conf' -e '/# cluster-require-full-coverage yes/c cluster-require-full-coverage no' /apps/redis/etc/redis.conf
4. Restart the service ( All nodes )
systemctl enable --now redis
[[email protected]:~]#
ps aux|grep redis
redis 5578 0.1 0.1 162500 2944 ? Ssl Jul24 0:06 /apps/redis/bin/redis-server 0.0.0.0:6379
root 5866 0.0 0.0 112808 968 pts/0 S+ 00:24 0:00 grep --color=auto redis
# Restart again
systemctl restart redis
[[email protected]:~]#
ps aux|grep redis
redis 6013 0.1 0.1 162500 3520 ? Ssl 00:57 0:00 /apps/redis/bin/redis-server 0.0.0.0:6379 [cluster] #cluster sign
root 6021 0.0 0.0 112808 968 pts/0 S+ 00:58 0:00 grep --color=auto redis
[[email protected]:~]#
redis-cli -a 123456
127.0.0.1:6379> info cluster
# Cluster
cluster_enabled:1
2. All nodes interact with each other meet
1. Check the connection
[[email protected]:~]#
redis-cli -a 123456 cluster nodes
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
fdec26daee7636c212283fd8b32c8088e54a6655 :[email protected] myself,master - 0 0 0 connected
# There is no connection with any one at this time ,6 Each node is independent .
2. On any node and all other nodes meet signal communication ( This time at node1 operation ,node1 It's the middleman , All connected )
[[email protected]:~]#
redis-cli -a 123456 --no-auth-warning cluster meet 10.0.0.17 6379
[[email protected]:~]#
ss -nt
State Recv-Q Send-Q Local Address:Port Peer Address:Port
ESTAB 0 0 10.0.0.7:36605 10.0.0.17:16379
ESTAB 0 36 10.0.0.7:22 10.0.0.1:51254
ESTAB 0 0 10.0.0.7:16379 10.0.0.17:44342
# The cluster port is 16379、
[[email protected]:~]#
redis-cli -a 123456 --no-auth-warning cluster meet 10.0.0.27 6379
OK
[[email protected]:~]#
redis-cli -a 123456 --no-auth-warning cluster meet 10.0.0.37 6379
OK
[[email protected]:~]#
redis-cli -a 123456 --no-auth-warning cluster meet 10.0.0.47 6379
OK
[[email protected]:~]#
redis-cli -a 123456 --no-auth-warning cluster meet 10.0.0.57 6379
OK
# Check the connection
[[email protected]:~]#
redis-cli -a 123456 cluster info
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
cluster_state:fail
cluster_slots_assigned:0
cluster_slots_ok:0
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:6 # Express 6 Connections have been established between nodes
cluster_size:0
cluster_current_epoch:5
cluster_my_epoch:0
cluster_stats_messages_ping_sent:468
cluster_stats_messages_pong_sent:475
cluster_stats_messages_meet_sent:6
cluster_stats_messages_sent:949
cluster_stats_messages_ping_received:475
cluster_stats_messages_pong_received:474
cluster_stats_messages_received:949
[[email protected]:~]#
redis-cli -a 123456 cluster nodes
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
4e456d304f1971c3fe776c21d8dd2c880dd29fd2 10.0.0.27:[email protected] master - 0 1658683099799 2 connected
008abaa9cf3b273f905a26838f675c1be17b8570 10.0.0.37:[email protected] master - 0 1658683097000 3 connected
c30419b368a783f4c4d9de948dcc7f3d44ee4797 10.0.0.17:[email protected] master - 0 1658683098000 1 connected
f941e86ede0fad0dfe70b5ee6ad0577e21cb0d98 10.0.0.47:[email protected] master - 0 1658683099000 4 connected
46b3deba6bdaf57e481cce86f4335963d555dcdc 10.0.0.57:[email protected] master - 0 1658683096000 5 connected
fdec26daee7636c212283fd8b32c8088e54a6655 10.0.0.7:[email protected] myself,master - 0 1658683098000 0 connected
3. Assign slots ( Script implementation )
[[email protected]:~]#
vim addslot.sh
#!/bin/bash
#****************************************************
#Date: 2022-07-25
#Author: wwzroom
#FileName: addslot.sh
#Description: The test script
#QQ: 896517050
#sh****************************************************
host=$1
port=$2
start=$3
end=$4
pass=123456
for slot in `seq ${
start} ${
end}`;do
echo slot:$slot
redis-cli -h ${host} -p $port -a ${pass} --no-auth-warning cluster addslots ${slot}
done
2. Add execute permission
[[email protected]:~]#
chmod +x addslot.sh
3. Assign slots
[[email protected]:~]#
./addslot.sh 10.0.0.7 6379 0 5461
[[email protected]:~]#
./addslot.sh 10.0.0.17 6379 5462 10922
[[email protected]:~]#
./addslot.sh 10.0.0.27 6379 10923 16383
# When allocating, if the first node is allocated incorrectly , When the second node is reallocated , It can't be allocated , It doesn't affect the experiment , If the first score is too much , There is no way to divide the back , Therefore, the recorded file can be deleted ,rm -rf /apps/redis/data/nodes-6379.conf, again meet, Redistribution .
# View allocation
[[email protected]:~]#
redis-cli -a 123456
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> cluster nodes
4e456d304f1971c3fe776c21d8dd2c880dd29fd2 10.0.0.27:[email protected] master - 0 1658684953613 2 connected 10923-16383
008abaa9cf3b273f905a26838f675c1be17b8570 10.0.0.37:[email protected] master - 0 1658684952000 3 connected
c30419b368a783f4c4d9de948dcc7f3d44ee4797 10.0.0.17:[email protected] master - 0 1658684953000 1 connected 5462-10922
f941e86ede0fad0dfe70b5ee6ad0577e21cb0d98 10.0.0.47:[email protected] master - 0 1658684953000 4 connected
46b3deba6bdaf57e481cce86f4335963d555dcdc 10.0.0.57:[email protected] master - 0 1658684952609 5 connected
fdec26daee7636c212283fd8b32c8088e54a6655 10.0.0.7:[email protected] myself,master - 0 1658684951000 0 connected 0-5461
4. Specify the master-slave relationship of each node
[[email protected]:~]#
redis-cli -h 10.0.0.37 -a 123456 --no-auth-warning cluster replicate fdec26daee7636c212283fd8b32c8088e54a6655 # The master node id, Set up here 37 by 07 The slave node ,id Number is 07 Of ,ID No. has the above nodes Information acquisition .
[[email protected]:~]#
redis-cli -h 10.0.0.47 -a 123456 --no-auth-warning cluster replicate c30419b368a783f4c4d9de948dcc7f3d44ee4797
[[email protected]:~]#
redis-cli -h 10.0.0.57 -a 123456 --no-auth-warning cluster replicate 4e456d304f1971c3fe776c21d8dd2c880dd29fd2
# Check the details
[[email protected]:~]#
redis-cli -a 123456 cluster nodes
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
4e456d304f1971c3fe776c21d8dd2c880dd29fd2 10.0.0.27:[email protected] master - 0 1658686186000 2 connected 10923-16383
008abaa9cf3b273f905a26838f675c1be17b8570 10.0.0.37:[email protected] slave fdec26daee7636c212283fd8b32c8088e54a6655 0 1658686187701 0 connected
c30419b368a783f4c4d9de948dcc7f3d44ee4797 10.0.0.17:[email protected] master - 0 1658686186693 1 connected 5462-10922
f941e86ede0fad0dfe70b5ee6ad0577e21cb0d98 10.0.0.47:[email protected] slave c30419b368a783f4c4d9de948dcc7f3d44ee4797 0 1658686185684 1 connected
46b3deba6bdaf57e481cce86f4335963d555dcdc 10.0.0.57:[email protected] slave 4e456d304f1971c3fe776c21d8dd2c880dd29fd2 0 1658686185000 2 connected
fdec26daee7636c212283fd8b32c8088e54a6655 10.0.0.7:[email protected] myself,master - 0 1658686185000 0 connected 0-5461
[[email protected]:~]#
redis-cli -a 123456 cluster info
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
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 #3 Group cluster
cluster_current_epoch:5
cluster_my_epoch:0
cluster_stats_messages_ping_sent:3721
cluster_stats_messages_pong_sent:3753
cluster_stats_messages_meet_sent:6
cluster_stats_messages_sent:7480
cluster_stats_messages_ping_received:3753
cluster_stats_messages_pong_received:3727
cluster_stats_messages_received:7480
[[email protected]:~]#
redis-cli -a 123456 --no-auth-warning cluster slots
1) 1) (integer) 0
2) (integer) 5461
3) 1) "10.0.0.7"
2) (integer) 6379
3) "fdec26daee7636c212283fd8b32c8088e54a6655"
4) 1) "10.0.0.37"
2) (integer) 6379
3) "008abaa9cf3b273f905a26838f675c1be17b8570"
2) 1) (integer) 5462
2) (integer) 10922
3) 1) "10.0.0.17"
2) (integer) 6379
3) "c30419b368a783f4c4d9de948dcc7f3d44ee4797"
4) 1) "10.0.0.47"
2) (integer) 6379
3) "f941e86ede0fad0dfe70b5ee6ad0577e21cb0d98"
3) 1) (integer) 10923
2) (integer) 16383
3) 1) "10.0.0.27"
2) (integer) 6379
3) "4e456d304f1971c3fe776c21d8dd2c880dd29fd2"
4) 1) "10.0.0.57"
2) (integer) 6379
3) "46b3deba6bdaf57e481cce86f4335963d555dcdc"
5. Write data test
1. Connect any master node to write data , about key Value for hash operation ( And value irrelevant ), Then re allocate according to the card slot relationship , If not assigned to this node , You will be prompted to report an error (error) MOVED 7755 10.0.0.17:6379, Prompt to put in the specific slot .
[[email protected]:~]#
redis-cli -a 123456
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> set class m44
(error) MOVED 7755 10.0.0.17:6379
127.0.0.1:6379>
2 Log in to the specified slot to write data , Can succeed , You cannot check the data at the slave node , Not enabled
[[email protected]:~]#
redis-cli -a 123456
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> set class m44
OK
# Data cannot be queried from the node , That is, read and write can only be provided by the master node , The slave node cannot provide services .
127.0.0.1:6379> keys class
1) "class"
127.0.0.1:6379> get class
(error) MOVED 7755 10.0.0.17:6379
3. Specify the options -c Indicates accessing in a cluster , There is no limit on the , Master or slave login can be used .
[[email protected]:~]#
redis-cli -c -a 123456 --no-auth-warning set name wang
OK
[[email protected]:~]#
redis-cli -c -a 123456 --no-auth-warning get name
"wang"
# Prompt to redirect to a specific node .
[[email protected]:~]#
redis-cli -a 123456 -c # Log in as a cluster
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> set age 20
-> Redirected to slot [741] located at 10.0.0.7:6379
OK
10.0.0.7:6379> get age
"20"
10.0.0.7:6379> set class M47
-> Redirected to slot [7755] located at 10.0.0.17:6379
OK
10.0.0.17:6379> get class
"M47"
边栏推荐
- IAAs infrastructure cloud cloud network
- Roson的Qt之旅#99 QML表格控件-TableView
- 失意的互联网人拼命叩开Web3大门
- Talk about how to use redis to realize distributed locks?
- Is the online account opening of Founder futures reliable and safe?
- 免费的低代码开发平台有哪些?
- 第五章:流程控制
- Rosen's QT journey 100 QML four standard dialog boxes (color, font, file, promotion)
- 【知识图谱】实践篇——基于医疗知识图谱的问答系统实践(Part4):结合问题分类的问题解析与检索语句生成
- 博云容器云、DevOps平台斩获可信云“技术最佳实践奖”
猜你喜欢
![[knowledge atlas] practice -- Practice of question answering system based on medical knowledge atlas (Part3): rule-based problem classification](/img/4c/aeebbc9698f8d5c23ed6473c9aca34.png)
[knowledge atlas] practice -- Practice of question answering system based on medical knowledge atlas (Part3): rule-based problem classification

Jenkins' file parameters can be used to upload files

基于redis6.2.4的redis cluster部署

复旦大学EMBA2022毕业季丨毕业不忘初心 荣耀再上征程
![[knowledge atlas] practice -- Practice of question answering system based on medical knowledge atlas (Part4): problem analysis and retrieval sentence generation combined with problem classification](/img/22/01297d28e5bfb105fc65ee29248a7c.png)
[knowledge atlas] practice -- Practice of question answering system based on medical knowledge atlas (Part4): problem analysis and retrieval sentence generation combined with problem classification

2022年最新北京建筑施工焊工(建筑特种作业)模拟题库及答案解析

【目标检测】YOLOv5跑通VisDrone数据集

2022 latest Beijing Construction welder (construction special operation) simulation question bank and answer analysis

企业直播风起:目睹聚焦产品,微赞拥抱生态

EasyUI DataGrid control uses
随机推荐
第四章:操作符
3D 语义分割——Scribble-Supervised LiDAR Semantic Segmentation
easyui下拉框,增加以及商品的上架,下架
Gtx1080ti fiber HDMI interference flash screen 1080ti flash screen solution
动态规划题目记录
复旦大学EMBA同学同行专题:始终将消费者的价值放在最重要的位置
Budget report ppt
【读书会第13期】+FFmpeg视频采集功能
Attachment handling of SAP Fiori
Roson的Qt之旅#99 QML表格控件-TableView
虚拟内存管理
slf4j 搭配 log4j2 处理日志
[target detection] yolov5 Runtong visdrone data set
7. Dependency injection
Don't believe these "rumors" in the process of preparing for the exam!
简述redis集群的实现原理
How to delete Microsoft Pinyin input method in win10
Baidu rich text editor ueeditor image width 100% adaptive, mobile terminal
QT ListView 列表显示组件笔记
IaaS基础架构云 —— 云网络