当前位置: 首页 > news >正文

安阳市地图小辉seo

安阳市地图,小辉seo,长沙做网站比较好的公司,整合网络营销外包团队优势1.简介 本文档为prometheus和grafana安装配置手册,prometheus和grafana的内容、和操作过程,详细介绍了服务监控配置、dashboard配置、告警配置等操作。 2.部署说明 Prometheus基于Golang编写(需要安装),编译后的软件…

1.简介

本文档为prometheus和grafana安装配置手册,prometheus和grafana的内容、和操作过程,详细介绍了服务监控配置、dashboard配置、告警配置等操作。

2.部署说明

Prometheus基于Golang编写(需要安装),编译后的软件包,不依赖于任何的第三方依赖。用户只需要下载对应平台的二进制包,解压并且添加基本的配置即可正常启动Prometheus Server。 Grafana提供离线的rpm安装包,直接安装即可。

2.1环境配置

操作系统版本:

centos7.2

IP地址规划:

prometheus server+grafana:10.3.10.135
node_explorer: 10.3.10.136

Prometheus版本:

prometheus-2.14.0

Grafana版本:

grafana-6.5.1-1

2.2软件介质

Prometheus安装包:

prometheus-2.14.0.linux-amd64.tar.gz

grafana安装包:

grafana-6.5.1-1.x86_64.rpm

node_explorer安装包:

node_exporter-0.18.1.linux-amd64.tar.gz

mysqld_exporte_node安装包:

mysqld_exporter-0.12.1.linux-amd64.tar.gz

3.安装配置

3.1 安装Prometheus

添加用户prometheus

# useradd --no-create-home --shell /bin/false prometheus

创建相关目录

# mkdir /etc/prometheus
# mkdir /var/lib/prometheus

改目录权限

# chown prometheus:prometheus /etc/prometheus
# chown prometheus:prometheus /var/lib/prometheus

解压 & 移动到相应目录

# tar xvf prometheus-2.14.0.linux-amd64.tar.gz # cp prometheus-2.14.0.linux-amd64/prometheus /usr/local/bin/
# cp prometheus-2.14.0.linux-amd64/promtool /usr/local/bin/# cp -r prometheus-2.14.0.linux-amd64/consoles/ /etc/prometheus/
# cp -r prometheus-2.14.0.linux-amd64/console_libraries/ /etc/prometheus/
# cp prometheus-2.14.0.linux-amd64/prometheus.yml /etc/prometheus/# chown prometheus:prometheus /usr/local/bin/prometheus
# chown prometheus:prometheus /usr/local/bin/promtool# chown -R prometheus:prometheus /etc/prometheus/consoles
# chown -R prometheus:prometheus /etc/prometheus/console_libraries
# chown -R prometheus:prometheus /etc/prometheus/prometheus.yml 

配置Prometheus service,端口为9090

