mysqld_exporter使用
【代码】mysqld_exporter使用。
·
下载自己解压好
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
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
已为社区贡献9条内容
所有评论(0)