node_exporter安装03

IT
IT
IT
335
文章
1
评论
2020年3月23日11:50:01 评论 1,146 4716字阅读15分43秒

简述

监控服务器 CPU , 内存 , 磁盘 , I/O 等信息,需要在被监控机器上安装 node_exporter 服务。

首先我们需要从 node_exporter下载页 下载我们需要安装的版本,这里我们选择则安装的 node_exporter 版本是v0.18.0 的最新版本。

安装

[root@iZ2ze4v2sdd3v6w7w8doecZ src]# ll
total 63452
-rw-r--r-- 1 root root  8083296 Oct 26 14:31 node_exporter-0.18.1.linux-amd64.tar.gz
-rw-r--r-- 1 root root 56885361 Oct 26 14:32 prometheus-2.13.0.linux-amd64.tar.gz
[root@iZ2ze4v2sdd3v6w7w8doecZ src]# tar zxf node_exporter-0.18.1.linux-amd64.tar.gz
[root@iZ2ze4v2sdd3v6w7w8doecZ src]# mv node_exporter-0.18.1.linux-amd64/ node_exporter
[root@iZ2ze4v2sdd3v6w7w8doecZ src]# mv node_exporter /home/
[root@iZ2ze4v2sdd3v6w7w8doecZ src]# ll /home/
total 8
drwxr-xr-x 2 3434 3434 4096 Jun  5 00:51 node_exporter
drwxr-xr-x 5 root root 4096 Oct 26 14:45 prometheus

创建启动服务

[root@iZ2ze4v2sdd3v6w7w8doecZ src]# vim /usr/lib/systemd/system/node_exporter.service
#Prometheus Node Exporter Upstart script
[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target
  
[Service]
ExecStart=/home/node_exporter/node_exporter
  
[Install]
WantedBy=default.target

启动服务

[root@iZ2ze4v2sdd3v6w7w8doecZ src]# systemctl daemon-reload
[root@iZ2ze4v2sdd3v6w7w8doecZ src]# systemctl enable node_exporter
Created symlink from /etc/systemd/system/default.target.wants/node_exporter.service to /usr/lib/systemd/system/node_exporter.service.
[root@iZ2ze4v2sdd3v6w7w8doecZ src]# systemctl start node_exporter
[root@iZ2ze4v2sdd3v6w7w8doecZ src]# systemctl status node_exporter
● node_exporter.service - Node Exporter
   Loaded: loaded (/usr/lib/systemd/system/node_exporter.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2019-10-26 15:29:25 CST; 5s ago
 Main PID: 11521 (node_exporter)
   CGroup: /system.slice/node_exporter.service
           └─11521 /home/node_exporter/node_exporter
 
Oct 26 15:29:25 iZ2ze4v2sdd3v6w7w8doecZ node_exporter[11521]: time="2019-10-26T15:29:25+08:00" level=info msg=" - sockstat" source="node_exporter.go:104"
Oct 26 15:29:25 iZ2ze4v2sdd3v6w7w8doecZ node_exporter[11521]: time="2019-10-26T15:29:25+08:00" level=info msg=" - stat" source="node_exporter.go:104"
Oct 26 15:29:25 iZ2ze4v2sdd3v6w7w8doecZ node_exporter[11521]: time="2019-10-26T15:29:25+08:00" level=info msg=" - textfile" source="node_exporter.go:104"
Oct 26 15:29:25 iZ2ze4v2sdd3v6w7w8doecZ node_exporter[11521]: time="2019-10-26T15:29:25+08:00" level=info msg=" - time" source="node_exporter.go:104"
Oct 26 15:29:25 iZ2ze4v2sdd3v6w7w8doecZ node_exporter[11521]: time="2019-10-26T15:29:25+08:00" level=info msg=" - timex" source="node_exporter.go:104"
Oct 26 15:29:25 iZ2ze4v2sdd3v6w7w8doecZ node_exporter[11521]: time="2019-10-26T15:29:25+08:00" level=info msg=" - uname" source="node_exporter.go:104"
Oct 26 15:29:25 iZ2ze4v2sdd3v6w7w8doecZ node_exporter[11521]: time="2019-10-26T15:29:25+08:00" level=info msg=" - vmstat" source="node_exporter.go:104"
Oct 26 15:29:25 iZ2ze4v2sdd3v6w7w8doecZ node_exporter[11521]: time="2019-10-26T15:29:25+08:00" level=info msg=" - xfs" source="node_exporter.go:104"
Oct 26 15:29:25 iZ2ze4v2sdd3v6w7w8doecZ node_exporter[11521]: time="2019-10-26T15:29:25+08:00" level=info msg=" - zfs" source="node_exporter.go:104"
Oct 26 15:29:25 iZ2ze4v2sdd3v6w7w8doecZ node_exporter[11521]: time="2019-10-26T15:29:25+08:00" level=info msg="Listening on :9100" source="node_exporter.go:170"

服务启动后可以用 http://localhost:9100/metrics 测试 node_exporter 是否获取到节点的监控指标。

node_exporter安装03

prometheus服务端配置

[root@iZ2ze4v2sdd3v6w7w8doecZ src]# vim /home/prometheus/prometheus.yml
# my global config
global:
  scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).
 
# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    - targets:
      # - alertmanager:9093
 
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"
 
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'
 
    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.
 
    static_configs:
    - targets: ['localhost:9090']
   
  - job_name: 'linux'
    static_configs:
    - targets: ['10.10.0.217:9100']

node_exporter安装03

检查服务端配置文件有没有错误

[root@iZ2ze4v2sdd3v6w7w8doecZ src]# cd /home/prometheus/
[root@iZ2ze4v2sdd3v6w7w8doecZ prometheus]# ll
total 135728
drwxr-xr-x 2       3434       3434     4096 Oct  4 21:17 console_libraries
drwxr-xr-x 2       3434       3434     4096 Oct  4 21:17 consoles
drwxr-xr-x 3 prometheus prometheus     4096 Oct 26 14:45 data
-rw-r--r-- 1       3434       3434    11357 Oct  4 21:17 LICENSE
-rw-r--r-- 1       3434       3434     2770 Oct  4 21:17 NOTICE
-rwxr-xr-x 1       3434       3434 78504508 Oct  4 19:27 prometheus
-rw-r--r-- 1       3434       3434     1005 Oct 26 15:38 prometheus.yml
-rwxr-xr-x 1       3434       3434 47080589 Oct  4 19:28 promtool
-rwxr-xr-x 1       3434       3434 13360202 Oct  4 19:29 tsdb
[root@iZ2ze4v2sdd3v6w7w8doecZ prometheus]# ./promtool check config prometheus.yml
Checking prometheus.yml
SUCCESS: 0 rule files found

重新加载prometheus

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

应用端口监控

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