# vi /etc/systemd/system/prometheus.service
[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/local/bin/prometheus \--config.file /etc/prometheus/prometheus.yml \--storage.tsdb.path /var/lib/prometheus/ \--web.console.templates=/etc/prometheus/consoles \
--web.console.libraries=/etc/prometheus/console_libraries \
--web.enable-lifecycle \--web.listen-address=:9090[Install]
WantedBy=multi-user.target

Prometheus启动参数说明 --config.file -- 指明prometheus的配置文件路径 --web.enable-lifecycle -- 指明prometheus配置更改后可以进行热加载 --storage.tsdb.path -- 指明监控数据存储路径 --storage.tsdb.retention --指明数据保留时间

说明: prometheus在2.0之后默认的热加载配置没有开启, 配置修改后, 需要重启prometheus server才能生效, 这对于生产环境的监控是不可容忍的, 所以我们需要开启prometheus server的配置热加载功能. 在启动prometheus时加上参数 web.enable-lifecycle , 可以启用配置的热加载, 配置修改后, 热加载配置:

curl -X POST  http://localhost:9090/-/reload

加载systemd服务 & 启动

# 加载 
systemctl daemon-reload
# 开机启动
systemctl enable prometheus.service
# 启动
systemctl start prometheus
# 查看状态
systemctl status prometheus

访问URL: http://10.3.10.135:9090/graph

3.2 安装Grafana

rpm包上传到服务器上后,直接执行:

# yum localinstall grafana-6.5.1-1.x86_64.rpm

安装完之后进行Grafana配置的修改:修改端口 vim /etc/grafana/grafana.ini ,关于配置说明请见:官方文档、Grafana配置和Grafana 配置文件详解

http_port = 3000

加载systemd服务 & 启动

直接启动
# systemctl start grafana-server
#加载
# systemctl daemon-reload
#开启
# systemctl start grafana-server
#查看状态
# systemctl status grafana-server
#开启启动
# systemctl enable grafana-server.service

日志&数据目录 日志目录: 配置为在引导时启动 数据目录:

/var/lib/grafana/grafana.db

访问URL: granafa默认端口为3000,可以在浏览器中输入

http://10.3.10.135:3000/ granafa首次登录账户名和密码admin/admin,可以修改

用户名:admin
密码:admin

3.3安装Exporter

在3.1和3.2操作中,已经把Prometheus和Grafana安装完毕,现在开始安装Exporter来采集数据。 Exporter是Prometheus的一类数据采集组件的总称。它负责从目标处搜集数据,并将其转化为Prometheus支持的格式。与传统的数据采集组件不同的是,它并不向中央服务器发送数据,而是等待中央服务器主动前来抓取,默认的抓取地址为 http://CURRENT_IP:9100/metrics

3.3.1 Linux主机监控

node_exporter的作用是用于机器系统数据收集,监控服务器CPU、内存、磁盘、I/O、网络等等信息。

3.3.1.1安装node_exporter

准备介质,上传到服务器

node_exporter-0.18.1.linux-amd64.tar.gz

解压

tar xvf node_exporter-0.18.1.linux-amd64.tar.gz
cp node_exporter-0.18.1.linux-amd64/node_exporter /usr/sbin/

帮助

node_exporter --help

开启,端口:9199

node_exporter --web.listen-address=:9199

添加用户prometheus

useradd --no-create-home --shell /bin/false prometheus

加载systemd服务 & 启动 vi /etc/systemd/system/node_exporter.service

[Unit]
Description=node_exporter
Documentation=https://prometheus.io/
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=/usr/sbin/node_exporter --web.listen-address=:9199
Restart=on-failure
[Install]
WantedBy=multi-user.target

systemctl 启动

# 加载 
systemctl daemon-reload
# 开机启动
systemctl enable node_exporter.service
# 启动
systemctl start node_exporter
# 查看状态
systemctl status node_exporter

启动 node_exporter 服务并设置开机启动

# systemctl daemon-reload
# systemctl enable node_exporter.service
# systemctl start node_exporter.service
# systemctl status node_exporter.service
# systemctl restart node_exporter.service
# systemctl start node_exporter.service
# systemctl stop node_exporter.service

此时,node_exporter启动后已经开始采集指标信息,node_exporter启动成功后, 你就可以通过如下api看到你的监控数据了(将下面的node_exporter_server_ip替换成你的node_exporter的IP地址, 放到浏览器中访问就可以了 ). 可以通过地址访问: http://10.3.10.135:9199/metrics

3.3.1.2可视化监控配置

上面已经安装部署好了Prometheus、Grafana和Exporter,现在需要把这3者联系起来进行数据展示。如已经安装了node_exporter,需要把node_exporter采集的信息配置到Prometheus上。即修改Prometheus配置文件: 为了更好的展示, 接下来我们将这个api 配置到 prometheus server中, 并通过grafana进行展示. 将 node_exporter 加入 prometheus.yml配置中

vi /etc/prometheus/prometheus.yml- job_name: 'Linux'file_sd_configs:- files: ['/etc/prometheus/sd_cfg/Linux.yml']refresh_interval: 5s

并在文件/etc/prometheus/sd_cfg/Linux.yml中写入如下内容

- targets: ['IP地址:9100']labels:name: Linux-node1[这里建议给每个主机打个有意义的标签,方便识别.]

例如:

这样做的好处是, 方便以后配置监控自动化, 规范化, 将每一类的监控放到自己的配置文件中, 方便维护. 当然, 如果你的服务器少, 要监控的组件少的话, 你也可以将配置都写入prometheus的主配置文件prometheus.yml中

重启Prometheus:

systemctl restart Prometheus

重载prometheus配置

curl -X POST  http://localhost:9090/-/reload
3.3.1.3查看监控端是否介入

发现 target 中只有 prometheus server, 因为我们还没有加入其他监控, 下面进行介绍, 后续还将介绍如何监控 mysql, redis, RabbitMQ, Kafka, nginx, java等常见服务.

3.3.1.4 Grafana导入Linux模板

Granfana 导入Linux主机监控图表

推荐图表ID:https://grafana.com/dashboards/11074

操作步骤:

Grafana首页-->左上角图标-->Dashboard-->import

Upload已下载至本地的json文件(或者使用dashboard id,如这里的11074),如下:

数据源选择"prometheus",即添加的数据源name,点击"Import"按钮,如下:

配置完保存后即可看到逼格非常高的系统主机节点监控信息,包括系统运行时间, 内存和CPU的配置, CPU、内存、磁盘、网络流量等信息, 以及磁盘IO、CPU温度等信息。 

3.3.2 Mysql数据库监控

mysqld_exporter的作用是用于MySQL数据库数据收集。

3.3.2.1安装mysqld_exporter

准备介质,上传到服务器

mysqld_exporter-0.12.1.linux-amd64.tar.gz

解压

tar xvf mysqld_exporter-0.12.1.linux-amd64.tar.gz
cp mysqld_exporter /usr/sbin/

帮助

mysqld_exporter --help

mysqld_exporter需要连接Mysql,首先为它创建用户并赋予所需要的权限:

登录mysql为exporter创建账号并授权
mysql> set global validate_password_policy=LOW;
# 创建数据库用户。
mysql> CREATE USER 'exporter'@'localhost' IDENTIFIED BY 'exporter';
# 可查看主从运行情况查看线程,及所有数据库。
mysql> GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'localhost';
mysql> flush privileges;

2:创建.my.cnf文件,mysql配置文件、运行时可免密码连接数据库

vi /usr/local/mysql_exporter/.my.cnf
[client]
host=10.3.10.136
port=3306
user=root
password=Intel@123456

systemctl启动mysqld_exporter,编辑系统启动文件

vi /etc/systemd/system/mysqld_exporter.service
[Unit]
Description=mysqld_exporter
Documentation=https://prometheus.io/
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=/usr/sbin/mysqld_exporter --web.listen-address=:9104 --config.my-cnf=/usr/local/mysql_exporter/.my.cnf
Restart=on-failure
[Install]
WantedBy=multi-user.target

启动

# systemctl daemon-reload
# systemctl enable mysqld_exporter
# systemctl restart mysqld_exporter
# systemctl status mysqld_exporter

也可以直接运行:

./mysqld_exporter --config.my-cnf=/usr/local/mysql_exporter/.my.cnf

此时,mysqld_exporter启动后已经开始采集指标信息,可以通过地址访问:

http://10.3.10.136:9104/metrics

3.3.2.2可视化配置

Prometheus配置: 修改prometheus.yml加入MySql节点,将mysqld_exporter加入 prometheus.yml配置中

vi /etc/prometheus/prometheus.yml- job_name: 'Mysql'file_sd_configs:- files: ['/etc/prometheus/sd_cfg/Mysql.yml']refresh_interval: 5s

并在文件/etc/prometheus/sd_cfg/Mysql.yml中写入如下内容

- targets: ['10.3.10.136:9104']labels:instance: node_exporter_mysql_10.3.10.136

检查并重启服务

promtool check config /etc/prometheus/prometheus.yml

重启prometheus生效

# systemctl restart prometheus
# systemctl status prometheus
3.3.2.3 查看监控端是否介入

3.3.2.4 Granfana 导入Mysql 监控图表

Granfana 导入Mysql监控图表

推荐图表ID:https://grafana.com/dashboards/7362

操作步骤:

Grafana首页-->左上角图标-->Dashboard-->import

Upload已下载至本地的json文件(或者使用dashboard id,如这里的7362),如下:

数据源选择"prometheus",即添加的数据源name,点击"Import"按钮,如下:

Mysql监控展示

http://www.zhongyajixie.com/news/39454.html

相关文章:

  • 网站建设问卷调查爱站网站长seo综合查询工具
  • 什么直播可以做游戏视频网站南宁seo网站排名优化公司
  • 济南网站建设找聚搜网络长沙网站推广 下拉通推广
  • 广告网站建设教育培训报名
  • JavaScript做的网站网络推广外包注意哪些
  • 珠海专业做网站制作域名查询大全
  • 免费行情软件网站大全网页版徐州百度运营中心
  • 怎样把网站做的好看女生做sem专员的工作难吗
  • 中山模板自助建站查看别人网站的访问量
  • 佛山找人做网站英文网站seo
  • 首饰网站模板百度怎么优化关键词排名
  • 网畅学校网站管理系统百度推广网站平台
  • 用php做网站用什么框架石家庄疫情太严重了
  • 如何提高seo关键词排名seo广告优化
  • 需要手机号注册的网站关键词优化策略有哪些
  • 学技巧网站制作百度人气榜排名
  • 网站开发 测试用例公司网站建设服务机构
  • 宁波公司网站开发seo的内容怎么优化
  • 百度给做的网站如何登陆网站后台云南百度推广开户
  • wordpress 文章 相对路径苏州seo免费咨询
  • 做网站3年3万全国各城市疫情搜索高峰进度
  • 外贸网站建设报价网络营销的概念及内容
  • 单位网站建设方案刷关键词排名seo软件软件
  • 做艺术品展览的网站国产最好的a级suv
  • 农产品网站建设策划seo网站排名优化工具
  • 做好公众号 网站建设百度seo什么意思
  • 咋么做进网站跳转加群如何让网站快速收录
  • 烟台网站制作步骤2345浏览器网页版
  • 企业局域网做网站屏蔽百度指数的使用
  • 保定网络公司网站seo推广培训