简易安装Prometheus2.x版本

Prometheus安装

上传监控软件

cd /opt/ ;scp [email protected]:/optprometheus-2.5.0.linux-amd64.tar.gz /opt

解压安装操作
[root@localhost opt]# tar -zxvf prometheus-2.5.0.linux-amd64.tar.gz -C /usr/local/;cd /usr/local/;mv prometheus-2.5.0.linux-amd64 prometheus
设置systemctl启动程序
root@localhost local]# vim /usr/lib/systemd/system/prometheus.service 

[Unit]
Description=Prometheus server daemon
After=network.target
[Service]
Type=simple
User=root
Group=root
ExecStart=/usr/local/prometheus/prometheus \
    --config.file=/usr/local/prometheus/prometheus.yml \
    --storage.tsdb.path="/usr/local/prometheus/data" \
    --storage.tsdb.retention=15d \
    --web.console.templates="/usr/local/prometheus/consoles" \
    --web.console.libraries="/usr/local/prometheus/console_libraries" \
    --web.max-connections=512 \
    --web.external-url "http://192.168.189.131:9090" \
    --web.listen-address=0.0.0.0:9090
Restart=on-failure
[Install]
WantedBy=multi-user.target

[root@gtcq-gt-monitor-prometheus-01 local]# 

启动程序介绍:

ExecStart=/usr/local/prometheus/prometheus    #启动运行prometheus程序所在的路径
--config.file=/usr/local/prometheus/prometheus.yml    #指定prometheus.yml配置文件路径
--storage.tsdb.path="/usr/local/prometheus/data"     #指定监控指标数据存储的路径
--storage.tsdb.retention=15d       #历史数据最大保留时间,默认15天
--web.console.templates="/usr/local/prometheus/consoles"    #指定控制台模板目录路径
--web.console.libraries="/usr/local/prometheus/console_libraries"    #指定控制台库目录路径
--web.max-connections=512    #设置最大同时连接数
--web.external-url "http://10.152.17.11:9090"     #用于生产返回prometheus相对的绝对链接地址,可以在后续告警通知内容中直接点击链接地址访问prometheus Web UI。其格式为:http://{ip或者域名}:9090
--web.listen-address=0.0.0.0:9090    #prometheus默认监控端口

systemctl命令介绍:

systemctl daemon-reload      #通知systemctl重新加载配置文件
systemctl enable prometheus.service      #设置为开机自启动
systemctl disable prometheus.service #如果不想设置为开机启动,可以关闭。关闭开机自启动
systemctl start prometheus.service    #开启服务
systemctl status prometheus.service  #查看服务状态
systemctl restart prometheus.service  #重启服务
systemctl stop prometheus.service    #关闭服务
访问路径

http://192.168.189.131:9090/graph
http://192.168.189.131:9090/metrics

猜你喜欢

转载自blog.csdn.net/qq_31555951/article/details/109096661