Prometheus环境配置

1、环境准备

服务器IP是202.101.58.162,登入,建立相应文件夹

2、安装Prometheus Server

安装docker

准备应用  https://prometheus.io/download/ 

或者 git clone https://github.com/prometheus/client_golang.git

//wget https://github.com/prometheus/prometheus/releases/download/v2.8.1/prometheus-2.8.1.linux-amd64.tar.gz

上传后解压 

tar xvzf /home/prometheus-2.21.0-rc.1.linux-amd64.tar.gz

移动到文件夹

 mv prometheus-2.21.0-rc.1.linux-amd64 /home/prometheus
 

修改  prometheus.yml

     - targets: ['localhost:9090']

# 赋权和创建prometheus运行数据目录

[root@localhost prometheus]# cd ~

[root@localhost ~]# chown -R prometheus:prometheus /usr/local/prometheus/

[root@localhost ~]# mkdir -p /home/software/prometheus-data

[root@localhost ~]# chown -R prometheus:prometheus /home/software/prometheus-data

4、以服务方式启动

添加到系统服务,方便于管理

1

vi /etc/systemd/system/prometheus.service

1

2

3

4

5

6

7

8

9

10

11

[Unit]

Description=Prometheus Monitoring System

Documentation=Prometheus Monitoring System

[Service]

ExecStart=/usr/local/prometheus/prometheus \

  --config.file=/usr/local/prometheus/prometheus.yml \

  --web.listen-address=:9090

[Install]

WantedBy=multi-user.target

启动服务,设置开机自启

1

2

3

systemctl daemon-reload

systemctl enable prometheus

systemctl start prometheus

设置用户(节点)

groupadd prometheus

useradd -g prometheus -s /sbin/nologin prometheus

chown -R prometheus:prometheus /usr/local/node_exporter

 vim /usr/lib/systemd/system/node_exporter.service

Unit]

Description=node_exporter

Documentation=https://prometheus.io/

After=network.target

[Service]

Type=simple

User=prometheus

ExecStart=/usr/local/node_exporter/node_exporter

[root@node1 ~]# systemctl enable node_exporter

[root@node1 ~]# systemctl start node_exporter

Restart=on-failure

[Install]

WantedBy=multi-user.target

grafana安装

复制代码

wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.2.2.linux-amd64.tar.gz 
tar -zxvf grafana-5.2.2.linux-amd64.tar.gz 

systemctl enable grafana-server

systemctl start grafana-server

sudo systemctl daemon-reload
sudo systemctl start grafana-server
sudo systemctl status grafana-server
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值