helm 安装mysql主从(8.0.36)版本

helm repo add bitnami https://charts.bitnami.com/bitnami
helm pull bitnami/mysql --untar
> helm search repo  bitnami/mysql
NAME         	CHART VERSION	APP VERSION	DESCRIPTION                                       
bitnami/mysql	9.19.1       	8.0.36     	MySQL is a fast, reliable, scalable, and easy t...

YAML调整 #存储类,用于从库持久化数据用的是openebs-hostpath

 # grep -Ev "$^|#" values.yaml 
global:
  imageRegistry: ""
  imagePullSecrets: []
  storageClass: "openebs-hostpath"
kubeVersion: ""
nameOverride: ""
fullnameOverride: ""
namespaceOverride: ""
clusterDomain: cluster.local
commonAnnotations: {}
commonLabels: {}
extraDeploy: []
serviceBindings:
  enabled: false
diagnosticMode:
  enabled: false
  command:
    - sleep
  args:
    - infinity
image:
  registry: docker.io
  repository: bitnami/mysql
  tag: 8.0.36-debian-11-r4
  digest: ""
  pullPolicy: IfNotPresent
  pullSecrets: []
  debug: false
architecture: replication #architecture参数表示mysql的架构,本次部署架构是主从复制,取值replication #如果部署的是单机版,取值standalone即可,下面secondary部分不用改
auth:
  rootPassword: ""
  createDatabase: false
  database: "my_database"
  username: ""
  password: ""
  replicationUser: replicator  #主从复制的专用用户
  replicationPassword: "123qweasd"  #主从复制的专用用户密码
  existingSecret: ""
  usePasswordFiles: false
  customPasswordFiles: {}
  defaultAuthenticationPlugin: ""
initdbScripts: {}
initdbScriptsConfigMap: ""
startdbScripts: {}
startdbScriptsConfigMap: ""
primary:  #这块是主库配置,这里没有定义主库的pod副本数,是在主库模板文件里面定义的
  name: master
  command: []
  args: []
  lifecycleHooks: {}
  automountServiceAccountToken: false
  hostAliases: []
  configuration: |-
    [mysqld]
    default_authentication_plugin={{- .Values.auth.defaultAuthenticationPlugin | default "caching_sha2_password" }}
    skip-name-resolve
    explicit_defaults_for_timestamp
    basedir=/opt/bitnami/mysql
    plugin_dir=/opt/bitnami/mysql/lib/plugin
    port= {{ .Values.primary.containerPorts.mysql }}
    socket=/opt/bitnami/mysql/tmp/mysql.sock
    datadir=/bitnami/mysql/data
    tmpdir=/opt/bitnami/mysql/tmp
    max_allowed_packet=16M
    bind-address=*
    pid-file=/opt/bitnami/mysql/tmp/mysqld.pid
    log-error=/opt/bitnami/mysql/logs/mysqld.log
    character-set-server=UTF8
    slow_query_log=0
    long_query_time=10.0
    [client]
    port=3306
    socket=/opt/bitnami/mysql/tmp/mysql.sock
    default-character-set=UTF8
    plugin_dir=/opt/bitnami/mysql/lib/plugin
    [manager]
    port=3306
    socket=/opt/bitnami/mysql/tmp/mysql.sock
    pid-file=/opt/bitnami/mysql/tmp/mysqld.pid
  existingConfigmap: ""
  containerPorts:
    mysql: 3306
  updateStrategy:
    type: RollingUpdate
  podAnnotations: {}
  podAffinityPreset: ""
  podAntiAffinityPreset: soft
  nodeAffinityPreset:
    type: ""
    key: ""
    values: []
  affinity: {}
  nodeSelector: {}
  tolerations: []
  priorityClassName: ""
  runtimeClassName: ""
  schedulerName: ""
  terminationGracePeriodSeconds: ""
  topologySpreadConstraints: []
  podManagementPolicy: ""
  podSecurityContext:
    enabled: true
    fsGroupChangePolicy: Always
    sysctls: []
    supplementalGroups: []
    fsGroup: 1001
  containerSecurityContext:
    enabled: true
    seLinuxOptions: null
    runAsUser: 1001
    runAsNonRoot: true
    allowPrivilegeEscalation: false
    capabilities:
      drop: ["ALL"]
    seccompProfile:
      type: "RuntimeDefault"
  resources:
    limits: {}
    requests: {}
  livenessProbe:
    enabled: true
    initialDelaySeconds: 5
    periodSeconds: 10
    timeoutSeconds: 1
    failureThreshold: 3
    successThreshold: 1
  readinessProbe:
    enabled: true
    initialDelaySeconds: 5
    periodSeconds: 10
    timeoutSeconds: 1
    failureThreshold: 3
    successThreshold: 1
  startupProbe:
    enabled: true
    initialDelaySeconds: 15
    periodSeconds: 10
    timeoutSeconds: 1
    failureThreshold: 10
    successThreshold: 1
  customLivenessProbe: {}
  customReadinessProbe: {}
  customStartupProbe: {}
  extraFlags: ""
  extraEnvVars: []
  extraEnvVarsCM: ""
  extraEnvVarsSecret: ""
  extraPodSpec: {}
  extraPorts: []
  persistence:
    enabled: true
    existingClaim: ""
    subPath: ""
    storageClass: "openebs-hostpath"
    annotations: {}
    accessModes:
      - ReadWriteOnce
    size: 8Gi
    selector: {}
  persistentVolumeClaimRetentionPolicy:
    enabled: false
    whenScaled: Retain
    whenDeleted: Retain
  extraVolumes: []
  extraVolumeMounts: []
  initContainers: []
  sidecars: []
  service:
    type: ClusterIP
    ports:
      mysql: 3306
    nodePorts:
      mysql: ""
    clusterIP: ""
    loadBalancerIP: ""
    externalTrafficPolicy: Cluster
    loadBalancerSourceRanges: []
    extraPorts: []
    annotations: {}
    sessionAffinity: None
    sessionAffinityConfig: {}
    headless:
      annotations: {}
  pdb:
    create: false
    minAvailable: 1
    maxUnavailable: ""
  podLabels: {}
