首页 > 数据库 >redis 哨兵部署

redis 哨兵部署

时间:2024-04-18 10:26:22浏览次数:30  
标签:false 部署 enabled redis 哨兵 sentinel true annotations

redis 生产哨兵的测试

1、helm release的版本

helm repo add bitnami https://charts.bitnami.com/bitnami
helm pull bitnami/redis --version 18.2.2

sentinel-redis]# ls
redis  redis-18.2.2.tgz

values.yaml 配置文件

注意配置文件的cm部分,先使用默认的configmap配置然后再单独修改cm,这样防止部署的时候第一次启动就报错。
这里把官方的注释和空行都过滤了,详细的配置可以参考官方的注释说明。

jgj-sentinel-redis]# grep -Ev '#|^$' redis/values.yaml 
global:
  imageRegistry: "swr.cn-south-1.myhuaweicloud.com/aaa"
  imagePullSecrets: ["registry-huawei"]
  storageClass: "csi-disk"
  redis:
    password: "AdVji0a"
kubeVersion: ""
nameOverride: ""
fullnameOverride: ""
commonLabels: {}
commonAnnotations: {}
secretAnnotations: {}
clusterDomain: cluster.local
extraDeploy: []
useHostnames: true
nameResolutionThreshold: 5
nameResolutionTimeout: 5
diagnosticMode:
  enabled: false
  command:
    - sleep
  args:
    - infinity
image:
  registry: swr.cn-south-1.myhuaweicloud.com/aaa
  repository: redis
  tag: 7.2.3-debian-11-r0
  digest: ""
  pullPolicy: IfNotPresent
  pullSecrets: ["registry-huawei"]
  debug: false
architecture: replication
auth:
  enabled: true
  sentinel: true
  password: "AdVji0a"
  existingSecret: ""
  existingSecretPasswordKey: ""
  usePasswordFiles: false
commonConfiguration: |-
  appendonly no
  save ""
existingConfigmap: ""
master:
  count: 1
  configuration: ""
  disableCommands:
    - FLUSHDB
    - FLUSHALL
  command: []
  args: []
  enableServiceLinks: true
  preExecCmds: []
  extraFlags: []
  extraEnvVars: []
  extraEnvVarsCM: ""
  extraEnvVarsSecret: ""
  containerPorts:
    redis: 6379
  startupProbe:
    enabled: false
    initialDelaySeconds: 20
    periodSeconds: 5
    timeoutSeconds: 5
    successThreshold: 1
    failureThreshold: 5
  livenessProbe:
    enabled: true
    initialDelaySeconds: 20
    periodSeconds: 5
    timeoutSeconds: 5
    successThreshold: 1
    failureThreshold: 5
  readinessProbe:
    enabled: true
    initialDelaySeconds: 20
    periodSeconds: 5
    timeoutSeconds: 1
    successThreshold: 1
    failureThreshold: 5
  customStartupProbe: {}
  customLivenessProbe: {}
  customReadinessProbe: {}
  resources:
    limits: {cpu: 2, memory: 4G}
    requests: {cpu: 1, memory: 4G}
  podSecurityContext:
    enabled: true
    fsGroup: 1001
  containerSecurityContext:
    enabled: true
    runAsUser: 1001
    runAsGroup: 0
    runAsNonRoot: true
    allowPrivilegeEscalation: false
    seccompProfile:
      type: RuntimeDefault
    capabilities:
      drop:
        - ALL
  kind: StatefulSet
  schedulerName: ""
  updateStrategy:
    type: RollingUpdate
  minReadySeconds: 0
  priorityClassName: ""
  hostAliases: []
  podLabels: {}
  podAnnotations: {}
  shareProcessNamespace: false
  podAffinityPreset: ""
  podAntiAffinityPreset: soft
  nodeAffinityPreset:
    type: ""
    key: ""
    values: []
  affinity: {}
  nodeSelector: {}
  tolerations: []
  topologySpreadConstraints: []
  dnsPolicy: ""
  dnsConfig: {}
  lifecycleHooks: {}
  extraVolumes: []
  extraVolumeMounts: []
  sidecars: []
  initContainers: []
  persistence:
    enabled: true
    medium: ""
    sizeLimit: ""
    path: /data
    subPath: ""
    subPathExpr: ""
    storageClass: ""
    accessModes:
      - ReadWriteOnce
    size: 2Gi
    annotations: {}
    labels: {}
    selector: {}
    dataSource: {}
    existingClaim: ""
  persistentVolumeClaimRetentionPolicy:
    enabled: false
    whenScaled: Retain
    whenDeleted: Retain
  service:
    type: ClusterIP
    ports:
      redis: 6379
    nodePorts:
      redis: ""
    externalTrafficPolicy: Cluster
    extraPorts: []
    internalTrafficPolicy: Cluster
    clusterIP: ""
    loadBalancerIP: ""
    loadBalancerSourceRanges: []
    externalIPs: []
    annotations: {}
    sessionAffinity: None
    sessionAffinityConfig: {}
  terminationGracePeriodSeconds: 30
  serviceAccount:
    create: false
    name: ""
    automountServiceAccountToken: true
    annotations: {}
