mysqltuner工具使用,本工具建议定期运行,发现目前MYSQL数据库存在的问题及修改相关的参数

工具的下载及部署

解决环境依赖,因为工具是perl脚本开发的,需要perl脚本环境

# yun install -y perl*

下载脚本

在http://mysqltuner.com/下载major-MySQLTuner-perl-1.6.0-142-g42593c6.zip



将下载的mysqltuner.pl文件上传到需要测试的mysql服务器中

# chmod +x mysqltuner.pl

执行脚本

# ./mysqltuner.pl

根据提示输入管理员账号密码,得出建议:





报错



# ./mysqltuner.pl 

 >>  MySQLTuner 1.6.9 - Major Hayden <major@mhtx.net>

 >>  Bug reports, feature requests, and downloads at http://mysqltuner.com/

 >>  Run with '--help' for additional options and output filtering

which: no mysqladmin in (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)

[!!] Couldn't find mysqladmin in your $PATH. Is MySQL installed?



添加环境变量

# vi /etc/profile.d/mysql.sh

加入

export PATH=/opt/lampp/bin:$PATH





>>  MySQLTuner 1.6.9 - Major Hayden <major@mhtx.net>

 >>  Bug reports, feature requests, and downloads at http://mysqltuner.com/

 >>  Run with '--help' for additional options and output filtering

Please enter your MySQL administrative login: root200

Please enter your MySQL administrative password: 

[--] Skipped version check for MySQLTuner script

[!!] Your MySQL version 5.0.67 is EOL software!  Upgrade soon!

[OK] Operating on 64-bit architecture





-------- Storage Engine Statistics -------------------------------------------

[--] Status: +Archive -BDB +Federated +InnoDB -ISAM -NDBCluster 

[--] Data in MyISAM tables: 8G (Tables: 448)

[--] Data in InnoDB tables: 320K (Tables: 2)

[--] Data in MEMORY tables: 1M (Tables: 4)

[!!] Total fragmented tables: 42





-------- Security Recommendations  -------------------------------------------

[OK] There are no anonymous accounts for any database users

[!!] failed to execute: SELECT CONCAT(user, '@', host) FROM mysql.user WHERE (password = '' OR password IS NULL) AND plugin NOT IN ('unix_socket', 'win_socket')

[!!] FAIL Execute SQL / return code: 256

[OK] All database users have passwords assigned

[!!] User 'em@%' hasn't specific host restriction.

[!!] User 'huhonggen@%' hasn't specific host restriction.

[!!] User 'rone@%' hasn't specific host restriction.

[!!] There is no basic password file list!





-------- CVE Security Recommendations  ---------------------------------------

[--] Skipped due to --cvefile option undefined





-------- Performance Metrics -------------------------------------------------

[--] Up for: 13h 30m 47s (81M q [1K qps], 39K conn, TX: 1G, RX: 1G)

[--] Reads / Writes: 95% / 5%

[--] Binary logging is disabled

[--] Total buffers: 4.3G global + 48.3M per thread (1500 max threads)

[!!] Maximum reached memory usage: 31.4G (100.18% of installed RAM)

[!!] Maximum possible memory usage: 75.1G (239.73% of installed RAM)

[OK] Slow queries: 0% (144/81M)

[OK] Highest usage of available connections: 38% (574/1500)

[!!] Aborted connections: 6.73%  (2688/39922)

[OK] Query cache efficiency: 63.4% (49M cached / 78M selects)

[!!] Query cache prunes per day: 149286

[OK] Sorts requiring temporary tables: 0% (97 temp sorts / 862K sorts)

[OK] Temporary tables created on disk: 13% (46K on disk / 347K total)

[OK] Thread cache hit rate: 98% (643 created / 39K connections)

[OK] Table cache hit rate: 99% (1K open / 1K opened)

[OK] Open file limit used: 13% (1K/7K)

[OK] Table locks acquired immediately: 98% (35M immediate / 36M locks)





-------- ThreadPool Metrics --------------------------------------------------

