当前位置:网站首页>Docker compose public network deployment redis sentinel mode
Docker compose public network deployment redis sentinel mode
2022-07-04 14:29:00 【mp9105】
docker-compose Public network deployment redis Sentinel mode
Cloud services are used here redis The sentry cluster , And exposed to the public network , This is for testing purposes only , Production should not be exposed to the public network
About online redis Sentinel and cluster docker There are many deployment tutorials , Refer to the following
https://segmentfault.com/a/1190000040755506
https://cloud.tencent.com/developer/news/688466
These deployment tutorials are available on the intranet , But it will not be connected under the public network , Make a note of the main differences
1 start-up redis Master slave node
To write reids Master-slave docker-compose.yml
version: '3.8'
services:
master:
image: redis:6.0.8
container_name: redis-master
privileged: true
restart: always
# Note that there --cluster-announce-ip Specify the exposed address , Fill in the public network address here
# Many deployments here are not specified --masterauth,master After the node restarts, it will not be able to join the cluster
command: redis-server --port 6380 --requirepass redispwd --masterauth redispwd --appendonly yes --cluster-announce-ip xxx.xxx.xxx.xxx --cluster-announce-port 6380 --cluster-announce-bus-port 16380
ports: # As specified above --port Agreement
- 6380:6380
volumes:
- ./data1:/data
slave1:
image: redis:6.0.8
container_name: redis-slave-1
privileged: true
restart: always
# There's a pit here ,--slaveof Don't write directly redis-master, Otherwise, it will be recognized as an intranet IP
command: redis-server --port 6381 --slaveof xxx.xxx.xxx.xxx 6380 --requirepass redispwd --masterauth redispwd --appendonly yes --cluster-announce-ip xxx.xxx.xxx.xxx --cluster-announce-port 6381 --cluster-announce-bus-port 16381
ports: # As specified above --port Agreement
- 6381:6381
volumes:
- ./data2:/data
slave2:
image: redis:6.0.8
container_name: redis-slave-2
privileged: true
restart: always
command: redis-server --port 6382 --slaveof xxx.xxx.xxx.xxx 6380 --requirepass redispwd --masterauth redispwd --appendonly yes --cluster-announce-ip xxx.xxx.xxx.xxx --cluster-announce-port 6382 --cluster-announce-bus-port 16382
ports: # As specified above --port Agreement
- 6382:6382
volumes:
- ./data3:/data
networks:
default:
external:
name: redis_default
Get into redis Corresponding docker-compose.yml
The catalog of , Carry out orders :
# Creating networks , There is no need to create
docker network create redis_default
# -d Means running in the background
docker-compose up -d
2 Sentinel file preparation
To write docker-compose.yml
version: '3.8'
services:
sentinel1:
image: redis:6.0.8
container_name: redis-sentinel-1
privileged: true
restart: always
ports:
- 26380:26380
volumes:
- ./sentinel1.conf:/usr/local/etc/redis/sentinel.conf
command: bash -c "redis-sentinel /usr/local/etc/redis/sentinel.conf && chmod 777 /usr/local/etc/redis/sentinel.conf"
sentinel2:
image: redis:6.0.8
container_name: redis-sentinel-2
privileged: true
restart: always
ports:
- 26381:26380
volumes:
- ./sentinel2.conf:/usr/local/etc/redis/sentinel.conf
command: bash -c "redis-sentinel /usr/local/etc/redis/sentinel.conf && chmod 777 /usr/local/etc/redis/sentinel.conf"
sentinel3:
image: redis:6.0.8
container_name: redis-sentinel-3
privileged: true
ports:
- 26382:26380
volumes:
- ./sentinel3.conf:/usr/local/etc/redis/sentinel.conf
command: bash -c "redis-sentinel /usr/local/etc/redis/sentinel.conf && chmod 777 /usr/local/etc/redis/sentinel.conf"
networks:
default:
external:
name: redis_default
To write sentinel.conf
The configuration file
# mymaster Is the custom cluster name
# xxx.xxx.xxx.xxx Master node IP The public address of
# 6380 by redis-master The port of ,2 Is the minimum number of votes ( Because there is 3 platform Sentinel So it can be set to 2)
port 26380
dir /tmp
# protected-mode no
# bind 0.0.0.0
sentinel monitor mymaster xxx.xxx.xxx.xxx 6380 2
sentinel down-after-milliseconds mymaster 30000
sentinel parallel-syncs mymaster 1
# The password is consistent with the above
sentinel auth-pass mymaster redispwd
sentinel failover-timeout mymaster 180000
sentinel deny-scripts-reconfig yes
Copy the above documents separately 3 The copies are named sentinel1.conf
、sentinel2.conf
、sentinel3.conf
And docker-compose.yml
The configuration file in corresponds to , Then place and the sentry's docker-compose.yml
In the same directory
3 Activate the sentry
# Get into docker-compose.yml Execute in the folder
docker-compose up -d
4 Test connection
With ARDM For example , Fill in the corresponding information
It can be connected normally.
边栏推荐
- 电商系统中红包活动设计
- 【MySQL从入门到精通】【高级篇】(四)MySQL权限管理与控制
- What is the difference between Bi financial analysis in a narrow sense and financial analysis in a broad sense?
- MATLAB中tiledlayout函数使用
- Detailed analysis of pytorch's automatic derivation mechanism, pytorch's core magic
- Nowcoder reverse linked list
- AI与生命科学
- R language ggplot2 visualization: gganimate package creates dynamic line graph animation (GIF) and uses transition_ The reveal function displays data step by step along a given dimension in the animat
- leetcode:6110. 网格图中递增路径的数目【dfs + cache】
- LifeCycle
猜你喜欢
leetcode:6110. The number of incremental paths in the grid graph [DFS + cache]
RK1126平台OSD的实现支持颜色半透明度多通道支持中文
codeforce:C. Sum of Substrings【边界处理 + 贡献思维 + 灵光一现】
Detailed explanation of visual studio debugging methods
统计php程序运行时间及设置PHP最长运行时间
Ruiji takeout notes
Leetcode T48:旋转图像
Ultrasonic distance meter based on 51 single chip microcomputer
Intelligence d'affaires bi analyse financière, analyse financière au sens étroit et analyse financière au sens large sont - ils différents?
[information retrieval] link analysis
随机推荐
Test process arrangement (3)
Leetcode T49: 字母异位词分组
Query optimizer for SQL optimization
Supprimer les lettres dupliquées [avidité + pile monotone (maintenir la séquence monotone avec un tableau + Len)]
实战解惑 | OpenCV中如何提取不规则ROI区域
What is the difference between Bi financial analysis in a narrow sense and financial analysis in a broad sense?
Solutions aux problèmes d'utilisation de l'au ou du povo 2 dans le riz rouge k20pro MIUI 12.5
Ml: introduction, principle, use method and detailed introduction of classic cases of snap value
为什么图片传输要使用base64编码
Rich text editing: wangeditor tutorial
One architecture to complete all tasks - transformer architecture is unifying the AI Jianghu on its own
Leetcode T48:旋转图像
Sqlserver functions, creation and use of stored procedures
flink sql-client. SH tutorial
[MySQL from introduction to proficiency] [advanced chapter] (IV) MySQL permission management and control
Chapter 16 string localization and message Dictionary (2)
流行框架:Glide的使用
RK1126平台OSD的实现支持颜色半透明度多通道支持中文
Talk about 10 tips to ensure thread safety
docker-compose公网部署redis哨兵模式