redis-cluster集群搭建

集群节点信息

192.168.222.131:46379 主要节点1
192.168.222.131:46380 从节点1
192.168.222.131:46381 从节点2192.168.222.132:46379 主要节点2
192.168.222.132:46380 从节点1
192.168.222.132:46381 从节点2192.168.222.133:46379 主要节点3
192.168.222.133:46380 从节点1
192.168.222.133:46381 从节点2

集群节点配置

集群主节点配置
[root@localhost redis]# cat redis-46379.conf 
port 46379
cluster-enabled yes
cluster-config-file nodes-46379.conf
cluster-node-timeout 5000
requirepass F3EE4Dk44ddDSLKL
masterauth F3EE4Dk44ddDSLKL
#protected-mode no
daemonize yes
appendonly yes
appendfilename "appendonly.aof"
dbfilename dump-46379.rdb
dir /data/redis/46379
logfile /data/redis/46379/redis.log
集群从节点1 配置
[root@localhost redis]# cat redis-46380.conf 
port 46380
cluster-enabled yes
cluster-config-file nodes-46380.conf
cluster-node-timeout 5000
requirepass F3EE4Dk44ddDSLKL
masterauth F3EE4Dk44ddDSLKL
#protected-mode no
daemonize yes
appendonly yes
appendfilename "appendonly.aof"
dbfilename dump-46380.rdb
dir /data/redis/46380
logfile /data/redis/46380/redis.log
集群从节点2 配置
[root@localhost redis]# cat redis-46381.conf 
port 46381
cluster-enabled yes
cluster-config-file nodes-46381.conf
cluster-node-timeout 5000
requirepass F3EE4Dk44ddDSLKL
masterauth F3EE4Dk44ddDSLKL
#protected-mode no
daemonize yes
appendonly yes
appendfilename "appendonly.aof"
dbfilename dump-46381.rdb
dir /data/redis/46381
logfile /data/redis/46381/redis.log

节点启动命令

/data/redis/redis-stack-server-7.2.0-v8/bin/redis-server /data/redis/redis-46379.conf
/data/redis/redis-stack-server-7.2.0-v8/bin/redis-server /data/redis/redis-46380.conf
/data/redis/redis-stack-server-7.2.0-v8/bin/redis-server /data/redis/redis-46381.conf

节点停止命令

/data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -p 46379 -a F3EE4Dk44ddDSLKL shutdown
/data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -p 46380 -a F3EE4Dk44ddDSLKL shutdown
/data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -p 46381 -a F3EE4Dk44ddDSLKL shutdown

集群构建

/data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL --cluster create \
192.168.222.131:46379 192.168.222.131:46380 192.168.222.131:46381 \
192.168.222.132:46379 192.168.222.132:46380 192.168.222.132:46381 \
192.168.222.133:46379 192.168.222.133:46380 192.168.222.133:46381 --cluster-replicas 2

检查集群节点信息

[root@localhost ~]# /data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL -p 46379 -h 192.168.222.131 CLUSTER NODES
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
a2b16bfa39fafe9b536ac6c952ae2dec58a8e35e 192.168.222.133:46379@56379 master - 0 1732698781824 7 connected 10923-16383
c6927c5de96959a24d04defe1227ca338089219e 192.168.222.131:46379@56379 myself,master - 0 1732698781000 1 connected 0-5460
964f27d3abd421ce99d6814cbc33f7efc3bd473d 192.168.222.132:46379@56379 master - 0 1732698779513 4 connected 5461-10922
4870524e9a47506996015387ea67e6491dd3adac 192.168.222.131:46380@56380 slave a2b16bfa39fafe9b536ac6c952ae2dec58a8e35e 0 1732698781522 7 connected
4891c05297daa8e310ac616d159b444d54ba7b51 192.168.222.132:46381@56381 slave a2b16bfa39fafe9b536ac6c952ae2dec58a8e35e 0 1732698780517 7 connected
0b88544c661dafef8f79c5204a5f6d7a8abde20b 192.168.222.133:46380@56380 slave c6927c5de96959a24d04defe1227ca338089219e 0 1732698780819 1 connected
bf5549f442b6c096efda3c97472813fdfd1338f3 192.168.222.132:46380@56380 slave c6927c5de96959a24d04defe1227ca338089219e 0 1732698780000 1 connected
b4e716e733cfbe3b61130981fe479f9b38ba2f1e 192.168.222.131:46381@56381 slave 964f27d3abd421ce99d6814cbc33f7efc3bd473d 0 1732698780517 4 connected
504cbbeb8a73512127a1566ac91f846145b11a58 192.168.222.133:46381@56381 slave 964f27d3abd421ce99d6814cbc33f7efc3bd473d 0 1732698781000 4 connected