replica:
  replicaCount: 3
  configuration: ""
  disableCommands:
    - FLUSHDB
    - FLUSHALL
  command: []
  args: []
  enableServiceLinks: true
  preExecCmds: []
  extraFlags: []
  extraEnvVars: []
  extraEnvVarsCM: ""
  extraEnvVarsSecret: ""
  externalMaster:
    enabled: false
    host: ""
    port: 6379
  containerPorts:
    redis: 6379
  startupProbe:
    enabled: true
    initialDelaySeconds: 10
    periodSeconds: 10
    timeoutSeconds: 5
    successThreshold: 1
    failureThreshold: 22
  livenessProbe:
    enabled: true
    initialDelaySeconds: 20
    periodSeconds: 5
    timeoutSeconds: 5
    successThreshold: 1
    failureThreshold: 5
  readinessProbe:
    enabled: true
    initialDelaySeconds: 20
    periodSeconds: 5
    timeoutSeconds: 1
    successThreshold: 1
    failureThreshold: 5
  customStartupProbe: {}
  customLivenessProbe: {}
  customReadinessProbe: {}
  resources:
    limits: {cpu: 2, memory: 2G}
    requests: {cpu: 1, memory: 2G}
  podSecurityContext:
    enabled: true
    fsGroup: 1001
  containerSecurityContext:
    enabled: true
    runAsUser: 1001
    runAsGroup: 0
    runAsNonRoot: true
    allowPrivilegeEscalation: false
    seccompProfile:
      type: RuntimeDefault
    capabilities:
      drop:
        - ALL
  schedulerName: ""
  updateStrategy:
    type: RollingUpdate
  minReadySeconds: 0
  priorityClassName: ""
  podManagementPolicy: ""
  hostAliases: []
  podLabels: {}
  podAnnotations: {}
  shareProcessNamespace: false
  podAffinityPreset: ""
  podAntiAffinityPreset: soft
  nodeAffinityPreset:
    type: ""
    key: ""
    values: []
  affinity: {}
  nodeSelector: {}
  tolerations: []
  topologySpreadConstraints: []
  dnsPolicy: ""
  dnsConfig: {}
  lifecycleHooks: {}
  extraVolumes: []
  extraVolumeMounts: []
  sidecars: []
  initContainers: []
  persistence:
    enabled: true
    medium: ""
    sizeLimit: ""
    path: /data
    subPath: ""
    subPathExpr: ""
    storageClass: ""
    accessModes:
      - ReadWriteOnce
    size: 2Gi
    annotations: {}
    labels: {}
    selector: {}
    dataSource: {}
    existingClaim: ""
  persistentVolumeClaimRetentionPolicy:
    enabled: false
    whenScaled: Retain
    whenDeleted: Retain
  service:
    type: ClusterIP
    ports:
      redis: 6379
    nodePorts:
      redis: ""
    externalTrafficPolicy: Cluster
    internalTrafficPolicy: Cluster
    extraPorts: []
    clusterIP: ""
    loadBalancerIP: ""
    loadBalancerSourceRanges: []
    annotations: {}
    sessionAffinity: None
    sessionAffinityConfig: {}
  terminationGracePeriodSeconds: 30
  autoscaling:
    enabled: false
    minReplicas: 1
    maxReplicas: 11
    targetCPU: ""
    targetMemory: ""
  serviceAccount:
    create: false
    name: ""
    automountServiceAccountToken: true
    annotations: {}
