当前位置:网站首页>搭建主从模式集群redis
搭建主从模式集群redis
2022-07-02 18:23:00 【夏诗曼CharmaineXia】
安装单机reids详细教程:https://blog.csdn.net/CharmaineXia/article/details/125297843?spm=1001.2014.3001.5502
一个主节点(master)可以有多个从节点(slave),一个从节点只能有一个主节点。
每台redis都默认自己是主节点,所以只配置从机,不用配置主机。
搭建一主二从集群
三台服务器都装好redis,先配置好一台从机的配置文件,然后把配置文件复制到其他从机即可。
方法1.配置文件配置从机(永久,重启生效)
①编辑从机配置文件
vi /home/admin/redis/redis-5.0.7/theRedisConf/redis.conf
添加上master的IP或主机及端口号
replicaof 192.168.xxx.xxx 6379
配置完重启生效。
方法2.命令配置从机(即时生效,但redis服务重启就失效了)
①进度客户端,查看当前库信息
redis-cli -p 6379 或者进到src下执行 ./redis-cli -p 6379
info replication
127.0.0.1:6379> info replication
# Replication
role:master #角色是master
connected_slaves:0 # 没有从机
master_replid:04caec4cc89fb5a3e5515c90f91d4e4922fe6e6b
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:0
second_repl_offset:-1
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
②设置从机的主节点
SLAVEOF 主机的IP 6379
查看设置以后的库信息
info replication
#从机中查看
127.0.0.1:6379> info replication
# Replication
role:slave #角色变成了从机
master_host:192.168.60.83 #主机的IP地址
master_port:6379 #主机中redis的端口号
master_link_status:down
#在主机中查看
127.0.0.1:6379> info replication
# Replication
role:master
connected_slaves:2
slave0:ip=192.168.60.84,port=6379,state=online,offset=14,lag=0
slave1:ip=192.168.60.85,port=6379,state=online,offset=14,lag=1
master_replid:8e296970ccfa0ebd6dff8416e1d21d8f892d0dab
三台配置完成后:
依次启动redis服务,先启动主节点,后启动从节点。
cd /
./usr/local/bin/redis-server /home/admin/redis/redis-5.0.7/theRedisConf/redis.conf
主从复制的原理:

边栏推荐
- Processing strategy of message queue message loss and repeated message sending
- metric_logger小解
- 【ERP软件】ERP体系二次开发有哪些危险?
- Which video recording software is better for the computer
- Machine learning notes - time series prediction research: monthly sales of French champagne
- ORA-01455: converting column overflows integer datatype
- Watchful pioneer world outlook Architecture - (how does a good game come from)
- [test development] software testing - concept
- The difference between interceptor and filter
- Masa framework - DDD design (1)
猜你喜欢

MySQL advanced learning summary 8: overview of InnoDB data storage structure page, internal structure of page, row format

Tutorial (5.0) 09 Restful API * fortiedr * Fortinet network security expert NSE 5

Compile oglpg-9th-edition source code with clion

高级性能测试系列《24. 通过jdbc执行sql脚本》

Windows2008R2 安装 PHP7.4.30 必须 LocalSystem 启动应用程序池 不然500错误 FastCGI 进程意外退出
![[0701] [paper reading] allowing data imbalance issue with perforated input during influence](/img/c7/9b7dc4b4bda4ecfe07aec1367fe059.png)
[0701] [paper reading] allowing data imbalance issue with perforated input during influence
![[论文阅读] CA-Net: Leveraging Contextual Features for Lung Cancer Prediction](/img/ef/bb48ee88d5dc6fe876a498ab53106e.png)
[论文阅读] CA-Net: Leveraging Contextual Features for Lung Cancer Prediction

中国信通院《数据安全产品与服务图谱》,美创科技实现四大板块全覆盖

教程篇(5.0) 10. 故障排除 * FortiEDR * Fortinet 网络安全专家 NSE 5

Why should we build an enterprise fixed asset management system and how can enterprises strengthen fixed asset management
随机推荐
ICDE 2023|TKDE Poster Session(CFP)
【测试开发】一文带你了解什么是软件测试
SIFT feature point extraction "suggestions collection"
论文导读 | 机器学习在数据库基数估计中的应用
Gamefi chain game system development (NFT chain game development function) NFT chain game system development (gamefi chain game development source code)
Gamefi链游系统开发(NFT链游开发功能)丨NFT链游系统开发(Gamefi链游开发源码)
《代码整洁之道》读书笔记
A4988 drive stepper motor "recommended collection"
End-to-End Object Detection with Transformers(DETR)论文阅读与理解
C的内存管理
Juypter notebook modify the default open folder and default browser
Kubernetes three open interfaces first sight
ORA-01455: converting column overflows integer datatype
Notes de lecture sur le code propre
《代碼整潔之道》讀書筆記
数字滚动带动画
MySQL advanced learning summary 8: overview of InnoDB data storage structure page, internal structure of page, row format
What is 9D movie like? (+ common sense of dimension space)
移动机器人路径规划:人工势场法[通俗易懂]
Web2.0的巨头纷纷布局VC,Tiger DAO VC或成抵达Web3捷径