数据写入测试

# cat write-data-redis.py 
from rediscluster import RedisCluster
# 启动节点列表
startup_nodes = [{"host": "192.168.222.131", "port": "46379"}]
# 创建集群连接
rc = RedisCluster(startup_nodes=startup_nodes, decode_responses=True, password='F3EE4Dk44ddDSLKL')
# 写入数据
for i in range(100):# 例如,写入的数据data_size_kb = 1data = 'kjasjkldfjalsdflasdflasdfjllkasjdflasf' * (data_size_kb * 1024 * 1024)  rc.set(f'key:{i}', data)print(f'Written key:{i} with {data_size_kb}KB of data')
print("Data written.")# python3 write-data-redis.py

主机内存查看

[root@localhost ~]# free -htotal        used        free      shared  buff/cache   available
Mem:           7.8G        2.2G        5.5G         11M        120M        5.4G
Swap:          3.6G          0B        3.6G

节点信息查询

# 连接集群
/data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL -c  -p 46379 -h 192.168.222.131# 监控redis服务器的性能
/data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL -p 46379 -h 192.168.222.131 --stat# 获取服务器的统计信息
/data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL -p 46379 -h 192.168.222.131 INFO# 检查集群状态
/data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL -p 46379 -h 192.168.222.131 CLUSTER INFO# 检查集群节点信息
/data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL -p 46379 -h 192.168.222.131 CLUSTER NODES

新添加集群节点信息

192.168.222.134:46379
192.168.222.134:46380
192.168.222.134:46381192.168.222.135:46379
192.168.222.135:46380
192.168.222.135:46381192.168.222.136:46379
192.168.222.136:46380
192.168.222.136:46381

添加新节点到集群

  1. 将新节点加入集群
# 添加主节点
/data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL --cluster add-node 192.168.222.134:46379 192.168.222.131:46379
# 查询主节点id
[root@localhost ~]# /data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL -p 46379 -h 192.168.222.131 CLUSTER  NODES |grep 134
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
7e4645f509d071be565d53f7167464456f869094 192.168.222.134:46379@56379 master - 0 1732699138000 0 connected
# 添加从节点
/data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL --cluster add-node 192.168.222.134:46380 192.168.222.131:46379 --cluster-slave --cluster-master-id 7e4645f509d071be565d53f7167464456f869094
/data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL --cluster add-node 192.168.222.134:46381 192.168.222.131:46379 --cluster-slave --cluster-master-id 7e4645f509d071be565d53f7167464456f869094# 添加主节点
/data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL --cluster add-node 192.168.222.135:46379 192.168.222.131:46379
# 查询主节点id
[root@localhost ~]# /data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL -p 46379 -h 192.168.222.131 CLUSTER  NODES |grep 135
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
68520244e77a3a69122816496f5c9773b50e5277 192.168.222.135:46379@56379 master - 0 1732699237110 11 connected
# 添加从节点
/data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL --cluster add-node 192.168.222.135:46380 192.168.222.131:46379 --cluster-slave --cluster-master-id  68520244e77a3a69122816496f5c9773b50e5277
/data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL --cluster add-node 192.168.222.135:46381 192.168.222.131:46379 --cluster-slave --cluster-master-id  68520244e77a3a69122816496f5c9773b50e5277# 添加主节点
/data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL --cluster add-node 192.168.222.136:46379 192.168.222.131:46379
# 查询主节点id
[root@localhost ~]# /data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL -p 46379 -h 192.168.222.131 CLUSTER  NODES |grep 136
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
fa79672847de00a6590a0ebb2ee7d93b5ca11c82 192.168.222.136:46379@56379 master - 0 1732699305971 0 connected
# 添加从节点
/data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL --cluster add-node 192.168.222.136:46380 192.168.222.131:46379 --cluster-slave --cluster-master-id fa79672847de00a6590a0ebb2ee7d93b5ca11c82
/data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL --cluster add-node 192.168.222.136:46381 192.168.222.131:46379 --cluster-slave --cluster-master-id fa79672847de00a6590a0ebb2ee7d93b5ca11c82

检查集群节点信息

[root@localhost ~]# /data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL -p 46379 -h 192.168.222.131 CLUSTER  NODES 
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
849bcb37b280614a2314a989114f204546f17d7d 192.168.222.134:46380@56380 slave 7e4645f509d071be565d53f7167464456f869094 0 1732699378000 12 connected
fa79672847de00a6590a0ebb2ee7d93b5ca11c82 192.168.222.136:46379@56379 master - 0 1732699377568 0 connected
c530f5086b3c5da80e3d8351d5572880f74a8761 192.168.222.136:46380@56380 slave fa79672847de00a6590a0ebb2ee7d93b5ca11c82 0 1732699377000 0 connected
bf534fe091be5239c268d0aa90a4fb937c493f72 192.168.222.136:46381@56381 slave fa79672847de00a6590a0ebb2ee7d93b5ca11c82 0 1732699377000 0 connected
964f27d3abd421ce99d6814cbc33f7efc3bd473d 192.168.222.132:46379@56379 master - 0 1732699378071 4 connected 5461-10922
bbb3838d05683746ff5a848a0b4ef08fee49c1fb 192.168.222.135:46381@56381 slave 68520244e77a3a69122816496f5c9773b50e5277 0 1732699377065 11 connected
4ea5c56c01a07f9cec7d6ba2c7b7e3b2a0743642 192.168.222.134:46381@56381 slave 7e4645f509d071be565d53f7167464456f869094 0 1732699377000 12 connected
bf5549f442b6c096efda3c97472813fdfd1338f3 192.168.222.132:46380@56380 slave c6927c5de96959a24d04defe1227ca338089219e 0 1732699378372 1 connected
68520244e77a3a69122816496f5c9773b50e5277 192.168.222.135:46379@56379 master - 0 1732699378000 11 connected
a2b16bfa39fafe9b536ac6c952ae2dec58a8e35e 192.168.222.133:46379@56379 master - 0 1732699377568 7 connected 10923-16383
c6927c5de96959a24d04defe1227ca338089219e 192.168.222.131:46379@56379 myself,master - 0 1732699377000 1 connected 0-5460
4891c05297daa8e310ac616d159b444d54ba7b51 192.168.222.132:46381@56381 slave a2b16bfa39fafe9b536ac6c952ae2dec58a8e35e 0 1732699378575 7 connected
4870524e9a47506996015387ea67e6491dd3adac 192.168.222.131:46380@56380 slave a2b16bfa39fafe9b536ac6c952ae2dec58a8e35e 0 1732699378574 7 connected
0b88544c661dafef8f79c5204a5f6d7a8abde20b 192.168.222.133:46380@56380 slave c6927c5de96959a24d04defe1227ca338089219e 0 1732699377568 1 connected
7e4645f509d071be565d53f7167464456f869094 192.168.222.134:46379@56379 master - 0 1732699378575 12 connected
b4e716e733cfbe3b61130981fe479f9b38ba2f1e 192.168.222.131:46381@56381 slave 964f27d3abd421ce99d6814cbc33f7efc3bd473d 0 1732699377366 4 connected
504cbbeb8a73512127a1566ac91f846145b11a58 192.168.222.133:46381@56381 slave 964f27d3abd421ce99d6814cbc33f7efc3bd473d 0 1732699377568 4 connected
9343f98f07ee8a0f442bdfd5197ee13c40e5e203 192.168.222.135:46380@56380 slave 68520244e77a3a69122816496f5c9773b50e5277 0 1732699378575 11 connected

槽位重新分配