sentinel:
  enabled: true
  image:
    registry: docker.io
    repository: redis-sentinel
    tag: 7.2.3-debian-11-r0
    digest: ""
    pullPolicy: IfNotPresent
    pullSecrets: []
    debug: false
  annotations: {}
  masterSet: mymaster
  quorum: 3
  getMasterTimeout: 99
  automateClusterRecovery: false
  redisShutdownWaitFailover: true
  downAfterMilliseconds: 60000
  failoverTimeout: 180000
  parallelSyncs: 1
  configuration: ""
  command: []
  args: []
  enableServiceLinks: true
  preExecCmds: []
  extraEnvVars: []
  extraEnvVarsCM: ""
  extraEnvVarsSecret: ""
  externalMaster:
    enabled: false
    host: ""
    port: 6379
  containerPorts:
    sentinel: 26379
  startupProbe:
    enabled: true
    initialDelaySeconds: 10
    periodSeconds: 10
    timeoutSeconds: 5
    successThreshold: 1
    failureThreshold: 22
  livenessProbe:
    enabled: true
    initialDelaySeconds: 20
    periodSeconds: 10
    timeoutSeconds: 5
    successThreshold: 1
    failureThreshold: 6
  readinessProbe:
    enabled: true
    initialDelaySeconds: 20
    periodSeconds: 5
    timeoutSeconds: 1
    successThreshold: 1
    failureThreshold: 6
  customStartupProbe: {}
  customLivenessProbe: {}
  customReadinessProbe: {}
  persistence:
    enabled: false
    storageClass: ""
    accessModes:
      - ReadWriteOnce
    size: 100Mi
    annotations: {}
    labels: {}
    selector: {}
    dataSource: {}
    medium: ""
    sizeLimit: ""
  persistentVolumeClaimRetentionPolicy:
    enabled: false
    whenScaled: Retain
    whenDeleted: Retain
  resources:
    limits: {cpu: 2, memory: 2G}
    requests: {cpu: 1, memory: 2G}
  containerSecurityContext:
    enabled: true
    runAsUser: 1001
    runAsGroup: 0
    runAsNonRoot: true
    allowPrivilegeEscalation: false
    seccompProfile:
      type: RuntimeDefault
    capabilities:
      drop:
        - ALL
  lifecycleHooks: {}
  extraVolumes: []
  extraVolumeMounts: []
  service:
    type: ClusterIP
    ports:
      redis: 6379
      sentinel: 26379
    nodePorts:
      redis: ""
      sentinel: ""
    externalTrafficPolicy: Cluster
    extraPorts: []
    clusterIP: ""
    loadBalancerIP: ""
    loadBalancerSourceRanges: []
    annotations: {}
    sessionAffinity: None
    sessionAffinityConfig: {}
    headless:
      annotations: {}
  terminationGracePeriodSeconds: 30
serviceBindings:
  enabled: false
networkPolicy:
  enabled: false
  allowExternal: true
  extraIngress: []
  extraEgress: []
  ingressNSMatchLabels: {}
  ingressNSPodMatchLabels: {}
  metrics:
    allowExternal: true
    ingressNSMatchLabels: {}
    ingressNSPodMatchLabels: {}

podSecurityPolicy:
  create: false
  enabled: false
rbac:
  create: false
  rules: []
serviceAccount:
  create: true
  name: ""
  automountServiceAccountToken: true
  annotations: {}
pdb:
  create: false
  minAvailable: 1
  maxUnavailable: ""
tls:
  enabled: false
  authClients: true
  autoGenerated: false
  existingSecret: ""
  certificatesSecret: ""
  certFilename: ""
  certKeyFilename: ""
  certCAFilename: ""
  dhParamsFilename: ""
