prometheus

prometheus

1. 部署

下载软件github

 prometheus-2.14.0-rc.0.linux-amd64.tar.gz

解压

mkdir /opt/src
tar -xvf prometheus-2.14.0-rc.0.linux-amd64.tar.gz -C /opt/
cd /opt/
ln -s prometheus-2.14.0-rc.0.linux-amd64/ prometheus

添加用户

groupadd prometheus
useradd -g prometheus -s /sbin/nologin prometheus

创建数据目录+权限

chown -R prometheus:prometheus /opt/prometheus
mkdir -p /data/prometheus
chown -R prometheus:prometheus /data/prometheus

配置启动文件

v /usr/lib/systemd/system/prometheus.service

[Unit]

Description=Prometheus

Documentation=https://prometheus.io/

After=network.target

[Service]

# Type设置为notify时,服务会不断重启

Type=simple

User=prometheus

# --storage.tsdb.path是可选项,默认数据目录在运行目录的./dada目录中

ExecStart=/opt/prometheus/prometheus --config.file=/opt/prometheus/prometheus.yml --storage.tsdb.path=/data/prometheus/

Restart=on-failure

[Install]

WantedBy=multi-user.target



chown prometheus:prometheus /usr/lib/systemd/system/prometheus.service

 

安装node_export

tar -xvf node_exporter-0.18.1.linux-amd64.tar.gz -C /opt/
cd /opt/
ln -s node_exporter-0.18.1.linux-amd64/ node_exporter
groupadd prometheus

useradd -g prometheus -s /sbin/nologin prometheus

chown -R prometheus:prometheus /opt/node_exporter

 


vi /usr/lib/systemd/system/node_exporter.service


[Unit]

Description=node_exporter

Documentation=https://prometheus.io/

After=network.target

[Service]

Type=simple

User=prometheus

ExecStart=/opt/node_exporter/node_exporter

Restart=on-failure

[Install]

WantedBy=multi-user.target

 

systemctl enable node_exporter

systemctl start node_exporter


mkdir -p /var/lib/node_exporter/textfile_collector

 

上一篇:prometheus+grafana监控设置


下一篇:Docker 安装node_exporter