当前位置: 首页 > news >正文

福建建设工程交易中心网站wordpress优缺点

福建建设工程交易中心网站,wordpress优缺点,哪些网站可以做英语等级试题,电子商务网站的推广方式文章目录 使用 Kubernetes 部署 Redis 主从及 Sentinel 高可用架构Redis 主从架构部署 (1.yaml)Redis Sentinel 部署 (2.yaml)Sentinel 服务暴露 (3.yaml)部署步骤总结 使用 Kubernetes 部署 Redis 主从及 Sentinel 高可用架构 本文将详细介绍如何在 Kubernetes 中部署 Redis …

文章目录

  • 使用 Kubernetes 部署 Redis 主从及 Sentinel 高可用架构
  • Redis 主从架构部署 (`1.yaml`)
  • Redis Sentinel 部署 (`2.yaml`)
  • Sentinel 服务暴露 (`3.yaml`)
  • 部署步骤
  • 总结


使用 Kubernetes 部署 Redis 主从及 Sentinel 高可用架构

本文将详细介绍如何在 Kubernetes 中部署 Redis 主从及 Sentinel 高可用架构,提供完整的 YAML 配置文件,并逐步解析其关键配置。命名空间已调整为 test

我这是单点,未做共享存储版


Redis 主从架构部署 (1.yaml)

首先,使用 StatefulSet 部署 Redis 主从结构,每个实例通过主机名确定角色:

apiVersion: apps/v1
kind: StatefulSet
metadata:name: redisnamespace: test
spec:serviceName: redisreplicas: 3selector:matchLabels:app: redistemplate:metadata:labels:app: redisspec:initContainers:- name: init-redisimage: docker.wctmd.us.kg/busybox:latestcommand: ["/bin/sh", "-c"]args: ["mkdir -p /data/redis/$(hostname)"]volumeMounts:- name: redis-datamountPath: /datacontainers:- name: redisimage: docker.wctmd.us.kg/redis:5.0.14ports:- containerPort: 6379command: ["/bin/sh"]args: - "-c"- |if [ $(hostname) = "redis-0" ]; thenredis-server --port 6379 --protected-mode no --replica-announce-ip $(hostname).rediselseredis-server --port 6379 --protected-mode no --replicaof redis-0.redis 6379 --replica-announce-ip $(hostname).redisfivolumeMounts:- name: redis-datamountPath: /datavolumes:- name: redis-datahostPath:path: /data/redistype: DirectoryOrCreate

关键点解析

  • 主从自动识别redis-0 为主节点,其它 Pod 配置为从节点并通过 --replicaof 指定主节点。
  • 数据持久化:使用 hostPath 存储 Redis 数据,映射到宿主机的 /data/redis
  • 独立目录管理:通过 initContainer 动态创建 /data/redis/$(hostname),避免目录冲突。

Redis Sentinel 部署 (2.yaml)

接下来,部署 Sentinel 来监控 Redis 主从并实现自动故障转移:

apiVersion: apps/v1
kind: Deployment
metadata:name: redis-sentinelnamespace: test
spec:replicas: 3selector:matchLabels:app: redis-sentineltemplate:metadata:labels:app: redis-sentinelspec:containers:- name: redis-sentinelimage: docker.wctmd.us.kg/redis:5.0.14ports:- containerPort: 26379command: [ "redis-sentinel" ]args: ["/data/sentinel.conf"]volumeMounts:- name: sentinel-confmountPath: /datainitContainers:- name: init-sentinelimage: docker.wctmd.us.kg/busybox:latestcommand: ["/bin/sh", "-c"]args:- cp /etc/redis/sentinel.conf /data/sentinel.conf && chmod 600 /data/sentinel.confvolumeMounts:- name: sentinel-confmountPath: /data- name: config-volumemountPath: /etc/redisvolumes:- name: sentinel-confemptyDir: {}- name: config-volumeconfigMap:name: sentinel-config
---
apiVersion: v1
kind: ConfigMap
metadata:name: sentinel-confignamespace: test
data:sentinel.conf: |sentinel monitor mymaster redis-0.redis 6379 2sentinel down-after-milliseconds mymaster 5000sentinel failover-timeout mymaster 60000sentinel parallel-syncs mymaster 1

