当前位置:网站首页>Build a master-slave mode cluster redis
Build a master-slave mode cluster redis
2022-07-02 19:33:00 【Charmaine Xia】
Install stand alone reids Detailed tutorial :https://blog.csdn.net/CharmaineXia/article/details/125297843?spm=1001.2014.3001.5502
A master node (master) There can be multiple slave nodes (slave), A slave node can only have one master node .
Each station redis By default, they are the primary node , So only the slave is configured , Do not configure the host .
Build a master-slave cluster
All three servers are installed redis, First configure the configuration file of a slave , Then copy the configuration file to other slaves .
Method 1. The configuration file configures the slave ( permanent , Restart and take effect )
① Edit the slave configuration file
vi /home/admin/redis/redis-5.0.7/theRedisConf/redis.conf
add master Of IP Or host and port number
replicaof 192.168.xxx.xxx 6379
After configuration, restart and take effect .
Method 2. Command configuration slave ( Immediate effect , but redis The service fails when it is restarted )
① Progress client , View current library information
redis-cli -p 6379 Or enter src perform ./redis-cli -p 6379
info replication
127.0.0.1:6379> info replication
# Replication
role:master # The role is master
connected_slaves:0 # No slave
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
② Set the master node of the slave
SLAVEOF The host IP 6379
View the library information after setting
info replication
# View from the machine
127.0.0.1:6379> info replication
# Replication
role:slave # The role becomes a slave
master_host:192.168.60.83 # The host IP Address
master_port:6379 # In the host redis Port number
master_link_status:down
# View... In the host
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
After the three sets are configured :
Start in turn redis service , Start the master node first , After starting the slave node .
cd /
./usr/local/bin/redis-server /home/admin/redis/redis-5.0.7/theRedisConf/redis.conf
The principle of master-slave replication :
边栏推荐
猜你喜欢
教程篇(5.0) 09. RESTful API * FortiEDR * Fortinet 网络安全专家 NSE 5
Reading notes of "the way to clean structure" (Part 2)
End-to-End Object Detection with Transformers(DETR)论文阅读与理解
搭建主从模式集群redis
Compile oglpg-9th-edition source code with clion
PHP-Parser羽毛球预约小程序开发require线上系统
Web2.0的巨头纷纷布局VC,Tiger DAO VC或成抵达Web3捷径
Chic Lang: completely solve the problem of markdown pictures - no need to upload pictures - no need to network - there is no lack of pictures forwarded to others
Windows2008R2 安装 PHP7.4.30 必须 LocalSystem 启动应用程序池 不然500错误 FastCGI 进程意外退出
云呐|为什么要用固定资产管理系统,怎么启用固定资产管理系统
随机推荐
Markdown basic grammar
AcWing 383. 观光 题解(最短路)
AcWing 1137. Select the best line solution (the shortest circuit)
Registration opportunity of autowiredannotationbeanpostprocessor in XML development mode
机器学习笔记 - 时间序列预测研究:法国香槟的月销量
Golang并发编程——goroutine、channel、sync
Use cheat engine to modify money, life and stars in Kingdom rush
MySQL表历史数据清理总结
AcWing 341. 最优贸易 题解 (最短路、dp)
Yolov3 trains its own data set to generate train txt
AcWing 383. Sightseeing problem solution (shortest circuit)
Qpropertyanimation use and toast case list in QT
Tutorial (5.0) 10 Troubleshooting * fortiedr * Fortinet network security expert NSE 5
LeetCode 0871. Minimum refueling times - similar to poj2431 jungle adventure
Advanced performance test series "24. Execute SQL script through JDBC"
横向越权与纵向越权[通俗易懂]
高级性能测试系列《24. 通过jdbc执行sql脚本》
《重构:改善既有代码的设计》读书笔记(下)
虚拟机初始化脚本, 虚拟机相互免秘钥
Implementation of 452 strcpy, strcat, StrCmp, strstr, strchr