使用MySQLTuner-perl对MySQL进行优化
项目地址https://github.com/major/MySQLTuner-perl.git
抄一把说明,不翻译了,累……
MySQLTuner is a script written in Perl that allows you to review a MySQL installation quickly and make adjustments to increase performance and stability. The current configuration variables and status data is retrieved and
presented in a brief format along with some basic performance suggestions.
MySQLTuner supports in this last version ~300 indicators for MySQL/MariaDB/Percona Server.
MySQLTuner is maintained and indicator collect is increasing week after week supporting a lot of configuration such as Galera
Cluster, TokuDB, Performance
schema, Linux OS metrics, InnoDB, MyISAM, Aria,
...
You can find more details on these indicators here: Indicators description.

MySQLTuner
needs you:
MySQLTuner needs contributors for documentation, code and feedbacks..
- Please join us on issue track at GitHub tracker.
- Contribution guide is available following MySQLTuner contributing guide
- Star MySQLTuner project at MySQLTuner Git Hub Project
Compatibility:
- MySQL 5.7 (full support)
- MySQL 5.6 (full support)
- MySQL 5.5 (full support)
- MariaDB 10.1 (full support)
- MariaDB 10.0 (full support)
- Percona Server 5.6 (full support)
- Percona XtraDB cluster (full support)
- MySQL 3.23, 4.0, 4.1, 5.0, 5.1 (partial support - deprecated version)
- Perl 5.6 or later (with perl-doc package)
- Unix/Linux based operating system (tested on Linux, BSD variants, and Solaris variants)
- Windows is not supported at this time (Help wanted !!!!!)
- Unrestricted read access to the MySQL server (OS root access recommended for MySQL < 5.1)
- CVE vulnerabilites detection support from https://cve.mitre.org
WARNING
It is extremely important for you to fully understand each change you make to a MySQL database server. If you don't understand portions of the script's output, or if you don't understand the recommendations, you
should consult a knowledgeable DBA or system administrator that you trust. Always test your changes on staging environments, and always keep in mind that improvements in one area can negatively
affect MySQL in other areas.
Seriously - please review the FAQ section below.
Security
recommandations
Hi directadmin user! We detected that you run mysqltuner with da_admin's credentials taken from /usr/local/directadmin/conf/my.cnf, which might bring to a password discovery! Read link for more details Issue
#289.
What
MySQLTuner is checking exactly ?
All checks done by MySQLTuner are documented in MySQLTuner Internals documentation.
Download/Installation
You can download the entire repository by using 'git clone' followed by the cloning URL above. The simplest and shortest method is:
wget http://mysqltuner.pl/ -O mysqltuner.pl
wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/basic_passwords.txt -O basic_passwords.txt
wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/vulnerabilities.csv -O vulnerabilities.csv
perl mysqltuner.pl
Of course, you can add the execute bit (chmod +x mysqltuner.pl) so you can execute it without calling perl directly.
Specific
usage
Usage: Minimal usage locally
perl mysqltuner.pl
Usage: Minimal usage remotely
perl mysqltuner.pl --host targetDNS_IP --user admin_user --pass admin_password
Usage: Enable maximum output information around MySQL/MariaDb without debugging
perl mysqltuner.pl --verbose
perl mysqltuner.pl --buffers --dbstat --idxstat --sysstat --pfstat
Usage: Enable CVE vulnerabilities check for your MariaDB or MySQL version
perl mysqltuner.pl --cvefile=vulnerabilities.csv
Usage: Write your result in a file with information displayed
perl mysqltuner.pl --outputfile /tmp/result_mysqltuner.txt
Usage: Write your result in a file without outputting information
perl mysqltuner.pl --silent --outputfile /tmp/result_mysqltuner.txt
Usage: Using template model to customize your reporting file based on Text::Template syntax.
perl mysqltuner.pl --silent --reportfile /tmp/result_mysqltuner.txt --template=/tmp/mymodel.tmpl
Usage: Enable debugging information
perl mysqltuner.pl --debug
FAQ
Question: Will MySQLTuner fix my slow MySQL server?
No. MySQLTuner is a read only script. It won't write to any configuration files, change the status of any daemons, or call your mother to wish her a happy birthday. It will give you an overview of your server's performance
and make some basic recommendations about improvements that you can make after it completes. Make sure you read the warning above prior to following any recommendations.
Question: Can I fire my DBA now?
MySQLTuner will not replace your DBA in any form or fashion. If your DBA constantly takes your parking spot and steals your lunch from the fridge, then you may want to consider it - but that's your call.
Question: Why does MySQLTuner keep asking me the login credentials for MySQL over and over?
The script will try its best to log in via any means possible. It will check for ~/.my.cnf files, Plesk password files, and empty password root logins. If none of those are available, then you'll be prompted for a password. If you'd like the script to run in
an automated fashion without user intervention, then create a .my.cnf file in your home directory which contains:
[client]
user=someusername
pass=thatuserspassword
Once you create it, make sure it's owned by your user and the mode on the file is 0600. This should prevent the prying eyes from getting your database login credentials under normal conditions. If a T-1000
shows up in a LAPD uniform and demands your database credentials, you won't have much of an option.
Question: Is there another way to secure credentials on latest MySQL and MariaDB distributions ?
You could use mysql_config_editor utilities.
$ mysql_config_editor set --login-path=client --user=someusername --password --host=localhost
Enter passord: ********
$
At this time, ~/.mylogin.cnf has been written with appropriated rigth access.
To get information about stored credentials, use the following command:
$mysql_config_editor print
[client]
user = someusername
password = *****
host = localhost
Question: What's minimum privileges needed by a specific mysqltuner user in database ?
mysql>GRANT SELECT, PROCESS,EXECUTE, REPLICATION CLIENT,SHOW DATABASES,SHOW VIEW ON *.* FOR 'mysqltuner'@'localhost' identified by pwd1234;
Question: It's not working on my OS! What gives?!
These kinds of things are bound to happen. Here are the details I need from you in order to research the problem thoroughly:
- OS and OS version
- Architecture (x86, x86_64, IA64, Commodore 64)
- Exact MySQL version
- Where you obtained your MySQL version (OS package, source, etc)
- The full text of the error
- A copy of SHOW VARIABLES and SHOW GLOBAL STATUS output (if possible)
Question: How to perform CVE vulnerability checks?
- Download vulnerabilities.csv from this repository.
- use option --cvefile to perform CVE checks
Question: How to use mysqltuner from a remote host? Thanks to @rolandomysqldba
- You will still have to connect like a mysql client:
Connection and Authentication
--host <hostname> Connect to a remote host to perform tests (default: localhost)
--socket <socket> Use a different socket for a local connection
--port <port> Port to use for connection (default: 3306)
--user <username> Username to use for authentication
--pass <password> Password to use for authentication
--defaults-file <path> defaulfs file for credentials
Since you are using a remote host, use parameters to supply values from the OS
--forcemem <size> Amount of RAM installed in megabytes
--forceswap <size> Amount of swap memory configured in megabytes
- You may have to contact your remote SysAdmin to ask how much RAM and swap you have
If the database has too many tables, or very large table, use this:
--skipsize Don't enumerate tables and their types/sizes (default: on)
(Recommended for servers with many tables)
Question: Can I install this project using homebrew on Apple Macintosh?
Yes! brew install mysqltuner can be used to install this application using homebrew on
Apple Macintosh.
MySQLTuner
and Vagrant
MySQLTuner contains following Vagrant configurations:
- Fedora Core 23 / MariaDB 10.0
- Fedora Core 23 / MariaDB 10.1
- Fedora Core 23 / MySQL 5.6
- Fedora Core 23 / MySQL 5.7
Vagrant File are stored in Vagrant subdirectory.
- Follow this 2 steps after vagrant installation:
- Rename VagrantFile_for_Mxxx into Vagrantfile
- vagrant up
MySQLTuner contains a Vagrant configurations for test purpose and development
- Install VirtualBox and Vagrant
- Clone repository
- Install Vagrant plugins vagrant-hostmanager and vagrant-vbguest
- vagrant plugin install vagrant-hostmanager
- vagrant plugin install vagrant-vbguest
- Add Fedora Core 23 box for official Fedora Download Website
- Create a data directory
- mkdir data
- Rename Vagrantfile_MariaDB10.0 into Vagrantfile
- cp MySQLTuner-perl/Vagrant/Vagrantfile_for_MariaDB10.0 Vagrantfile
- Start vagrant
- vagrant up
MySQLTuner
needs you
MySQLTuner needs contributors for documentation, code and feedbacks..
- Please join us on issue track at GitHub tracker.
- Contribution guide is avalaible following MySQLTuner contributing guide
- Star MySQLTuner project at MySQLTuner Git Hub Project
使用MySQLTuner-perl对MySQL进行优化的更多相关文章
- 利用mysqltuner工具对mysql数据库进行优化
mysqltuner工具使用,本工具建议定期运行,发现目前MYSQL数据库存在的问题及修改相关的参数 工具的下载及部署 解决环境依赖,因为工具是perl脚本开发的,需要perl脚本环境 # yun i ...
- redmine在linux上的mysql性能优化方法与问题排查方案
iredmine的linux服务器mysql性能优化方法与问题排查方案 问题定位: 客户端工具: 1. 浏览器inspect-tool的network timing工具分析 2. 浏览 ...
- 从运维角度来分析mysql数据库优化的一些关键点【转】
概述 一个成熟的数据库架构并不是一开始设计就具备高可用.高伸缩等特性的,它是随着用户量的增加,基础架构才逐渐完善. 1.数据库表设计 项目立项后,开发部根据产品部需求开发项目,开发工程师工作其中一部分 ...
- mysql数据库优化 pt-query-digest使用
mysql数据库优化 pt-query-digest使用 一.pt-query-digest工具简介 pt-query-digest是用于分析 mysql慢查询的一个工具,它可以分析binlog.Ge ...
- Mysql - 性能优化之子查询
记得在做项目的时候, 听到过一句话, 尽量不要使用子查询, 那么这一篇就来看一下, 这句话是否是正确的. 那在这之前, 需要介绍一些概念性东西和mysql对语句的大致处理. 当Mysql Server ...
- Mysql性能优化三(分表、增量备份、还原)
接上篇Mysql性能优化二 对表进行水平划分 如果一个表的记录数太多了,比如上千万条,而且需要经常检索,那么我们就有必要化整为零了.如果我拆成100个表,那么每个表只有10万条记录.当然这需要数据在逻 ...
- Mysql性能优化一
下一篇:Mysql性能优化二 mysql的性能优化无法一蹴而就,必须一步一步慢慢来,从各个方面进行优化,最终性能就会有大的提升. Mysql数据库的优化技术 对mysql优化是一个综合性的技术,主要包 ...
- 关于MySQL数据库优化的部分整理
在之前我写过一篇关于这个方面的文章 <[原创]为什么使用数据索引能提高效率?(本文针对mysql进行概述)(更新)> 这次,主要侧重点讲下两种常用存储引擎. 我们一般从两个方面进行MySQ ...
- [MySQL性能优化系列]提高缓存命中率
1. 背景 通常情况下,能用一条sql语句完成的查询,我们尽量不用多次查询完成.因为,查询次数越多,通信开销越大.但是,分多次查询,有可能提高缓存命中率.到底使用一个复合查询还是多个独立查询,需要根据 ...
- [MySQL性能优化系列]巧用索引
1. 普通青年的索引使用方式 假设我们有一个用户表 tb_user,内容如下: name age sex jack 22 男 rose 21 女 tom 20 男 ... ... ... 执行SQL语 ...
随机推荐
- JQUERY链式操作实例分析
本文实例讲述了jQuery链式操作.分享给大家供大家参考,具体如下: 从过去的实例中,我们知道jQuery语句可以链接在一起,这不仅可以缩短代码长度,而且很多时候可以实现特殊的效果. <scri ...
- python 本地化 local
locale 模块提供了 C 本地化( localization )函数的接口, 如 Example 8-1 所示. 同时提供相关函数, 实现基于当前 locale 设置的数字, 字符串转换. (而 ...
- [原][osg][osgEarth]关于在OE中使用物理引擎的调研
关于物理引擎旋转的一些整理 参考文档 http://blog.wolfire.com/2010/03/Comparing-ODE-and-Bullet 介绍ODE和bullet的利弊 http://s ...
- linux c/c++ 删除文件
linux c/c++ 删除文件 #include <stdio.h> int FileRemove(const char* fname) { return remove(fname); ...
- mvn编译
mvn clean install -pl com:boss -am -DskipTests
- UltraDropDown
private void FruitInit() { //Create some fruit fruits.Add(-1,"apple"); fruits.Add(-2," ...
- 绑定任意格式的XML文档到WPF的TreeView
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> ...
- Confluence 6 嵌套用户组的影响
本部分说明了嵌套用户组对用户登录,权限和查看更新用户组的影响. 登录 如果用户属于一个授权的用户组或者授权用户组中的子用户组,当用户登录后,用户可以访问应用程序. 权限 如果用户属于的用户组或者用户组 ...
- 『cs231n』神经网络组件
- python-day36--并发编程之多线程
十三.死锁.递归锁 1.所谓死锁: 是指两个或两个以上的进程或线程在执行过程中,因争夺资源而造成的一种互相等待的现象,若无外力作用,它们都将无法推进下去.此时称系统处于死锁状态或系统产生了死锁,这些永 ...