CentOS7安装Prometheus(二进制)
2024-09-02 07:36:58
一、概述
Prometheus是由SoundCloud开发的开源监控报警系统和时序列数据库(TSDB)。Prometheus使用Go语言开发,是Google BorgMon监控系统的开源版本。
环境说明
操作系统:centos 7.6
ip地址:192.168.31.150
下载包
https://prometheus.io/download/
目前最新版是:2.14.0
下载链接:
https://github.com/prometheus/prometheus/releases/download/v2.14.0/prometheus-2.14.0.linux-amd64.tar.gz
二、安装
useradd prometheus -s /sbin/nologin
tar zxvf prometheus-2.14..linux-amd64.tar.gz -C /data
mv /data/prometheus-2.14..linux-amd64 /data/prometheus
chown prometheus:prometheus -R /data/prometheus
封装service
vi /etc/systemd/system/prometheus.service
内容如下:
[Unit]
Description=Prometheus
After=network.target
[Service]
ExecStart=/data/prometheus/prometheus --config.file=/data/prometheus/prometheus.yml --storage.tsdb.path=/data/prometheus/data
User=prometheus
[Install]
WantedBy=multi-user.target
注意:主要修改ExecStart和User
设置开机自启动
systemctl daemon-reload
systemctl enable prometheus
systemctl start prometheus
查看端口
# ss -tunlp|grep prometheus
tcp LISTEN ::: :::* users:(("prometheus",pid=,fd=))
如果是centos 6.x系统,需要自己写一个启动脚本。
vi /etc/init.d/prometheus
内容如下:
#!/bin/bash
# auditd Start jar package
# chkconfig: 2345 14 87
# description: This is admin project
#define var
PROJECT_SERVICE="prometheus"
PORT=""
. /etc/init.d/functions
export START="nohup /data/prometheus/prometheus --config.file=/data/prometheus/prometheus.yml --storage.tsdb.path=/data/prometheus/data &"
#服务脚本
start(){
echo "${PROJECT_SERVICE} starting....."
cd /data/${PROJECT_SERVICE} && eval $START
if [ $? -eq 0 ];then
action "$PROJECT_SERVICE is starting" /bin/true
else
action "$PROJECT_SERVICE is starting" /bin/false
fi
}
stop(){
kill -9 `lsof -t -i:${PORT}`
if [ $? -eq 0 ];then
action "$PROJECT_SERVICE is stoping" /bin/true
else
action "$PROJECT_SERVICE is stoping" /bin/false
fi
}
status(){
if [ `ss -tunlp|grep ${PROJECT_SERVICE}|awk '{print $5}'|cut -d: -f4` = ${PORT} ];then
echo "${PROJECT_SERVICE} is running....."
else
echo "${PROJECT_SERVICE} is stopping....."
fi
}
case $1 in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status
;;
*)
echo "$0 <start|stop|restart>"
esac
添加权限,并启动
chmod 755 /etc/init.d/prometheus
/etc/init.d/prometheus start
三、访问页面
访问targets
http://192.168.31.150:9090/targets
到这里,安装就结束了。
最新文章
- CSS 中Font Awesome 图标(附码表)
- 处理UnicodeDecodeError: ‘XXX&#39; codec can&#39;t decode bytes in position...的问题
- 安卓xml颜色设置
- 关于jQuery新的事件绑定机制on()的使用技巧
- js数组常用操作方法小结(增加,删除,合并,分割等)
- linux用户配置和用户权限
- Storage Keepers
- Colletion View 简单的备忘
- java学习笔记day01
- UltraISO做U盘启动盘教程
- ruby, gem install 出现网络错误
- storybody中页面跳转
- 在VM中给Linux安装Tool
- Ubuntu 16.04 安装wine QQ
- 08 ListView 优化的例子
- ajax的小知识---总是得到重复的数据
- idea调试代码跟踪到tomcat代码里面
- sql 查询结果自定义排序
- JDK9.0.4环境变量配置
- React之Perf