promethus+grafana监控

1、监控 MySQL

(终端可以安装在任意主机,不一定按在mysql节点上,注:mysql版本需在5.5以上)

  I、首先在mysql中添加监控使用的用户:

  create user 'exp'@'%' identified by 'exp';

  grant process,replication client,select on *.* to 'exp'@'%';

  II、安装监控终端 mysqld_exporter 

  cd /data/prometheus/ (此目录为服务器上任意目录,根据个人习惯而定)

  下载地址:https://github.com/prometheus/mysqld_exporter/releases/download/v0.12.1/mysqld_exporter-0.12.1.linux-amd64.tar.gz

  tar -xvf mysqld_exporter-0.12.1.linux-amd64.tar.gz

  mv mysqld_exporter-0.12.1.linux-amd64 mysqld_exporter

  cd mysqld_exporter

  编辑终端使用的配置文件

  vim mysqld_exporter.cnf

  [client]

  host=172.xxx.xxx.xxx
  user=exp
  password=exp

  启动终端程序(次程序为后台启动程序)

  nohup ./mysqld_exporter --config.my-cnf=mysqld_exporter.cnf > mysqld_exporter.log 2>&1 &

  启动后此程序默认端口为9104
  III、添加prometheus监控及倒入grafana模版

  cd /prometheus/prometheus/

  vim prometheus.yml

  - job_name: 'mysql' (监控作业名称)

    static_configs:(静态添加)

    - targets: ['172.26.1.134:9104'](终端地址及端口)

  重新引导prometheus

  curl -X POST http://localhost:9090/-/reload (在prometheus主机上) 

  grafana添加模版

  

   导入后效果

  

 

 

2、监控 Redis

  I、安装监控终端  

  cd /data/prometheus/ (此目录为服务器上任意目录,根据个人习惯而定)

  下载地址:https://github.com/oliver006/redis_exporter/releases/download/v0.30.0/redis_exporter-v0.30.0.linux-amd64.tar.gz

  tar -xvf redis_exporter-v0.30.0.linux-amd64.tar.gz

  mv redis_exporter-v0.30.0.linux-amd64 redis_exporter

  cd redis_exporter 

  启动终端程序

  ## 无密码 nohup ./redis_exporter -redis.addr 172.26.1.120:6379 &

  ## 有密码 nohup ./redis_exporter -redis.addr 172.26.1.120:6379 -redis.password 123456   
  III、添加prometheus监控及倒入grafana模版

  cd /prometheus/prometheus/

  vim prometheus.yml

  - job_name: 'redis' (监控作业名称)

    static_configs:(静态添加)

    - targets: ['172.26.1.134:9121'](终端地址及端口)

  重新引导prometheus

  curl -X POST http://localhost:9090/-/reload (在prometheus主机上) 

  grafana 模版763

  导入后效果

      

3、监控 Elasticsearch

  I、安装监控终端  

  cd /data/prometheus/ (此目录为服务器上任意目录,根据个人习惯而定)

  下载地址:wget https://github.com/justwatchcom/elasticsearch_exporter/releases/download/v1.1.0/elasticsearch_exporter-1.1.0.linux-amd64.tar.gz

  tar -xvf elasticsearch_exporter-1.1.0.linux-amd64.tar.gz

  mv elasticsearch_exporter-1.1.0.linux-amd64 elasticsearch_exporter

  cd elasticsearch_exporter 

  启动终端程序

  nohup ./elasticsearch_exporter --es.uri http://localhost:9200 & 

  ## 参数说明:
  --es.uri     默认http://localhost:9200,连接到的Elasticsearch节点的地址(主机和端口)。 这可以是本地节点(例如localhost:9200),也可以是远程Elasticsearch服务器的地址
  --es.all 默认flase,如果为true,则查询群集中所有节点的统计信息,而不仅仅是查询我们连接到的节点。
  --es.cluster_settings 默认flase,如果为true,请在统计信息中查询集群设置
  --es.indices 默认flase,如果为true,则查询统计信息以获取集群中的所有索引。
  --es.indices_settings 默认flase,如果为true,则查询集群中所有索引的设置统计信息。
  --es.shards 默认flase,如果为true,则查询集群中所有索引的统计信息,包括分片级统计信息(意味着es.indices = true)。
  --es.snapshots 默认flase,如果为true,则查询集群快照的统计信息。

  III、添加prometheus监控及倒入grafana模版

  cd /prometheus/prometheus/

  vim prometheus.yml

  - job_name: 'es' (监控作业名称)

    static_configs:(静态添加)

    - targets: ['172.26.1.134:9114'](终端地址及端口)

  重新引导prometheus

  curl -X POST http://localhost:9090/-/reload (在prometheus主机上) 

  grafana 模版2322

  导入后效果

  

 

4、监控 RabbitMQ

   

I、安装监控终端  

  cd /data/prometheus/ (此目录为服务器上任意目录,根据个人习惯而定)

  下载地址:wget wget https://github.com/kbudde/rabbitmq_exporter/releases/download/v0.29.0/rabbitmq_exporter-0.29.0.linux-amd64.tar.gz

  tar -xvf rabbitmq_exporter-0.29.0.linux-amd64.tar.gz

  mv rabbitmq_exporter-0.29.0.linux-amd64.tar.gz rabbitmq_exporter

  cd rabbitmq_exporter 

  启动终端程序

  RABBIT_USER=geust RABBIT_PASSWORD=geust OUTPUT_FORMAT=JSON PUBLISH_PORT=9099 RABBIT_URL=http://ip:15672 nohup ./rabbitmq_exporter &

  RABBIT_USER 用户名

  RABBIT_PASSWORD 密码
  PUBLISH_PORT 监控端口
  RABBIT_URL 监控地址
  

  II、添加prometheus监控及倒入grafana模版

  cd /prometheus/prometheus/

  vim prometheus.yml

  - job_name: 'es' (监控作业名称)

     static_configs:(静态添加)

     - targets: ['172.26.1.134:9099'](终端地址及端口)

  重新引导prometheus

  curl -X POST http://localhost:9090/-/reload (在prometheus主机上) 

  grafana 模版2121

  导入后效果

  

 

 

 

 

 

 

 

 

posted @ 2021-05-26 19:02  木易-故事里的人  阅读(119)  评论(0编辑  收藏  举报