diff --git a/USAGE.md b/USAGE.md index e69de29..f894e19 100644 --- a/USAGE.md +++ b/USAGE.md @@ -0,0 +1,153 @@ +# NAME + + MySQLTuner 1.7.15 - MySQL High Performance Tuning Script + +# IMPORTANT USAGE GUIDELINES + +To run the script with the default options, run the script without arguments +Allow MySQL server to run for at least 24-48 hours before trusting suggestions +Some routines may require root level privileges (script will provide warnings) +You must provide the remote server's total memory when connecting to other servers + +# CONNECTION AND AUTHENTICATION + + --host Connect to a remote host to perform tests (default: localhost) + --socket Use a different socket for a local connection + --port Port to use for connection (default: 3306) + --user Username to use for authentication + --userenv Name of env variable which contains username to use for authentication + --pass Password to use for authentication + --passenv Name of env variable which contains password to use for authentication + --ssl-ca Path to public key + --mysqladmin Path to a custom mysqladmin executable + --mysqlcmd Path to a custom mysql executable + --defaults-file Path to a custom .my.cnf + +# PERFORMANCE AND REPORTING OPTIONS + + --skipsize Don't enumerate tables and their types/sizes (default: on) + (Recommended for servers with many tables) + --skippassword Don't perform checks on user passwords(default: off) + --checkversion Check for updates to MySQLTuner (default: don't check) + --updateversion Check for updates to MySQLTuner and update when newer version is available (default: don't check) + --forcemem Amount of RAM installed in megabytes + --forceswap Amount of swap memory configured in megabytes + --passwordfile Path to a password file list(one password by line) + +# OUTPUT OPTIONS + + --silent Don't output anything on screen + --nogood Remove OK responses + --nobad Remove negative/suggestion responses + --noinfo Remove informational responses + --debug Print debug information + --noprocess Consider no other process is running + --dbstat Print database information + --nodbstat Don't Print database information + --tbstat Print table information + --notbstat Don't Print table information + --idxstat Print index information + --noidxstat Don't Print index information + --sysstat Print system information + --nosysstat Don't Print system information + --pfstat Print Performance schema + --nopfstat Don't Print Performance schema + --verbose Prints out all options (default: no verbose, dbstat, idxstat, sysstat, tbstat, pfstat) + --bannedports Ports banned separated by comma(,) + --maxportallowed Number of ports opened allowed on this hosts + --cvefile CVE File for vulnerability checks + --nocolor Don't print output in color + --json Print result as JSON string + --buffers Print global and per-thread buffer values + --outputfile Path to a output txt file + --reportfile Path to a report txt file + --template Path to a template file + +# PERLDOC + +You can find documentation for this module with the perldoc command. + + perldoc mysqltuner + +## INTERNALS + +[https://github.com/major/MySQLTuner-perl/blob/master/INTERNALS.md](https://github.com/major/MySQLTuner-perl/blob/master/INTERNALS.md) + + Internal documentation + +# AUTHORS + +Major Hayden - major@mhtx.net + +# CONTRIBUTORS + +- Matthew Montgomery +- Paul Kehrer +- Dave Burgess +- Jonathan Hinds +- Mike Jackson +- Nils Breunese +- Shawn Ashlee +- Luuk Vosslamber +- Ville Skytta +- Trent Hornibrook +- Jason Gill +- Mark Imbriaco +- Greg Eden +- Aubin Galinotti +- Giovanni Bechis +- Bill Bradford +- Ryan Novosielski +- Michael Scheidell +- Blair Christensen +- Hans du Plooy +- Victor Trac +- Everett Barnes +- Tom Krouper +- Gary Barrueto +- Simon Greenaway +- Adam Stein +- Isart Montane +- Baptiste M. +- Cole Turner +- Major Hayden +- Joe Ashcraft +- Jean-Marie Renouard +- Stephan GroBberndt +- Christian Loos + +# SUPPORT + +Bug reports, feature requests, and downloads at http://mysqltuner.com/ + +Bug tracker can be found at https://github.com/major/MySQLTuner-perl/issues + +Maintained by Major Hayden (major\\@mhtx.net) - Licensed under GPL + +# SOURCE CODE + +[https://github.com/major/MySQLTuner-perl](https://github.com/major/MySQLTuner-perl) + + git clone https://github.com/major/MySQLTuner-perl.git + +# COPYRIGHT AND LICENSE + +Copyright (C) 2006-2018 Major Hayden - major@mhtx.net + +For the latest updates, please visit http://mysqltuner.com/ + +Git repository available at https://github.com/major/MySQLTuner-perl + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <https://www.gnu.org/licenses/>. diff --git a/mysqltuner.pl b/mysqltuner.pl index 9bd86a0..52158af 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -198,7 +198,7 @@ $opt{dbstat} = 0 if ( $opt{nodbstat} == 1 ); # Don't Print database information $opt{noprocess} = 0 if ( $opt{noprocess} == 1 ); # Don't Print process information $opt{sysstat} = 0 if ( $opt{nosysstat} == 1 ); # Don't Print sysstat information -$opt{pfstat} = 0 +$opt{pfstat} = 0 if ( $opt{nopfstat} == 1 ); # Don't Print performance schema information $opt{idxstat} = 0 if ( $opt{noidxstat} == 1 ); # Don't Print index information @@ -1097,7 +1097,9 @@ sub get_all_vars { unless ( defined( $myvar{'innodb_support_xa'} ) ) { $myvar{'innodb_support_xa'} = 'ON'; } - $mystat{'Uptime'} = 1 unless defined($mystat{'Uptime'}) and $mystat{'Uptime'}>0; + $mystat{'Uptime'} = 1 + unless defined( $mystat{'Uptime'} ) + and $mystat{'Uptime'} > 0; $myvar{'have_galera'} = "NO"; if ( defined( $myvar{'wsrep_provider_options'} ) && $myvar{'wsrep_provider_options'} ne "" @@ -1738,7 +1740,8 @@ sub security_recommendations { my $PASS_COLUMN_NAME = 'password'; if ( $myvar{'version'} =~ /5\.7|10\..*MariaDB*/ ) { - my $password_column_exists = `$mysqlcmd $mysqllogin -Bse "SELECT 1 FROM information_schema.columns WHERE TABLE_SCHEMA = 'mysql' AND TABLE_NAME = 'user' AND COLUMN_NAME = 'password'" 2>>/dev/null`; + my $password_column_exists = +`$mysqlcmd $mysqllogin -Bse "SELECT 1 FROM information_schema.columns WHERE TABLE_SCHEMA = 'mysql' AND TABLE_NAME = 'user' AND COLUMN_NAME = 'password'" 2>>/dev/null`; if ($password_column_exists) { $PASS_COLUMN_NAME = "IF(plugin='mysql_native_password', authentication_string, password)"; @@ -3509,7 +3512,7 @@ sub mysqsl_pfs { ) unless ( mysql_version_le( 5, 6 ) ); push( @generalrec, "Consider installing Sys schema from https://github.com/good-dba/mariadb-sys for MariaDB" - ) unless ( mysql_version_eq( 10, 0 ) or mysql_version_eq( 5, 5 ) ); + ) unless ( mysql_version_eq( 10, 0 ) or mysql_version_eq( 5, 5 ) ); return; } @@ -5142,7 +5145,7 @@ sub trim { sub get_wsrep_options { return () unless defined $myvar{'wsrep_provider_options'}; - my @galera_options = split /;/, $myvar{'wsrep_provider_options'}; + my @galera_options = split /;/, $myvar{'wsrep_provider_options'}; my $wsrep_slave_threads = $myvar{'wsrep_slave_threads'}; push @galera_options, ' wsrep_slave_threads = ' . $wsrep_slave_threads; @galera_options = remove_cr @galera_options; @@ -5164,7 +5167,7 @@ sub get_wsrep_option { my @galera_options = get_wsrep_options; return '' unless scalar(@galera_options) > 0; my @memValues = grep /\s*$key =/, @galera_options; - my $memValue = $memValues[0]; + my $memValue = $memValues[0]; return 0 unless defined $memValue; $memValue =~ s/.*=\s*(.+)$/$1/g; return $memValue; @@ -5340,7 +5343,7 @@ having sum(if(c.column_key in ('PRI','UNI'), 1,0)) = 0" goodprint "Galera Cluster address is defined: " . $myvar{'wsrep_cluster_address'}; my @NodesTmp = split /,/, $myvar{'wsrep_cluster_address'}; - my $nbNodes = @NodesTmp; + my $nbNodes = @NodesTmp; infoprint "There are $nbNodes nodes in wsrep_cluster_address"; my $nbNodesSize = trim( $mystat{'wsrep_cluster_size'} ); if ( $nbNodesSize == 3 or $nbNodesSize == 5 ) { @@ -5772,8 +5775,9 @@ sub mysql_innodb { sub check_metadata_perf { subheaderprint "Analysis Performance Metrics"; - if (defined $myvar{'innodb_stats_on_metadata'}) { - infoprint "innodb_stats_on_metadata: " . $myvar{'innodb_stats_on_metadata'}; + if ( defined $myvar{'innodb_stats_on_metadata'} ) { + infoprint "innodb_stats_on_metadata: " + . $myvar{'innodb_stats_on_metadata'}; if ( $myvar{'innodb_stats_on_metadata'} eq 'ON' ) { badprint "Stat are updated during querying INFORMATION_SCHEMA."; push @adjvars, "SET innodb_stats_on_metadata = OFF"; @@ -6000,7 +6004,7 @@ sub mysql_tables { my $current_type = uc($ctype) . ( $isnull eq 'NO' ? " NOT NULL" : "" ); my $optimal_type = select_str_g( "Optimal_fieldtype", - "SELECT \\`$_\\` FROM \\`$dbname\\`.\\`$tbname\\` PROCEDURE ANALYSE(100000)" +"SELECT \\`$_\\` FROM \\`$dbname\\`.\\`$tbname\\` PROCEDURE ANALYSE(100000)" ); if ( not defined($optimal_type) or $optimal_type eq '' ) { infoprint " Current Fieldtype: $current_type"; @@ -6012,7 +6016,7 @@ sub mysql_tables { badprint "Consider changing type for column $_ in table $dbname.$tbname"; push( @generalrec, - "ALTER TABLE \`$dbname\`.\`$tbname\` MODIFY \`$_\` $optimal_type;" +"ALTER TABLE \`$dbname\`.\`$tbname\` MODIFY \`$_\` $optimal_type;" ); } @@ -6225,19 +6229,19 @@ sub dump_result { die "Text::Template Module is needed."; } - my $json = JSON->new->allow_nonref; - my $json_text = $json->pretty->encode( \%result ); - my %vars = ( - 'data' => \%result, + my $json = JSON->new->allow_nonref; + my $json_text = $json->pretty->encode( \%result ); + my %vars = ( + 'data' => \%result, 'debug' => $json_text, ); my $template; { no warnings 'once'; $template = Text::Template->new( - TYPE => 'STRING', - PREPEND => q{;}, - SOURCE => $templateModel, + TYPE => 'STRING', + PREPEND => q{;}, + SOURCE => $templateModel, DELIMITERS => [ '[%', '%]' ] ) or die "Couldn't construct template: $Text::Template::ERROR"; }