Prometheus环境配置

1、环境准备

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

Prometheus环境配置

Prometheus环境配置

2、安装Prometheus Server

安装docker

Prometheus环境配置

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

Prometheus环境配置

或者 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环境配置

# 赋权和创建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安装

Prometheus环境配置

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
上一篇:Prometheus学习(二)之Prometheus FIRST STEPS


下一篇:K8s——kubernetes集群中ceph集群使用【下】