当前位置:网站首页>搭建主从模式集群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
主从复制的原理:

边栏推荐
- C的内存管理
- Gamefi链游系统开发(NFT链游开发功能)丨NFT链游系统开发(Gamefi链游开发源码)
- MySQL
- Reduce -- traverse element calculation. The specific calculation formula needs to be passed in and combined with BigDecimal
- Which video recording software is better for the computer
- 线程应用实例
- metric_ Logger urination
- [0701] [paper reading] allowing data imbalance issue with perforated input during influence
- Gmapping code analysis [easy to understand]
- Quanzhi A33 uses mainline u-boot
猜你喜欢
![[paper reading] Ca net: leveraging contextual features for lung cancer prediction](/img/ef/bb48ee88d5dc6fe876a498ab53106e.png)
[paper reading] Ca net: leveraging contextual features for lung cancer prediction
![[error record] problems related to the installation of the shuttle environment (follow-up error handling after executing the shuttle doctor command)](/img/c1/a00425f2e1824a50644c8fbb15fe38.jpg)
[error record] problems related to the installation of the shuttle environment (follow-up error handling after executing the shuttle doctor command)

According to the atlas of data security products and services issued by the China Academy of information technology, meichuang technology has achieved full coverage of four major sectors

Processing strategy of message queue message loss and repeated message sending

xml开发方式下AutowiredAnnotationBeanPostProcessor的注册时机

新手必看,點擊兩個按鈕切換至不同的內容

juypter notebook 修改默认打开文件夹以及默认浏览器

仿京东放大镜效果(pink老师版)

PHP parser badminton reservation applet development requires online system

论文导读 | 机器学习在数据库基数估计中的应用
随机推荐
以太网PHY层芯片LAN8720A简介
MySQL表历史数据清理总结
Thread application instance
使用CLion编译OGLPG-9th-Edition源码
End to end object detection with transformers (Detr) paper reading and understanding
Imitation Jingdong magnifying glass effect (pink teacher version)
What is the MySQL backup suffix_ MySQL backup restore
Golang concurrent programming goroutine, channel, sync
Develop fixed asset management system, what voice is used to develop fixed asset management system
横向越权与纵向越权[通俗易懂]
《病人家属,请来一下》读书笔记
[test development] software testing - concept
End-to-End Object Detection with Transformers(DETR)论文阅读与理解
为什么要做企业固定资产管理系统,企业如何加强固定资产管理
When converting from list to map, if a certain attribute may cause key duplication and exceptions, you can set the way to deal with this duplication
SIFT feature point extraction "suggestions collection"
Golang:[]byte to string
NPOI导出Excel2007
2022.7.1-----leetcode.241
C的内存管理