aaahd 发表于 2018-9-28 08:30:13

7.MySQL 性能监控

  MySQL运行状态的监控是每个运维工程师,和MySQL DBA的主要工作之一。我们把MySQL的监控分为两个部分,一部分为基本状态的监控(请参考《Linux 系统运维之运维监控》),一部分为性能方面的监控,是为MySQL 性能优化提供的参考信息,在这一章节,详细讲解,MySQL 性能监控方面的内容。
7.1 性能监控的工具
  在MySQL的命令行中,DBA们通常使用一下命令来获取MySQL的状态报告:
  Mysql> show status;
  Mysql> show master status;
  Mysql> show slave status;
  Mysql> show inodb status;
  下面是show status输出的最后一行,可以看到总共有268行。面对如此庞大的性能指标,让很多DBA望而生畏。
  268 rows in set (0.00 sec)
7.2 mysqlreport
  Mysqlreport 是用perl编写的一个命令行工具,解决了show status产生的大量我们难以阅读的状况。
7.2.1 mysqlreport的相关资源
  http://hackmysql.com/mysqlreport      (官方首页)
  http://hackmysql.com/mysqlreportguide(用户手册)
7.2.2 mysqlreport 安装
  Mysqlreport需要Perl-DBI和Perl-DBD-Mysql的支持。
  # cd /usr/local/src
  # wget http://hackmysql.com/scripts/mysqlreport-3.5.tgz
  # tar zxvf mysqlreport-3.5.tgz
  mysqlreport-3.5/
  mysqlreport-3.5/COPYING
  mysqlreport-3.5/mysqlreportdoc.html
  mysqlreport-3.5/mysqlreportguide.html
  mysqlreport-3.5/mysqlreport
7.2.3 mysqlreport 参数详解
  # perl mysqlreport --help
  mysqlreport v3.5 Apr 16 2008
  mysqlreport makes an easy-to-read report of important MySQL status values.
  Command line options (abbreviations work):
  --user USER       Connect to MySQL as USER#用户名
  --password PASS   Use PASS or prompt for MySQL user's password   #密码
  --host ADDRESS    Connect to MySQL at ADDRESS    #主机IP或可以解析的域名
  --port PORT       Connect to MySQL at PORT         #mysql 端口。
  --socket SOCKET   Connect to MySQL at SOCKET   #设置通过mysql socket连接。
  --no-mycnf      Don't read ~/.my.cnf               #不读取my.cnf配置文件
  --infile FILE   Read status values from FILE instead of MySQL
  --outfile FILE    Write report to FILE            #输出写入到文件中
  --email ADDRESS   Email report to ADDRESS (doesn't work on Windows) #发送输出日志到邮件
  --flush-status    Issue FLUSH STATUS; after getting current values
  --relative X      Generate relative reports. If X is an integer,
  reports are live from the MySQL server X seconds apart.
  If X is a list of infiles (file1 file2 etc.),
  reports are generated from the infiles in the order
  that they are given.
  --report-count NCollect N number of live relative reports (default 1)
  --detach          Fork and detach from terminal (run in background)
  --help            Prints this   #打印此帮助日志
  --debug         Print debugging information
  Visit http://hackmysql.com/mysqlreport for more information.

页: [1]
查看完整版本: 7.MySQL 性能监控