如在使用中有疑问,可以交流哈
##前提已经有了k8s集群钱上面部署有promenade
#https://prometheus.io/download/ 去官网下载exporter
#解压
mkdir -p /opt/soft && cd /opt/soft
tar -xf mysqld_exporter-0.13.0.linux-amd64.tar.gz
ln -s mysqld_exporter-0.13.0.linux-amd64 mysqld_exporter
groupadd prometheus
useradd -g prometheus -m -d /var/lib/prometheus -s /sbin/nologin prometheus
chown -R prometheus:prometheus /opt/soft/
##因为有密码所以报存起来 客户端链接配置
cat /opt/soft/mysqld_exporter/.my.cnf
[client]
user=mysqld_exporter
password=mysqld_exporter
##做成后端服务,systemd来管理 需要到system目录建service
`cd /etc/systemd/system/` ##必须此目录下新建service,不然报错
cat <<'EOF' > mysqld_exporter.service
[Unit]
Description=mysqld_exporter
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
User=prometheus
ExecStart=/opt/soft/mysqld_exporter/mysqld_exporter --config.my-cnf=/opt/soft/mysqld_exporter/.my.cnf --collect.auto_increment.columns --collect.engine_innodb_status --collect.global_status --web.listen-address=0.0.0.0:9104
Restart=always
[Install]
WantedBy=multi-user.target
EOF
##需哟登陆mysql数据库,此处需要使用
user.host=‘localhost’;
CREATE USER 'mysqld_exporter'@'%' IDENTIFIED BY 'mysqld_exporter;
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'mysqld_exporter'@'%';
flush privileges;
#加载新建或者修改service配置
systemctl daemon-reload
#启动服务
systemctl start mysqld_exporter.service
#加到开机自启动
systemctl enable node_exporter.service
#查看服务状态非常有用 加个 -l 参数
systemctl status mysqld_exporter.service -l
#################以上步骤为msyql主机的操作#################
```bash
#################在k8s集群修改prometheues.configmap监控系统操作###################
##在configmap增加msyql的job配置
- job_name: prometheus
static_configs:
- targets:
- localhost:9090
- job_name: mysqld_exporter
static_configs:
- targets:
- x.x.x.x:9104 ###此处冒号不能是空格
#详细内容见 本目录下 promethuesConfigmap.yml
###重启pod 因为deployment 删除pod后会重新加载comfigmap配置