首页 > 数据库 >helm 安装redis的主从、哨兵

helm 安装redis的主从、哨兵

时间:2024-03-15 22:01:03浏览次数:24  
标签:10 false enabled redis type helm true 主从

helm 安装redis的主从、哨兵

主要的配置还是得看helm values中的注释说明

安装库

$ helm repo add bitnami https://charts.bitnami.com/bitnami

# 查询redis资源
$ helm repo update
$ helm search repo redis

# 把redis拉到本地
$ helm pull bitnami/redis --version 16.11.2

基础配置文件

    dir /data
    # User-supplied master configuration:
    appendonly no
    save ""
    maxclients 65535
    maxmemory 2G
    slowlog-log-slower-than 10000
    slowlog-max-len 128
    timeout 10
    tcp-keepalive 30
    rename-command FLUSHDB ""
    rename-command FLUSHALL ""
    # End of master configuration

修改values文件

注释部分是主从要修改的配置。下面的这个value会创建一个主从实例的redis

global:
  imageRegistry: ""
  imagePullSecrets: []
  # 使用哪个sc
  storageClass: "nfs"
  redis:
  # redis密码
    password: "S2xqdD9zY3h4Ygo="


kubeVersion: ""
nameOverride: ""
fullnameOverride: ""
namespaceOverride: ""
commonLabels: {}
commonAnnotations: {}
secretAnnotations: {}
clusterDomain: cluster.local
extraDeploy: []
useHostnames: true
nameResolutionThreshold: 5
nameResolutionTimeout: 5

diagnosticMode:
  enabled: false
  command:
    - sleep
  args:
    - infinity


image:
  registry: docker.io
  repository: bitnami/redis
  tag: 7.2.4-debian-11-r2
  digest: ""
  pullPolicy: IfNotPresent
  pullSecrets: []
  debug: false


architecture: replication
auth:
  enabled: true
  sentinel: true
  password: ""
  existingSecret: ""
  existingSecretPasswordKey: ""
  usePasswordFiles: false

# redis.conf 生成的cm
commonConfiguration: |-
  appendonly no
  save ""
  maxclients 65535
  maxmemory 2G
  slowlog-log-slower-than 10000
  slowlog-max-len 128
  timeout 10
  tcp-keepalive 30
existingConfigmap: ""

# 配置master部分
master:
  count: 1
  configuration: |-
    appendonly no
    save ""
    maxclients 65535
    maxmemory 2G
    slowlog-log-slower-than 10000
    slowlog-max-len 128
    timeout 10
    tcp-keepalive 30

  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: {}
  # master占用的资源
  resources:
    limits: {cpu: 1, memory: 2Gi}
    requests: {}
  podSecurityContext:
    enabled: true
    fsGroupChangePolicy: Always
    sysctls: []
    supplementalGroups: []
    fsGroup: 1001
  containerSecurityContext:
    enabled: true
    seLinuxOptions: null
    runAsUser: 1001
    runAsGroup: 0
    runAsNonRoot: true
    allowPrivilegeEscalation: false
    seccompProfile:
      type: RuntimeDefault
    capabilities:
      drop:
        - ALL
  kind: StatefulSet
  schedulerName: ""
  updateStrategy:
    type: RollingUpdate
  minReadySeconds: 0
  priorityClassName: ""
  automountServiceAccountToken: false
  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: 256Mi
    annotations: {}
    labels: {}
    selector: {}
    dataSource: {}
    existingClaim: ""
  persistentVolumeClaimRetentionPolicy:
    enabled: false
    whenScaled: Retain
    whenDeleted: Retain
  service:
    type: NodePort
    ports:
      redis: 6379
    nodePorts:
      redis: ""
    externalTrafficPolicy: Cluster
    extraPorts: []
    internalTrafficPolicy: Cluster
    clusterIP: ""
    loadBalancerIP: ""
    loadBalancerClass: ""
    loadBalancerSourceRanges: []
    externalIPs: []
    annotations: {}
    sessionAffinity: None
    sessionAffinityConfig: {}
  terminationGracePeriodSeconds: 30
  serviceAccount:
    create: true
    name: ""
    automountServiceAccountToken: false
    annotations: {}

# 主从,从库配置
replica:
  kind: StatefulSet
  # 从库数量
  replicaCount: 1
  # 从库配置文件
  configuration: |-
    appendonly no
    save ""
    maxclients 65535
    maxmemory 2G
    slowlog-log-slower-than 10000
    slowlog-max-len 128
    timeout 10
    tcp-keepalive 30
  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: 1,memory: 2Gi}
  podSecurityContext:
    enabled: true
    fsGroupChangePolicy: Always
    sysctls: []
    supplementalGroups: []
    fsGroup: 1001
  containerSecurityContext:
    enabled: true
    seLinuxOptions: null
    runAsUser: 1001
    runAsGroup: 0
    runAsNonRoot: true
    allowPrivilegeEscalation: false
    seccompProfile:
      type: RuntimeDefault
    capabilities:
      drop:
        - ALL
  schedulerName: ""
  updateStrategy:
    type: RollingUpdate
  minReadySeconds: 0
  priorityClassName: ""
  podManagementPolicy: ""
  automountServiceAccountToken: false
  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: 256Mi
    annotations: {}
    labels: {}
    selector: {}
    dataSource: {}
    existingClaim: ""
  persistentVolumeClaimRetentionPolicy:
    enabled: false
    whenScaled: Retain
    whenDeleted: Retain
  # 服务放开的方式
  service:
    type: NodePort
    ports:
      redis: 6379
    nodePorts:
      redis: ""
    externalTrafficPolicy: Cluster
    internalTrafficPolicy: Cluster
    extraPorts: []
    clusterIP: ""
    loadBalancerIP: ""
    loadBalancerClass: ""
    loadBalancerSourceRanges: []
    annotations: {}
    sessionAffinity: None
    sessionAffinityConfig: {}
  terminationGracePeriodSeconds: 30
  autoscaling:
    enabled: false
    minReplicas: 1
    maxReplicas: 11
    targetCPU: ""
    targetMemory: ""
  serviceAccount:
    create: true
    name: ""
    automountServiceAccountToken: false
    annotations: {}

# 哨兵的配置
sentinel:
  enabled: false
  image:
    registry: docker.io
    repository: bitnami/redis-sentinel
    tag: 7.2.4-debian-11-r3
    digest: ""
    pullPolicy: IfNotPresent
    pullSecrets: []
    debug: false
  annotations: {}
  masterSet: mymaster
  quorum: 2
  getMasterTimeout: 90
  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: {}
    requests: {}
  containerSecurityContext:
    enabled: true
    seLinuxOptions: null
    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: ""
    loadBalancerClass: ""
    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: false
  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.56.0-debian-11-r1
    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
    seLinuxOptions: null
    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: ""
    loadBalancerClass: ""
    loadBalancerSourceRanges: []
    annotations: {}
    clusterIP: ""
  serviceMonitor:
    enabled: false
    namespace: ""
    interval: 30s
    scrapeTimeout: ""
    relabellings: []
    metricRelabelings: []
    honorLabels: false
    additionalLabels: {}
    podTargetLabels: []
    sampleLimit: false
    targetLimit: false
    additionalEndpoints: []
  podMonitor:
    enabled: false
    namespace: ""
    interval: 30s
    scrapeTimeout: ""
    relabellings: []
    metricRelabelings: []
    honorLabels: false
    additionalLabels: {}
    podTargetLabels: []
    sampleLimit: false
    targetLimit: false
    additionalEndpoints: []

  prometheusRule:
    enabled: false
    namespace: ""
    additionalLabels: {}
    rules: []


volumePermissions:
  enabled: false
  image:
    registry: docker.io
    repository: bitnami/os-shell
    tag: 11-debian-11-r94
    digest: ""
    pullPolicy: IfNotPresent
    pullSecrets: []
  resources:
    limits: {}
    requests: {}
  containerSecurityContext:
    seLinuxOptions: null
    runAsUser: 0

sysctl:
  enabled: false
  image:
    registry: docker.io
    repository: bitnami/os-shell
    tag: 11-debian-11-r94
    digest: ""
    pullPolicy: IfNotPresent
    pullSecrets: []
  command: []
  mountHostSys: false
  resources:
    limits: {}
    requests: {}