a2b16bfa39fafe9b536ac6c952ae2dec58a8e35e 192.168.222.133:46379@56379 master - 0 1732699377568 7 connected 10923-16383
一共是0-16383 个槽位,平均分布在3个节点上,我现在需要平局分布在6个节点上,每个节点大概是2730个槽位,也可以把现有主节点槽位移动一半到没有槽位的主节点上
迁移到哪里去
7e4645f509d071be565d53f7167464456f869094 192.168.222.134:46379@56379 master - 0 1732699378575 12 connected
68520244e77a3a69122816496f5c9773b50e5277 192.168.222.135:46379@56379 master - 0 1732699378000 11 connected
fa79672847de00a6590a0ebb2ee7d93b5ca11c82 192.168.222.136:46379@56379 master - 0 1732699377568 0 connected从哪里迁移
c6927c5de96959a24d04defe1227ca338089219e 192.168.222.131:46379@56379 myself,master - 0 1732699377000 1 connected 0-5460
964f27d3abd421ce99d6814cbc33f7efc3bd473d 192.168.222.132:46379@56379 master - 0 1732699378071 4 connected 5461-10922
a2b16bfa39fafe9b536ac6c952ae2dec58a8e35e 192.168.222.133:46379@56379 master - 0 1732699377568 7 connected 10923-16383迁移的命令
/data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL --cluster reshard 192.168.222.131:46379
/data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL --cluster reshard 192.168.222.132:46379
/data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL --cluster reshard 192.168.222.133:46379fa79672847de00a6590a0ebb2ee7d93b5ca11c82 192.168.222.136:46379@56379 master - 0 1732700418532 0 connected
b4e716e733cfbe3b61130981fe479f9b38ba2f1e 192.168.222.131:46381@56381 master - 0 1732700419538 19 connected 5461-10922

槽位置迁移示范

[root@localhost ~]# /data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL --cluster reshard 192.168.222.131:46379
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.222.131:46379)
M: c6927c5de96959a24d04defe1227ca338089219e 192.168.222.131:46379slots:[0-5460] (5461 slots) master2 additional replica(s)
...........
[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)? 2730
What is the receiving node ID? 7e4645f509d071be565d53f7167464456f869094
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: c6927c5de96959a24d04defe1227ca338089219e
Source node #2: done
...........
Moving slot 2729 from c6927c5de96959a24d04defe1227ca338089219e
Do you want to proceed with the proposed reshard plan (yes/no)? yes
...........
Moving slot 2729 from 192.168.222.131:46379 to 192.168.222.134:46379:

检查集群节点信息

