使用MySQLTuner脚本检测、优化MySQL数据库
2018-01-17 10:46
429 查看
MySQLTuner 是一个 Perl 脚本,可以用来分析您的 MySQL 性能,并且基于收集到的信息给出相应的优化建议。这样子,您就可以调整 my.cnf 从而优化您的 MySQL 设置。
这边只是介绍使用方法,不保证说 MySQLTuner 对您就是绝对有效。
首先需要下载 MySQLTuner
运行后的内容如下:
./mysqltuner.pl --user root --pass nongyao001 --socket /tmp/mysq.sock
General recommendations:
Control warning line(s) into /www/wdlinux/mysql-5.5.48/data/cent98.dt50.cn.err file
Control error line(s) into /www/wdlinux/mysql-5.5.48/data/cent98.dt50.cn.err file
Run OPTIMIZE TABLE to defragment tables for better performance
OPTIMIZE TABLE west.destoon_article_data_21; -- can free 158.651298522949 MB
Total freed space after theses OPTIMIZE TABLE : 158.651298522949 Mb
Restrict Host for user@% to user@SpecificDNSorIp
Reduce your overall MySQL memory footprint for system stability
Dedicate this server to your database for highest performance.
Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1
When making adjustments, make tmp_table_size/max_heap_table_size equal
Reduce your SELECT DISTINCT queries which have no LIMIT clause
Variables to adjust:
MySQL's maximum memory usage is dangerously high
Add RAM before increasing MySQL buffer variables
query_cache_type (=0)
tmp_table_size (> 16M)
max_heap_table_size (> 16M)
innodb_buffer_pool_instances(=4)
浏览输出的结果,特别是末尾的 Recommendations ,里面一般会提到您需要在 my.cnf 修改的内容。修改 my.cnf 后记得重启 MySQL 。重启后再运行 MySQLTuner 检查。另外需要注意的是 MySQL 需要启动 24 小时候再运行 MySQLTuner ,不然有些内容会不准。
这边只是介绍使用方法,不保证说 MySQLTuner 对您就是绝对有效。
首先需要下载 MySQLTuner
wget https://raw.github.com/major/MySQLTuner-perl/master/mysqltuner.pl
设置权限为可执行chmod +x mysqltuner.pl
然后就可以直接运行了./mysqltuner.pl
如果遇到错误 Unable to find mysqladmin in your $PATH 可以输入PATH=$PATH:/usr/local/mysql/bin
PS:把 /usr/local/mysql/bin 改为您 MySQL 程序 mysqladmin 的路径运行后的内容如下:
./mysqltuner.pl --user root --pass nongyao001 --socket /tmp/mysq.sock
General recommendations:
Control warning line(s) into /www/wdlinux/mysql-5.5.48/data/cent98.dt50.cn.err file
Control error line(s) into /www/wdlinux/mysql-5.5.48/data/cent98.dt50.cn.err file
Run OPTIMIZE TABLE to defragment tables for better performance
OPTIMIZE TABLE west.destoon_article_data_21; -- can free 158.651298522949 MB
Total freed space after theses OPTIMIZE TABLE : 158.651298522949 Mb
Restrict Host for user@% to user@SpecificDNSorIp
Reduce your overall MySQL memory footprint for system stability
Dedicate this server to your database for highest performance.
Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1
When making adjustments, make tmp_table_size/max_heap_table_size equal
Reduce your SELECT DISTINCT queries which have no LIMIT clause
Variables to adjust:
MySQL's maximum memory usage is dangerously high
Add RAM before increasing MySQL buffer variables
query_cache_type (=0)
tmp_table_size (> 16M)
max_heap_table_size (> 16M)
innodb_buffer_pool_instances(=4)
浏览输出的结果,特别是末尾的 Recommendations ,里面一般会提到您需要在 my.cnf 修改的内容。修改 my.cnf 后记得重启 MySQL 。重启后再运行 MySQLTuner 检查。另外需要注意的是 MySQL 需要启动 24 小时候再运行 MySQLTuner ,不然有些内容会不准。
相关文章推荐
- 使用MySQLTuner脚本检测、优化MySQL数据库
- 使用Junit4从测试场景的准备优化测试脚本的执行效率
- 使用python检测手机QQ在线状态的脚本代码
- mysql性能优化脚本mysqltuner.pl使用介绍
- PowerShell脚本简单使用 检测网络状况 date ping
- 使用脚本自动化远程备份mysql数据库
- [PHP] 导出mysql数据库结构并生成列表的小脚本,供VIM使用
- SqlServer性能检测和优化工具使用详细
- Shell 脚本基础 - 使用 if 语句进行条件检测
- SqlServer性能检测和优化工具使用详细
- mysql数据库优化 pt-query-digest使用
- 使用脚本检测域名是否被注册了
- SqlServer性能检测和优化工具使用详细
- 使用shell检查并修复mysql数据库表的脚本
- SQL Server 强大的分区技术(使用语句检测和优化数据库 (MSSQL个人笔记之数据库优化之路 三)
- Mysql数据库优化系列(二)------AWK脚本统计数据库性能参数
- 使用语句检测和优化数据库 (MSSQL个人笔记之数据库优化之路 二)
- Linux 使用脚本安装MySQL数据库
- 使用inno setup打包程序完整脚本(.net框架检测,重复安装检测)