SRE第八周作业

目录

1. redis搭建哨兵原理和集群实现。

1.1哨兵原理

1.2搭建哨兵原理

1.3redis集群功能实现

2. LVS常用模型工作原理,及实现。

3. LVS的负载策略有哪些,各应用在什么场景,通过LVS DR任意实现1-2种场景。

3.1 负载策略

4. web http协议通信过程,相关技术术语总结。

5. 总结网络IO模型和nginx架构。

网络I/O

I/O介绍

I/O模型

同步阻塞IO模型

同步非阻塞IO模型

IO多路复用模型

信号驱动IO模型

异步IO(非阻塞)模型

I/O模型对比

I/O模型实现方式

Nginx架构

6. nginx总结核心配置和优化。

Nginx核心配置

第一部分:全局块

第二部分:events 块

第三部分:http 块

全局 server 块

location 块

Nginx优化实战

7 使用脚本完成一键编译安装nginx任意版本。 

8. 任意编译一个第3方nginx模块,并使用。


完成作业:
1. redis搭建哨兵原理和集群实现。
2. LVS常用模型工作原理,及实现。
3. LVS的负载策略有哪些,各应用在什么场景,通过LVS DR任意实现1-2种场景。
4. web http协议通信过程,相关技术术语总结。
5. 总结网络IO模型和nginx架构。
6. nginx总结核心配置和优化。
7. 使用脚本完成一键编译安装nginx任意版本。
8. 任意编译一个第3方nginx模块,并使用。

1. redis搭建哨兵原理和集群实现。

1.1哨兵原理

哨兵,英文名 Sentinel,是一个分布式系统,用于对主从结构中的每一台服务器进行监控,当主节点出现故障后通过投票机制来挑选新的主节点,并且将所有的从节点连接到新的主节点上。

哨兵的三个作用:

监控:监控谁?支持主从结构的工作一个是主节点一个是从节点,那肯定就是监控这俩个了。监控主节点和从节点是否正常运行;检测主节点是否存活,主节点和从节点运行情况。

通知:哨兵检测的服务器出现问题时,会向其他的哨兵发送通知,哨兵之间就相当于一个微信群,每个哨兵发现的问题都会发在这个群里。

自动转移故障:当检测到主节点宕机后,断开与宕机主节点连接的所有从节点,在从节点中选取一个作为主节点,然后将其他的从节点连接到这个最新主节点的上。并且告知客户端最新的服务器地址。这里有一个注意点,哨兵也是一台 Redis 服务器,只是不对外提供任何服务。配置哨兵时配置为单数。

1.2搭建哨兵原理

