Linux安装Prometheus+Grafana+node_exporter
Linux安装Prometheus+Grafana+node_exporter
一、安装准备
1.下载prometheus和grafana,以及监控插件
prometheus官网地址:https://prometheus.io/download/
grafana官网地址:https://grafana.com/grafana/download
prometheus github地址: https://github.com/prometheus
windows系统监控exporter
windows_exporter 地址:https://github.com/prometheus-community/windows_exporter/tags
linux系统监控exporter
node_exporter 地址:https://github.com/prometheus/node_exporter/releases
https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz
mysql系统监控exporter
mysql_exporter 地址:https://github.com/prometheus/mysqld_exporter/releases/tag/v0.12.1
二、安装配置node_exporter
1.解压node_exporter
tar -zxvf node_exporter-0.18.1.linux-amd64.tar.gz -C /usr/local/
2.配置node_exporter
1) vim /etc/systemd/system/node_exporter.service
[Unit] Description=node_exporter After=network.target [Service] Restart=on-failure ExecStart=/usr/local/node_exporter-0.18.1.linux-amd64/node_exporter [Install] WantedBy=multi-user.target
2) 修改了/etc/systemd/system/下的文件,要执行:
systemctl daemon-reload
3. 启动查看node_exporter
启动: systemctl start node_exporter
查看状态: systemctl status node_exporter
重启: systemctl restart node_exporter
node_exporter 默认启动占用9100端口
4.设置开机启动
设置开机启动: systemctl enable node_exporter
设置开机不启动: systemctl disable node_exporter
查看是否开机启动: systemctl is-enabled node_exporter
三、安装Prometheus
1.解压到/usr/local/
tar -zxvf prometheus-2.19.1.linux-amd64.tar.gz -C /usr/local/
2.文件重命名
mv /usr/local/prometheus-2.19.1.linux-amd64 /usr/local/prometheus
3.配置Prometheus后台启动
vim /etc/systemd/system/prometheus.service
[Unit] Description=Prometheus Server Documentation=https://prometheus.io/docs/introduction/overview/After=network-online.target [Service] Restart=on-failureExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --storage.tsdb.path=/var/lib/prometheus --web.external-url=http://ip:9090 [Install] WantedBy=multi-user.target
上面ip地址填外网ip;如果是虚拟机环境,也就是局域网,填内网ip
4. 启动查看prometheus
启动: systemctl start prometheus
查看状态: systemctl status prometheus
重启: systemctl restart prometheus
prometheus 默认启动占用9090端口
5.设置开机启动
设置开机启动: systemctl enable prometheus
设置开机不启动: systemctl disable prometheus
查看是否开机启动: systemctl is-enabled prometheus
四、安装Grafana
1.解压Grafana
tar -zxvf grafana-6.7.3-1.x86_64.rpm.tar -C /usr/local/
2.重命名Grafana
mv grafana-6.7.3-1.x86_64 grafana
3.启动Grafana
启动: systemctl start grafana-server.service
查看状态: systemctl status grafana-server.service
重启: systemctl restart grafana-server.service
Grafana默认占用端口3000
Linux监控模板 9276
dashboards网址:https://grafana.com/grafana/dashboards