Prometheus 监控 Ceph
启用Dashboard
查看模块是否可以启用:可以看到dashboard可以启用,但是influx是没有启用的,因为缺少一个模块
ceph mgr module ls ... { "name": "dashboard", "can_run": true, "error_string": "" }, ... { "name": "influx", "can_run": false, "error_string": "influxdb python module not found" },
启用模块:如果可以启用则启用即可。
ceph mgr module enable dashboard
关闭SSL:默认使用SSL提供服务所以需要提供证书,这里直接关闭SSL。
ceph config set mgr mgr/dashboard/ssl false
指定Dashboard监听的地址和端口:
ceph config set mgr mgr/dashboard/server_addr 0.0.0.0 ceph config set mgr mgr/dashboard/server_port 8080 # 或 ceph config set mgr mgr/dashboard/ceph03/server_addr 0.0.0.0 ceph config set mgr mgr/dashboard/ceph03/server_port 8080
设置登陆的账号和密码:
ceph dashboard set-login-credentials admin qiyang
用浏览器打开下面地址:登陆即可看到关于ceph集群的各种信息。
http://192.168.1.62:8080
Prometheus监控Ceph
Ceph默认已近集成了Prometheus中用于收集数据的node_exporter,只要开启即可收集到Ceph集群的各项指标,但是要收集Ceph所在的各个节点数据还是要部署node_exporter。
部署prometheus节点:
下载:
wget https://github.com/prometheus/prometheus/releases/download/v2.7.2/prometheus-2.7.2.linux-amd64.tar.gz
解压安装:
tar -xf prometheus-2.7.2.linux-amd64.tar.gz -C /usr/local/ cd /usr/local/ ln -sv prometheus prometheus-2.7.2.linux-amd64/
创建用户:
useradd -r -d /var/lib/prometheus -m prometheus
Unit文件:/usr/lib/systemd/system/prometheus.service
[Unit] After=network.target [Service] EnvironmentFile=-/etc/sysconfig/prometheus User=prometheus ExecStart=/usr/local/prometheus/prometheus \ --storage.tsdb.path=/var/lib/prometheus \ --config.file=/usr/local/prometheus/prometheus.yml \ --web.listen-address=0.0.0.0:9090 \ --web.external-url= \ $PROM_EXTRA_ARGS Restart=on-failure StartLimitInterval=1 RestartSec=3 [Install] WantedBy=multi-user.target
启动Prometheus:
systemctl daemon-reload systemctl start prometheus.service
默认监听在9090端口:
http://192.168.1.12:9090
部署node_exporter:
下载:
wget https://github.com/prometheus/node_exporter/releases/download/v0.17.0/node_exporter-0.17.0.linux-amd64.tar.gz
解压安装:
tar -xf node_exporter-0.17.0.linux-amd64.tar.gz -C /usr/local/ cd /usr/local/ ln -sv node_exporter-0.17.0.linux-amd64/ node_exporter
创建用户:
useradd -r -m -d /var/lib/prometheus prometheus
Unit文件:/usr/lib/systemd/system/node_exporter.service
[Unit] After=network.target [Service] EnvironmentFile=-/etc/sysconfig/node_exporter User=prometheus ExecStart=/usr/local/node_exporter/node_exporter \ $NODE_EXPORTER_OPTS Restart=on-failure StartLimitInterval=1 RestartSec=3 [Install] WantedBy=multi-user.target
启动node_exporter:
systemctl daemon-reload systemctl start node_exporter.service
默认监听9100端口:
curl localhost:9100/metrics
配置prometheus收集node_exporter的数据:
打开/usr/local/prometheus/prometheus.yml文件,在文件末尾处添加如下配置,这里以静态配置的方式来监控节点。
- job_name: 'nodes' static_configs: - targets: ['192.168.1.62:9100']
重启prometheus 打开prometheus的web页面 Status -> Targets 即可看到已近监控的node节点了。
systemctl restart prometheus.service
Ceph开启prometheus的数据收集端口:
在Ceph管理节点开启该功能:
ceph mgr module enable prometheus
默认监听在9283端口:
curl 192.168.1.62:9283/metrics
同样打开web端的Status -> Targets页面即可看到该地址的端口已近进入prometheus的监控了,在首页的监控项下拉框就可以看到有关Ceph的监控项了。
使用grafana展示数据:
安装grafana:如果要设置密码在配置文件 /etc/grafana/grafana.ini 中找password即可,不修改直接跳过也行。
下载安装:
wget https://dl.grafana.com/oss/release/grafana-6.0.1-1.x86_64.rpm yum install grafana-6.0.1-1.x86_64.rpm
启动:
systemctl start grafana-server.service
默认监听在3000端口:
http://192.168.1.12:3000
需要到官网下载模板:
找到这个页面 grafana.com/grafana/dashboards 打开后在左边栏处搜索模板即可找到需要的模板。
这里选好了直接下载使用即可,导入后就可以看到图形。
https://grafana.com/grafana/dashboards/2842/reviews