[--] ThreadPool stat is disabled.





-------- Performance schema --------------------------------------------------

[--] Performance schema is disabled.





-------- MyISAM Metrics ------------------------------------------------------

[!!] Key buffer used: 40.7% (1B used / 4B cache)

[OK] Key buffer size / total MyISAM indexes: 4.0G/3.9G

[OK] Read Key buffer hit rate: 100.0% (1B cached / 373K reads)

[!!] Write Key buffer hit rate: 83.9% (2M cached / 344K writes)





-------- AriaDB Metrics ------------------------------------------------------

[--] AriaDB is disabled.





-------- InnoDB Metrics ------------------------------------------------------

[--] InnoDB is enabled.

[OK] InnoDB buffer pool / data size: 128.0M/320.0K

[!!] InnoDB Used buffer: 0.78% (64 used/ 8192 total)

[OK] InnoDB Read buffer efficiency: 93.93% (201 hits/ 214 total)

[!!] InnoDB Write Log efficiency: 0% (-1 hits/ 0 total)

[OK] InnoDB log waits: 0.00% (0 waits / 1 writes)





-------- TokuDB Metrics ------------------------------------------------------

[--] TokuDB is disabled.





-------- Galera Metrics ------------------------------------------------------

[--] Galera is disabled.





-------- Replication Metrics -------------------------------------------------

[--] No replication slave(s) for this server.

[--] This is a standalone server..

针对给出的意见进行修改

-------- Recommendations -----------------------------------------------------

General recommendations:

    Run OPTIMIZE TABLE to defragment tables for better performance

    Restrict Host for user@% to user@SpecificDNSorIp

    MySQL started within last 24 hours - recommendations may be inaccurate

    Reduce your overall MySQL memory footprint for system stability

    Enable the slow query log to troubleshoot bad queries

    Reduce or eliminate unclosed connections and network issues

    Increasing the query_cache size over 128M may reduce performance

    Upgrade to MySQL 5.5+ to use asynchrone write

Variables to adjust:

  *** MySQL's maximum memory usage is dangerously high ***

  *** Add RAM before increasing MySQL buffer variables ***

query_cache_size (> 128M) [see warning above]

注意:

浏览输出的结果,特别是末尾的 Recommendations ,里面一般会提到您需要在 my.cnf 修改的内容。修改 my.cnf 后记得重启 MySQL 。重启后再运行 MySQLTuner 检查。另外需要注意的是 MySQL 需要启动 24 小时候再运行 MySQLTuner ,不然有些内容会不准。

利用mysqltuner工具对mysql数据库进行优化的更多相关文章

  1. MYSQL启用日志,查看日志,利用mysqlbinlog工具恢复MySQL数据库【转载】

    转自 MYSQL启用日志,查看日志,利用mysqlbinlog工具恢复MySQL数据库 - _安静 - 博客园http://www.cnblogs.com/xionghui/archive/2012/ ...

  2. MySQL数据库性能优化与监控实战(阶段四)

    MySQL数据库性能优化与监控实战(阶段四) 作者 刘畅 时间 2020-10-20 目录 1 sys数据库 1 2 系统变量 1 3 性能优化 1 3.1 硬件层 1 3.2 系统层 1 3.3 软 ...

  3. mysql数据库性能优化(包括SQL,表结构,索引,缓存)

    优化目标减少 IO 次数IO永远是数据库最容易瓶颈的地方,这是由数据库的职责所决定的,大部分数据库操作中超过90%的时间都是 IO 操作所占用的,减少 IO 次数是 SQL 优化中需要第一优先考虑,当 ...

  4. MySQL数据库性能优化:表、索引、SQL等

    一.MySQL 数据库性能优化之SQL优化 注:这篇文章是以 MySQL 为背景,很多内容同时适用于其他关系型数据库,需要有一些索引知识为基础 优化目标 减少 IO 次数IO永远是数据库最容易瓶颈的地 ...

  5. MYSQL数据库的优化

    我们究竟应该如何对MySQL数据库进行优化?下面我就从MySQL对硬件的选择.MySQL的安装.my.cnf的优化.MySQL如何进行架构设计及数据切分等方面来说明这个问题. 服务器物理硬件的优化 在 ...

  6. [转]MySQL数据库的优化-运维架构师必会高薪技能,笔者近六年来一线城市工作实战经验

    本文转自:http://liangweilinux.blog.51cto.com/8340258/1728131 年,嘿,废话不多说,下面开启MySQL优化之旅! 我们究竟应该如何对MySQL数据库进 ...

  7. MySQL 数据库性能优化之索引优化

    接着上一篇 MySQL 数据库性能优化之表结构,这是 MySQL数据库性能优化专题 系列的第三篇文章:MySQL 数据库性能优化之索引优化 大家都知道索引对于数据访问的性能有非常关键的作用,都知道索引 ...

  8. MySQL数据库的优化-运维架构师必会高薪技能,笔者近六年来一线城市工作实战经验

    原文地址:http://liangweilinux.blog.51cto.com/8340258/1728131 首先在此感谢下我的老师年一线实战经验,我当然不能和我的老师平起平坐,得到老师三分之一的 ...

  9. Mysql数据库性能优化(一)

    参考 http://www.jb51.net/article/82254.htm 今天,数据库的操作越来越成为整个应用的性能瓶颈了,这点对于Web应用尤其明显.关于数据库的性能,这并不只是DBA才需要 ...

