Prometheus 安装
环境
系统
Ubuntu 16.04
软件包下载地址:https://prometheus.io/download/
Prometheus server 安装
创建 prometheus 用户用户组
groupadd prometheus
useradd -g prometheus -s /sbin/nologin prometheus -M
创建 prometheus 配置文件目录
mkdir /etc/prometheus
创建 prometheus 运行数据的目录(数据量较大,可放在空间较大的分区)
mkdir /var/lib/prometheus
chown -R prometheus:prometheus /var/lib/prometheus
cd /opt
wget https://github.com/prometheus/prometheus/releases/download/v2.6.0/prometheus-2.6.0.linux-amd64.tar.gz
tar -xf prometheus-2.6.0.linux-amd64.tar.gz
mv /opt/prometheus-2.6.0.linux-amd64 prometheus-2.6.0
cp -r /opt/prometheus-2.6.0/console_libraries /etc/prometheus
cp -r /opt/prometheus-2.6.0/consoles /etc/prometheus
cp /opt/prometheus.yml /etc/prometheus
chown -R prometheus:prometheus /etc/prometheus
设置开机启动
touch /etc/systemd/system/prometheus.service
chown prometheus:prometheus /etc/systemd/system/prometheus.service
将如下内容写入配置文件(/etc/systemd/system/prometheus.service )
[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target
[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/bin/prometheus \
--web.enable-admin-api \
--web.enable-lifecycle \
--web.external-url=http://ip:9090 \
--storage.tsdb.retention=90d \
--config.file /etc/prometheus/prometheus.yml \
--storage.tsdb.path /var/lib/prometheus/ \
--web.console.templates=/etc/prometheus/consoles \
--web.console.libraries=/etc/prometheus/console_libraries
[Install]
WantedBy=multi-user.target
systemd 方式配置守护进程
systemctl daemon-reload
systemctl start prometheus.service
systemctl enable prometheus.service

浙公网安备 33010602011771号