关键点解析

  • 动态配置文件管理:通过 initContainer 将只读的 ConfigMap 文件复制到可写路径,并调整权限。
  • 多实例部署:使用 Deployment 创建 3 个 Sentinel 实例以实现高可用。
  • 监控配置ConfigMap 定义了 Sentinel 的监控规则,包括主节点、超时、同步参数等。

Sentinel 服务暴露 (3.yaml)

最后,通过 Service 将 Sentinel 对外暴露,便于外部访问:

apiVersion: v1
kind: Service
metadata:name: redis-sentinelnamespace: test
spec:type: NodePortports:- nodePort: 30154port: 26379targetPort: 26379protocol: TCPselector:app: redis-sentinel

关键点解析

  • 外部访问支持:使用 NodePort 暴露 Sentinel 服务,监听宿主机的 30154 端口。
  • 服务选择器:通过标签 app: redis-sentinel 将流量路由到 Sentinel Pod。

部署步骤

  1. 创建命名空间 test
    kubectl create namespace test
    
  2. 应用 1.yaml 部署 Redis:
    kubectl apply -f 1.yaml
    
  3. 应用 2.yaml 部署 Sentinel:
    kubectl apply -f 2.yaml
    
  4. 应用 3.yaml 创建服务:
    kubectl apply -f 3.yaml
    
  5. 验证部署状态:
    kubectl -n test get pods
    kubectl -n test get svc
    

总结

本文展示了如何使用 Kubernetes 部署 Redis 主从架构和 Sentinel 高可用集群。通过灵活的 StatefulSetDeployment 配置,我们实现了高可靠性和动态配置管理,同时确保数据持久化和集群安全性。

建议:在生产环境中,可以进一步优化存储方案(如使用 PersistentVolume)并增强安全配置(如启用 Redis/Sentinel 认证)。

http://www.yayakq.cn/news/416912/

相关文章:

  • 微信第三方网站开发教程微信小程序网页版
  • 优秀网站有哪些ui设计和平面设计有什么区别
  • 网站建设师特点上海建设网站定做
  • 查看服务器上的网站金华网站建设团队
  • 景洪市新农村建设网站济南教育平台网站建设
  • 基于asp网站开发 论文小程序推广方式
  • 织梦系统网站模板修改北京营销型网站建设哪家好
  • 单位做网站需要多少钱中国建设人才网信息网证书是假的吗
  • 大连建站个人网站备案名字大全
  • 网上商城平台运营方案南宁seo收费
  • 网站建设与制作与维护做一元购网站会被封吗
  • 网页设计公司网站制作wordpress小黄锁
  • 常州网站制作案例域名是什么样式的
  • 广州做企业网站找哪家公司好wordpress提醒用法
  • 给别人做网站别人违法经营网站建站的一般步骤
  • php手机网站怎么做北京网站排行
  • 沈阳软件公司 网站制作企点下载官网
  • 网站后台怎么进入wordpress建网站需要哪些步骤
  • 山西智能建站系统价格网站站点文件夹权限设置
  • 公益建设网站的作用网站设计中建设规划和准备阶段
  • 最超值的网站建设赚钱黑渠道入口
  • 著名设计网站deviantart的id模板高端做网站哪家好
  • 中石建基础设施建设有限公司网站好网站建设公司地址
  • 公司网站可以自己做吗h5商城网站开发
  • 如何做房产网站wordpress会员打赏插件
  • 用dw6做网站wp大学wordpress建站流程
  • 中英文网站建设经典软文文案
  • 网站建站费用多少邢台招聘信息最新招聘2023
  • 建立网站需要怎么做网页设计与制作实训心得体会
  • 有没有专业做二手老车的网站可以分销的平台