其他分享
首页 > 其他分享> > prometheus快速部署

prometheus快速部署

作者:互联网

1.下载软件

https://www.prometheus.io/download/

2.创建部署路径

1.创建路径
mkdir -p /usr/local/prometheus/{data,logs,etc}
mkdir -p /data/prometheus/{data,logs,etc}

2.解压文件
tar xf prometheus-2.27.1.linux-amd64.tar.gz -C /usr/local/prometheus/

3.修改路径名
cd /usr/local/prometheus/
mv prometheus-2.27.1.linux-amd64 bin/

3.托管到systemd

1.在/usr/local/prometheus/etc创建prometheus.service
[root@prometheus-17 etc]# cat prometheus.service 
# -*- mode: conf -*-
[Unit]
Description=Prometheus
Documentation=https://prometheus.io/
After=network.target

[Service]
EnvironmentFile=-/usr/local/prometheus/etc/prometheus.env
User=prometheus
ExecStart=/usr/local/prometheus/bin/prometheus  --web.console.libraries=/usr/local/prometheus/bin/console_libraries --web.console.templates=/usr/local/prometheus/bin/consoles $PROMETHEUS_OPTS
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
LimitNOFILE=65535

[Install]
WantedBy=multi-user.target

2.创建软连接
ln -sv /usr/local/prometheus/etc/prometheus.service  /usr/lib/systemd/system/prometheus.service

3.reload
systemctl daemon-reload

4.创建配置文件

1.在/usr/local/prometheus/etc下创建prometheus.env文件,内容如下
[root@prometheus-17 etc]# cat prometheus.env
PROMETHEUS_OPTS='--config.file=/usr/local/prometheus/etc/prometheus.yml \
	--storage.tsdb.path=/usr/local/prometheus/data \
	--web.listen-address=0.0.0.0:9090 \
	--web.enable-lifecycle'

2.复制 prometheus/bin 下的 prometheus.yml ⽂件到 prometheus/etc

cp /usr/local/prometheus/bin/prometheus.yml /usr/local/prometheus/etc/prometheus.yml

3. 在 prometheus/etc 下创建 prom-rsyslog.conf 配置⽂件,内容如下:
if $programname == 'prometheus' then { 
  action(type="omfile" file="/usr/local/prometheus/logs/prometheus.log")
  stop
}

4.创建软连接
ln -sv /usr/local/prometheus/etc/prom-rsyslog.conf /etc/rsyslog.d/prom-rsyslog.conf

5. 重启 rsyslog
systemctl restart rsyslog.service

5.启动服务

1.创建用户
useradd -M -s /sbin/nologin prometheus

2.修改目录主属
chown -R prometheus:prometheus /usr/local/prometheus

3.启动服务
systemctl start prometheus.service

6.确认服务正常运行

[root@prometheus-17 etc]# netstat  -tunlp |grep 9090
tcp6       0      0 :::9090                 :::*                    LISTEN      8688/prometheus

浏览器:http://10.0.0.17:9090

主机数据显示: http://10.0.0.17:9090/metrics

7.prometheus默认监控图像

标签:bin,部署,快速,etc,prometheus,usr,rsyslog,local
来源: https://www.cnblogs.com/w1sh/p/15589742.html