centos7下部署 Prometheus+Grafana超炫监控

1.环境说明

监控主机 被监控主机
192.168.0.66 192.168.0.67
运维主机 MySQL

2.主机安装Prometheus

下载:https://prometheus.io/download/

上传到主机
[[email protected] ~]# yum -y ×××tall vim lrzsz

3.安装go

[[email protected] ~]# yum -y ×××tall epel-release
[[email protected] ~]# yum -y ×××tall go
Prometheus解压即可用
[[email protected] ~]# tar xf prometheus-2.10.0.linux-amd64.tar.gz -C /usr/local/

4.安装编辑Prometheus配置文件

[[email protected] ~]# vim /usr/local/prometheus-2.10.0.linux-amd64/prometheus.yml
追加如下内容(前方空格一定要对齐):
  - job_name: system-status
    static_configs:
    - targets: [‘192.168.0.67:9100‘]
      labels:
        ×××tance: 7-7
  - job_name: mysql-status
    static_configs:
    - targets: [‘192.168.0.67:9104‘]
      labels:
        ×××tance: 7-7-mysql

5.启动Prometheus

[[email protected] ~]# systemctl stop firewalld
[[email protected] ~]# cd /usr/local/prometheus-2.10.0.linux-amd64/
[[email protected] prometheus-2.10.0.linux-amd64]# ./prometheus --config.file=prometheus.yml &    # &意为后台启动

Prometheus页面如下

6.配置被监控服务器

(1)、node_exporter 用于监控操作系统的性能和运行状态(官网自行下载)
(2)、mysqld_exporter 用于监控 mysql 服务(官网自行下载)
(3)、snmp_exporter 用于监控网络设备
更多 exporter 可在官网下载:https://prometheus.io/download/#node_exporter

7.mysql安装和授权

