1.安装前准备
Prometheus Server 192.168.2.79
node_exporter 192.168.2.702.下载所需的包下载所需的包
$ cd /usr/local/
prometheus-2.11.1.linux-amd64.tar
node_exporter-0.18.1.linux-amd64.tar
tar -zxvf prometheus-2.11.1.linux-amd64.tar
mv prometheus-2.11.1.linux-amd64 prometheus3.创建prometheus用户。
$ groupadd prometheus
$ useradd -g prometheus -m -d /var/lib/prometheus -s /sbin/nologin prometheus4.创建systemctl启动文件
添加systemctl 启动文件
vim /usr/lib/systemd/system/prometheus.service
[Unit]
Description=prometheus
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --storage.tsdb.path=/var/lib/prometheus --storage.tsdb.retention=15d --log.level=info
Restart=on-failure
[Install]
WantedBy=multi-user.target5.启动prometheus
systemctl daemon-reload
systemctl start prometheus
systemctl enable prometheus6.浏览器访问:
192.168.2.79:9090即可打开Prometheus Server
7.安装agent端,创建prometheus用户。
$ groupadd prometheus
$ useradd -g prometheus -m -d /var/lib/prometheus -s /sbin/nologin prometheus8.解压包
$ cd /usr/local/
tar -zxvf node_exporter-0.18.1.linux-amd64.tar
mv node_exporter-0.18.1.linux-amd64 node_exporter9.创建systemctl启动文件
vim /usr/lib/systemd/system/node_exporter.service
[Unit]
Description=node_export
Documentation=https://github.com/prometheus/node_exporter
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=/usr/local/node_exporter/node_exporter
Restart=on-failure
[Install]
WantedBy=multi-user.target10,启动node_export
systemctl daemon-reload
systemctl start node_exporter
systemctl enable node_exporter11.去Prometheus Server端修改配置文件,将agent端加入到主节点中
- job_name: 'jp-test'
scrape_interval: 5s
static_configs:
- targets: ['192.168.2.70:9100','192.168.2.71:9100','192.168.2.72:9100','192.168.2.73:9100']
- job_name: '50-mysql'
scrape_interval: 5s
static_configs:
- targets: ['192.168.2.50:9104']加入以上,保存配置文件
12重启prometheus
systemctl restart prometheus13部署grafana
先去官网下载rpm包,直接yum install
yum install grafana-7.0.5-1.x86_64.rpm14 启动grafana
systemctl start grafana-server
systemctl enable grafana-server15 访问浏览器:192.168.2.79:3000即可打开页面
重置密码
进入后选择data sources 设置prometheus 地址选择localhost:9090
导入的模板编码【8919】即可


以上是监控模板统计图