CentOS 7安装 prometheus+grafana

1 篇文章 0 订阅
1 篇文章 0 订阅

安装prometheus-1.8.2.linux-amd64

访问地址http://x.x.x.122:9090/targets
启动

nohup ./prometheus -config.file=prometheus.yml &
nohup ./prometheus -storage.local.retention 8760h0m0s  &  保存1年的数据
-storage.local.retention 360h0m0s   历史数据存储多久,默认15天。

安装node_exporter

版本匹配主要是node_exporter(不要用最新版)
https://github.com/prometheus/node_exporter/releases/download/0.11.0/node_exporter-0.11.0.linux-amd64.tar.gz
注意:最新版只有node_memory_MemTotal_bytes而没有node_memory_MemTotal

nohup ./node_exporter &

安装grafana

wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-4.2.0-1.x86_64.rpm
sudo yum install initscripts fontconfig -y
sudo rpm -Uvh grafana-4.2.0-1.x86_64.rpm

启动服务service grafana-server start
grafana访问页面http://localhost:3000 ,默认账号、密码admin/admin
dashboards(Grafana)仪表盘模板

git clone https://github.com/percona/grafana-dashboards.git
cp -r grafana-dashboards/dashboards /var/lib/grafana/dashboards

编辑Grafana配置文件

vi /etc/grafana/grafana.ini
[dashboards.json]
enabled = true
path = /var/lib/grafana/dashboards

修改端口号

http_port = 3333
root_url = http://localhost:3333

重启service grafana-server restart

mysql监控部署

在需要监控的mysql上安装 node_exporter和 mysqld_exporter
https://prometheus.io/download/
下载node_exporter(启动后端口为9100)
node_exporter访问地址 http://x.x.x.122:9100/metrics
监听121服务器(只需在121安装node_exporter打开9100端口)

vim /home/tools/prometheus-1.8.2.linux-amd64/prometheus.yml
......
  - job_name: linux24
    static_configs:
      - targets: ['x.x.x.x:3564']
        labels:
          instance: linux24
  - job_name: linux121
    static_configs:
      - targets: ['x..x.x:9100']
        labels:
          instance: linux121        
  - job_name: mongo121
    static_configs:
      - targets: ['x.x.x.121:9001']
        labels:
          instance: mongo121
  - job_name: linux122
    static_configs:
      - targets: ['x.x.x.122:9100']
        labels:
          instance: linux122

mongodb监控部署

查看当前centos的GO版本
go version
下载安装mongodb_exporter

go get github.com/dcu/mongodb_exporter
cd $GOPATH/src/github.com/dcu/mongodb_exporter
make build

启动 登录到mongodb server
mongodb授权

db.getSiblingDB("admin").createUser({
    user: "mongodb_exporter",
    pwd: "xxx",
    roles: [
        { role: "clusterMonitor", db: "admin" },
        { role: "read", db: "local" }
    ]
})

export MONGODB_URL=mongodb://mongodb_exporter:xxx@x.x.x.121:27017
./mongodb_exporter

监听mongodb

查看端口占用

netstat -anp|grep 9100

mongodb所在服务器 安装 node_exporter ,mongodb_exporter

git clone https://github.com/percona/mongodb_exporter.git
https://packages.debian.org/stretch/prometheus-mongodb-exporter

启动 登录到mongodb server.

./mongodb_exporter -mongodb.uri mongodb://name:pwd@x.x.x.121:27017/sddata

该方式已过时

./mongodb_exporter-linux-amd64 -mongodb.uri mongodb://name:pwd@x.x.x.121:27017/sddata
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值