prometheus监控mysql,mysql_exporter安装
监控mysql主机需要安装mysql_exporter,到官网下载自己需要的版本下载地址https://prometheus.io/download/下载node_exportwget https://github.com/prometheus/mysqld_exporter/releases/download/v0.13.0/mysqld_exporter-0.13.0.linux-amd64.
·
监控mysql主机需要安装mysql_exporter,到官网下载自己需要的版本
下载地址https://prometheus.io/download/
下载node_export
wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.13.0/mysqld_exporter-0.13.0.linux-amd64.tar.gz
#解压
tar -zxvf mysqld_exporter-0.13.0.linux-amd64.tar.gz
复制到/usr/local/下
cp -rf mysqld_exporter-0.13.0.linux-amd64.tar.gz /usr/local/mysqld_exporter
创建连接数据库的配置文件
cd /usr/local/mysqld_exporter
vim my.cnf
[client]
host=127.0.0.1
port=13306
user=root
password=xxxxxxx
启动服务
./mysqld_exporter --config.my-cnf="./my.cnf"
查询服务启动是否成功,端口为9104
systemctl 启动mysql_exporter
vim /usr/lib/systemd/system/mysqld_exporter.service
[Unit]
Description=mysqld_exporter
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/mysqld_exporter/mysqld_exporter --config.my-cnf=/usr/local/mysqld_exporter/my.cnf
Restart=on-failure
[Install]
WantedBy=multi-user.target
启动服务
systemctl daemon-reload
systemctl start mysqld_exporter
systemctl status mysqld_exporter
systemctl enable mysqld_exporter # 设置开机启动
prometheus 收集数据并监控
vi /prometheus/prometheus.yml
- job_name: mysql_exporter
static_configs:
- targets: ['192.168.*.**:9104']
labels:
group: mysqlgroup
完成监控
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
已为社区贡献1条内容
所有评论(0)