#准备:哨兵配置文件默认存放位置:
/usr/local/src/redis-6.2.6/sentinel.conf
cp /usr/local/src/redis-6.2.6/sentinel.conf /apps/redis/etc/
chown redis. /apps/redis/etc/*#修改sentinel配置文件

vim /apps/redis/etc/sentinel.conf
# protected-mode no
bind 0.0.0.0

# port <sentinel-port>
# The port that this sentinel instance will run on
port 26379

# By default Redis Sentinel does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis-sentinel.pid when
# daemonized.
daemonize no

# When running daemonized, Redis Sentinel writes a pid file in
# /var/run/redis-sentinel.pid by default. You can specify a custom pid file
# location here.
pidfile /var/run/redis-sentinel.pid

# Specify the log file name. Also the empty string can be used to force
# Sentinel to log on the standard output. Note that if you use standard
# output for logging but daemonize, logs will be sent to /dev/null
logfile "/apps/redis/log/sentinel.log"

# Note: master name should not include special characters or spaces.
# The valid charset is A-z 0-9 and the three characters ".-_".
sentinel monitor mymaster 192.168.72.142 6379 2
sentinel auth-pass mymaster 123456

# Default is 30 seconds.
sentinel down-after-milliseconds mymaster 3000


chown redis. /apps/redis/etc/*

#把主节点修改好的哨兵配置文件带属性复制到另外两台从节点上

[root@Rocky8 ~]# ll /apps/redis/etc
total 108
-rw-r--r-- 1 redis redis 93834 Nov 30 21:48 redis.conf
-rw-r--r-- 1 redis redis 13768 Nov 30 21:51 sentinel.conf

[root@Rocky8 ~]# rsync -a /apps/redis/etc/sentinel.conf 192.168.72.151:/apps/redis/etc/
[root@Rocky8 ~]# rsync -a /apps/redis/etc/sentinel.conf 192.168.72.155:/apps/redis/etc/

#三台机器分别在前台启动哨兵

[root@Rocky8 ~]#/apps/redis/bin/redis-sentinel /apps/redis/etc/sentinel.conf

验证启动后自动改动的哨兵配置文件vim /apps/redis/etc/sentinel.conf

#主节点验证
# Generated by CONFIG REWRITE
protected-mode no
user default on nopass ~* &* +@all
sentinel myid 3285e24f38bec229c1ae6f6e7c9040b67633e313
sentinel config-epoch mymaster 0
sentinel leader-epoch mymaster 0
sentinel current-epoch 0
sentinel known-replica mymaster 192.168.72.151 6379
sentinel known-replica mymaster 192.168.72.155 6379

#第一个从节点验证:

# Generated by CONFIG REWRITE
protected-mode no
user default on nopass ~* &* +@all
sentinel myid 9bd9b2a20176cdba2c102071710e9da821e18051
sentinel config-epoch mymaster 0
sentinel leader-epoch mymaster 0
sentinel current-epoch 0
sentinel known-replica mymaster 192.168.72.151 6379
sentinel known-replica mymaster 192.168.72.155 6379
sentinel known-sentinel mymaster 192.168.72.142 26379 3285e24f38bec229c1ae6f6e7c9040b67633e313

#第二个从节点验证:

# Generated by CONFIG REWRITE
protected-mode no
user default on nopass ~* &* +@all
sentinel myid d398f9beb74e52d518bf9fdf021a4c660ba369a6
sentinel config-epoch mymaster 0
sentinel leader-epoch mymaster 0
sentinel current-epoch 0
sentinel known-replica mymaster 192.168.72.155 6379
sentinel known-replica mymaster 192.168.72.151 6379
sentinel known-sentinel mymaster 192.168.72.142 26379 3285e24f38bec229c1ae6f6e7c9040b67633e313
sentinel known-sentinel mymaster 192.168.72.151 26379 9bd9b2a20176cdba2c102071710e9da821e18051

注:此处生成的三台服务器的sentinel myid 必须唯一,否则就是失败

#三台服务器一起创建service服务文件

[root@Rocky8 ~]# cat /lib/systemd/system/redis-sentinel.service
cat: /lib/systemd/system/redis-sentinel.service: No such file or directory
[root@Rocky8 ~]# vim /lib/systemd/system/redis-sentinel.service
[Unit]
Description=Redis Sentinel
After=network.target
[Service]
ExecStart=/apps/redis/bin/redis-sentinel /apps/redis/etc/sentinel.conf --supervised systemd
ExecStop=/bin/kill -s QUIT $MAINPID
User=redis
Group=redis
RuntimeDirectory=redis
RuntimeDirectoryMode=0755
[Install]
WantedBy=multi-user.target

#修改文件属性,把创建好的service文件复制到另外两台节点上

[root@Rocky8 ~]# chown -R redis.redis /apps/redis/
[root@Rocky8 ~]# scp /lib/systemd/system/redis-sentinel.service 192.168.72.151:/lib/systemd/system
root@192.168.72.151's password: 
redis-sentinel.service                                                                                        100%  303   266.0KB/s   00:00    
[root@Rocky8 ~]# scp /lib/systemd/system/redis-sentinel.service 192.168.72.155:/lib/systemd/system
root@192.168.72.155's password: 
redis-sentinel.service   

#三台服务器都设置为开机自启动且立即启动

[root@Rocky8 ~]# systemctl enable --now redis-sentinel.service
#进行端口验证
[root@Rocky8 ~]# ss -ntl
State           Recv-Q           Send-Q                     Local Address:Port                      Peer Address:Port          Process          
LISTEN          1                511                              0.0.0.0:26379                          0.0.0.0:*                              
LISTEN          0                511                              0.0.0.0:6379                           0.0.0.0:*                              
LISTEN          0                128                              0.0.0.0:22                             0.0.0.0:*                              
LISTEN          0                244                              0.0.0.0:5432                           0.0.0.0:*                              
LISTEN          0                128                                    *:9090                                 *:*                              
LISTEN          0                511                                [::1]:6379                              [::]:*                              
LISTEN          0                128                                 [::]:22                                [::]:*                              

#登陆sentinel的专用端口验证:

[root@Rocky8 ~]# redis-cli -p 26379
127.0.0.1:26379> info
# Sentinel
sentinel_masters:1
sentinel_tilt:0
sentinel_running_scripts:0
sentinel_scripts_queue_length:0
sentinel_simulate_failure_flags:0
master0:name=mymaster,status=ok,address=192.168.72.142:6379,slaves=2,sentinels=3

#通过日志验证

[root@Rocky8 ~]# cat /apps/redis/log/sentinel.log
2356:X 30 Nov 2022 22:32:17.122 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
2356:X 30 Nov 2022 22:32:17.122 # Redis version=6.2.6, bits=64, commit=00000000, modified=0, pid=2356, just started
2356:X 30 Nov 2022 22:32:17.122 # Configuration loaded
2356:X 30 Nov 2022 22:32:17.142 * Increased maximum number of open files to 10032 (it was originally set to 1024).
2356:X 30 Nov 2022 22:32:17.142 * monotonic clock: POSIX clock_gettime
2356:X 30 Nov 2022 22:32:17.208 * Running mode=sentinel, port=26379.
2356:X 30 Nov 2022 22:32:17.678 # Sentinel ID is 3285e24f38bec229c1ae6f6e7c9040b67633e313
2356:X 30 Nov 2022 22:32:17.678 # +monitor master mymaster 192.168.72.142 6379 quorum 2
2356:X 30 Nov 2022 22:32:18.019 * +slave slave 192.168.72.151:6379 192.168.72.151 6379 @ mymaster 192.168.72.142 6379
2356:X 30 Nov 2022 22:32:18.035 * +slave slave 192.168.72.155:6379 192.168.72.155 6379 @ mymaster 192.168.72.142 6379
2356:X 30 Nov 2022 22:33:19.935 # +tilt #tilt mode entered
2356:X 30 Nov 2022 22:33:50.010 # -tilt #tilt mode exited
2356:X 30 Nov 2022 22:38:43.490 * +sentinel sentinel 9bd9b2a20176cdba2c102071710e9da821e18051 192.168.72.151 26379 @ mymaster 192.168.72.142 6379
2356:X 30 Nov 2022 22:40:26.216 * +sentinel sentinel d398f9beb74e52d518bf9fdf021a4c660ba369a6 192.168.72.155 26379 @ mymaster 192.168.72.142 6379

#停掉主节点142服务器后,哨兵投票自动随机决定了155成为新的主节点,而151和被停掉的142服务器已变为新的从节点。

[root@Rocky8 ~]# tail -f /apps/redis/log/sentinel.log
1694:X 01 Dec 2022 22:35:31.239 # +sdown master mymaster 192.168.72.142 6379
1694:X 01 Dec 2022 22:35:31.328 # +new-epoch 1
1694:X 01 Dec 2022 22:35:31.332 # +vote-for-leader 3285e24f38bec229c1ae6f6e7c9040b67633e313 1
1694:X 01 Dec 2022 22:35:32.305 # +odown master mymaster 192.168.72.142 6379 #quorum 3/2
1694:X 01 Dec 2022 22:35:32.306 # Next failover delay: I will not start a failover before Thu Dec  1 22:41:31 2022
1694:X 01 Dec 2022 22:35:32.442 # +config-update-from sentinel 3285e24f38bec229c1ae6f6e7c9040b67633e313 192.168.72.142 26379 @ mymaster 192.168.72.142 6379
1694:X 01 Dec 2022 22:35:32.442 # +switch-master mymaster 192.168.72.142 6379 192.168.72.155 6379
1694:X 01 Dec 2022 22:35:32.442 * +slave slave 192.168.72.151:6379 192.168.72.151 6379 @ mymaster 192.168.72.155 6379
1694:X 01 Dec 2022 22:35:32.442 * +slave slave 192.168.72.142:6379 192.168.72.142 6379 @ mymaster 192.168.72.155 6379
1694:X 01 Dec 2022 22:35:35.475 # +sdown slave 192.168.72.142:6379 192.168.72.142 6379 @ mymaster 192.168.72.155 6379

#手动让主节点下线
[root@centos8 ~]#vim /etc/redis.conf
replica-priority 10 #指定优先级,值越小sentinel会优先将之选为新的master,默为值为100
[root@centos8 ~]#systemctl restart redis
127.0.0.1:26379> sentinel failover <masterName>

1.3redis集群功能实现

#可以用一条sed命令修改下列6项redis配置文件以实现cluster功能

敲入命令

sed -i.bak -e '/masterauth/a masterauth 123456' -e '/# cluster-enabled yes/a cluster-enabled yes' -e '/# cluster-config-filenodes-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

#开启cluster集群后重启redis服务

[root@Rocky8 ~]# systemctl restart redis
[root@Rocky8 ~]# ss -ntl
State          Recv-Q         Send-Q                  Local Address:Port                    Peer Address:Port         Process         
LISTEN         0              511                           0.0.0.0:6379                         0.0.0.0:*                            
LISTEN         0              128                           0.0.0.0:22                           0.0.0.0:*                            
LISTEN         0              244                           0.0.0.0:5432                         0.0.0.0:*                            
LISTEN         0              511                           0.0.0.0:16379                        0.0.0.0:*                            
LISTEN         0              128                                 *:9090                               *:*                            
LISTEN         0              511                             [::1]:6379                            [::]:*                            
LISTEN         0              128                              [::]:22                              [::]:*                            
LISTEN         0              511                             [::1]:16379                           [::]:*     

#在6台服务器中的任意一台输入创建集群的命令(注:开启集群前要确保所有节点redis的数据为空且互相没有主从复制关系或哨兵服务关系,有的话则必须清除掉配置文件里相关的复制关系)
redis-cli -a 123456 --cluster create 192.168.72.142:6379 192.168.72.151:6379 192.168.72.155:6379 192.168.72.152:6379 192.168.72.153:6379 192.168.72.150:6379 --cluster-replicas 1
#具体执行验证结果如下

[root@Rocky8 ~]# ls /apps/redis/data/
nodes-6379.conf
[root@Rocky8 ~]# redis-cli -a 123456 --cluster create 192.168.72.142:6379 192.168.72.151:6379 192.168.72.155:6379 192.168.72.152:6379 192.168.72.153:6379 192.168.72.150:6379 --cluster-replicas 1
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
>>> Performing hash slots allocation on 6 nodes...
Master[0] -> Slots 0 - 5460
Master[1] -> Slots 5461 - 10922
Master[2] -> Slots 10923 - 16383
Adding replica 192.168.72.150:6379 to 192.168.72.142:6379
Adding replica 192.168.72.153:6379 to 192.168.72.151:6379
Adding replica 192.168.72.152:6379 to 192.168.72.155:6379
M: 1c10f642637b8e997fca9c1e8f9e73699bc60b15 192.168.72.142:6379
   slots:[0-5460] (5461 slots) master
M: accd85afbe7c1d9bded991f045703974a1931ad4 192.168.72.151:6379
   slots:[5461-10922] (5462 slots) master
M: ddbc2de4bc11c18ac85b024b17f6f5812e9d0c13 192.168.72.155:6379
   slots:[10923-16383] (5461 slots) master
S: b86eced539971413958b34d4e320556d2482f4bd 192.168.72.152:6379
   replicates ddbc2de4bc11c18ac85b024b17f6f5812e9d0c13
S: cb965245d3d9836de27b483dd861b24c8969aae2 192.168.72.150:6379
   replicates 1c10f642637b8e997fca9c1e8f9e73699bc60b15
S: c200aab6263548b949a44bb1754a461c7038b418 192.168.72.153:6379
   replicates accd85afbe7c1d9bded991f045703974a1931ad4
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.72.142:6379)
M: 1c10f642637b8e997fca9c1e8f9e73699bc60b15 192.168.72.142:6379
   slots:[0-5460] (5461 slots) master
   1 additional replica(s)
M: accd85afbe7c1d9bded991f045703974a1931ad4 192.168.72.151:6379
   slots:[5461-10922] (5462 slots) master
   1 additional replica(s)
S: b86eced539971413958b34d4e320556d2482f4bd 192.168.72.152:6379
   slots: (0 slots) slave
   replicates ddbc2de4bc11c18ac85b024b17f6f5812e9d0c13
S: c200aab6263548b949a44bb1754a461c7038b418 192.168.72.153:6379
   slots: (0 slots) slave
   replicates accd85afbe7c1d9bded991f045703974a1931ad4
S: cb965245d3d9836de27b483dd861b24c8969aae2 192.168.72.150:6379
   slots: (0 slots) slave
   replicates 1c10f642637b8e997fca9c1e8f9e73699bc60b15
M: ddbc2de4bc11c18ac85b024b17f6f5812e9d0c13 192.168.72.155:6379
   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.

#查看cluster集群主从节点关系的命令

[root@Rocky8 ~]# cat /apps/redis/data/nodes-6379.conf
b86eced539971413958b34d4e320556d2482f4bd 192.168.72.152:6379@16379 slave ddbc2de4bc11c18ac85b024b17f6f5812e9d0c13 0 1670085679813 10 connected
c200aab6263548b949a44bb1754a461c7038b418 192.168.72.153:6379@16379 slave accd85afbe7c1d9bded991f045703974a1931ad4 0 1670085678000 2 connected
cb965245d3d9836de27b483dd861b24c8969aae2 192.168.72.150:6379@16379 myself,slave 1c10f642637b8e997fca9c1e8f9e73699bc60b15 0 1670085678000 1 connected
accd85afbe7c1d9bded991f045703974a1931ad4 192.168.72.151:6379@16379 master - 0 1670085679224 2 connected 5461-10922
ddbc2de4bc11c18ac85b024b17f6f5812e9d0c13 192.168.72.155:6379@16379 master - 0 1670085677000 10 connected 10923-16383
1c10f642637b8e997fca9c1e8f9e73699bc60b15 192.168.72.142:6379@16379 master - 0 1670085678217 1 connected 0-5460
vars currentEpoch 10 lastVoteEpoch 0

[root@Rocky8 ~]# redis-cli -a 123456 -c INFO replication

[root@Rocky8 ~]# redis-cli -a 123456 cluster nodes
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
b86eced539971413958b34d4e320556d2482f4bd 192.168.72.152:6379@16379 slave,fail ddbc2de4bc11c18ac85b024b17f6f5812e9d0c13 1670085453518 1670085453333 10 connected
c200aab6263548b949a44bb1754a461c7038b418 192.168.72.153:6379@16379 slave,fail accd85afbe7c1d9bded991f045703974a1931ad4 1670085453518 1670085453333 2 connected
cb965245d3d9836de27b483dd861b24c8969aae2 192.168.72.150:6379@16379 myself,slave 1c10f642637b8e997fca9c1e8f9e73699bc60b15 0 1670085620000 1 connected
accd85afbe7c1d9bded991f045703974a1931ad4 192.168.72.151:6379@16379 master - 0 1670085622876 2 connected 5461-10922
ddbc2de4bc11c18ac85b024b17f6f5812e9d0c13 192.168.72.155:6379@16379 master - 0 1670085621871 10 connected 10923-16383
1c10f642637b8e997fca9c1e8f9e73699bc60b15 192.168.72.142:6379@16379 master - 0 1670085619000 1 connected 0-5460

#扩容:添加一个节点到集群中

[root@Rocky8 ~]# redis-cli -a 123456 --cluster add-node 192.168.72.157:6379 192.168.72.151:6379
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
>>> Adding node 192.168.72.157:6379 to cluster 192.168.72.151:6379
>>> Performing Cluster Check (using node 192.168.72.151:6379)
M: accd85afbe7c1d9bded991f045703974a1931ad4 192.168.72.151:6379
   slots:[5461-10922] (5462 slots) master
   1 additional replica(s)
S: cb965245d3d9836de27b483dd861b24c8969aae2 192.168.72.150:6379
   slots: (0 slots) slave
   replicates 1c10f642637b8e997fca9c1e8f9e73699bc60b15
M: ddbc2de4bc11c18ac85b024b17f6f5812e9d0c13 192.168.72.155:6379
   slots:[10923-16383] (5461 slots) master
   1 additional replica(s)
S: b86eced539971413958b34d4e320556d2482f4bd 192.168.72.152:6379
   slots: (0 slots) slave
   replicates ddbc2de4bc11c18ac85b024b17f6f5812e9d0c13
S: c200aab6263548b949a44bb1754a461c7038b418 192.168.72.153:6379
   slots: (0 slots) slave
   replicates accd85afbe7c1d9bded991f045703974a1931ad4
M: 1c10f642637b8e997fca9c1e8f9e73699bc60b15 192.168.72.142:6379
   slots:[0-5460] (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.
>>> Send CLUSTER MEET to node 192.168.72.157:6379 to make it join the cluster.
[OK] New node added correctly.

#在另一台服务器192.168.72.150上确认新添加节点之后的集群状态

[root@Rocky8 ~]# redis-cli -a 123456 --cluster info 192.168.72.150:6379
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
192.168.72.155:6379 (ddbc2de4...) -> 0 keys | 5461 slots | 1 slaves.
192.168.72.151:6379 (accd85af...) -> 0 keys | 5462 slots | 1 slaves.
192.168.72.157:6379 (480577a4...) -> 0 keys | 0 slots | 0 slaves.
192.168.72.142:6379 (1c10f642...) -> 0 keys | 5461 slots | 1 slaves.
[OK] 0 keys in 4 masters.
0.00 keys per slot on average.
[root@Rocky8 ~]# 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:7
cluster_size:3
cluster_current_epoch:10
cluster_my_epoch:1
cluster_stats_messages_ping_sent:2564
cluster_stats_messages_pong_sent:2444
cluster_stats_messages_sent:5008
cluster_stats_messages_ping_received:2444
cluster_stats_messages_pong_received:2564
cluster_stats_messages_received:5008

#在新的master上重新分配槽位
(注:重新分配槽位需要清空数据,所以需要先备份数据,扩展后再恢复数据)

[root@Rocky8 ~]#redis-cli -a 123456 --cluster reshard 192.168.72.157:6379
Warning: Using a password with '-a' or '-u' option on the command line interface
may not be safe.
>>> Performing Cluster Check (using node 192.168.72.157:6379)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
How many slots do you want to move (from 1 to 16384)?4096          #新分配多少个槽位
=16384/master个数
What is the receiving node ID? d6e2eca6b338b717923f64866bd31d42e52edc98    #新的master的ID
Please enter all the source node IDs.
Type 'all' to use all the nodes as source nodes for the hash slots.
Type 'done' once you entered all the source nodes IDs.
Source node #1: all                       #输入all,将哪些源主机的槽位分配给新的节点,all是自动在所有的redis
node选择划分,如果是从redis cluster删除某个主机可以使用此方式将指定主机上的槽位全部移动到别的
redis主机
......
Do you want to proceed with the proposed reshard plan (yes/no)? yes     #确认分配 
Moving slot 317 from 192.168.72.142:6379 to 192.168.72.157:6379: 
Moving slot 318 from 192.168.72.142:6379 to 192.168.72.157:6379: 
Moving slot 319 from 192.168.72.142:6379 to 192.168.72.157:6379: 
Moving slot 320 from 192.168.72.142:6379 to 192.168.72.157:6379: 
Moving slot 321 from 192.168.72.142:6379 to 192.168.72.157:6379: 
Moving slot 322 from 192.168.72.142:6379 to 192.168.72.157:6379: 
Moving slot 323 from 192.168.72.142:6379 to 192.168.72.157:6379: 
Moving slot 324 from 192.168.72.142:6379 to 192.168.72.157:6379: 
Moving slot 325 from 192.168.72.142:6379 to 192.168.72.157:6379: 
.......

#确认slot分配成功

[root@Rocky8 ~]# redis-cli -a 123456 cluster nodes
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
ddbc2de4bc11c18ac85b024b17f6f5812e9d0c13 192.168.72.155:6379@16379 master - 0 1670133312733 10 connected 12288-16383
accd85afbe7c1d9bded991f045703974a1931ad4 192.168.72.151:6379@16379 master - 0 1670133314745 2 connected 6827-10922
1c10f642637b8e997fca9c1e8f9e73699bc60b15 192.168.72.142:6379@16379 master - 0 1670133315000 1 connected 1365-5460
480577a4e5260efab5cadd4216cdec30125a5a88 192.168.72.157:6379@16379 master - 0 1670133315750 11 connected 0-1364 5461-6826 10923-12287
b86eced539971413958b34d4e320556d2482f4bd 192.168.72.152:6379@16379 myself,slave ddbc2de4bc11c18ac85b024b17f6f5812e9d0c13 0 1670133311000 10 connected
cb965245d3d9836de27b483dd861b24c8969aae2 192.168.72.150:6379@16379 slave 1c10f642637b8e997fca9c1e8f9e73699bc60b15 0 1670133313739 1 connected
c200aab6263548b949a44bb1754a461c7038b418 192.168.72.153:6379@16379 slave accd85afbe7c1d9bded991f045703974a1931ad4 0 1670133314000 2 connected

#再新加一个节点到集群中并同时设置它为192.168.72.157的从节点,这样话目前构建好的此集群中两两相配,刚好形成了4主4从的格局

[root@Rocky8 ~]# redis-cli -a 12345
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值