转载:centos7安装Prometheus+Grafana步骤_嘣嘣嘣的博客-优快云博客_centos7安装prometheus
环境部署规划表
Prometheus服务端安装部署
采用源码编译安装的方式,下载最新版本的安装包地址:
Downloads - The Go Programming Language
Go环境Linux版本安装包:
https://go.dev/dl/go1.17.6.linux-amd64.tar.gz
[root@grafana ~]# cd /usr/local/
[root@grafana local]# curl -OL https://go.dev/dl/go1.17.6.linux-amd64.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 75 100 75 0 0 104 0 --:--:-- --:--:-- --:--:-- 104
100 128M 100 128M 0 0 2150k 0 0:01:01 0:01:01 --:--:-- 2228k
[root@grafana local]# ls
bin etc games go1.17.6.linux-amd64.tar.gz include lib lib64 libexec sbin share src
1.2、将Go压缩包解压
bin etc games go1.17.6.linux-amd64.tar.gz include lib lib64 libexec sbin share src
[root@grafana local]# tar -zxf go1.17.6.linux-amd64.tar.gz
[root@grafana local]# ls
bin etc games go go1.17.6.linux-amd64.tar.gz include lib lib64 libexec sbin share src
[root@grafana local]
1.3、配置环境变量
[root@grafana local]# vim /etc/profile
-bash: vim: command not found
//出现上述报错信息,执行yum install -y vim*命令安装Vim编辑器
[root@grafana local]# yum install -y vim*
[root@grafana local]# vim /etc/profile
[root@grafana local]# cat /etc/profile
//在profile配置文件里最后添加以下两行命令,保存并退出即可
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
[root@grafana local]# source /etc/profile
//执行此命令,使其生效
1.4、测试Go环境是否安装成功
执行go version命令,查询版本号,成功显示,即安装完成。
2.1、下载 Prometheus 安装包
Prometheus安装包下载地址:
Download | Prometheus
Prometheus Linux版本压缩包下载链接:
prometheus-2.33.0.linux-amd64.tar.gz
[root@grafana local]# curl -OL https://github.com/prometheus/prometheus/releases/download/v2.33.0/prometheus-2.33.0.linux-amd64.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 671 100 671 0 0 566 0 0:00:01 0:00:01 --:--:-- 566
100 72.3M 100 72.3M 0 0 1987k 0 0:00:37 0:00:37 --:--:-- 2188k
[root@grafana local]# ls
bin games go1.17.6.linux-amd64.tar.gz lib libexec sbin src
etc go include lib64 prometheus-2.33.0.linux-amd64.tar.gz share
2.2、解压 Prometheus 压缩包
[root@grafana local]# tar -zxf prometheus-2.33.0.linux-amd64.tar.gz
[root@grafana local]# ls
bin go lib prometheus-2.33.0.linux-amd64 share
etc go1.17.6.linux-amd64.tar.gz lib64 prometheus-2.33.0.linux-amd64.tar.gz src
games include libexec sbin
[root@grafana local]# mv prometheus-2.33.0.linux-amd64 prometheus
//修改安装包文件名称
[root@grafana local]# ls
bin games go1.17.6.linux-amd64.tar.gz lib libexec prometheus-2.33.0.linux-amd64.tar.gz share
etc go include lib64 prometheus sbin src
2.3、启动并验证Prometheus服务
[root@grafana local]# cd prometheus
[root@grafana prometheus]# ls
console_libraries consoles LICENSE NOTICE prometheus prometheus.yml promtool
[root@grafana prometheus]# ./prometheus --config.file=/usr/local/prometheus/prometheus.yml &
验证Prometheus服务是否启动,打开浏览器输入http://192.168.3.230:9090,打开Prometheus自带的监控界面。
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Z6KaupHe-1644559283219)(C:\Users\86194\AppData\Roaming\Typora\typora-user-images\image-20220211111853535.png)]
**按*CTRL+C*键结束Prometheus进程。
2.4、设置Prometheus服务开机自启动
- 添加prometheus.service配置文件
[root@grafana prometheus]# vim /etc/systemd/system/prometheus.service
[root@grafana prometheus]# cat /etc/systemd/system/prometheus.service
[Unit]
Description=Prometheus Monitoring System
Documentation=Prometheus Monitoring System
[Service]
ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --web.listen-address=:9090
Restart=on-failure
[Install]
WantedBy=multi-user.target
[root@grafana prometheus]#
- 启动Prometheus服务,并设置开机自启动
[root@grafana prometheus]# systemctl start prometheus.service
[root@grafana prometheus]# systemctl enable prometheus.service
[root@grafana prometheus]# systemctl status prometheus.service
● prometheus.service - Prometheus Monitoring System
Loaded: loaded (/etc/systemd/system/prometheus.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2022-01-31 15:02:37 CST; 1s ago
Main PID: 9877 (prometheus)
CGroup: /system.slice/prometheus.service
└─9877 /usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --web.listen-address=:9090...
Jan 31 15:02:37 grafana prometheus[9877]: ts=2022-01-31T07:02:37.065Z caller=head.go:533 level=info component=tsdb msg="Re...while"
Jan 31 15:02:37 grafana prometheus[9877]: ts=2022-01-31T07:02:37.067Z caller=tls_config.go:195 level=info component=web ms...=false
Jan 31 15:02:37 grafana prometheus[9877]: ts=2022-01-31T07:02:37.480Z caller=head.go:604 level=info component=tsdb msg="WA...ment=1
Jan 31 15:02:37 grafana prometheus[9877]: ts=2022-01-31T07:02:37.481Z caller=head.go:604 level=info component=tsdb msg="WA...ment=1
Jan 31 15:02:37 grafana prometheus[9877]: ts=2022-01-31T07:02:37.481Z caller=head.go:610 level=info component=tsdb msg="WA…915309ms
Jan 31 15:02:37 grafana prometheus[9877]: ts=2022-01-31T07:02:37.484Z caller=main.go:944 level=info fs_type=XFS_SUPER_MAGIC
Jan 31 15:02:37 grafana prometheus[9877]: ts=2022-01-31T07:02:37.484Z caller=main.go:947 level=info msg="TSDB started"
Jan 31 15:02:37 grafana prometheus[9877]: ts=2022-01-31T07:02:37.484Z caller=main.go:1128 level=info msg="Loading configur...us.yml
Jan 31 15:02:37 grafana prometheus[9877]: ts=2022-01-31T07:02:37.491Z caller=main.go:1165 level=info msg="Completed loading of c…µs
Jan 31 15:02:37 grafana prometheus[9877]: ts=2022-01-31T07:02:37.491Z caller=main.go:896 level=info msg="Server is ready t...ests."
Hint: Some lines were ellipsized, use -l to show in full.
[root@grafana prometheus]#
Grafana服务端安装部署
1.1、下载并安装
遇到以下报错信息,执行以下命令安装vim编辑器即可。
[root@grafana ~]# vim /etc/yum.repos.d/grafana.repo
bash: vim: command not found
[root@grafana ~]# yum install -y vim*
123
将新文件添加到 YUM 存储库
[root@grafana ~]# vim /etc/yum.repos.d/grafana.repo
[root@grafana ~]# cat /etc/yum.repos.d/grafana.repo
[grafana]
name=grafana
baseurl=https://packages.grafana.com/enterprise/rpm
repo_gpgcheck=1
enabled=1
gpgcheck=1
gpgkey=https://packages.grafana.com/gpg.key
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
使用以下命令之一安装 Grafana
sudo yum install grafana
# or
sudo yum install grafana-enterprise
[root@grafana ~]# yum install grafana-enterprise
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.ustc.edu.cn
* extras: mirrors.nju.edu.cn
* updates: mirrors.nju.edu.cn
grafana/signature | 454 B 00:00:00
Retrieving key from https://packages.grafana.com/gpg.key
Importing GPG key 0x24098CB6:
Userid : "Grafana <info@grafana.com>"
Fingerprint: 4e40 ddf6 d76e 284a 4a67 80e4 8c8c 34c5 2409 8cb6
From : https://packages.grafana.com/gpg.key
Is this ok [y/N]: y
grafana/signature | 3.0 kB 00:00:17 !!!
grafana/primary_db | 92 kB 00:00:01
Resolving Dependencies
--> Running transaction check
---> Package grafana-enterprise.x86_64 0:8.3.4-1 will be installed
--> Processing Dependency: urw-fonts for package: grafana-enterprise-8.3.4-1.x86_64
--> Running transaction check
---> Package urw-base35-fonts.noarch 0:20170801-10.el7 will be installed
--> Processing Dependency: urw-base35-fonts-common = 20170801-10.el7 for package: urw-base35-fonts-20170801-10.el7.noarch
--> Processing Dependency: urw-base35-z003-fonts for package: urw-base35-fonts-20170801-10.el7.noarch
--> Processing Dependency: urw-base35-standard-symbols-ps-fonts for package: urw-base35-fonts-20170801-10.el7.noarch
--> Processing Dependency: urw-base35-p052-fonts for package: urw-base35-fonts-20170801-10.el7.noarch
--> Processing Dependency: urw-base35-nimbus-sans-fonts for package: urw-base35-fonts-20170801-10.el7.noarch
--> Processing Dependency: urw-base35-nimbus-roman-fonts for package: urw-base35-fonts-20170801-10.el7.noarch
--> Processing Dependency: urw-base35-nimbus-mono-ps-fonts for package: urw-base35-fonts-20170801-10.el7.noarch
--> Processing Dependency: urw-base35-gothic-fonts for package: urw-base35-fonts-20170801-10.el7.noarch
--> Processing Dependency: urw-base35-d050000l-fonts for package: urw-base35-fonts-20170801-10.el7.noarch
--> Processing Dependency: urw-base35-c059-fonts for package: urw-base35-fonts-20170801-10.el7.noarch
--> Processing Dependency: urw-base35-bookman-fonts for package: urw-base35-fonts-20170801-10.el7.noarch
--> Running transaction check
---> Package urw-base35-bookman-fonts.noarch 0:20170801-10.el7 will be installed
--> Processing Dependency: xorg-x11-server-utils for package: urw-base35-bookman-fonts-20170801-10.el7.noarch
--> Processing Dependency: xorg-x11-server-utils for package: urw-base35-bookman-fonts-20170801-10.el7.noarch
--> Processing Dependency: xorg-x11-font-utils for package: urw-base35-bookman-fonts-20170801-10.el7.noarch
--> Processing Dependency: xorg-x11-font-utils for package: urw-base35-bookman-fonts-20170801-10.el7.noarch
---> Package urw-base35-c059-fonts.noarch 0:20170801-10.el7 will be installed
---> Package urw-base35-d050000l-fonts.noarch 0:20170801-10.el7 will be installed
---> Package urw-base35-fonts-common.noarch 0:20170801-10.el7 will be installed
---> Package urw-base35-gothic-fonts.noarch 0:20170801-10.el7 will be installed
---> Package urw-base35-nimbus-mono-ps-fonts.noarch 0:20170801-10.el7 will be installed
---> Package urw-base35-nimbus-roman-fonts.noarch 0:20170801-10.el7 will be installed
---> Package urw-base35-nimbus-sans-fonts.noarch 0:20170801-10.el7 will be installed
---> Package urw-base35-p052-fonts.noarch 0:20170801-10.el7 will be installed
---> Package urw-base35-standard-symbols-ps-fonts.noarch 0:20170801-10.el7 will be installed
---> Package urw-base35-z003-fonts.noarch 0:20170801-10.el7 will be installed
--> Running transaction check
---> Package xorg-x11-font-utils.x86_64 1:7.5-21.el7 will be installed
--> Processing Dependency: libfontenc.so.1()(64bit) for package: 1:xorg-x11-font-utils-7.5-21.el7.x86_64
---> Package xorg-x11-server-utils.x86_64 0:7.7-20.el7 will be installed
--> Processing Dependency: libXxf86misc.so.1()(64bit) for package: xorg-x11-server-utils-7.7-20.el7.x86_64
--> Processing Dependency: libXmuu.so.1()(64bit) for package: xorg-x11-server-utils-7.7-20.el7.x86_64
--> Processing Dependency: libXmu.so.6()(64bit) for package: xorg-x11-server-utils-7.7-20.el7.x86_64
--> Running transaction check
---> Package libXmu.x86_64 0:1.1.2-2.el7 will be installed
---> Package libXxf86misc.x86_64 0:1.0.3-7.1.el7 will be installed
---> Package libfontenc.x86_64 0:1.1.3-3.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
======================================================================================================================================
Package Arch Version Repository Size
======================================================================================================================================
Installing:
grafana-enterprise x86_64 8.3.4-1 grafana 78 M
Installing for dependencies:
libXmu x86_64 1.1.2-2.el7 base 71 k
libXxf86misc x86_64 1.0.3-7.1.el7 base 19 k
libfontenc x86_64 1.1.3-3.el7 base 31 k
urw-base35-bookman-fonts noarch 20170801-10.el7 base 852 k
urw-base35-c059-fonts noarch 20170801-10.el7 base 879 k
urw-base35-d050000l-fonts noarch 20170801-10.el7 base 75 k
urw-base35-fonts noarch 20170801-10.el7 base 7.6 k
urw-base35-fonts-common noarch 20170801-10.el7 base 19 k
urw-base35-gothic-fonts noarch 20170801-10.el7 base 650 k
urw-base35-nimbus-mono-ps-fonts noarch 20170801-10.el7 base 796 k
urw-base35-nimbus-roman-fonts noarch 20170801-10.el7 base 860 k
urw-base35-nimbus-sans-fonts noarch 20170801-10.el7 base 1.3 M
urw-base35-p052-fonts noarch 20170801-10.el7 base 978 k
urw-base35-standard-symbols-ps-fonts noarch 20170801-10.el7 base 40 k
urw-base35-z003-fonts noarch 20170801-10.el7 base 275 k
xorg-x11-font-utils x86_64 1:7.5-21.el7 base 104 k
xorg-x11-server-utils x86_64 7.7-20.el7 base 178 k
Transaction Summary
======================================================================================================================================
Install 1 Package (+17 Dependent packages)
Total download size: 84 M
Installed size: 276 M
Is this ok [y/d/N]:y
************
*安装过程省略*
************
Installed:
grafana-enterprise.x86_64 0:8.3.4-1
Dependency Installed:
libXmu.x86_64 0:1.1.2-2.el7 libXxf86misc.x86_64 0:1.0.3-7.1.el7
libfontenc.x86_64 0:1.1.3-3.el7 urw-base35-bookman-fonts.noarch 0:20170801-10.el7
urw-base35-c059-fonts.noarch 0:20170801-10.el7 urw-base35-d050000l-fonts.noarch 0:20170801-10.el7
urw-base35-fonts.noarch 0:20170801-10.el7 urw-base35-fonts-common.noarch 0:20170801-10.el7
urw-base35-gothic-fonts.noarch 0:20170801-10.el7 urw-base35-nimbus-mono-ps-fonts.noarch 0:20170801-10.el7
urw-base35-nimbus-roman-fonts.noarch 0:20170801-10.el7 urw-base35-nimbus-sans-fonts.noarch 0:20170801-10.el7
urw-base35-p052-fonts.noarch 0:20170801-10.el7 urw-base35-standard-symbols-ps-fonts.noarch 0:20170801-10.el7
urw-base35-z003-fonts.noarch 0:20170801-10.el7 xorg-x11-font-utils.x86_64 1:7.5-21.el7
xorg-x11-server-utils.x86_64 0:7.7-20.el7
Complete!
1.2、启动并设置开机自启动服务
[root@grafana local]# systemctl daemon-reload
[root@grafana local]# systemctl start grafana-server
[root@grafana local]# systemctl enable grafana-server
Created symlink from /etc/systemd/system/multi-user.target.wants/grafana-server.service to /usr/lib/systemd/system/grafana-server.service.
[root@grafana local]# systemctl status grafana-server
● grafana-server.service - Grafana instance
Loaded: loaded (/usr/lib/systemd/system/grafana-server.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2022-01-31 15:34:48 CST; 13s ago
Docs: http://docs.grafana.org
Main PID: 50955 (grafana-server)
CGroup: /system.slice/grafana-server.service
└─50955 /usr/sbin/grafana-server --config=/etc/grafana/grafana.ini --pidfile=/var/run/grafana/grafana-ser...
Jan 31 15:34:53 grafana systemd[1]: [/usr/lib/systemd/system/grafana-server.service:29] Unknown lvalue 'Protec...rvice'
Jan 31 15:34:53 grafana systemd[1]: [/usr/lib/systemd/system/grafana-server.service:31] Unknown lvalue 'Protec...rvice'
Jan 31 15:34:53 grafana systemd[1]: [/usr/lib/systemd/system/grafana-server.service:32] Unknown lvalue 'Protec...rvice'
Jan 31 15:34:53 grafana systemd[1]: [/usr/lib/systemd/system/grafana-server.service:33] Unknown lvalue 'Protec...rvice'
Jan 31 15:34:53 grafana systemd[1]: [/usr/lib/systemd/system/grafana-server.service:34] Unknown lvalue 'Protec...rvice'
Jan 31 15:34:53 grafana systemd[1]: [/usr/lib/systemd/system/grafana-server.service:35] Unknown lvalue 'Protec...rvice'
Jan 31 15:34:53 grafana systemd[1]: [/usr/lib/systemd/system/grafana-server.service:37] Unknown lvalue 'Remove...rvice'
Jan 31 15:34:53 grafana systemd[1]: [/usr/lib/systemd/system/grafana-server.service:39] Unknown lvalue 'Restri...rvice'
Jan 31 15:34:53 grafana systemd[1]: [/usr/lib/systemd/system/grafana-server.service:40] Unknown lvalue 'Restri...rvice'
Jan 31 15:34:53 grafana systemd[1]: [/usr/lib/systemd/system/grafana-server.service:41] Unknown lvalue 'Restri...rvice'
Hint: Some lines were ellipsized, use -l to show in full.
[root@grafana local]#
1.3、访问Grafana控制页面
打开浏览器,输入http://192.168.3.230:3000(端口为3000),打开Grafana控制面板, 初始默认账号和密码均为 admin,初次登录需要修改密码。
进入Web控制界面
点击Data sources
点击“Add data source”
URL处填写Prometheus服务所在的IP地址,此处将Prometheus服务与Grafana安装在同一台机器上,直接填写localhost即可。
点击Save & test,保存并测试。如图所示。
安装 node-exporter 插件
在需要被监视的Linux主机上安装*node-exporter* 插件,进行安装部署监控。
1.1、下载 node-exporter 插件
注意:注意需要下载对应的版本插件,否则会启动失败!!!
插件下载链接🔗:node_exporter-1.3.1.linux-386.tar.gz
[root@centos7 ~]# cd /usr/local/
[root@centos7 local]# curl -OL https://github.com/prometheus/node_exporter/releases/download/v1.3.1/node_exporter-1.3.1.linux-386.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 671 100 671 0 0 327 0 0:00:02 0:00:02 --:--:-- 327
100 8422k 100 8422k 0 0 1037k 0 0:00:08 0:00:08 --:--:-- 1824k
[root@centos7 local]#
1.2、解压压缩包并更改名称
[root@centos7 local]# tar -zxf node_exporter-1.3.1.linux-386.tar.gz
[root@centos7 local]# mv node_exporter-1.3.1.linux-386 node_exporter
1.3、启动并验证服务是否正常启动
[root@centos7 local]# cd node_exporter
[root@centos7 node_exporter]# ./node_exporter
打开浏览器,输入http://192.168.3.31:9100
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-dSlKwGjk-1644559283220)(C:\Users\86194\AppData\Roaming\Typora\typora-user-images\image-20220211112916796.png)]
**按*CTRL+C*键结束node_exporter进程
1.4、设置node_exporter开机自启动
创建node_exporter服务,让node_exporter以服务的方式,开机自启。
**添加*node_exporter.service*配置文件
vim /etc/systemd/system/node_exporter.service
[root@centos7 node_exporter]# vim /etc/systemd/system/node_exporter.service
[root@centos7 node_exporter]# cat /etc/systemd/system/node_exporter.service
[Unit]
Description=node_exporter
After=network.target
[Service]
ExecStart=/usr/local/node_exporter/node_exporter
Restart=on-failure
[Install]
WantedBy=multi-user.target
[root@centos7 node_exporter]#
启动node_exporter,并设置开机自启动
[root@centos7 node_exporter]# systemctl daemon-reload
[root@centos7 node_exporter]# systemctl start node_exporter
[root@centos7 node_exporter]# systemctl enable node_exporter
[root@centos7 node_exporter]# systemctl status node_exporter
配置Prometheus
**进入**Prometheus**的安装文件夹,打开*Prometheus*配置文件。
**在*scrape_configs*标签下,添加以下内容,配置监控主机信息。
[root@grafana ~]# cd /usr/local/prometheus
[root@grafana prometheus]# ll
total 196060
drwxr-xr-x 2 3434 3434 38 Jan 30 05:53 console_libraries
drwxr-xr-x 2 3434 3434 173 Jan 30 05:53 consoles
drwxr-xr-x 4 root root 58 Jan 31 15:02 data
-rw-r--r-- 1 3434 3434 11357 Jan 30 05:53 LICENSE
-rw-r--r-- 1 3434 3434 3773 Jan 30 05:53 NOTICE
-rwxr-xr-x 1 3434 3434 104419069 Jan 30 05:47 prometheus
-rw-r--r-- 1 3434 3434 934 Jan 30 05:53 prometheus.yml
-rwxr-xr-x 1 3434 3434 96325624 Jan 30 05:50 promtool
[root@grafana prometheus]# vim prometheus.yml
[root@grafana prometheus]# cat 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: 'CentOS7.9'
static_configs:
- targets: ['192.168.56.201:9100']
labels:
instance: CentOS系统监控管理平台
[root@grafana prometheus]#
1.2、重启Prometheus服务
[root@grafana prometheus]# systemctl restart prometheus
1.3、浏览器访问Prometheus控制面板
打开浏览器,输入http://192.168.3.230:9090/targets,查看到主机已经显示。
配置Grafana
Grafana官方为我们提供了很多dashboard页面,可直接下载使用。浏览器访问 https://grafana.com/grafana/dashboards下载所需要的dashboard页面
本示例使用的Dashboard如下图所示,链接如下:
1 Node Exporter for Prometheus Dashboard CN 20201010 dashboard for Grafana | Grafana Labs
1.2、复制此Dashboard ID
复制 ID,并下载JSON文件,用于之后的导入。
新添加一台被监视主机
1.1、修改 prometheus.yml 配置文件
基于服务端,即监控端进行操作。
[root@grafana prometheus]# pwd
/usr/local/prometheus
[root@grafana prometheus]# vim prometheus.yml
//添加新node主机信息
- job_name: 'Computer-VM'
static_configs:
- targets: ['192.168.200.20:9100']
labels:
instance: Computer-VM
//按:wq保存退出即可
[root@grafana prometheus]# systemctl daemon-reload //重新加载
[root@grafana prometheus]# systemctl restart prometheus //重启服务
[root@grafana prometheus]# systemctl status prometheus //查看服务状态
1.2、修改被监控端安装node-exporter
[root@centos7 ~]# cd /usr/local/ [root@centos7 local]# curl -OL https://github.com/prometheus/node_exporter/releases/download/v1.3.1/node_exporter-1.3.1.linux-386.tar.gz % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 671 100 671 0 0 327 0 0:00:02 0:00:02 --:--:-- 327 100 8422k 100 8422k 0 0 1037k 0 0:00:08 0:00:08 --:--:-- 1824k [root@centos7 local]# 解压压缩包并更改名称 [root@centos7 local]# tar -zxf node_exporter-1.3.1.linux-386.tar.gz [root@centos7 local]# mv node_exporter-1.3.1.linux-386 node_exporter 启动并验证服务是否正常启动 [root@centos7 local]# cd node_exporter [root@centos7 node_exporter]# ./node_exporter 设置node_exporter开机自启动 添加node_exporter.service配置文件 vim /etc/systemd/system/node_exporter.service [root@centos7 node_exporter]# vim /etc/systemd/system/node_exporter.service [root@centos7 node_exporter]# cat /etc/systemd/system/node_exporter.service [Unit] Description=node_exporter After=network.target [Service] ExecStart=/usr/local/node_exporter/node_exporter Restart=on-failure [Install] WantedBy=multi-user.target [root@centos7 node_exporter]# 启动node_exporter,并设置开机自启动 [root@centos7 node_exporter]# systemctl daemon-reload [root@centos7 node_exporter]# systemctl start node_exporter [root@centos7 node_exporter]# systemctl enable node_exporter [root@centos7 node_exporter]# systemctl status node_exporter
1.2、查看新添被监控主机的控制面板信息
[Service]
ExecStart=/usr/local/node_exporter/node_exporter
Restart=on-failure
[Install]
WantedBy=multi-user.target
[root@centos7 node_exporter]#
启动node_exporter,并设置开机自启动
[root@centos7 node_exporter]# systemctl daemon-reload
[root@centos7 node_exporter]# systemctl start node_exporter
[root@centos7 node_exporter]# systemctl enable node_exporter
[root@centos7 node_exporter]# systemctl status node_exporter
[Service]
ExecStart=/usr/local/node_exporter/node_exporter
Restart=on-failure
[Install]
WantedBy=multi-user.target
[root@centos7 node_exporter]#
启动node_exporter,并设置开机自启动
[root@centos7 node_exporter]# systemctl daemon-reload
[root@centos7 node_exporter]# systemctl start node_exporter
[root@centos7 node_exporter]# systemctl enable node_exporter
[root@centos7 node_exporter]# systemctl status node_exporter