metrics:
  enabled: false
  image:
    registry: docker.io
    repository: bitnami/redis-exporter
    tag: 1.55.0-debian-11-r0
    digest: ""
    pullPolicy: IfNotPresent
    pullSecrets: []
  startupProbe:
    enabled: false
    initialDelaySeconds: 10
    periodSeconds: 10
    timeoutSeconds: 5
    successThreshold: 1
    failureThreshold: 5
  livenessProbe:
    enabled: true
    initialDelaySeconds: 10
    periodSeconds: 10
    timeoutSeconds: 5
    successThreshold: 1
    failureThreshold: 5
  readinessProbe:
    enabled: true
    initialDelaySeconds: 5
    periodSeconds: 10
    timeoutSeconds: 1
    successThreshold: 1
    failureThreshold: 3
  customStartupProbe: {}
  customLivenessProbe: {}
  customReadinessProbe: {}
  command: []
  redisTargetHost: "localhost"
  extraArgs: {}
  extraEnvVars: []
  containerSecurityContext:
    enabled: true
    runAsUser: 1001
    runAsGroup: 0
    runAsNonRoot: true
    allowPrivilegeEscalation: false
    seccompProfile:
      type: RuntimeDefault
    capabilities:
      drop:
        - ALL
  extraVolumes: []
  extraVolumeMounts: []
  resources:
    limits: {}
    requests: {}
  podLabels: {}
  podAnnotations:
    prometheus.io/scrape: "true"
    prometheus.io/port: "9121"
  service:
    type: ClusterIP
    port: 9121
    externalTrafficPolicy: Cluster
    extraPorts: []
    loadBalancerIP: ""
    loadBalancerSourceRanges: []
    annotations: {}
    clusterIP: ""
  serviceMonitor:
    enabled: false
    namespace: ""
    interval: 30s
    scrapeTimeout: ""
    relabellings: []
    metricRelabelings: []
    honorLabels: false
    additionalLabels: {}
    podTargetLabels: []
    sampleLimit: false
    targetLimit: false
  podMonitor:
    enabled: false
    namespace: ""
    interval: 30s
    scrapeTimeout: ""
    relabellings: []
    metricRelabelings: []
    honorLabels: false
    additionalLabels: {}
    podTargetLabels: []
    sampleLimit: false
    targetLimit: false
  prometheusRule:
    enabled: false
    namespace: ""
    additionalLabels: {}
    rules: []
volumePermissions:
  enabled: false
  image:
    registry: docker.io
    repository: bitnami/os-shell
    tag: 11-debian-11-r90
    digest: ""
    pullPolicy: IfNotPresent
    pullSecrets: []
  resources:
    limits: {}
    requests: {}
  containerSecurityContext:
    runAsUser: 0
sysctl:
  enabled: false
  image:
    registry: docker.io
    repository: bitnami/os-shell
    tag: 11-debian-11-r90
    digest: ""
    pullPolicy: IfNotPresent
    pullSecrets: []
  command: []
  mountHostSys: false
  resources:
    limits: {}
    requests: {}
useExternalDNS:
  enabled: false
  suffix: ""
  annotationKey: external-dns.alpha.kubernetes.io/
  additionalAnnotations: {}

部署 redis

helm -n jian-butler install redis redis/

修改configmap

ckubectl -n jian-butler get cm redis-configuration -o yaml
apiVersion: v1
data:
  master.conf: |-
    dir /tmp
    # User-supplied master configuration:
    rename-command FLUSHDB ""
    rename-command FLUSHALL ""
    appendonly no
    save ""
    maxclients 65535
    maxmemory 4G
    slowlog-log-slower-than 10000
    slowlog-max-len 128
    timeout 10
    tcp-keepalive 30
    # End of master configuration
  redis.conf: |-
    appendonly no
    save ""
    dir /tmp
    maxclients 65535
    maxmemory 4G
    slowlog-log-slower-than 10000
    slowlog-max-len 128
    timeout 10
    tcp-keepalive 30
  replica.conf: |-
    dir /data
    appendonly yes
    rename-command FLUSHDB ""
    rename-command FLUSHALL ""
    # End of replica configuration
  sentinel.conf: |-
    dir "/tmp"
    port 26379
    sentinel monitor mymaster redis-node-0.redis-headless.jian-butler.svc.cluster.local 6379 3
    sentinel down-after-milliseconds mymaster 60000
    sentinel failover-timeout mymaster 180000
    sentinel parallel-syncs mymaster 1
    # User-supplied sentinel configuration:
    # End of sentinel configuration
kind: ConfigMap
metadata:
  annotations:
    meta.helm.sh/release-name: redis
    meta.helm.sh/release-namespace: jian-butler
  labels:
    app.kubernetes.io/instance: redis
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: redis
    app.kubernetes.io/version: 7.2.3
    helm.sh/chart: redis-18.2.2
  name: redis-configuration
  namespace: jian-butler

查看修改之后的redis 哨兵状态。

 jgj-sentinel-redis]# ckubectl -n jian-butler get pod
NAME           READY   STATUS    RESTARTS   AGE
redis-node-0   2/2     Running   0          15m
redis-node-1   2/2     Running   0          16m
redis-node-2   2/2     Running   0          16m

修改内核参数,优化配置

修改之后会重启redis的每个pod

      initContainers:
        - image: busybox
          command:
            - sh
            - -c
            - |
              sysctl -w net.core.somaxconn=65535
              sysctl -w fs.file-max=1048576
          imagePullPolicy: Always
          name: setsysctl
          securityContext:
            privileged: true