[[email protected] ~]# yum -y ×××tall mariadb mariadb-server
[[email protected] ~]# systemctl restart mariadb
[[email protected] ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

MariaDB [(none)]>  GRANT REPLICATION CLIENT,PROCESS ON *.* TO ‘mysql_monitor‘@‘localhost‘
    -> identified by ‘123456‘;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> GRANT SELECT ON *.* TO ‘mysql_monitor‘@‘localhost‘;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit
Bye

8.安装主机监控的node_exporter

[[email protected] ~]# tar xf node_exporter-0.17.0.linux-amd64.tar.gz -C /usr/local/
[[email protected] ~]# /usr/local/node_exporter-0.17.0.linux-amd64/node_exporter &

9.安装主机监控的mysql_exporter

[[email protected] ~]# tar xf mysqld_exporter-0.11.0.linux-amd64.tar.gz -C /usr/local/
[[email protected] ~]# vim /usr/local/mysqld_exporter-0.11.0.linux-amd64/.my.cnf
写入如下内容:
[client]
user=mysql_monitor
password= 123456
启动
[[email protected] ~]# cd /usr/local/mysqld_exporter-0.11.0.linux-amd64/
[[email protected] mysqld_exporter-0.11.0.linux-amd64]# ./mysqld_exporter --config.my-cnf=".my.cnf"   &

后台启动的“ & ” 一定要写,不然推出当前操作终端后就会自动关掉
再次刷新Prometheus时,页面被监控都为up

10.安装grafana

下载:https://grafana.com/grafana/download
上传到运维主机

[[email protected] ~]# yum -y ×××tall /root/grafana-6.2.2-1.x86_64.rpm
下载饼状图插件,便于美化数据
[[email protected] ~]# grafana-cli plug××× ×××tall grafana-piechart-panel
启动grafana
[[email protected] ~]# systemctl restart grafana-server

11.登录grafana

默认端口3000,初始用户名和密码都为admin
http://192.168.0.66:3000
根据引导,登录后修改自己的密码





如上图:find dashboards on grafana.com 里可以找到需要监控的模板,查到相应的模板id
import dashboard 可以导入相应的模板id,其中8919为主机模板,9777为MySQL模板

点击load导入即可。
刷新到主页,效果如下

原文地址:https://blog.51cto.com/11573159/2409226

时间: 2024-08-30 17:49:17

centos7下部署 Prometheus+Grafana超炫监控的相关文章

Centos7下部署Nginx

一.续Centos7下部署Node,Nginx安装部署: Nginx选择安装的是编译版(附下载地址:https://nginx.org/download/),根据自己的系统环境选择. 1.进入保存下载文件的路径,cd进入文件保存路径,命令: cd /usr/local/src 2.下载文件,我这选择最新版本nginx-1.13.11.命令: wget https://nginx.org/download/nginx-1.13.11.tar.gz 3.解压到特定文件夹下,进行解压,执行命令: ta

CentOS7下部署rsync服务

说明: 在CentOS7下部署rsync服务和在CentOS6上部署基本上是一样的,只是CentOS7自带了rsyncd启动脚本,由systemd管理而已. rsync服务端配置 [[email protected] ~]# rpm -qa|grep rsync rsync-3.0.9-17.el7.x86_64 [[email protected] ~]# uname -r 3.10.0-514.el7.x86_64 [[email protected] ~]# systemctl stop

Rancher2.x 一键式部署 Prometheus + Grafana 监控 Kubernetes 集群

目录 1.Prometheus & Grafana 介绍 2.环境.软件准备 3.Rancher 2.x 应用商店 4.一键式部署 Prometheus 5.验证 Prometheus + Grafana 1.Prometheus & Grafana 介绍 Prometheus 是一套开源的系统监控.报警.时间序列数据库的组合,Prometheus 基本原理是通过 Http 协议周期性抓取被监控组件的状态,而通过 Exporter Http 接口输出这些被监控的组件信息,而且已经有很多 E

最新版Prometheus+Grafana+node-exporter炫酷界面

一.概述 理论知识就不多介绍了,参考链接: https://www.cnblogs.com/xiao987334176/p/9930517.html 本文使用2台服务器,来搭建. 环境 操作系统 docker版本 ip 容器 centos 7.4 18.09.2 192.168.10.104 Prometheus+Grafana+node-exporter centos 7.4 18.09.2 192.168.10.20 node-exporter 二.安装 请确保2台服务器,已经安装了dock

centos7下部署elasticSearch集群

OS:Centos7x虚拟机 1H2Gjdk:1.8elasticsearch:5.6.0 单节点配置请参考:centos7下elasticSearch安装配置 配置master节点 # 在配置文件的最后加上下面的配置 # 集群的名字 cluster.name: snsprj # 节点的名字 node.name: master # 是否是master节点 node.master: true 配置slave节点 # 新建文件夹es_slave mkdir es_slave # 解压并复制两份es_

Prometheus+grafana搭建jenkins监控

为了便于监控Jenkins搭建后的执行情况呢,我们搭建一个完整的监控体系,使用的Prometheus监控报警  ,展示用的是grafana. 安装prometheus brew install prometheus 安装grafana brew install grafana 安装后,启动grafana brew services start grafana 启动prometheus,需要有 prometheus.yml,我们创建prometheus文件即可. global: scrape_in

【转载】centos7+tomcat部署JavaWeb项目超详细步骤

我们平时访问的网站大多都是发布在云服务器上的,比如阿里云.腾讯云等.对于新手,尤其是没有接触过linux系统的人而言是比较有困难的,而且至今使用云服务器也是有成本的,很多时候我们可以通过虚拟机自己搭建一个测试服务器来运行我们的javaWeb项目.这里我就从头到尾开始详细的介绍一下如何部署javaWeb项目到centos7上. 总体分为三部分:1.java环境.2.tomcat环境.3.JavaWeb项目部署 一.安装java环境 centos7安装java环境比较简单,我是通过virtualBo

Centos7下部署两套python版本并存

需求说明:centos7.2系统的开发机器上已经自带了python2.7版本,但是开发的项目中用的是python3.5版本,为了保证Centos系统的正常运行,以及节省机器资源(不想因此再申请另外一台开发机器部署python3.5),所以需要安装python3.5与python2.7共存的开发环境.具体操作记录如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33

centos7下安装docker(17.5docker监控的总结对比)

到现在为止,我已经学习了docker自带的监控方案:ps/ls/top/stats,以及sysdig,weave scope,cadvisor,prometheus多种监控工具,现在做个总结和比较 部署容易度: ps/ls/top/stats肯定是最容易部署的了,毕竟是docker 自带的命令,能随时随地的查看容器的状态. 其他的几种工具都可以利用容器来运行,也是比较容器部署的,相对而言,prometheus组件相对较多,需要运行的容器也比较多 数据详细程度 ps/ls/top/stats可以监