prometheus之mysqld_exporter部署

news/2024/5/19 1:19:42 标签: prometheus

mysql_exporter部署

下载解压压缩包
mkdir /opt/mysqld_exporter/
cd /opt/mysqld_exporter/
# 修改为自己的软件下载地址
wget http://soft.download/soft/linux/prometheus/mysqld_exporter/mysqld_exporter-0.14.0.linux-amd64.tar.gz
tar -zxvf  mysqld_exporter-0.14.0.linux-amd64.tar.gz
添加mysqld_exporter配置文件
[root@shuan-node0132 mysqld_exporter-0.14.0.linux-amd64]# cat .my.cnf
[client]
host = localhost
user = reporter #mysql账号
password = 123456yuyuyut #mysql密码
port = 3308 #mysql端口
mysql授权监控账号exporter
CREATE USER 'reporter'@'localhost' IDENTIFIED BY '123456yuyuyut' WITH MAX_USER_CONNECTIONS 3;
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'reporter'@'localhost';
编写service服务文件
vim /etc/systemd/system/mysqld_exporter.service
[Service]
ExecStart=/opt/mysqld_exporter/mysqld_exporter-0.14.0.linux-amd64/mysqld_exporter --config.my-cnf /opt/mysqld_exporter/mysqld_exporter-0.14.0.linux-amd64/.my.cnf
[Install]
WantedBy=multi-user.target
[Unit]
Description=mysqld_exporter
After=network.target
启动服务并设置开机自启
systemctl start mysqld_exporter
systemctl enable mysqld_exporter
防火墙开放端口
firewall-cmd --permanent --add-port=9104/tcp --zone=public&&firewall-cmd --reload
安装脚本
cat install_mysqld_exporter.sh
#!/bin/bash
InstallDir='/opt/mysqld_exporter/'
FileName='mysqld_exporter-0.14.0.linux-amd64.tar.gz'

function RedFont(){
  echo -e "\033[31mError: $1 \033[0m"
}

function GreenFont(){
  echo -e "\033[32mSuccess: $1 \033[0m"
}

function YellowFont(){
  echo -e "\033[33mWarning: $1 \033[0m"
}

if [ ! -d "$InstallDir" ];then
    mkdir $InstallDir
else
    YellowFont "${InstallDir}文件夹已经存在,请删除后重新执行"
    exit
fi

#进入安装目录
cd $InstallDir

#下载安装包
wget http://soft.download/soft/linux/prometheus/mysqld_exporter/$FileName > /dev/null 2>&1

if [ $? -eq 0 ];then
   GreenFont "$FileName download success"
else
   RedFont "$FileName download faild"
   exit
fi

#解压安装包到指定目录,解压不包含压缩一级目录
tar -zxf $FileName --strip-components 1 -C $InstallDir > /dev/null 2>&1

if [ $? -eq 0 ];then
   GreenFont "$FileName decompress success"
else
   RedFont "$FileName decompress faild"
   exit
fi

#创建配置文件
cat > ${InstallDir}.my.cnf << EOF
[client]
host = localhost
user = reporter #mysql账号
password = 123456yuyuyut #mysql密码
port = 3308 #mysql端口
EOF

#设置开机自启
cat > /etc/systemd/system/mysqld_exporter.service << EOF
[Service]
ExecStart=${InstallDir}mysqld_exporter --config.my-cnf ${InstallDir}.my.cnf
[Install]
WantedBy=multi-user.target
[Unit]
Description=mysqld_exporter
After=network.target
EOF

#防火墙放行端口
firewall-cmd --permanent --add-port=9104/tcp --zone=public&&firewall-cmd --reload

#启动服务
systemctl  daemon-reload
systemctl enable mysqld_exporter
systemctl start mysqld_exporter && GreenFont "started mysqld_exporter" || RedFont "start mysqld_exporter faild"

http://www.niftyadmin.cn/n/5367625.html

相关文章

MybatisPlus快速入门及常见设置

目录 一、快速入门 1.1 准备数据 1.2 创建SpringBoot工程 1.3 使用MP 1.4 获取Mapper进行测试 二、常用设置 2.1 设置表映射规则 2.1.1 单独设置 2.1.2 全局设置 2.2 设置主键生成策略 2.2.1 为什么会有雪花算法&#xff1f; 2.2.2 垂直分表 2.2.3 水平分表 2.…

Doris中的本地routineload环境,用于开发回归测试用例

----------------2024-2-6-更新-------------- doris的routineload&#xff0c;就是从kafka中加载数据到表&#xff0c;特点是定时、周期性的从kafka取数据。 要想在本地开发测试routine load相关功能&#xff0c;需要配置kafka环境&#xff0c;尤其是需要增加routine load回…

【react native】ScrollView的触摸事件与TouchableWithoutFeedback的点击事件冲突

需求背景 使用 ScrollView 组件实现轮播图效果&#xff0c;该轮播图可以自动向右滑动。有下面两个需求&#xff1a; &#xff08;1&#xff09;希望用户左右点击的时候&#xff0c;视图可以向左/向右滚动&#xff1b; &#xff08;2&#xff09;希望用户触摸在屏幕的时候&am…

openssl3.2 - update debian12‘s default openssl to openssl3.2

文章目录 openssl3.2 - update debian12s default openssl to openssl3.2概述笔记回到debian12自带的openssl版本从源码编译安装最新版的openssl配置ssl访问END openssl3.2 - update debian12’s default openssl to openssl3.2 概述 在debian12虚拟机中编译了openssl3.2(ope…

Java中JVM常用参数配置(提供配置示例)

目录 前言一、内存参数配置二、垃圾收集器配置三、GC策略配置3.1、基础通用配置3.2、Parallel 和 Parallel Old 常用参数配置3.3、CMS 常用参数配置3.4、G1 常用参数配置 四、GC日志配置五、dump 日志参数配置5.1、OutOfMemory异常时生成dump文件5.2、发生Full GC时生成dump文件…

利用LLM大模型生成sql的深入应用探究

Chat2DB 是一款有开源免费的多数据库客户端工具,和传统的数据库客户端软件Navicat、DBeaver 相比 Chat2DB 集成了 AIGC 的能力&#xff0c;能够将自然语言转换为 SQL&#xff0c;也可以将 SQL 转换为自然语言&#xff0c;可以给出研发人员 SQL 的优化建议&#xff0c;极大地提升…

2.6学习总结

2.6 1.蓝桥公园 2.路径 3.打印路径 4.【模板】Floyd Floyd算法&#xff1a; 是一种多源的最短路径算法&#xff0c;经过一次计算可以得到任意两个点之间的最短路径。 这种算法是基于动态规划的思想&#xff1a; m[i][j]表示从i到j这条边的距离&#xff0c;dp[k][i][j]表示从…

【机器学习300问】23、什么是主动学习?

一、带标签的数据很难获得 机器学习中&#xff0c;比如监督学习需要带有标签的训练样本才能得到模型&#xff0c;然而在以下几种场景中去获取带有标签的数据是很难的&#xff1a; 自动驾驶场景&#xff1a;对自动驾驶汽车收集的高清地图数据或实时摄像头数据进行标注&#xff…