标签:false,部署,enabled,redis,哨兵,sentinel,true,annotations
From: https://www.cnblogs.com/gshelldon/p/18142925

相关文章

  • GPT-SoVITS 部署
    GPT-SoVITShttps://github.com/RVC-Boss/GPT-SoVITShttps://www.yuque.com/baicaigongchang1145haoyuangong/ib3g1egitclonehttps://github.com/RVC-Boss/GPT-SoVITS.gitcondacreate-nGPTSoVitspython=3.9condaactivateGPTSoVitsbashinstall.shsudovimstartup.s......
  • EQ-BDS面板部署机器人
    一、机器人配置教程0.预处理首先处理杀毒软件误报问题。在服务器上安装火绒安全当然,您也可以不选择火绒,使用其他杀毒软件,到时候给插件加上信任即可安装完成后禁用WindowsDefender,详见EQ-BDS面板用户手册1.下载然后解压压缩包点我跳转到下载页面这个网盘不需要开会员,您只......
  • 部署Jenkins + 遇到的问题
    阿里云服务器部署Jenkins基础配置安装在部署jenkins之前需要将git、jdk、maven在云服务器中安装好。Git1、安装指令sudoapt-getinstallgit使用git--version查看是否安装成功2、配置用户名和邮箱名gitconfig--globaluser.name"YourName"gitconfig--global......
  • 腾讯音乐:说说Redis脑裂问题?
    Redis脑裂问题是指,在Redis哨兵模式或集群模式中,由于网络原因,导致主节点(Master)与哨兵(Sentinel)和从节点(Slave)的通讯中断,此时哨兵就会误以为主节点已宕机,就会在从节点中选举出一个新的主节点,此时Redis的集群中就出现了两个主节点的问题,就是Redis脑裂问题。脑裂问题影响Redis......
  • openGauss Prometheus-Exporter组件环境部署
    环境部署用户可以从Prometheus的官网上下载Prometheus-server和node-exporter,然后根据官方文档中的说明启动它们;也可以通过DBMind提供的快捷部署工具进行部署;如果用户自行部署,则可以跳到部署过程中为支持部署位置正确以及后续的运行和监测...。通过命令行进行Prometheus和......
  • 夜莺监控 V7 第二个 beta 版本发布,内置集成故障自愈能力,简化部署
    经过一个半月的打磨改进,夜莺监控V7第二个beta版本发布了,本次发布的主要亮点是内置集成故障自愈能力,简化架构,同时做了其他19项改进。一些重要的改进如下:feat:集成故障自愈的能力,不需要再单独部署ibex模块了refactor:内置仪表盘和内置规则页面重构refactor:业务组树......
  • 这篇 DolphinScheduler on k8s 云原生部署实践,值得所有大数据人看!
    在当前快速发展的技术格局中,企业寻求创新解决方案来简化运营并提高效率成为一种趋势。ApacheDolphinScheduler作为一个强大的工具,允许跨分布式系统进行复杂的工作流任务调度。本文将深入探讨如何将ApacheDolphinScheduler适配并整合进现代IT环境,提升其在云原生部署中的表现。......
  • k8s快速部署xxl-job
    1.初始化数据库wgethttps://raw.githubusercontent.com/xuxueli/xxl-job/2.1.2/doc/db/tables_xxl_job.sqlmysql-uroot-psource/root/tables_xxl_job.sql;CREATEUSER't1_zdbl_xxl_job'@'%'IDENTIFIEDBY'OYP!z5%0O2lALdLi';GRANTALL......
  • 10_QT系统移植之在开发板上部署QT运行环境
    QT系统移植之在开发板上部署QT运行环境一.开始部署1.我们在Ubuntu新创建一个文件夹,然后把我们用busybox做好的文件系统拷贝到这个文件下。如下图所示:2.然后我们解压这个根文件系统到当前所在的路径下。3.我们在这个解压出来的根文件系统下新创建一个opt的文件夹,如下图所示:......
  • docker部署nginx
    拉取镜像dockerpullnginx创建映射目录mkdir-p/data/server/nginx/{conf,log,html}先创建一个nginx容器,然后将容器中的nginx.conf文件和conf.d文件夹复制到宿主机创建容器dockerrun-d--namenginx01-p20080:80nginx将容器中的nginx.conf文件复制到宿主机docker......