# 创建持久化目录
mkdir -p /opt/bigdata/servers/mysql/data/data1
# 先准备好镜像
docker pull docker.io/bitnami/mysql:8.0.30-debian-11-r15
docker tag docker.io/bitnami/mysql:8.0.30-debian-11-r15 myharbor.com/bigdata/mysql:8.0.30-debian-11-r15
docker push myharbor.com/bigdata/mysql:8.0.30-debian-11-r15
# mysqld-exporter
docker pull docker.io/bitnami/mysqld-exporter:0.14.0-debian-11-r33
docker tag docker.io/bitnami/mysqld-exporter:0.14.0-debian-11-r33 myharbor.com/bigdata/mysqld-exporter:0.14.0-debian-11-r33
docker push myharbor.com/bigdata/mysqld-exporter:0.14.0-debian-11-r33
# 开始安装
helm install mysql ./mysql -n mysql --create-namespace
NAME: mysql
LASTDEPLOYED:MonSep1923:57:182022NAMESPACE: mysql
STATUS: deployed
REVISION:1TESTSUITE:NoneNOTES:CHARTNAME: mysql
CHARTVERSION:9.3.3APPVERSION:8.0.30**Please be patient while the chart is being deployed **Tip:Watch the deployment status using the command: kubectl get pods -w --namespace mysql
Services:
echo Primary: mysql-primary.mysql.svc.cluster.local:3306
echo Secondary: mysql-secondary.mysql.svc.cluster.local:3306Execute the following to get the administrator credentials:
echo Username: root
MYSQL_ROOT_PASSWORD=$(kubectl get secret --namespace mysql mysql -o jsonpath="{.data.mysql-root-password}"| base64 -d)To connect to your database:1.Run a pod that you can useas a client:
kubectl run mysql-client --rm --tty -i --restart='Never' --image myharbor.com/bigdata/mysql:8.0.30-debian-11-r15 --namespace mysql --env MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD--command -- bash
2.To connect to primary service(read/write):
mysql -h mysql-primary.mysql.svc.cluster.local -uroot -p"$MYSQL_ROOT_PASSWORD"3.To connect to secondary service(read-only):
mysql -h mysql-secondary.mysql.svc.cluster.local -uroot -p"$MYSQL_ROOT_PASSWORD"To access the MySQLPrometheus metrics from outside the cluster execute the following commands:
kubectl port-forward --namespace mysql svc/mysql-metrics 9104:9104&
curl http://127.0.0.1:9104/metrics
查看 pod 状态:
kubectl get pods,svc -n mysql -owide
五、Prometheus 监控
Prometheus:
https://prometheus.k8s.local/targets?search=mysql
可以通过命令查看采集数据:
kubectl get --raw http://10.244.0.74:9104/metrics
kubectl get --raw http://10.244.1.125:9104/metrics
kubectl get --raw http://10.244.2.178:9104/metrics
helm uninstall mysql -n mysql
kubectl delete pod -n mysql `kubectl get pod -n mysql |awk 'NR>1{print $1}'` --force
kubectl patch ns mysql -p '{"metadata":{"finalizers":null}}'
kubectl delete ns mysql --force
T-CODE——axtshow DATA:lv_zzbranch TYPE ze_les_branch, ls_aet088 TYPE zlesaet088_bol_attr, lr_adminh TYPE REF TO cl_crm_bol_entity. lr_entity_relationv TYPE REF TO cl_crm_bol_entity. lr_entity_relationv lr_adminh->get_related_entity( …