網站首頁 編程語言 正文
redis版本:redis-2.8.19.tar.gz
架構:2個節點
節點1: 10.10.10.10
節點2: 10.10.10.20
節點1部署redis實例,角色master,部署sentinel實例,監控redis-master節點
節點2部署redis實例,角色slave ,部署sentinel實例,監控redis-master節點
一.配置redis主從
節點1:redis-master配置
1.編譯安裝redis
Copy安裝文件到/usr目錄下:
tar zxvf redis-2.8.19.tar.gz
cd redis-2.8.19
Make
2.更改redis.conf配置文件
daemonize no 改為 yes #后臺運行
節點2:redis-slave配置
1.編譯安裝redis
Copy安裝文件到/usr目錄下:
tar zxvf redis-2.8.19.tar.gz
cd redis-2.8.19
Make
2.更改redis.conf配置文件
daemonize no 改為 yes #后臺運行
slaveof 10.10.10.10 6379 #指向master服務器IP、端口
啟動redis-master
# src/redis-server -p 6379 redis.conf -h 10.10.10.10
啟動redis-slave
# src/redis-server -p 6379 redis.conf -h 10.10.10.20
查看redis-master運行信息
# src/redis-cli -h 10.10.10.10 -p 6379 info replication
# Replication
role:master
connected_slaves:1
slave0:ip=10.10.10.20,port=6379,state=online,offset=69298006,lag=0
master_repl_offset:69298143
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:68249568
repl_backlog_histlen:1048576
查看redis-slave運行信息
# src/redis-cli -h 10.10.10.20 -p 6379 info replication
# Replication
role:slave
master_host:10.10.10.10
master_port:6379
master_link_status:up
master_last_io_seconds_ago:0
master_sync_in_progress:0
slave_repl_offset:69302158
slave_priority:100
slave_read_only:1
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
測試主從復制
redis-master
# src/redis-cli -p 6379 -h 10.10.10.10
10.10.10.10:6379> set name 123
OK
10.10.10.10:6379> get name "123"
Redis-slave
# src/redis-cli -p 6379 -h 10.10.10.20
10.10.10.20:6379> get name "123"
二.配置sentinel哨兵模式
1.配置sentinel.conf配置文件
2個sentinel實例配置相同mastername mymaster
port 26379
sentinel monitor mymaster 10.10.10.10 6379 1
啟動redis-master上的sentinel
src/redis-sentinel sentinel.conf -h 10.10.10.10 &
啟動redis-slave上的sentinel
src/redis-sentinel sentinel.conf -h 10.10.10.20 &
查看redis-master上的sentinel運行信息,端口不可省略
# src/redis-cli ?-h 10.10.10.10 -p 26379 info sentinel
# Sentinel
sentinel_masters:1
sentinel_tilt:0
sentinel_running_scripts:0
sentinel_scripts_queue_length:0
master0:name=mymaster,status=ok,address=10.10.10.10:6379,slaves=1,sentinels=2
查看redis-slave上的sentinel運行信息,端口不可省略
# src/redis-cli ?-h 10.10.10.20 -p 26379 info sentinel
# Sentinel
sentinel_masters:1
sentinel_tilt:0
sentinel_running_scripts:0
sentinel_scripts_queue_length:0
master0:name=mymaster,status=ok,address=10.10.10.10:6379,slaves=1,sentinels=2?
2.驗證sentinel切換主從
# src/redis-cli ?-h 10.10.10.10 shutdown
查看redis-master上的sentinel運行信息
# src/redis-cli ?-h 10.10.10.10 -p 26379 info sentinel
# Sentinel
sentinel_masters:1
sentinel_tilt:0
sentinel_running_scripts:0
sentinel_scripts_queue_length:0
master0:name=mymaster,status=ok,address=10.10.10.20:6379,slaves=1,sentinels=2?
查看redis-slave上的sentinel運行信息
?# # src/redis-cli ?-h 10.10.10.20 -p 26379 info sentinel
# Sentinel
sentinel_masters:1
sentinel_tilt:0
sentinel_running_scripts:0
sentinel_scripts_queue_length:0
master0:name=mymaster,status=ok,address=10.10.10.20:6379,slaves=1,sentinels=2
原文鏈接:https://blog.csdn.net/weixin_49889731/article/details/125688679
相關推薦
- 2022-07-25 通過底層源碼理解YOLOv5的Backbone_python
- 2023-12-23 mybatis的selectOne()方法使用記錄
- 2022-10-29 Spring的純注解配置詳解
- 2022-04-03 C#字符串內存駐留機制分析_C#教程
- 2022-10-17 android中px、sp與dp之間進行轉換詳解_Android
- 2023-03-29 Android?Flutter中Offstage組件的使用教程詳解_Android
- 2022-11-08 go語言Pflag?Viper?Cobra?核心功能使用介紹_Golang
- 2023-10-30 解決SpringBoot3整合Druid的兼容性問題
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支