# 迁移完成
[root@localhost ~]# /data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL -p 46379 -h 192.168.222.131 CLUSTER  NODES 
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
849bcb37b280614a2314a989114f204546f17d7d 192.168.222.134:46380@56380 slave 7e4645f509d071be565d53f7167464456f869094 0 1732700757000 25 connected
fa79672847de00a6590a0ebb2ee7d93b5ca11c82 192.168.222.136:46379@56379 master - 0 1732700756000 27 connected 5461-8190
c530f5086b3c5da80e3d8351d5572880f74a8761 192.168.222.136:46380@56380 slave fa79672847de00a6590a0ebb2ee7d93b5ca11c82 0 1732700757583 27 connected
bf534fe091be5239c268d0aa90a4fb937c493f72 192.168.222.136:46381@56381 slave fa79672847de00a6590a0ebb2ee7d93b5ca11c82 0 1732700758085 27 connected
964f27d3abd421ce99d6814cbc33f7efc3bd473d 192.168.222.132:46379@56379 slave b4e716e733cfbe3b61130981fe479f9b38ba2f1e 0 1732700757482 19 connected
bbb3838d05683746ff5a848a0b4ef08fee49c1fb 192.168.222.135:46381@56381 slave 68520244e77a3a69122816496f5c9773b50e5277 0 1732700757000 26 connected
4ea5c56c01a07f9cec7d6ba2c7b7e3b2a0743642 192.168.222.134:46381@56381 slave 7e4645f509d071be565d53f7167464456f869094 0 1732700756000 25 connected
bf5549f442b6c096efda3c97472813fdfd1338f3 192.168.222.132:46380@56380 slave c6927c5de96959a24d04defe1227ca338089219e 0 1732700757583 1 connected
68520244e77a3a69122816496f5c9773b50e5277 192.168.222.135:46379@56379 master - 0 1732700756476 26 connected 10923-13652
a2b16bfa39fafe9b536ac6c952ae2dec58a8e35e 192.168.222.133:46379@56379 slave 4870524e9a47506996015387ea67e6491dd3adac 0 1732700758085 17 connected
c6927c5de96959a24d04defe1227ca338089219e 192.168.222.131:46379@56379 myself,master - 0 1732700757000 1 connected 2730-5460
4891c05297daa8e310ac616d159b444d54ba7b51 192.168.222.132:46381@56381 slave 4870524e9a47506996015387ea67e6491dd3adac 0 1732700758085 17 connected
4870524e9a47506996015387ea67e6491dd3adac 192.168.222.131:46380@56380 master - 0 1732700757079 17 connected 13653-16383
0b88544c661dafef8f79c5204a5f6d7a8abde20b 192.168.222.133:46380@56380 slave c6927c5de96959a24d04defe1227ca338089219e 0 1732700756000 1 connected
7e4645f509d071be565d53f7167464456f869094 192.168.222.134:46379@56379 master - 0 1732700756000 25 connected 0-2729
b4e716e733cfbe3b61130981fe479f9b38ba2f1e 192.168.222.131:46381@56381 master - 0 1732700758085 19 connected 8191-10922
504cbbeb8a73512127a1566ac91f846145b11a58 192.168.222.133:46381@56381 slave b4e716e733cfbe3b61130981fe479f9b38ba2f1e 0 1732700757000 19 connected
9343f98f07ee8a0f442bdfd5197ee13c40e5e203 192.168.222.135:46380@56380 slave 68520244e77a3a69122816496f5c9773b50e5277 0 1732700756000 26 connected

查看节点内存使用信息

# 原先节点
[root@localhost ~]# free -htotal        used        free      shared  buff/cache   available
Mem:           7.8G        1.2G        6.5G         11M        121M        6.4G
Swap:          3.6G          0B        3.6G# 新增节点
[root@localhost ~]# free -htotal        used        free      shared  buff/cache   available
Mem:           7.8G        1.2G        6.5G         11M        112M        6.4G
Swap:          3.6G          0B        3.6G

集群各种操作命令

# 连接集群
/data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL -c  -p 46379 -h 192.168.222.131# 维护集群
# 监控命令:
# 监控redis服务器的性能
/data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL -p 46379 -h 192.168.222.131 --stat# 获取服务器的统计信息
/data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL -p 46379 -h 192.168.222.131 INFO# 检查集群状态和节点信息
/data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL -p 46379 -h 192.168.222.131 CLUSTER INFO
/data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL -p 46379 -h 192.168.222.131 CLUSTER NODES# 动态配置修改命令:
/data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL -p 46379 -h 192.168.222.131 CONFIG SET <配置项> <># 扩展集群(添加新节点):
/data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL --cluster add-node <新节点IP>:<新节点端口> <已存在节点IP>:<已存在节点端口># 缩减集群(删除节点):
/data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL --cluster del-node <已存在节点IP>:<已存在节点端口> <节点ID>
/data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL --cluster del-node 192.168.222.134:46379 05ddef40e900862d61ea895568dc0b65b562eb99
/data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL --cluster del-node 192.168.222.134:46380 1f02da1cd8339ae877f50ab7b24a46b2de0a4c2d
/data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL --cluster del-node 192.168.222.134:46381 eb0eb008856d63c7ae7671f70050939aac36a64f# 故障恢复
# 手动干预修复集群:
/data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL --cluster fix <任意节点IP>:<任意节点端口># 备份(在每个节点上执行):
/data/redis/redis-stack-server-7.2.0-v8/bin/redis-cli -a F3EE4Dk44ddDSLKL -p 46379 -h 192.168.222.131 BGSAVE# 恢复(假设你有一个 RDB 快照文件):
# 恢复通常涉及将 RDB 文件复制到 Redis 数据目录并重启 Redis 服务。确保在恢复之前关闭 Redis 服务。
cp /path/to/your/backup.rdb /var/lib/redis/dump.rdb
/data/redis/bin/redis-server /etc/redis/redis.conf查看日志:
Redis 日志文件的位置根据你的安装和配置可能不同,但通常你可以这样查看:
tail -f /var/log/redis/redis-server.log

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/479919.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