随机推荐

  1. c++11 线程

    转自:http://www.justsoftwaresolutions.co.uk/threading/multithreading-in-c++0x-part-3.html 是个just的c++库. ...

  2. linux已开机时间 系统信息

    linux 查看系统运行时间 (从开机当现在的开机时间) 1.uptime命令输出:16:11:40 up 59 days, 4:21, 2 users, load average: 0.00, 0. ...

  3. Python基础学习(四)

    菜鸟咀嚼python基础之继续. 一.返回函数 第三章已经简单操作了Python的高阶函数,目前继续练手函数作为返回值的特效:通常,高阶函数除了可以接收函数作为参数外,还可以把函数作为结果值返回. 案 ...

  4. echarts2 饼图处理标签文字过长使之达到指定字数换行的目的

    在使用echarts2的过程中,有时会遇到标签文字过长导致显示不完整的问题.例如: 这时候就需要用到 标签里的formatter 回调函数来处理这种情况了. 方式一:  formatter : ' { ...

  5. JVM综合调优汇总

    一.堆大小设置 JVM 中最大堆大小有三方面限制: 1. 相关操作系统的数据模型(32-bt还是64-bit)限制: 2. 系统的可用虚拟内存限制: 3. 系统的可用物理内存限制. 32位系统下,一般 ...

  6. js对象克隆

    大家都知道,js的对象是引用类型,如果直接var obj2 = obj,obj2和obj是共享同一个对象实体的,这往往不是我们想要的结果. 官方并没有给出通用的对象克隆方法: 我们给出以下几种写法: ...

  7. 即将上线的YARN服务器面临的一系列填坑笔记

    即将上线的YARN服务器面临的一系列填坑笔记 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 折腾了一个星期,终于让开发将数据跑起来了,可通过yarn的webUI界面,发现这里的核心 ...

  8. impala记录-安装kudu和impala

    1.配置/etc/yum.repos.d clouder-kudu.repo [cloudera-kudu]# Packages for Cloudera's Distribution for kud ...

  9. Hive记录-配置客户端可视化管理工具远程连接

    配置客户端远程连接(方便可视化工具操作)-不需要在hive服务器上敲命令了 1.安装DBeaver工具:https://dbeaver.com/download/ 2.准备相关驱动文件(服务器上hiv ...

  10. SqlServer中的临时表

    一.什么是临时表 临时表属于会话级的,会话结束的时候,临时表被释放,其创建.使用.删除都和普通表一样,临时表空间一般利用虚拟内存,不必进行磁盘I/O,因此效率较高..临时表有两种:普通临时表 (#Tb ...