使用Metricbeat监控Mysql性能

继续上篇内容介绍Elastic stach中beats相关的东西,由于新上线的mysql没有监控服务,这里就做下如何使用metricbeat另外完成mysql性能指标收集和所在主机的性能指标收集。

安装metricbeat

这次采用yum来安装,首先加入es官方yum的key

sudo rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch

之后在/etc/yum.repos.d/ 中增加一个repos

[elastic-7.x]
name=Elastic repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md

随后就可以通过yum安装

yum install -y metricbeat

安装完成后运行开机启动

systemctl enable metricbeat

配置

首先通过rpm安装的的metricbeat的默认配置文件在/etc/metricbeat下,通过修改metricbeat.yml来实现基本配置。修改和ES相关的配置

setup.kibana:

  # Kibana Host
  # Scheme and port can be left out and will be set to the default (http and 5601)
  # In case you specify and additional path, the scheme is required: http://localhost:5601/path
  # IPv6 addresses should always be defined as: https://[2001:db8::1]:5601

  host: "http://elk.5imakeup.com"
  
  output.elasticsearch:
  # Array of hosts to connect to.
  hosts: ["es.5imakeup.com"]
  username: "elastic"
  password: "pass"

启用监控mysql的模块:

metricbeat modules enable mysql

启用监控模块后可以在/etc/metricbeat下修改相应配置,如mysql.yml,没有开启前是mysql.yml.disabled
修改数据库连接用户名和密码就可以

# Module: mysql
# Docs: https://www.elastic.co/guide/en/beats/metricbeat/7.7/metricbeat-module-mysql.html

- module: mysql
  #metricsets:
  #  - status
  #  - galera_status
  period: 10s

  # Host DSN should be defined as "user:pass@tcp(127.0.0.1:3306)/"
  # or "unix(/var/lib/mysql/mysql.sock)/",
  # or another DSN format supported by <https://github.com/Go-SQL-Driver/MySQL/>.
  # The username and password can either be set in the DSN or using the username
  # and password config options. Those specified in the DSN take precedence.
  hosts: ["root:secret@tcp(127.0.0.1:3306)/"]

  # Username of hosts. Empty by default.
  #username: root

  # Password of hosts. Empty by default.
  #password: secret

随后setup kibana

metricbeat setup --dashboards

启动metricbeat

systemctl start metricbeat

配置成功后可以登录到kibana中的dashboards看到如下页面:

Lokie博客
请先登录后发表评论
  • 最新评论
  • 总共0条评论
  • 本博客使用免费开源的 laravel-bjyblog v5.5.1.1 搭建 © 2014-2018 lokie.wang 版权所有 ICP证:沪ICP备18016993号
  • 联系邮箱:kitche1985@hotmail.com