记一次安装prometheus过程

1. 下载必要的包
wget -c https://github.com/prometheus/prometheus/releases/download/v2.18.0/prometheus-2.18.0.linux-amd64.tar.gz
wget -c https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz
wget -c https://dl.grafana.com/oss/release/grafana-6.7.3-1.x86_64.rpm
2. 安装prometheus
  • 安装脚本
 tar -zxvf prometheus-2.18.0.linux-amd64.tar.gz -C /usr/local/
 cd /usr/local/
 mv prometheus-2.18.0.linux-amd64 prometheus
  • 启动项编写
vim /etc/systemd/system/prometheus.service

[Unit]
Description=Prometheus Server
Documentation=https://prometheus.io/docs/introduction/overview/
After=network-online.target

[Service]
Type=simple
#Change this line if you download the
#Prometheus on different path user
ExecStart=/usr/local/prometheus/prometheus \
  --config.file=/usr/local/prometheus/prometheus.yml \
  --storage.tsdb.path=/usr/local/prometheus/data \
  --web.listen-address=:9092
Restart=on-failure

[Install]
WantedBy=multi-user.target

  • 启动服务
 systemctl daemon-reload
 systemctl start prometheus.service
 systemctl status prometheus.service
 systemctl enable prometheus.service
3. 安装node_exporter
  • 安装脚本
 tar -zxvf node_exporter-0.18.1.linux-amd64.tar.gz -C /usr/local/prometheus/exporters
 cd /usr/local/prometheus/exporters
 mv node_exporter-0.18.1.linux-amd64 node_exporter
  • 启动项编写
vim /etc/systemd/system/node_exporter.service

[Unit]
Description=Prometheus node exporter
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/prometheus/exporters/node_exporter  --web.listen-address=:9101
Restart=on-failure

[Install]
WantedBy=multi-user.target
  • 启动服务
 systemctl daemon-reload
 systemctl start node_exporter.service
 systemctl status node_exporter.service
 systemctl enable node_exporter.service
4. 安装grafana
  yum localinstall grafana-6.7.3-1.x86_64.rpm 
  
  systemctl start grafana-server.service
  systemctl status grafana-server.service
  systemctl enable grafana-server.service
5. 安装过程中遇到的问题
  • Prometheus 以及 Exporter 的端口号冲突
    –web.listen-address=:9101 使用这个参数,可以自定义端口号

  • grafana 端口号冲突
    修改配置文件 /etc/grafana/grafana.ini ,http_port = 3001参数可修改端口号

vim /etc/grafana/grafana.ini
...
#################################### Server ####################################
[server]
# Protocol (http, https, h2, socket)
;protocol = http

# The ip address to bind to, empty will bind to all interfaces
;http_addr =

# The http port  to use
http_port = 3001
... 
  • systemd方式启动异常原因查找
  systemctl start grafana-server.service
  systemctl status grafana-server.service

启动时发现一直无法正常启动,此时我们可以用如下命令查看日志

# 查看全局
journalctl -xe

# 查看某个PID
journalctl   _PID=25532
  • 权限问题
chown -R grafana:grafana /var/run/grafana/

参考:

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值