secondary:   #这块是从库的相关配置
  name: slave
  replicaCount: 1  #从库的副本数量设置,默认是1
  automountServiceAccountToken: false
  hostAliases: []
  command: []
  args: []
  lifecycleHooks: {}
  configuration: |-
    [mysqld]
    default_authentication_plugin=caching_sha2_password
    skip-name-resolve
    explicit_defaults_for_timestamp
    basedir=/opt/bitnami/mysql
    plugin_dir=/opt/bitnami/mysql/lib/plugin
    port={{ .Values.secondary.containerPorts.mysql }}
    socket=/opt/bitnami/mysql/tmp/mysql.sock
    datadir=/bitnami/mysql/data
    tmpdir=/opt/bitnami/mysql/tmp
    max_allowed_packet=16M
    bind-address=*
    pid-file=/opt/bitnami/mysql/tmp/mysqld.pid
    log-error=/opt/bitnami/mysql/logs/mysqld.log
    character-set-server=UTF8
    slow_query_log=0
    long_query_time=10.0
    [client]
    port=3306
    socket=/opt/bitnami/mysql/tmp/mysql.sock
    default-character-set=UTF8
    plugin_dir=/opt/bitnami/mysql/lib/plugin
    [manager]
    port=3306
    socket=/opt/bitnami/mysql/tmp/mysql.sock
    pid-file=/opt/bitnami/mysql/tmp/mysqld.pid
  existingConfigmap: ""
  containerPorts:
    mysql: 3306
  updateStrategy:
    type: RollingUpdate
  podAnnotations: {}
  podAffinityPreset: ""
  podAntiAffinityPreset: soft
  nodeAffinityPreset:
    type: ""
    key: ""
    values: []
  affinity: {}
  nodeSelector: {}
  tolerations: []
  priorityClassName: ""
  runtimeClassName: ""
  schedulerName: ""
  terminationGracePeriodSeconds: ""
  topologySpreadConstraints: []
  podManagementPolicy: ""
  podSecurityContext:
    enabled: true
    fsGroupChangePolicy: Always
    sysctls: []
    supplementalGroups: []
    fsGroup: 1001
  containerSecurityContext:
    enabled: true
    seLinuxOptions: null
    runAsUser: 1001
    runAsNonRoot: true
    allowPrivilegeEscalation: false
    capabilities:
      drop: ["ALL"]
    seccompProfile:
      type: "RuntimeDefault"
  resources:
    limits: {}
    requests: {}
  livenessProbe:
    enabled: true
    initialDelaySeconds: 5
    periodSeconds: 10
    timeoutSeconds: 1
    failureThreshold: 3
    successThreshold: 1
  readinessProbe:
    enabled: true
    initialDelaySeconds: 5
    periodSeconds: 10
    timeoutSeconds: 1
    failureThreshold: 3
    successThreshold: 1
  startupProbe:
    enabled: true
    initialDelaySeconds: 15
    periodSeconds: 10
    timeoutSeconds: 1
    failureThreshold: 15
    successThreshold: 1
  customLivenessProbe: {}
  customReadinessProbe: {}
  customStartupProbe: {}
  extraFlags: ""
  extraEnvVars: []
  extraEnvVarsCM: ""
  extraEnvVarsSecret: ""
  extraPodSpec: {}
  extraPorts: []
  persistence:
    enabled: true
    existingClaim: ""
    subPath: ""
    storageClass: ""
    annotations: {}
    accessModes:
      - ReadWriteOnce
    size: 8Gi
    selector: {}
  persistentVolumeClaimRetentionPolicy:
    enabled: false
    whenScaled: Retain
    whenDeleted: Retain
  extraVolumes: []
  extraVolumeMounts: []
  initContainers: []
  sidecars: []
  service:
    type: ClusterIP
    ports:
      mysql: 3306
    nodePorts:
      mysql: ""
    clusterIP: ""
    loadBalancerIP: ""
    externalTrafficPolicy: Cluster
    loadBalancerSourceRanges: []
    extraPorts: []
    annotations: {}
    sessionAffinity: None
    sessionAffinityConfig: {}
    headless:
      annotations: {}
  pdb:
    create: false
    minAvailable: 1
    maxUnavailable: ""
  podLabels: {}