useExternalDNS:
  enabled: false
  suffix: ""
  annotationKey: external-dns.alpha.kubernetes.io/
  additionalAnnotations: {}

优化配置

启动之后手动修改,sts会重启每个pod
这个配置主要是为了优化系统的参数,当然这个是从docker中生效,如果不配置在日志中会有warnning告警。

      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

标签:10,false,enabled,redis,type,helm,true,主从
From: https://www.cnblogs.com/gshelldon/p/18076329

相关文章

  • Redis管理平台
     github地址:https://github.com/qq290070744/redis_admin国内仓库码云地址:https://gitee.com/jiangwenhui_admin/redis_admin安装redis_admin分之说明master为主开发分支,体验最新版本可clone该版本Vx.x.x为稳定发布版本Python环境python>=3.10mysql>=8.0clone项目和虚......
  • redis主从+哨兵模式
    什么是哨兵模式Redis哨兵模式是一种用于确保Redis高可用性的解决方案。通过运行独立的哨兵进程,它能监控主服务器和从服务器的状态,并在主服务器故障时自动执行故障转移操作,将一个从服务器晋升为新的主服务器,从而保障系统的持续可用性。哨兵模式工作原理;监控主从服务器:在Re......
  • Redis zset 底层结构
    Rediszset底层结构  概要  在Redis的五种主要数据类型中,zset(有序集合)类型可能是最复杂,但也是最强大的一种。zset不仅可以存储键值对,还可以为每个元素分配一个分数,然后根据这个分数进行排序。这使得Zset非常适合用于实现排行榜、时间线等功能。  一、Zset底层结......
  • 基于ubuntu镜像构建redis镜像
    第一步:编辑DockerfileviDockerfile#写入FROMubuntu:latestMAINTAINERlqzWORKDIR/softRUNapt-getupdate&&apt-getinstallwgetmakebuild-essential-yRUNwgethttps://github.com/redis/redis/archive/7.0.11.tar.gz&&tar-xzvf7.0.11.tar.gz......
  • 操作Redis之go-redis
    目录一、go操作redis的选择二、redis安装1.windowd平台安装方案2.mac平台和linux平台安装方案3.redis应用三、快速使用1.快速连接2.字符串操作(1)方法(2)示例3.列表操作(1)方法(2)示例4.hash操作(1)方法(2)示例5.集合操作(1)方法(2)示例6.有序集合操作(1)方法(2)示例7.通用操作(1)方法(2)示例8.......
  • 操作Redis之redigo
    目录一、go操作redis的选择二、redigo快速使用1.快速链接三、redis操作四、连接池一、go操作redis的选择golang操作redis主要有两个库,go-redis和redigo。go-redis:star数更多,支持连接哨兵及集群模式的Redisredigo:star数少一些,操作更简单二、redigo快速使用安装:gog......
  • redis自学(18)epoll
    Epollepoll模式是对select和poll的改进,它提供了三个函数:       Epoll有没有解决之前select或者poll的问题? select或者poll把要监听的数组或集合拷贝到内核空间,等待FD就绪,就绪后,还要拷贝回用户空间。 epoll把select函数的功能拆分开了,建立eventpoll以后......
  • Spring-Redis 使用
    基本类型:String存储数据:stringRedisTemplate.opsForValue().set("key","value");获取数据:Stringvalue=stringRedisTemplate.opsForValue().get("key");设置数据的过期时间(单位为秒):stringRedisTemplate.expire("key",60,Tim......
  • 面试知识汇总:Redis简介
    RemoteDictionaryServer(远程字典服务),是一个开源的使用ANSIC语言编写、支持网络、可基于内存亦可持久化的日志型、Key-Value数据库,并提供多种语言的API。基本的数据结构:String是Redis最基础的数据结构类型,它是二进制安全的,可以存储图片或者序列化的对象,值最大存储为512M。......
  • Redis高级-删除策略、主从复制、哨兵模式
    1.删除策略1.过期数据redis中的数据特征Redis是一种内存级数据库,所有数据均存放在内存中,内存中的数据可以通过TTL指令获取其状态TTL返回的值有三种情况:正数,-1,-2正数:代表该数据在内存中还能存活的时间-1:永久有效的数据-2 :已经过期的数据或被删除的数据或未定义的数据......