網(wǎng)站首頁 編程語言 正文
redis版本:redis-2.8.19.tar.gz
架構(gòu):2個節(jié)點
節(jié)點1: 10.10.10.10
節(jié)點2: 10.10.10.20
節(jié)點1部署redis實例,角色master,部署sentinel實例,監(jiān)控redis-master節(jié)點
節(jié)點2部署redis實例,角色slave ,部署sentinel實例,監(jiān)控redis-master節(jié)點
一.配置redis主從
節(jié)點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 #后臺運行
節(jié)點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服務(wù)器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
測試主從復(fù)制
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
相關(guān)推薦
- 2022-04-01 SQL?Server?數(shù)據(jù)庫基礎(chǔ)編程詳解_MsSql
- 2022-10-01 React?Hook中useState更新延遲問題及解決_React
- 2022-10-05 使用python?matplotlib?contour畫等高線圖的詳細(xì)過程講解_python
- 2022-05-14 Centos8安裝docker報錯(錯誤提示:All?mirrors?were?tried)的問題_
- 2022-08-26 淺談C++/C關(guān)于#define的那些奇奇怪怪的用法_C 語言
- 2022-06-22 Git文件常用操作總結(jié)及拓展_其它綜合
- 2022-08-21 Android設(shè)置重復(fù)文字水印背景的方法_Android
- 2022-10-19 Android項目中引入aar包的正確方法介紹_Android
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡單動態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支