项目实战 Prometheus环境搭建
项目摘要:
本文是搭建一套prometheus环境的教程。
前期准备:准备三台虚拟机,本文以centos7为例。
项目具体实施:
分别进入每台虚拟机设置hostname:
# hostnamectl set-hostname prometheus.demo
# hostnamectl set-hostname agent.demo
# hostnamectl set-hostname grafana.demo
在每台虚拟机的/etc/hosts文件中加入如下内容(ip改成真实的ip地址):
ip agent.demo
ip grafana.demo
ip prometheus.demo
每台虚拟机同步时间(前两条命令不一定需要):
# mount /dev/sr0/mnt
# yum install ntpdate -y
# ntpdate -u cn.pool.ntp.org
每台禁用SELINUX
# vim /etc/selinux/config
将SELINUX=enforcing 修改为:SELINUX=disabled
每台关闭防火墙
# systemctl stop firewalld
# systemctl disable firewalld
# iptables -F
安装prometheus(登录到prometheus主机)
下载后,解压就能用,不需要编译。
下载:
# wget https://github.com/prometheus/prometheus/releases/download/v2.5.0/prometheus-2.5.0.linux-amd64.tar.gz
解压、移动/重命名:
# tar xf prometheus-2.5.0.linux-amd64.tar.gz -C /usr/local
# mv /usr/local/prometheus-2.5.0.linux-amd64/ /usr/local/prometheus
# mkdir /etc/prometheus
# cp /usr/local/prometheus/prometheus.yml /etc/prometheus/
启动:
# /usr/local/prometheus/prometheus --config.file=" /etc/prometheus/
/prometheus.yml" &
解释:&:表示后台运行
默认端口是9090
查看端口占用情况:
# lsof -i:9090 或者 ss -naltp | grep 9090
此时,浏览器输入http://ip:9090即可访问到prometheus的主界面:
安装node_exporter监控远程Linux主机(登录到agent机器)
下载:
# wget https://github.com/prometheus/node_exporter/releases/download/v0.16.0/node_exporter-0.16.0.linux-amd64.tar.gz
解压:# tar xf node_exporter-0.16.0.linux-amd64.tar.gz -C /usr/local/
重命名: # mv /usr/local/node_exporter-0.16.0.linux-amd64/ /usr/local/node_exporter
启动:# nohup /usr/local/node_exporter/node_exporter &
查看启动情况:# lsof -i:9100
打开浏览器输入:http://ip:9100/metrics即可看到监控信息。
将该监控添加到prometheus监控软件,登录到prometheus机器。
修改prometheus.yml
# vim /etc/prometheus/prometheus.yml
末尾添加如下内容:
- job_name: 'agent'
static_configs:
- targets: ['ip:9100']
# ps -aux | grep prome
# kill -HUP 进程号
去控制台查看。(选择statusàtargets查看)
在agent机器添加一个mysql监控
下载:
# wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.11.0/mysqld_exporter-0.11.0.linux-amd64.tar.gz
解压:tar xf mysqld_exporter-0.11.0.linux-amd64.tar.gz -C /usr/local/重命名:# mv /usr/local/mysqld_exporter-0.11.0.linux-amd64/ /usr/local/mysqld_exporter
安装mysql数据库:
参考:https://www.jianshu.com/p/fe476f511485
创建一个mysql配置文件,写上连接的用户名与密码(和上面的授权的用户名 和密码要对应)
# vim /usr/local/mysqld_exporter/.my.cnf
[client]
user=用户名
password=密码
# nohup /usr/local/mysqld_exporter/mysqld_exporter --config.my-cnf=/usr/local/mysqld_exporter/.my.cnf &
确认端口(9104)
# lsof -i:9104
浏览器输入:http://ip:9104/metrics即可看到监控信息。
将该监控添加到prometheus监控软件,登录到prometheus机器。
编辑如下内容:
# vim /etc/prometheus/prometheus.yml
末尾添加如下内容:
- job_name: 'agent_mysql'
static_configs:
- targets: ['ip:9104']
# kill -HUP 进程号
再次去浏览器页面观察是否添加成功。
安装grafana
下载:# wget https://dl.grafana.com/oss/release/grafana-5.3.4-1.x86_64.rpm
安装:# rpm -ivh grafana-5.3.4-1.x86_64.rpm
启动:
# systemctl start grafana-server
# systemctl enable grafana-server
检查端口: # lsof -i:3000
打开浏览器输入:http://ip:3000查看是否成功运行。
至此,环境搭建完成。
项目实战 Prometheus环境搭建的更多相关文章
- OpenDaylight开发hello-world项目之开发环境搭建
OpenDaylight开发hello-world项目之开发环境搭建 OpenDaylight开发hello-world项目之开发工具安装 OpenDaylight开发hello-world项目之代码 ...
- node 项目中 koa2 环境搭建 以及项目发布
环境搭建: 1.Koa 必须使用 7.6 以上的版本.如果你的版本低于这个要求,就要先升级 Node. 查看node版本方法:node -v 2.使用koa-generator生成器生成项目 安装ko ...
- Android内核漏洞利用技术实战:环境搭建&栈溢出实战
前言 Android的内核采用的是 Linux 内核,所以在Android内核中进行漏洞利用其实和在 一般的 x86平台下的 linux 内核中进行利用差不多.主要区别在于 Android 下使用的是 ...
- Activiti实战02_环境搭建
1:下载Activiti 访问:https://www.activiti.org/download-bpm 可以下载Activiti相关文档和历史版本压缩包,在 https://www.activit ...
- 基于Flask框架的Python web程序的开发实战 <一> 环境搭建
最近在看<Flask Web开发基于Python的Web应用开发实战>Miguel Grinberg著.安道译 这本书,一步步跟着学习Flask框架的应用,这里做一下笔记 电脑只安装一个P ...
- 【一】Swift 3.0 新浪微博项目实战 -整体框架搭建
最近要接手swift,所以找了个视频跟着做一下实战项目,在此记录一下过程和心得 框架搭建和目录拆分 关键词:MVVM 架构,桥接文件 桥接文件用于引入OC的头文件,Swift就可以正常使用(宏除外). ...
- 【JAVAWEB学习笔记】网上商城实战:环境搭建和完成用户模块
网上商城实战 今日任务 完成用户模块的功能 1.1 网上商城的实战: 1.1.1 演示网上商城的功能: 1.1.2 制作目的: 灵活运用所学知识完成商城实战. 1.1.3 ...
- 1、手把手教React Native实战之环境搭建
React Native 的宗旨是,学习一次,高效编写跨平台原生应用. 在Windows下搭建React Native Android开发环境 1.安装jdk 2.安装sdk 在墙的环境下,为了 ...
- Spring cloud微服务安全实战-7-3prometheus环境搭建
Prmetheus 主要用来做来Metrics的监控和报警,这张图是官方的架构图. 这是他的核心 它的作用是根据我们的配置去完成数据的采集.服务的发现,以及数据的存储. 这是服务的发现,通过Servi ...
随机推荐
- swiper tabs综合示例
html部分: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <m ...
- Ubuntu 设置不更新某些软件
方法来自:https://blog.csdn.net/zhrq95/article/details/79527073 保持某软件版本不变,如我wps-office,(已测有效@Ubuntu 16.04 ...
- Python - 面向对象编程 - super()
前置知识 继承的详解:https://www.cnblogs.com/poloyy/p/15216652.html 子类方法的重写:https://www.cnblogs.com/poloyy/p/1 ...
- ReScript 与 TypeScript,谁是前端圈的“当红辣子鸡”
摘要: ReScript 和 TypeScript 的出现都是为了更好地使用JavaScript,但两者还是有很大的不同. 本文分享自华为云社区<[云创共驻]ReScript 和 TypeScr ...
- 微前端框架single-spa初探
前言 最近入职的一家公司采用single-spa这个微前端框架,所以自学了此框架. single-spa这个微前端框架虽然有中文文档,但是有些零散和晦涩. 所以我想在学习之余,写篇博客拉平一下这个学习 ...
- Django——session保持登录
Django操作session语法: # 1.设置Sessions值 request.session['session_name'] ="admin" # 2.获取Sessions ...
- python 修改图像大小和分辨率
1 概念: 分辨率,指的是图像或者显示屏在长和宽上各拥有的像素个数.比如一张照片分辨率为1920x1080,意思是这张照片是由横向1920个像素点和纵向1080个像素点构成,一共包含了1920x108 ...
- kernel_thread()和kthread_run()/kthread_create()的根本区别
0 本质区别 kthread_run()调用kthread_create(), kthread_create()加入链表后,有kthreadd()线程读取链表然后再调用kernel_thread()创 ...
- easyui修复浏览器刷新后,tab页全部关闭的问题
一.问题描述 使用easyui搭建的上左右页面布局,当我们在右侧打开了tab页,发现点击浏览器的刷新按钮后,整个页面会被重新渲染,导致所有打开的tab页都被关闭,回到初始状态的问题. 这个问题虽然不影 ...
- 使用easyui进行上左右布局
在后台管理系统开发的过程中,上左右的布局是最常见的页面布局方式,现在我们来看看使用easyui这个jquery前端框架如何快速搭建一个可用的页面框架. 1.在页面中引入easyui所需的文件 1 &l ...