前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >使用 Prometheus 监控 Ceph

使用 Prometheus 监控 Ceph

作者头像
用户2443625
发布2018-10-08 11:04:56
2.7K0
发布2018-10-08 11:04:56
举报
文章被收录于专栏:blackpigletblackpiglet

Prometheus

本文是在 Ubuntu 16.04 最新版基础上安装 Prometheus 监控系统,Ceph 版本为 Luminous 12.2.8。

1. 安装 Prometheus

直接使用 apt 安装的 Prometheus 版本较低,很多新的配置选项都已不再支持,建议使用 Prometheus 的安装包,接下来看看安 装包部署的步骤。

先下载安装包,这里用的是 2.0.0 版本,目前为止,最新的应该为 2.4.0,安装方法都是一样的。

代码语言:javascript
复制
$ wget https://github.com/prometheus/prometheus/releases/download/v2.0.0/prometheus-2.0.0.linux-amd64.tar.gz
$ tar zxvf prometheus-2.0.0.linux-amd64.tar.gz
$ cd prometheus-2.0.0.linux-amd64/
$ sudo cp prometheus /usr/bin/
$ sudo cp promtool /usr/bin/
代码语言:javascript
复制
$ vim /lib/systemd/system/prometheus.service
[Unit]
Description=Prometheus: the monitoring system
Documentation=http://prometheus.io/docs/

[Service]
ExecStart=/usr/bin/prometheus --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/var/lib/prometheus --web.console.templates=/etc/prometheus/consoles --web.console.libraries=/etc/prometheus/console_libraries --web.listen-address=0.0.0.0:9090 --web.external-url=
Restart=always
StartLimitInterval=0
RestartSec=10

[Install]
WantedBy=multi-user.target
代码语言:javascript
复制
$ sudo mkdir /etc/prometheus/ 
$ sudo cp -R consoles console_libraries prometheus.yml /etc/prometheus/
$ sudo mkdri /var/lib/prometheus/
$ sudo systemctl daemon-reload
$ sudo systemctl enable prometheus.service
$ sudo systemctl start prometheus.service

在下一步装好 ceph_exporter 后,还需要在 Promethues 中添加相应配置,不过现在执行到这一步就可以了。

2. 安装 ceph_exporter

2.1 安装 Go 语言环境

导出 Ceph 信息到 Prometheus 有多种方式,本文采用的是 DigitalOcean 的 ceph_exporter,ceph_exporter 使用 go 语言编写的,所以需要先安装 go 语言环境。还是一条命令解决:

代码语言:javascript
复制
$ apt install -y golang

安装好后执行 $ go env 命令验证并查看一下 go 环境信息。

代码语言:javascript
复制
$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH=""
GORACE=""
GOROOT="/usr/lib/go-1.6"
GOTOOLDIR="/usr/lib/go-1.6/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"

然后需要设置 Go 环境变量:

代码语言:javascript
复制
$ cat /etc/profile.d/go.sh 
export GOROOT=/usr/lib/go-1.6
export GOBIN=$GOROOT/bin
export GOPATH=/home/user/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

$ source /etc/profile.d/go.sh

已经配置好 Go 环境了,接下来创建 GOPATH 指定的目录:

代码语言:javascript
复制
$ mkdir /home/user/go

2.2 安装 ceph_exporter

Go 环境安装好后,我们接下来下载 ceph_exporter 代码,然后编译出可执行程序。

代码语言:javascript
复制
$ mkdir -p /home/user/go/github.com/digitalocean
$ cd /home/user/go/github.com/digitalocean
$ git clone github.com/digitalocean/ceph_exporter
$ cd ceph_exporter
$ go build

这时编译会报错,原因是需要依赖 ceph rados 相关的头文件,需要安装 librados-dev 包。

代码语言:javascript
复制
$ sudo apt install -y librados-dev

安装好后,在编译,复制可执行文件到对应目录完成安装。 再运行 go build 完成安装。

代码语言:javascript
复制
$ go build 
$ mkdir /home/user/go/bin
$ cp ceph_exporter /home/user/go/bin

执行 ceph_exporter 来验证一下是否可以正常使用

代码语言:javascript
复制
$ ceph_exporter --help
Usage of ceph_exporter:
  -ceph.config string
        path to ceph config file
  -ceph.user string
        Ceph user to connect to cluster. (default "admin")
  -exporter.config string
        Path to ceph exporter config. (default "/etc/ceph/exporter.yml")
  -rgw.mode int
        Enable collection of stats from RGW (0:disabled 1:enabled 2:background)
  -telemetry.addr string
        host:port for ceph exporter (default ":9128")
  -telemetry.path string
        URL path for surfacing collected metrics (default "/metrics")

2.3 修改 Promethues 配置

接下来需要修改 Prometheus 的配置,添加一会要安装的 ceph_exporter 的相关信息:

代码语言:javascript
复制
$ sudo vim /etc/prometheus/prometheus.yml
...
scrape_configs:
  - job_name: 'ceph_exporter'
    static_configs:
    - targets: ['localhost:9128']
      labels:
        alias: ceph_exporter
...

改好后,重启:

代码语言:javascript
复制
$ sudo systemctl restart prometheus.service

3. 安装 Grafana

3.1 安装

Grafana 也不推荐使用 APT 安装,原因也是版本太低,安装官方打包好的版本是更优的选择。

代码语言:javascript
复制
$ sudo apt-get install -y adduser libfontconfig
$ wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana_5.2.4_amd64.deb 
$ sudo dpkg -i grafana_5.2.4_amd64.deb 
$ sudo systemctl enable grafana-server
$ sudo systemctl start grafana-server

至此 Grafana 也已经安装好了,接下来登录 grafana 界面。

3.2 配置 dashboard

Grafana

访问 http://localhost:3000 来登录 Grafana,默认用户为 admin,密码也是 admin

data-source

登录后首先需要配置 data source,访问地址 http://localhost:3000/datasources,会出现如上图所示的界面,按照图中显示的信息配置即可。

import

最后需要导入 Ceph 相关的界面,如图所示,导入的是编号为 917 的 dashboard(从 grafana.com 上,导入编号为 917 的 dashboard)。

ceph-cluster

完成后,终于可以看到 Ceph 的监控信息了。

4. 参考文档

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018.09.12 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1. 安装 Prometheus
  • 2. 安装 ceph_exporter
    • 2.1 安装 Go 语言环境
      • 2.2 安装 ceph_exporter
        • 2.3 修改 Promethues 配置
        • 3. 安装 Grafana
          • 3.1 安装
            • 3.2 配置 dashboard
            • 4. 参考文档
            相关产品与服务
            Prometheus 监控服务
            Prometheus 监控服务(TencentCloud Managed Service for Prometheus,TMP)是基于开源 Prometheus 构建的高可用、全托管的服务,与腾讯云容器服务(TKE)高度集成,兼容开源生态丰富多样的应用组件,结合腾讯云可观测平台-告警管理和 Prometheus Alertmanager 能力,为您提供免搭建的高效运维能力,减少开发及运维成本。
            领券
            问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档