当前位置:网站首页>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"
边栏推荐
- 用秩讨论线性方程组的解/三个平面的位置关系
- Test framework unittest skip test
- 3D语义分割——PVD
- 异常处理机制专题1
- easyui datagrid控件使用
- IAAs infrastructure cloud cloud network
- Bo Yun container cloud and Devops platform won the trusted cloud "technology best practice Award"
- 方正期货网上开户靠谱吗,开户安全吗?
- Ilssi certification | the course of Six Sigma DMAIC
- 第四章:操作符
猜你喜欢

Replicate swin on Huawei ascend910_ transformer
![[mathematical modeling and drawing series tutorial] II. Drawing and optimization of line chart](/img/73/2b6fe0cf69fa013894abce331e1386.png)
[mathematical modeling and drawing series tutorial] II. Drawing and optimization of line chart

Outlook 教程,如何在 Outlook 中搜索日历项?

【目标检测】YOLOv5跑通VOC2007数据集(修复版)

Jenkins' file parameters can be used to upload files

3D 语义分割——Scribble-Supervised LiDAR Semantic Segmentation

Multi tenant software development architecture

Fudan University EMBA peer topic: always put the value of consumers in the most important position

中国芯片自给率大幅提升,导致外国芯片库存高企而损失惨重,美国芯片可谓捧起石头砸自己的脚...

Hcip notes 11 days
随机推荐
In the eyes of 100 users, there are 100 QQS
Jenkins' role based authorization strategy installation configuration
Don't believe these "rumors" in the process of preparing for the exam!
How to delete Microsoft Pinyin input method in win10
微信公众号开发之消息的自动回复
MySQL view
win10设备管理认不到GTX1080Ti 显示设备的解决办法
win10如何删除微软拼音输入法
链游开发现成版 链游系统开发详细原理 链游源码交付
Unity is better to use the hot scheme Wolong
What are the free low code development platforms?
Test framework unittest command line operation and assertion method
2022年最新北京建筑施工焊工(建筑特种作业)模拟题库及答案解析
异常处理机制专题1
【小5聊】公众号排查<该公众号提供的服务出现故障,请稍后>
7.依赖注入
2022 latest Beijing Construction welder (construction special operation) simulation question bank and answer analysis
C # introductory basic tutorial
从数字化到智能运维:有哪些价值,又有哪些挑战?
Fastadmin TP installation uses Baidu rich text editor ueeditor