prometheus的安装配置和grafana的使用

目录

一、prometheus的安装

使用容器安装

源码安装

二、在被监控的机器上下载node_exporter

三、grafana的安装

四、测试效果


一、prometheus的安装

使用容器安装

[root@prometheus ~]# docker run -d -p 9090:9090 --name sc-prom-1   prom/prometheus

源码安装

[root@prometheus ~]# mkdir /prometheus
[root@prometheus ~]# cd /prometheus
[root@prometheus prometheus]# rz
[root@prometheus prometheus]# ls
prometheus-2.29.1.linux-amd64.tar.gz
[root@prometheus prometheus]# tar xf prometheus-2.29.1.linux-amd64.tar.gz
#修改PATH环境变量
[root@prometheus prometheus]# PATH=$PATH:/prometheus/prometheus-2.29.1.linux-amd64
[root@prometheus prometheus]# which prometheus
/prometheus/prometheus-2.29.1.linux-amd64/prometheus
[root@prometheus prometheus]# vim /root/.bashrc
PATH=$PATH:/prometheus/prometheus-2.29.1.linux-amd64 #添加到末尾
[root@prometheus prometheus]# cd /prometheus/prometheus-2.29.1.linux-amd64 
[root@prometheus prometheus-2.29.1.linux-amd64]# vim prometheus.yml

scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: "prometheus"

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
      - targets: ["localhost:9090"]

#添加需要监控的服务器的信息
  - job_name: "manager"
    static_configs:
      - targets: ["192.168.10.230:9100"]
  - job_name: "node1"
    static_configs:
      - targets: ["192.168.10.231:9100"]
  - job_name: "node2"
    static_configs:
      - targets: ["192.168.10.232:9100"]
  - job_name: "node3"
    static_configs:
      - targets: ["192.168.10.234:9100"]

#后台运行
[root@prometheus prometheus-2.29.1.linux-amd64]# nohup ./prometheus --config.file=/prometheus/prometheus-2.29.1.linux-amd64/prometheus.yml  &

二、在被监控的机器上下载node_exporter

[root@manager ~]# rz

[root@manager ~]# mkdir /exporter
[root@manager ~]# mv node_exporter-1.2.2.linux-amd64.tar.gz /exporter/
[root@manager ~]# cd /exporter/
[root@manager exporter]#
解压软件
[root@manager exporter]# tar xf node_exporter-1.2.2.linux-amd64.tar.gz
[root@manager exporter]# ls
node_exporter-1.2.2.linux-amd64  node_exporter-1.2.2.linux-amd64.tar.gz
[root@manager exporter]# cd node_exporter-1.2.2.linux-amd64
[root@manager node_exporter-1.2.2.linux-amd64]# ls
LICENSE  node_exporter  NOTICE

修改PATH环境变量
[root@manager node_exporter-1.2.2.linux-amd64]# PATH=/exporter/node_exporter-1.2.2.linux-amd64:$PATH
[root@manager node_exporter-1.2.2.linux-amd64]# which node_exporter
/exporter/node_exporter-1.2.2.linux-amd64/node_exporter
[root@manager node_exporter-1.2.2.linux-amd64]#
[root@manager node_exporter-1.2.2.linux-amd64]# vim /root/.bashrc
PATH=/exporter/node_exporter-1.2.2.linux-amd64:$PATH  在末尾添加

执行软件
[root@manager node_exporter-1.2.2.linux-amd64]# nohup  ./node_exporter --web.listen-address="0.0.0.0:9100"  &
[1] 96546
[root@manager node_exporter-1.2.2.linux-amd64]# nohup: 忽略输入并把输出追加到'nohup.out'

[root@manager node_exporter-1.2.2.linux-amd64]#
[root@manager node_exporter-1.2.2.linux-amd64]# ps aux|grep node
root       96546  0.1  0.2 716440 10996 pts/1    Sl   10:38   0:00 ./node_exporter --web.listen-address=0.0.0.0:9100
root       96551  0.0  0.0  12348  1144 pts/1    S+   10:38   0:00 grep --color=auto node
[root@manager node_exporter-1.2.2.linux-amd64]#

三、grafana的安装

[root@grafana ~]# cd /etc/yum.repos.d/
#grafana.repo结尾的文件的作用是用来找到对方的软件的仓库
[root@grafana yum.repos.d]# vim grafana.repo
[root@grafana yum.repos.d]# cat grafana.repo
[grafana]
name=grafana
baseurl=https://packages.grafana.com/enterprise/rpm
repo_gpgcheck=1
enabled=1
gpgcheck=1
gpgkey=https://packages.grafana.com/gpg.key
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
[root@grafana yum.repos.d]# yum install grafana  -y
[root@grafana yum.repos.d]# systemctl  start grafana-server
[root@grafana yum.repos.d]# ss -anplut|grep grafana
tcp    LISTEN   0        128                     *:3000                 *:*      users:(("grafana-server",pid=43438,fd=8))
[root@nfs-server yum.repos.d]#

四、测试效果

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在Windows上安装PrometheusGrafana,可以按照以下步骤进行操作: 1. 首先,进入Prometheus官网(引用[1])或者其他可信的下载源,下载适用于Windows的Prometheus安装包。根据你的系统架构选择正确的版本,比如64位系统选择prometheus-2.20.1.windows-amd64.tar.gz(引用[1])。 2. 下载完成后,解压缩安装包。你可以选择将解压后的文件夹放在任意位置。 3. 进入解压后的目录,运行prometheus.exe。这将启动Prometheus服务。 4. 打开浏览器,访问http://localhost:9090,即可进入Prometheus的Web界面。在这里,你可以查看监控的对象列表,可以通过点击"Status",然后选择"Targets"来查看(引用[1])。 5. 接下来,你可以根据自己的需求编辑prometheus.yml文件,来配置你的监控数据源。这个文件位于解压后的目录中,你可以使用任何文本编辑器进行编辑。 6. 对于Grafana安装,你可以访问Grafana官方网站或其他可信的下载源,下载适用于Windows的Grafana安装包。 7. 下载完成后,运行安装包进行安装。按照安装向导的指示进行操作,选择安装位置和其他选项。 8. 安装完成后,运行Grafana。默认情况下,Grafana会在本地的3000端口启动。 9. 打开浏览器,访问http://localhost:3000,即可进入Grafana的Web界面。 10. 在Grafana中,你可以配置数据源、创建仪表盘和图表,以展示Prometheus收集到的监控数据。 请注意,以上步骤仅提供了基本的安装配置指南。具体的安装配置步骤可能会因版本和个人需求而有所不同。建议参考官方文档(引用[2])或其他可靠的资源,以获取更详细的指导和说明。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值