elasticsearch的索引模版使用方法

5 索引模版⭐️⭐️⭐️⭐️⭐️ 索引模板就是创建索引时要遵循的模板规则索引模板仅对新创建的索引有效&#xff0c;已经创建的索引并不受索引模板的影响 5.1 索引模版的基本使用 1.查看所有的索引模板 GET 10.0.0.91:9200/_index_template2.创建自定义索引模板 xixi &…

英语知识网站开发:Spring Boot框架应用

3系统分析 3.1可行性分析 通过对本英语知识应用网站实行的目的初步调查和分析&#xff0c;提出可行性方案并对其一一进行论证。我们在这里主要从技术可行性、经济可行性、操作可行性等方面进行分析。 3.1.1技术可行性 本英语知识应用网站采用SSM框架&#xff0c;JAVA作为开发语…

Linux自动化构建-make/Makefile

目录 1. 背景2. 基本使用3. 推导过程4. 好用的操作5. 拓展语法 1. 背景 会不会写makefile&#xff0c;从⼀个侧⾯说明了⼀个⼈是否具备完成⼤型⼯程的能⼒⼀个⼯程中的源⽂件不计数&#xff0c;其按类型、功能、模块分别放在若⼲个⽬录中&#xff0c;makefile定义了⼀系列的规…

Ubuntu20.04+ROS 进行机械臂抓取仿真:环境搭建(一)

目录 一、从官网上下载UR机械臂 二、给UR机械臂添加夹爪 三、报错解决 本文详细介绍如何在Ubuntu20.04ROS环境中为Universal Robots的UR机械臂添加夹爪。首先从官方和第三方源下载必要的软件包&#xff0c;包括UR机械臂驱动、夹爪插件和相关依赖。然后&#xff0c;针对gazeb…

C++11(下)

C11&#xff08;下&#xff09; 1.条件变量2.包装器&#xff08;重要&#xff09;3.bind &#x1f31f;&#x1f31f;hello&#xff0c;各位读者大大们你们好呀&#x1f31f;&#x1f31f; &#x1f680;&#x1f680;系列专栏&#xff1a;【C的学习】 &#x1f4dd;&#x1f4…

【组件封装】uniapp vue3 封装一个自定义下拉刷新组件pullRefresh,带刷新时间和加载动画教程

文章目录 前言一、实现原理二、组件样式和功能设计三、scroll-view 自定义下拉刷新使用回顾相关属性&#xff1a;最终版完整代码&#xff1a; 前言 手把手教你封装一个移动端 自定义下拉刷新组件带更新时间和加载动画&#xff08;PullRefresh&#xff09;&#xff0c;以uniapp …

14、保存与加载PyTorch训练的模型和超参数

文章目录 1. state_dict2. 模型保存3. check_point4. 详细保存5. Docker6. 机器学习常用库 1. state_dict nn.Module 类是所有神经网络构建的基类&#xff0c;即自己构建一个深度神经网络也是需要继承自nn.Module类才行&#xff0c;并且nn.Module中的state_dict包含神经网络中…

【Threejs进阶教程-着色器篇】9.顶点着色器入门

【Threejs进阶教程-着色器篇】9.顶点着色器入门 本系列教程第一篇地址&#xff0c;建议按顺序学习认识顶点着色器varying介绍顶点着色器与片元着色器分别的作用Threejs在Shader中的内置变量各种矩阵gl_Position 尝试使用顶点着色器增加分段数增强效果 制作平面鼓包效果鼓包效果…

w058基于web的美发门店管理系统

