centos7 搭建 prometheus
尝试两种安装方式:二进制安装和容器化
一、第一种:通过官方prometheus安装包安装
1、下载官方提供安装包,本文使用2.29.1版本的prometheus
下载地址:https://github.com/prometheus/prometheus/releases/download/v2.29.1/prometheus-2.29.1.linux-amd64.tar.gz
wget https://github.com/prometheus/prometheus/releases/download/v2.29.1/prometheus-2.29.1.linux-amd64.tar.gz
2、解压包,并将解压后的包放/usr/local/prometheus目录下
tar -zxf prometheus-2.29.1.linux-amd64.tar.gz #创建prometheus服务目录: mkdir /usr/local/prometheus mv prometheus-2.29.1.linux-amd64 /usr/lcoal/prometheus
cd /usr/lcoal/prometheus
3、修改配置文件
vim prometheus.yml scrape_configs: - job_name: 'prometheus' static_configs: # 监控本地及端口 - targets: ['localhost:9090']
4、启动服务
./prometheus --config.file=prometheus.yml
5、测试访问
访问:http://localhost:9090
二、第二次用容器化安装
注:将自定义的prometheus.yaml文件放到/tmp/下
docker run -d -p 9090:9090 -v /tmp/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus