k8s集群部署mysql8主备

一、搜索mysql8版本

# helm search repo mysql

# helm pull bitnami/mysql --version:11.1.2

# tar -zxf mysql-11.1.2.tgz

# cd mysql

二、修改value.ysqml文件

动态存储类自己提前搭建。

# helm install mysql8 -n mysql-cluster ./ -f values.yaml
NAME: mysql8
LAST DEPLOYED: Thu Jul 11 21:47:23 2024
NAMESPACE: mysql-cluster
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: mysql
CHART VERSION: 11.1.2
APP VERSION: 8.4.0

** Please be patient while the chart is being deployed **

Tip:

  Watch the deployment status using the command: kubectl get pods -w --namespace mysql-cluster

Services:

  echo Primary: mysql8-primary.mysql-cluster.svc.cluster.local:3306
  echo Secondary: mysql8-secondary.mysql-cluster.svc.cluster.local:3306

Execute the following to get the administrator credentials:

  echo Username: root
  MYSQL_ROOT_PASSWORD=$(kubectl get secret --namespace mysql-cluster mysql8 -o jsonpath="{.data.mysql-root-password}" | base64 -d)

To connect to your database:

  1. Run a pod that you can use as a client:

      kubectl run mysql8-client --rm --tty -i --restart='Never' --image  dhub.kubesre.xyz/bitnami/mysql:8.4.0-debian-12-r3 --namespace mysql-cluster --env MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD --command -- bash

  2. To connect to primary service (read/write):

      mysql -h mysql8-primary.mysql-cluster.svc.cluster.local -uroot -p"$MYSQL_ROOT_PASSWORD"

  3. To connect to secondary service (read-only):

      mysql -h mysql8-secondary.mysql-cluster.svc.cluster.local -uroot -p"$MYSQL_ROOT_PASSWORD"






WARNING: There are "resources" sections in the chart not set. Using "resourcesPreset" is not recommended for production. For production installations, please set the following values according to your workload needs:
  - primary.resources
  - secondary.resources
+info https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/

⚠ SECURITY WARNING: Original containers have been substituted. This Helm chart was designed, tested, and validated on multiple platforms using a specific set of Bitnami and Tanzu Application Catalog containers. Substituting other containers is likely to cause degraded security and performance, broken chart features, and missing environment variables.

Substituted images detected:
  - dhub.kubesre.xyz/bitnami/mysql:8.4.0-debian-12-r3
  - dhub.kubesre.xyz/bitnami/os-shell:12-debian-12-r22
  - dhub.kubesre.xyz/bitnami/mysqld-exporter:0.15.1-debian-12-r17

三、检查及测试

登录master:

登录备库:

相关推荐

  1. Kubernetes (K8s) 部署

    2024-07-12 11:00:05       64 阅读
  2. kubeadm部署k8s

    2024-07-12 11:00:05       48 阅读
  3. kubeasz部署k8s

    2024-07-12 11:00:05       50 阅读
  4. k8s部署Minio

    2024-07-12 11:00:05       45 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-12 11:00:05       66 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-12 11:00:05       70 阅读
  3. 在Django里面运行非项目文件

    2024-07-12 11:00:05       57 阅读
  4. Python语言-面向对象

    2024-07-12 11:00:05       68 阅读

热门阅读

  1. 常用的Web前端框架:深入探索与实用指南

    2024-07-12 11:00:05       18 阅读
  2. 使用Python自动识别和合并PDF中的跨页表格

    2024-07-12 11:00:05       19 阅读
  3. 如何用CSS3画一个三角形?

    2024-07-12 11:00:05       23 阅读
  4. Spring Boot实战:无缝对接OpenAI

    2024-07-12 11:00:05       20 阅读
  5. MVVM和MVC的原理以及它们的区别

    2024-07-12 11:00:05       24 阅读
  6. stopSelf 会走ondestory吗? 怎么关闭server

    2024-07-12 11:00:05       24 阅读
  7. YOLOv10单独推理的封装

    2024-07-12 11:00:05       16 阅读
  8. c#的几种通信

    2024-07-12 11:00:05       18 阅读
  9. 前端代码规范

    2024-07-12 11:00:05       19 阅读
  10. MATLAB——字符串处理

    2024-07-12 11:00:05       20 阅读