一、概述

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

到这里,安装就结束了。

最新文章

  1. CSS 中Font Awesome 图标(附码表)
  2. 处理UnicodeDecodeError: ‘XXX&#39; codec can&#39;t decode bytes in position...的问题
  3. 安卓xml颜色设置
  4. 关于jQuery新的事件绑定机制on()的使用技巧
  5. js数组常用操作方法小结(增加,删除,合并,分割等)
  6. linux用户配置和用户权限
  7. Storage Keepers
  8. Colletion View 简单的备忘
  9. java学习笔记day01
  10. UltraISO做U盘启动盘教程
  11. ruby, gem install 出现网络错误
  12. storybody中页面跳转
  13. 在VM中给Linux安装Tool
  14. Ubuntu 16.04 安装wine QQ
  15. 08 ListView 优化的例子
  16. ajax的小知识---总是得到重复的数据
  17. idea调试代码跟踪到tomcat代码里面
  18. sql 查询结果自定义排序
  19. JDK9.0.4环境变量配置
  20. React之Perf

热门文章

  1. javaScript 判断为false
  2. kkk
  3. Java Array二维数组使用
  4. CentOS里下载和离线安装rpm包
  5. html在div中显示滚动条
  6. 阿里云OSS设置跨域访问 H5的时候
  7. cps在jenkins构建报错
  8. Html JavaScript网页制作与开发完全学习手册
  9. Spring MVC -- 单元测试和集成测试
  10. c++生成数据程序模板