下载自己解压好
https://github.com/prometheus/mysqld_exporter/releases/download/v0.15.1/mysqld_exporter-0.15.1.linux-amd64.tar.gz
在需要监控的数据库上执行
CREATE USER 'monit_test'@'*' IDENTIFIED BY 'Sfn4ZCHsK' WITH MAX_USER_CONNECTIONS 3;
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'monit_test'@'%';
FLUSH PRIVILEGES;
# cat >my.cnf<<EOF
[client]
user=monit_test
password=Sfn4
host=im-rds-instance.ccom
prot=3306
EOF
cat >Dockerfile<<EOF
FROM alpine:latest
WORKDIR /app
RUN echo "https://mirrors.tuna.tsinghua.edu.cn/alpine/latest-stable/main" > /etc/apk/repositories && \
echo "https://mirrors.tuna.tsinghua.edu.cn/alpine/latest-stable/community" >> /etc/apk/repositories && \
apk update && \
apk add tzdata bash-doc bash && \
mkdir /lib64 && \
ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2
RUN mkdir /config/
COPY my.cnf /config/my.cnf
COPY mysqld_exporter /app/mysqld_exporter
ENTRYPOINT ["/app/mysqld_exporter", "--config.my-cnf=/config/my.cnf"]
EOF
cat >mysql-monit.yaml<<EOF
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysqld-exporter
spec:
replicas: 1
selector:
matchLabels:
app: mysqld-exporter
template:
metadata:
labels:
app: mysqld-exporter
spec:
containers:
- name: mysqld-exporter
image: mysqld:v01
ports:
- containerPort: 9104
resources:
requests:
cpu: "100m"
memory: "256Mi"
limits:
cpu: "4000m"
memory: "4096Mi"
---
apiVersion: v1
kind: Service
metadata:
name: mysqld-exporter
spec:
selector:
app: mysqld-exporter
ports:
- protocol: TCP
name: web
port: 9104
targetPort: 9104
EOF
文章来源地址https://www.toymoban.com/news/detail-769708.html
文章来源:https://www.toymoban.com/news/detail-769708.html
到了这里,关于mysqld_exporter使用的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!