搭建 Redis 叢集
搭建 Redis 叢集
vim docker-compose.yml
Redis Desktop Manager下載
https://www.jianshu.com/p/6895384d2b9e
version: '3.7'
services:
master:
image: redis
container_name: redis-master
ports:
- 6379:6379
slave1:
image: redis
container_name: redis-slave-1
ports:
- 6380:6379
command: redis-server --slaveof redis-master 6379
slave2:
image: redis
container_name: redis-slave-2
ports:
- 6381:6379
command: redis-server --slaveof redis-master 6379
搭建 Sentinel 叢集
我們至少需要建立三個 Sentinel 服務,docker-compose.yml 配置如下:
version: '3.7'
services:
sentinel1:
image: redis
container_name: redis-sentinel-1
ports:
- 26379:26379
command: redis-sentinel /usr/local/etc/redis/sentinel.conf
volumes:
- ./sentinel1.conf:/usr/local/etc/redis/sentinel.conf
sentinel2:
image: redis
container_name: redis-sentinel-2
ports:
- 26380:26379
command: redis-sentinel /usr/local/etc/redis/sentinel.conf
volumes:
- ./sentinel2.conf:/usr/local/etc/redis/sentinel.conf
sentinel3:
image: redis
container_name: redis-sentinel-3
ports:
- 26381:26379
command: redis-sentinel /usr/local/etc/redis/sentinel.conf
volumes:
- ./sentinel3.conf:/usr/local/etc/redis/sentinel.conf
修改 Sentinel 配置檔案
需要三份 sentinel.conf 配置檔案,分別為 sentinel1.conf
,sentinel2.conf
,sentinel3.conf
,配置檔案內容相同
port 26379
dir /tmp
# 自定義叢集名,其中 127.0.0.1 為 redis-master 的 ip,6379 為 redis-master 的埠,2 為最小投票數(因為有 3 臺 Sentinel 所以可以設定成 2)
sentinel monitor mymaster 192.168.100.11 6379 2
sentinel down-after-milliseconds mymaster 30000
sentinel parallel-syncs mymaster 1
sentinel failover-timeout mymaster 180000
sentinel deny-scripts-reconfig yes
檢視叢集是否生效
進入 Sentinel 容器,使用 Sentinel API 檢視監控情況:
docker exec -it redis-sentinel-1 /bin/bash
redis-cli -p 26379
sentinel master mymaster
sentinel slaves mymaster
127.0.0.1:26379> sentinel slaves mymaster
1) 1) "name"
2) "172.19.0.3:6379"
3) "ip"
4) "172.19.0.3"
5) "port"
6) "6379"
7) "runid"
8) ""
9) "flags"
10) "s_down,slave"
11) "link-pending-commands"
相關文章
- Redis系列:搭建Redis叢集(叢集模式)Redis模式
- redis叢集搭建Redis
- Redis(5.0) 叢集搭建Redis
- redis叢集的搭建Redis
- 搭建Redis原生叢集Redis
- Redis--叢集搭建Redis
- Docker搭建Redis叢集DockerRedis
- 搭建redis cluster叢集Redis
- redis 4.0.11 叢集搭建Redis
- 基於Dokcer搭建Redis叢集(主從叢集)Redis
- centos7搭建redis叢集CentOSRedis
- Docker Redis 5.0 叢集(cluster)搭建DockerRedis
- CentOS7 搭建 Redis 叢集CentOSRedis
- Redis 5.02官方叢集搭建Redis
- Redis主從同步叢集搭建Redis主從同步
- Redis5.0.10叢集搭建Redis
- Redis4.0.12叢集搭建Redis
- Redis叢集搭建 三主三從Redis
- Docker 容器搭建及 Redis 叢集原理DockerRedis
- Redis叢集搭建與簡單使用Redis
- Redis-cluster叢集搭建部署Redis
- Redis叢集環境搭建實踐Redis
- Redis叢集搭建(三主三從)Redis
- Redis叢集搭建採坑總結Redis
- 12. Redis叢集環境搭建Redis
- Redis 叢集搭建及使用Golang示例RedisGolang
- Redis單機及其叢集的搭建Redis
- 搭建分散式 Redis Cluster 叢集與 Redis 入門分散式Redis
- Redis學習之 Redis3.0.x 叢集搭建RedisS3
- Mac 環境下 Redis 叢集的搭建MacRedis
- Redis搭建主從複製、哨兵叢集Redis
- Linux_搭建Redis叢集哨兵模式LinuxRedis模式
- 使用redis-trib.rb工具快速搭建redis叢集Redis
- redis 叢集Redis
- redis叢集Redis
- 在K8S上搭建Redis叢集K8SRedis
- redis 叢集搭建以及redislive監測部署Redis
- 基於 Redis3.2.4 叢集搭建說明RedisS3