1.安装前准备
Prometheus Server 192.168.2.79
node_exporter 192.168.2.70
2.下载所需的包下载所需的包
$ 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 prometheus
3.创建prometheus用户。
$ groupadd prometheus
$ useradd -g prometheus -m -d /var/lib/prometheus -s /sbin/nologin prometheus
4.创建systemctl启动文件
[root@localhost ~]# cat /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.target
5.启动prometheus
systemctl daemon-reload
systemctl start prometheus
systemctl enable prometheus
6.浏览器访问:
192.168.2.79:9090即可打开Prometheus Server
7.安装agent端,创建prometheus用户。
$ groupadd prometheus
$ useradd -g prometheus -m -d /var/lib/prometheus -s /sbin/nologin prometheus
8.解压包
$ cd /usr/local/
tar -zxvf node_exporter-0.18.1.linux-amd64.tar
mv node_exporter-0.18.1.linux-amd64 node_exporter
9.创建systemctl启动文件
[root@localhost local]# cat /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.target
10启动node_export
systemctl daemon-reload
systemctl start node_exporter
systemctl enable node_exporter
11去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 prometheus
13部署grafana
yum install https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-4.4.3-1.x86_64.rpm
14 启动grafana
systemctl start grafana-server
systemctl enable grafana-server
15 访问浏览器:
192.168.2.79:3000即可打开页面 重置密码 进入后选择data sources 设置prometheus 地址选择localhost:9090 导入自带的模板即可