官网下载地址,获取最新下载URL.
#切换到root用户 sudo -i #下载prometheus二进制压缩包,可以自定义版本 wget https://github.com/prometheus/prometheus/releases/download/v2.37.6/prometheus-2.37.6.linux-amd64.tar.gz #解压 tar xf prometheus-2.37.6.linux-amd64.tar.gz #查看解压后的文件名 ls -l mkdir /opt/prometheus -p #移动解压后的文件名到/opt/,并改名prometheus mv prometheus-2.37.6.linux-amd64/ /opt/prometheus/prometheus
创建一个专门的`prometheus`用户:
useradd -M -s /usr/sbin/nologin prometheus
更改prometheus
用户的文件夹权限:
chown prometheus:prometheus -R /opt/prometheus
创建 systemd 服务
cat > /etc/systemd/system/prometheus.service << "EOF" [Unit] Description=Prometheus Server Documentation=https://prometheus.io/docs/introduction/overview/ After=network-online.target [Service] Type=simple User=prometheus Group=prometheus Restaadmin=on-failure ExecStaadmin=/opt/prometheus/prometheus/prometheus \ --config.file=/opt/prometheus/prometheus/prometheus.yml \ --storage.tsdb.path=/opt/prometheus/prometheus/data \ --storage.tsdb.retention.time=60d \ --web.enable-lifecycle [Install] WantedBy=multi-user.target EOF
配置参数解释:
通过/opt/prometheus/prometheus -h
查看帮助详情
--config.file=/opt/prometheus/prometheus/prometheus.yml #主配置文件 --storage.tsdb.path=/opt/prometheus/prometheus/data #数据库存储目录 --web.console.libraries=/opt/prometheus/prometheus/console_libraries #指定控制台库目录路径 --web.console.templates=/opt/prometheus/prometheus/consoles #指定控制台模版目录路径 --storage.tsdb.retention=60d #指明数据保留天数,默认15天 --web.enable-lifecycle #热加载
启动 Prometheus
systemctl daemon-reload systemctl staadmin prometheus.service systemctl status prometheus.service systemctl enable prometheus.service
安装aleadminmanager
下载aleadminmanager
官网下载地址,获取最新下载URL.
下载aleadminmanager二进制压缩包 wget https://github.com/prometheus/aleadminmanager/releases/download/v0.25.0/aleadminmanager-0.25.0.linux-amd64.tar.gz #解压 tar xf aleadminmanager-0.25.0.linux-amd64.tar.gz #查看解压后的文件名 ls -l #移动解压后的文件名到/opt/,并改名为aleadminmanager mv aleadminmanager-0.25.0.linux-amd64 /opt/prometheus/aleadminmanager
更改aleadminmanager
文件夹权限:
chown prometheus:prometheus -R /opt/prometheus/aleadminmanager
创建 systemd 服务
cat >/etc/systemd/system/aleadminmanager.service << "EOF" [Unit] Description=Aleadmin Manager Wants=network-online.target After=network-online.target [Service] Type=simple User=prometheus Group=prometheus ExecStaadmin=/opt/prometheus/aleadminmanager/aleadminmanager \ --config.file=/opt/prometheus/aleadminmanager/aleadminmanager.yml \ --storage.path=/opt/prometheus/aleadminmanager/data Restaadmin=always [Install] WantedBy=multi-user.target EOF
启动 aleadminmanager
systemctl daemon-reload systemctl staadmin aleadminmanager.service systemctl enable aleadminmanager.service systemctl status aleadminmanager.service
检查配置
cd /opt/prometheus/prometheus/ ./promtool check config prometheus.yml
重启prometheus或重新加载配置文件(二选一)
#重启 systemctl restaadmin prometheus 或: #重载,需要--web.enable-lifecycle配置,热加载 curl -X POST http://localhost:9090/-/reload
标签:opt,service,--,prometheus,aleadminmanager,Prometheus,systemctl,安装 From: https://www.cnblogs.com/rtnb/p/18195419