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.mzph.cn/web/61075.shtml

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

相关文章

探索Python WebSocket新境界:picows库揭秘

文章目录 探索Python WebSocket新境界&#xff1a;picows库揭秘第一部分&#xff1a;背景介绍第二部分&#xff1a;picows库概述第三部分&#xff1a;安装picows库第四部分&#xff1a;简单库函数使用方法第五部分&#xff1a;场景应用第六部分&#xff1a;常见Bug及解决方案第…

dmdba用户资源限制ulimit -a 部分配置未生效

dmdba用户资源限制ulimit -a 部分配置未生效 1 环境介绍2 数据库实例日志报错2.1 mpp01 实例日志报错2.2 mpp02 实例日志报错 3 mpp02 服务器资源限制情况4 关闭SELinux 问题解决4.1 临时关闭 SELinux4.2 永久关闭 SELinux 5 达梦数据库学习使用列表 1 环境介绍 Cpu x86 Os Ce…

安卓悬浮窗应用外无法穿透事件问题

现象&#xff1a; 应用内悬浮窗如何设置了 WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE在自己应用内事件穿透正常&#xff0c;但到应用外就无法点击。 原因&#xff1a; 解决方法&#xff1a; layoutParams.alpha 0.8f …

c++趣味编程玩转物联网:基于树莓派Pico控制有源蜂鸣器

有源蜂鸣器是一种简单高效的声音输出设备&#xff0c;广泛应用于电子报警器、玩具、计时器等领域。在本项目中&#xff0c;我们结合树莓派Pico开发板&#xff0c;通过C代码控制有源蜂鸣器发出“滴滴”声&#xff0c;并解析其中涉及的关键技术点和硬件知识。 一、项目概述 1. 项…

ubuntu+ROS推视频流至网络

目录 概述 工具 ros_rtsp 接受流 web_video_server 源码安装 二进制安装 ros接收rtsp视频流 总结 概述 ros_rtsp功能包可以将ros视频流以rtsp形式推送 web_video_server功能包可以将ros视频话题推HTTP流 rocon_rtsp_camera_relay可以接受同一网段下的rtsp视频流输出为…

探索光耦:光耦安全标准解读——确保设备隔离与安全的重要规范

在现代科技日新月异的今天&#xff0c;光耦&#xff08;光电耦合器&#xff09;作为电子设备中不可或缺的隔离元件&#xff0c;其重要性不言而喻。它不仅在电源调控、工业自动化及医疗设备等关键领域大显身手&#xff0c;更是确保系统电气隔离与运行稳定的守护神。特别是在保障…

Qt程序发布及打包成exe安装包

参考:Qt之程序发布以及打包成exe安装包 目录 一、简述 Qt 项目开发完成之后,需要打包发布程序,而因为用户电脑上没有 Qt 配置环境,所以需要将 release 生成的 exe 文件和所依赖的 dll 文件复制到一个文件夹中,然后再用 Inno Setup 打包工具打包成一个 exe 安装包,就可以…

JAVA题目笔记(二十)异常综合小练

一、键盘录入数据 import java.text.ParseException; import java.util.InputMismatchException; import java.util.Scanner;public class Co {public static void main(String[] args) throws ParseException {//键盘录入信息int age0;String namenull;Scanner sc new Scanne…

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…

shell脚本基础学习_总结篇(完结)

细致观看可以&#xff0c;访问shell脚本学习专栏&#xff0c;对应章节会有配图https://blog.csdn.net/2201_75446043/category_12833287.html?spm1001.2014.3001.5482 导语 一、shell脚本简介 1. 定义&#xff1a; 2. 主要特点&#xff1a; 3. shell脚本的基本结构 4. S…

Linux创建免密登陆(错误:Permission denied (publickey,gssapi-keyex,gssapi-with-mic))

报错截图 解决方法 1. mkdir -p ~/.ssh 2. chmod 700 ~/.ssh 3. ssh-keygen&#xff0c;一直回车 4. chmod 600 /root/.ssh/id_rsa 5. 将公钥内容追加到服务器上&#xff0c;cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys 6. chmod 600 ~/.ssh/authorized_keys…

低代码平台在医疗/医院行业应用案例与优势介绍

随着医疗行业的不断发展&#xff0c;数字化管理的需求日益迫切。传统的医疗信息化管理系统开发往往面临着成本高、周期长、定制性差等问题。在这个数字化转型的浪潮下&#xff0c;低代码平台应运而生&#xff0c;为医院快速搭建高效、灵活的医疗信息化管理系统提供了全新的解决…

在 Spring Boot 中构造 API 响应的最佳实践

在平时的开发和项目中&#xff0c;我们一定会涉及到接口对接的功能&#xff0c;由于不同开发人员的编码习惯不同&#xff0c;API报文在项目中通常是"百花齐放"的。 不但增加工作难度&#xff0c;往往也是扯皮的大头&#xff0c;如果能统一报文格式&#xff0c;不但能…

多目标优化算法——多目标粒子群优化算法(MOPSO)

Handling Multiple Objectives With Particle Swarm Optimization&#xff08;多目标粒子群优化算法&#xff09; 一、摘要&#xff1a; 本文提出了一种将帕累托优势引入粒子群优化算法的方法&#xff0c;使该算法能够处理具有多个目标函数的问题。与目前其他将粒子群算法扩展…

OpenCV与AI深度学习|16个含源码和数据集的计算机视觉实战项目(建议收藏!)

本文来源公众号“OpenCV与AI深度学习”&#xff0c;仅用于学术分享&#xff0c;侵权删&#xff0c;干货满满。 原文链接&#xff1a;分享&#xff5c;16个含源码和数据集的计算机视觉实战项目 本文将分享16个含源码和数据集的计算机视觉实战项目。具体包括&#xff1a; 1. 人…

Jenkins升级到最新版本后无法启动

1. 场景还原 最近在web界面将jenkins升级到最新版本后&#xff0c;后台无法启动jenkins服务&#xff0c;服务状态如下&#xff1a; 运行jenkins命令提示invalid Java version jenkins --version jenkins: invalid Java version: java version "1.8.0_202" Java(TM)…

【计算机视觉+MATLAB】自动检测并可视化圆形目标:通过 imfindcircles 和 viscircles 函数

引言 自动检测图像中的圆形或圆形对象&#xff0c;并可视化检测到的圆形。 函数详解 imfindcircles imfindcircles是MATLAB中的一个函数&#xff0c;用于在图像中检测并找出圆形区域。 基本语法&#xff1a; [centers, radii] imfindcircles(A, radiusRange) [centers, r…

鸿蒙NEXT元服务:利用App Linking实现无缝跳转与二维码拉起

【效果】 元服务链接格式&#xff08;API>12适用&#xff09;&#xff1a;https://hoas.drcn.agconnect.link/ggMRM 生成二维码后效果&#xff1a; 【参考网址】 使用App Linking实现元服务跳转&#xff1a;文档中心 草料二维码&#xff1a;草料二维码生成器 【引言】 …

下载安装Android Studio

&#xff08;一&#xff09;Android Studio下载地址 https://developer.android.google.cn/studio 滑动到 点击下载文档 打开新网页 切换到english ![](https://i-blog.csdnimg.cn/direct/b7052b434f9d4418b9d56c66cdd59fae.png 等待一会&#xff0c;出现 点同意后&#xff0…

【C/C++】深入解析 Stack 与 Queue 数据结构(详解):实现原理、应用场景与性能优化

文章目录 引言栈&#xff08;Stack&#xff09;数据结构详解1. 栈的基本概念2. 栈的实现原理3. C中的栈实现4. 栈的应用场景5. 栈的性能分析6. 实战示例&#xff1a;括号匹配 队列&#xff08;Queue&#xff09;数据结构详解1. 队列的基本概念2. 队列的实现原理3. C中的队列实现…