serviceAccount:
  create: true
  name: ""
  annotations: {}
  automountServiceAccountToken: false
rbac:
  create: false
  rules: []
networkPolicy:
  enabled: true
  allowExternal: true
  allowExternalEgress: true
  extraIngress: []
  extraEgress: []
  ingressNSMatchLabels: {}
  ingressNSPodMatchLabels: {}
volumePermissions:
  enabled: false
  image:
    registry: docker.io
    repository: bitnami/os-shell
    tag: 11-debian-11-r96
    digest: ""
    pullPolicy: IfNotPresent
    pullSecrets: []
  resources: {}
metrics:
  enabled: true
  image:
    registry: docker.io
    repository: bitnami/mysqld-exporter
    tag: 0.15.1-debian-11-r5
    digest: ""
    pullPolicy: IfNotPresent
    pullSecrets: []
  containerSecurityContext:
    enabled: true
    seLinuxOptions: null
    runAsUser: 1001
    runAsNonRoot: true
  containerPorts:
    http: 9104
  service:
    type: ClusterIP
    port: 9104
    clusterIP: ""
    annotations:
      prometheus.io/scrape: "true"
      prometheus.io/port: "{{ .Values.metrics.service.port }}"
  extraArgs:
    primary: []
    secondary: []
  resources:
    limits: {}
    requests: {}
  livenessProbe:
    enabled: true
    initialDelaySeconds: 120
    periodSeconds: 10
    timeoutSeconds: 1
    successThreshold: 1
    failureThreshold: 3
  readinessProbe:
    enabled: true
    initialDelaySeconds: 30
    periodSeconds: 10
    timeoutSeconds: 1
    successThreshold: 1
    failureThreshold: 3
  serviceMonitor:
    enabled: false
    namespace: ""
    jobLabel: ""
    interval: 30s
    scrapeTimeout: ""
    relabelings: []
    metricRelabelings: []
    selector: {}
    honorLabels: false
    labels: {}
    annotations: {}
  prometheusRule:
    enabled: false
    namespace: ""
    additionalLabels: {}
    rules: []
安装
helm install mysql mysql-9.19.1.tgz -f values.yaml

在这里插入图片描述

登录主库查看

helm 安装mysql主从(8.0.36)版本_第1张图片

再到从库

helm 安装mysql主从(8.0.36)版本_第2张图片

再主库导数据之后,从库查看数据一致就算成功

helm 安装mysql主从(8.0.36)版本_第3张图片

你可能感兴趣的:(存储,Kubernetes,mysql,adb,数据库)