&#x1f64a;作者简介&#xff1a;拥有多年开发工作经验&#xff0c;分享技术代码帮助学生学习&#xff0c;独立完成自己的项目或者毕业设计。 代码可以查看文章末尾⬇️联系方式获取&#xff0c;记得注明来意哦~&#x1f339;赠送计算机毕业设计600个选题excel文件&#xff0…

leetcode 二叉树的最大深度

104. 二叉树的最大深度 已解答 简单 相关标签 相关企业 给定一个二叉树 root &#xff0c;返回其最大深度。 二叉树的 最大深度 是指从根节点到最远叶子节点的最长路径上的节点数。 示例 1&#xff1a; 输入&#xff1a;root [3,9,20,null,null,15,7] 输出&#xff1a;3…

VMware ubuntu创建共享文件夹与Windows互传文件

1.如图1所示&#xff0c;点击虚拟机&#xff0c;点击设置&#xff1b; 图1 2.如图2所示&#xff0c;点击选项&#xff0c;点击共享文件夹&#xff0c;如图3所示&#xff0c;点击总是启用&#xff0c;点击添加&#xff1b; 图2 图3 3.如图4所示&#xff0c;出现命名共享文件夹…

matlab 实现混沌麻雀搜索算法的光伏MPPT控制仿真

1、内容简介 略 103-可以交流、咨询、答疑 2、内容说明 略 3、仿真分析 略 4、参考论文 略

Unity3D 截图

使用 Unity3D 自带的截图接口&#xff0c;制作截图工具。 截图 有时候我们想对 Unity 的窗口进行截图&#xff0c;如果直接使用一些截图工具&#xff0c;很难截取到一张完整分辨率的图片&#xff08;例如&#xff0c;我们想要截取一张 1920 * 1080 的图片&#xff09;。 其实…

STM32F10x 定时器

使用定时器实现&#xff1a;B5 E5的开关 添加相关的.h路径文件 添加相关的.c配置文件 led.h文件 用于声明LED函数 #ifndef __LED_H //没有定义__LED_H #define __LED_H //就定义__LED_H #define LED1_ON GPIO_ResetBits(GPIOB,GPIO_Pin_5) #defi…

PMP好考吗,有多大的价值?

非常好考&#xff01;PMP目前大陆地区的笔试是只有选择题的&#xff0c;运气好的话 蒙一个都能对&#xff0c;所以PMP的通过率高&#xff0c;这也是很多人考了吐槽PMP没用&#xff0c;是“水证”&#xff0c;但是每年考PMP 的人不减反增&#xff0c;大家可以想一下&#xff0c;…

css:项目

这是一个完整的网站制作的流程 美工会先制作一个原型图&#xff1a; 原型图写的不详细&#xff0c;就是体现一个网页大致的布局 然后美工再做一个psd样例图片 然后再交给程序员 项目 模块化开发&#xff1a;把代码的不同的样式封装起来&#xff0c;需要用到相同样式的标签就…

VsCode 插件推荐(个人常用)

VsCode 插件推荐&#xff08;个人常用&#xff09;

黑马程序员Java项目实战《苍穹外卖》Day01

苍穹外卖-day01 课程内容 软件开发整体介绍苍穹外卖项目介绍开发环境搭建导入接口文档Swagger 项目整体效果展示&#xff1a; ​ 管理端-外卖商家使用 ​ 用户端-点餐用户使用 当我们完成该项目的学习&#xff0c;可以培养以下能力&#xff1a; 1. 软件开发整体介绍 作为一…

Python双向链表、循环链表、栈

一、双向链表 1.作用 双向链表也叫双面链表。 对于单向链表而言。只能通过头节点或者第一个节点出发&#xff0c;单向的访问后继节点&#xff0c;每个节点只能记录其后继节点的信息&#xff08;位置&#xff09;&#xff0c;不能向前遍历。 所以引入双向链表&#xff0c;双…

k8s网络服务

k8s 中向外界提供服务的几种方法port-forward、NodePort&#xff0c;以及 更加常用的提供服务的资源ingress。 1 kubectl port-forward service/redis 6379:6379 现在k8s中有一个pod运行在6379&#xff0c;本机访问映射到6379上&#xff0c;它可以针对部署&#xff0c;服务&…