Prometheus安装01

IT
IT
IT
335
文章
1
评论
2020年3月23日11:47:54 评论 777 3876字阅读12分55秒

服务端安装

[root@iZ2ze4v2sdd3v6w7w8doecZ ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)

创建prometheus启动用户

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

解压

[root@iZ2ze4v2sdd3v6w7w8doecZ ~]# cd /usr/local/src/
[root@iZ2ze4v2sdd3v6w7w8doecZ src]# ls
node_exporter-0.18.1.linux-amd64.tar.gz  prometheus-2.13.0.linux-amd64.tar.gz
[root@iZ2ze4v2sdd3v6w7w8doecZ src]# tar zxf prometheus-2.13.0.linux-amd64.tar.gz

创建安装目录,并移动配置文件到安装目录

[root@iZ2ze4v2sdd3v6w7w8doecZ src]# mkdir -pv /home/prometheus/data
mkdir: created directory ‘/home/prometheus’
mkdir: created directory ‘/home/prometheus/data’
[root@iZ2ze4v2sdd3v6w7w8doecZ src]# chown -R prometheus.prometheus /home/prometheus/data
[root@iZ2ze4v2sdd3v6w7w8doecZ src]# cd prometheus-2.13.0.linux-amd64
[root@iZ2ze4v2sdd3v6w7w8doecZ prometheus-2.13.0.linux-amd64]# mv * /home/prometheus/
[root@iZ2ze4v2sdd3v6w7w8doecZ src]# pwd
/usr/local/src
[root@iZ2ze4v2sdd3v6w7w8doecZ src]# rm -rf prometheus-2.13.0.linux-amd64

创建服务启动配置

[root@iZ2ze4v2sdd3v6w7w8doecZ src]# vim /usr/lib/systemd/system/prometheus.service
[Unit]
Description=Prometheus Server
Documentation=https://prometheus.io/docs/introduction/overview/
After=network-online.target
  
[Service]
User=prometheus
Restart=on-failure
ExecStart=/home/prometheus/prometheus \
  --config.file=/home/prometheus/prometheus.yml \
  --storage.tsdb.path=/home/prometheus/data
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target

启动服务

[root@iZ2ze4v2sdd3v6w7w8doecZ src]# systemctl daemon-reload
[root@iZ2ze4v2sdd3v6w7w8doecZ src]# systemctl start prometheus.service
[root@iZ2ze4v2sdd3v6w7w8doecZ src]# systemctl enable prometheus.service
Created symlink from /etc/systemd/system/multi-user.target.wants/prometheus.service to /usr/lib/systemd/system/prometheus.service.
[root@iZ2ze4v2sdd3v6w7w8doecZ src]# systemctl status prometheus.service
● prometheus.service - Prometheus Server
   Loaded: loaded (/usr/lib/systemd/system/prometheus.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2019-10-26 14:45:33 CST; 12s ago
     Docs: https://prometheus.io/docs/introduction/overview/
 Main PID: 1691 (prometheus)
   CGroup: /system.slice/prometheus.service
           └─1691 /home/prometheus/prometheus --config.file=/home/prometheus/prometheus.yml --storage.tsdb.path=/home/prometheus/data
 
Oct 26 14:45:33 iZ2ze4v2sdd3v6w7w8doecZ prometheus[1691]: level=info ts=2019-10-26T06:45:33.249Z caller=main.go:336 vm_limits="(soft=unlimited, hard=unlimited)"
Oct 26 14:45:33 iZ2ze4v2sdd3v6w7w8doecZ prometheus[1691]: level=info ts=2019-10-26T06:45:33.250Z caller=main.go:657 msg="Starting TSDB ..."
Oct 26 14:45:33 iZ2ze4v2sdd3v6w7w8doecZ prometheus[1691]: level=info ts=2019-10-26T06:45:33.250Z caller=web.go:450 component=web msg="Start listening for connecti....0.0:9090
Oct 26 14:45:33 iZ2ze4v2sdd3v6w7w8doecZ prometheus[1691]: level=info ts=2019-10-26T06:45:33.254Z caller=head.go:512 component=tsdb msg="replaying WAL, this may take awhile"
Oct 26 14:45:33 iZ2ze4v2sdd3v6w7w8doecZ prometheus[1691]: level=info ts=2019-10-26T06:45:33.257Z caller=head.go:560 component=tsdb msg="WAL segment loaded" segmen...Segment=0
Oct 26 14:45:33 iZ2ze4v2sdd3v6w7w8doecZ prometheus[1691]: level=info ts=2019-10-26T06:45:33.259Z caller=main.go:672 fs_type=EXT4_SUPER_MAGIC
Oct 26 14:45:33 iZ2ze4v2sdd3v6w7w8doecZ prometheus[1691]: level=info ts=2019-10-26T06:45:33.259Z caller=main.go:673 msg="TSDB started"
Oct 26 14:45:33 iZ2ze4v2sdd3v6w7w8doecZ prometheus[1691]: level=info ts=2019-10-26T06:45:33.259Z caller=main.go:743 msg="Loading configuration file" filename=/hom...theus.yml
Oct 26 14:45:33 iZ2ze4v2sdd3v6w7w8doecZ prometheus[1691]: level=info ts=2019-10-26T06:45:33.261Z caller=main.go:771 msg="Completed loading of configuration file" ...theus.yml
Oct 26 14:45:33 iZ2ze4v2sdd3v6w7w8doecZ prometheus[1691]: level=info ts=2019-10-26T06:45:33.261Z caller=main.go:626 msg="Server is ready to receive web requests."
Hint: Some lines were ellipsized, use -l to show in full.

Prometheus 服务支持热加载配置

[root@iZ2ze4v2sdd3v6w7w8doecZ src]# systemctl reload prometheus.service

访问页面

http://IP:9090

Prometheus安装01

下载信息 prometheus-2.13.0.linux-amd64.tar.gz
网盘密码:登录可见
下载地址
继续阅读
  • 我的QQ
  • QQ扫一扫
  • weinxin
  • 我的头条
  • 头条扫一扫
  • weinxin
IT
  • 本文由 发表于 2020年3月23日11:47:54
  • 除非特殊声明,本站文章均为原创,转载请务必保留本文链接
应用端口监控 prometheus

应用端口监控

是指监控每个服务启动的端口,根据端口来判断服务存活。 lucky可以指定每个应用的负责人 # vim prometheus.yml - job_name: 'dispatch' metrics_pat...