Prometheus (二)——安装部署

准备环境

[root@pre1 ~]# systemctl stop firewalld

[root@pre1 ~]# setenforce 0
setenforce: SELinux is disabled

创建用户

[root@pre1 ~]# groupadd prometheus
[root@pre1 ~]# useradd -M -s /sbin/nologin prometheus -g prometheus

解压


[root@pre1 ~]# mkdir prometheus
[root@pre1 ~]# cd prometheus
[root@pre1 prometheus]# ls
prometheus-2.16.0.linux-amd64.tar.gz
[root@pre1 prometheus]# tar zxf prometheus-2.16.0.linux-amd64.tar.gz 
[root@pre1 prometheus]# ls
prometheus-2.16.0.linux-amd64  prometheus-2.16.0.linux-amd64.tar.gz

[root@pre1 prometheus]# cd prometheus-2.16.0.linux-amd64
[root@pre1 prometheus-2.16.0.linux-amd64]# ls
console_libraries  LICENSE  prometheus      promtool
consoles           NOTICE   prometheus.yml  tsdb

# 创建所需目录
[root@pre1 prometheus-2.16.0.linux-amd64]# mkdir conf relus data

# 修改配置文件路径
[root@pre1 prometheus-2.16.0.linux-amd64]# mv prometheus.yml  conf


# 复制可执行文件至 /usr/local/bin
[root@pre1 prometheus-2.16.0.linux-amd64]# cp prometheus  promtool tsdb  /usr/local/bin/

# 授权
[root@pre1 prometheus]# mv  prometheus-2.16.0.linux-amd64 prometheus-2.16.0
[root@pre1 prometheus]# chown -R prometheus:prometheus prometheus-2.16.0
[root@pre1 prometheus]# ll prometheus-2.16.0
总用量 140980
drwxr-xr-x 2 prometheus prometheus       28 1110 22:01 conf
drwxr-xr-x 2 prometheus prometheus       38 214 2020 console_libraries
drwxr-xr-x 2 prometheus prometheus      173 214 2020 consoles
drwxr-xr-x 2 prometheus prometheus        6 1110 22:01 data
-rw-r--r-- 1 prometheus prometheus    11357 214 2020 LICENSE
-rw-r--r-- 1 prometheus prometheus     3184 214 2020 NOTICE
-rwxr-xr-x 1 prometheus prometheus 82329106 214 2020 prometheus
-rwxr-xr-x 1 prometheus prometheus 48417809 214 2020 promtool
drwxr-xr-x 2 prometheus prometheus        6 1110 22:01 relus
-rwxr-xr-x 1 prometheus prometheus 13595766 214 2020 tsdb



修改配置文件

[root@pre1 prometheus-2.16.0]# cd conf/
[root@pre1 conf]# cp prometheus.yml prometheus.yml.bak
[root@pre1 conf]# vim prometheus.yml

[root@pre1 conf]# vim prometheus.yml

在这里插入图片描述

job_name: 'prometheus'		# 标签,监控任务的名称
   static_configs:		# 抓取的目标

添加为系统服务

[root@pre1 prometheus]#  mv prometheus-2.16.0 /usr/local/prometheus
[root@pre1 conf]# vim /usr/lib/systemd/system/prometheus.service
Unit]
Description=prometheus-server
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
 
[Service]
Type=simple
ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/conf/prometheus.yml --web.enable-lifecycle --storage.tsdb.path=/usr/local/prometheus/data --storage.tsdb.retention.time=7d --web.max-connections=512 --web.read-timeout=3m --query.max-concurrency=25 --query.timeout=2m
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
 
[Install]
WantedBy=multi-user.target
[root@pre1 conf]# systemctl daemon-reload
[root@pre1 conf]# systemctl enable prometheus.service 
Created symlink from /etc/systemd/system/multi-user.target.wants/prometheus.service to /usr/lib/systemd/system/prometheus.service.
[root@pre1 conf]# systemctl start prometheus.service 

在这里插入图片描述
访问 IP 进行查看 prometheus
在这里插入图片描述
查看监控任务的状态
在这里插入图片描述

查看 prometheus 的配置信息

在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值