parent
335e12aa9a
commit
2259dfc3b2
1 changed files with 48 additions and 48 deletions
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env perl
|
#!/usr/bin/env perl
|
||||||
# mysqltuner.pl - Version 2.0.5
|
# mysqltuner.pl - Version 2.0.6
|
||||||
# High Performance MySQL Tuning Script
|
# High Performance MySQL Tuning Script
|
||||||
# Copyright (C) 2006-2022 Major Hayden - major@mhtx.net
|
# Copyright (C) 2006-2022 Major Hayden - major@mhtx.net
|
||||||
# Copyright (C) 2015-2022 Jean-Marie Renouard - jmrenouard@gmail.com
|
# Copyright (C) 2015-2022 Jean-Marie Renouard - jmrenouard@gmail.com
|
||||||
|
@ -57,7 +57,7 @@ use Cwd 'abs_path';
|
||||||
#use Env;
|
#use Env;
|
||||||
|
|
||||||
# Set up a few variables for use in the script
|
# Set up a few variables for use in the script
|
||||||
my $tunerversion = "2.0.5";
|
my $tunerversion = "2.0.6";
|
||||||
my ( @adjvars, @generalrec );
|
my ( @adjvars, @generalrec );
|
||||||
|
|
||||||
# Set defaults
|
# Set defaults
|
||||||
|
@ -200,15 +200,15 @@ if ( $opt{verbose} ) {
|
||||||
$opt{cvefile} = 'vulnerabilities.csv'; #CVE File for vulnerability checks
|
$opt{cvefile} = 'vulnerabilities.csv'; #CVE File for vulnerability checks
|
||||||
}
|
}
|
||||||
$opt{nocolor} = 1 if defined( $opt{outputfile} );
|
$opt{nocolor} = 1 if defined( $opt{outputfile} );
|
||||||
$opt{tbstat} = 0 if ( $opt{notbstat} == 1 ); # Don't Print table information
|
$opt{tbstat} = 0 if ( $opt{notbstat} == 1 ); # Don't print table information
|
||||||
$opt{colstat} = 0 if ( $opt{nocolstat} == 1 ); # Don't Print column information
|
$opt{colstat} = 0 if ( $opt{nocolstat} == 1 ); # Don't print column information
|
||||||
$opt{dbstat} = 0 if ( $opt{nodbstat} == 1 ); # Don't Print database information
|
$opt{dbstat} = 0 if ( $opt{nodbstat} == 1 ); # Don't print database information
|
||||||
$opt{noprocess} = 0
|
$opt{noprocess} = 0
|
||||||
if ( $opt{noprocess} == 1 ); # Don't Print process information
|
if ( $opt{noprocess} == 1 ); # Don't print process information
|
||||||
$opt{sysstat} = 0 if ( $opt{nosysstat} == 1 ); # Don't Print sysstat 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
|
if ( $opt{nopfstat} == 1 ); # Don't print performance schema information
|
||||||
$opt{idxstat} = 0 if ( $opt{noidxstat} == 1 ); # Don't Print index information
|
$opt{idxstat} = 0 if ( $opt{noidxstat} == 1 ); # Don't print index information
|
||||||
|
|
||||||
# for RPM distributions
|
# for RPM distributions
|
||||||
$opt{cvefile} = "/usr/share/mysqltuner/vulnerabilities.csv"
|
$opt{cvefile} = "/usr/share/mysqltuner/vulnerabilities.csv"
|
||||||
|
@ -404,7 +404,7 @@ sub percentage {
|
||||||
return sprintf( "%.2f", ( $value * 100 / $total ) );
|
return sprintf( "%.2f", ( $value * 100 / $total ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
# Calculates uptime to display in a more attractive form
|
# Calculates uptime to display in a human-readable form
|
||||||
sub pretty_uptime {
|
sub pretty_uptime {
|
||||||
my $uptime = shift;
|
my $uptime = shift;
|
||||||
my $seconds = $uptime % 60;
|
my $seconds = $uptime % 60;
|
||||||
|
@ -581,7 +581,7 @@ sub validate_tuner_version {
|
||||||
debugprint "curl and wget are not available.";
|
debugprint "curl and wget are not available.";
|
||||||
infoprint "Unable to check for the latest MySQLTuner version";
|
infoprint "Unable to check for the latest MySQLTuner version";
|
||||||
infoprint
|
infoprint
|
||||||
"Using --pass and --password option is insecure during MySQLTuner execution(Password disclosure)"
|
"Using --pass and --password option is insecure during MySQLTuner execution (password disclosure)"
|
||||||
if ( defined( $opt{'pass'} ) );
|
if ( defined( $opt{'pass'} ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2422,7 +2422,7 @@ sub check_storage_engines {
|
||||||
infoprint "Status: $engines";
|
infoprint "Status: $engines";
|
||||||
if ( mysql_version_ge( 5, 1, 5 ) ) {
|
if ( mysql_version_ge( 5, 1, 5 ) ) {
|
||||||
|
|
||||||
# MySQL 5 servers can have table sizes calculated quickly from information schema
|
# MySQL 5+ servers can have table sizes calculated quickly from information schema
|
||||||
my @templist = select_array
|
my @templist = select_array
|
||||||
"SELECT ENGINE, SUM(DATA_LENGTH+INDEX_LENGTH), COUNT(ENGINE), SUM(DATA_LENGTH), SUM(INDEX_LENGTH) FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN ('information_schema', 'performance_schema', 'mysql') AND ENGINE IS NOT NULL GROUP BY ENGINE ORDER BY ENGINE ASC;";
|
"SELECT ENGINE, SUM(DATA_LENGTH+INDEX_LENGTH), COUNT(ENGINE), SUM(DATA_LENGTH), SUM(INDEX_LENGTH) FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN ('information_schema', 'performance_schema', 'mysql') AND ENGINE IS NOT NULL GROUP BY ENGINE ORDER BY ENGINE ASC;";
|
||||||
|
|
||||||
|
@ -2614,7 +2614,7 @@ my %mycalc;
|
||||||
sub calculations {
|
sub calculations {
|
||||||
if ( $mystat{'Questions'} < 1 ) {
|
if ( $mystat{'Questions'} < 1 ) {
|
||||||
badprint
|
badprint
|
||||||
"Your server has not answered any queries - cannot continue...";
|
"Your server has not answered any queries: cannot continue...";
|
||||||
exit 2;
|
exit 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3007,7 +3007,7 @@ sub mysql_stats {
|
||||||
$qps = sprintf( "%.3f", $mystat{'Questions'} / $mystat{'Uptime'} );
|
$qps = sprintf( "%.3f", $mystat{'Questions'} / $mystat{'Uptime'} );
|
||||||
}
|
}
|
||||||
push( @generalrec,
|
push( @generalrec,
|
||||||
"MySQL was started within the last 24 hours - recommendations may be inaccurate"
|
"MySQL was started within the last 24 hours: recommendations may be inaccurate"
|
||||||
) if ( $mystat{'Uptime'} < 86400 );
|
) if ( $mystat{'Uptime'} < 86400 );
|
||||||
infoprint "Up for: "
|
infoprint "Up for: "
|
||||||
. pretty_uptime( $mystat{'Uptime'} ) . " ("
|
. pretty_uptime( $mystat{'Uptime'} ) . " ("
|
||||||
|
@ -3043,9 +3043,9 @@ sub mysql_stats {
|
||||||
. " global + "
|
. " global + "
|
||||||
. hr_bytes( $mycalc{'per_thread_buffers'} )
|
. hr_bytes( $mycalc{'per_thread_buffers'} )
|
||||||
. " per thread ($myvar{'max_connections'} max threads)";
|
. " per thread ($myvar{'max_connections'} max threads)";
|
||||||
infoprint "P_S Max memory usage: " . hr_bytes_rnd( get_pf_memory() );
|
infoprint "Performance_schema Max memory usage: " . hr_bytes_rnd( get_pf_memory() );
|
||||||
$result{'P_S'}{'memory'} = get_pf_memory();
|
$result{'Performance_schema'}{'memory'} = get_pf_memory();
|
||||||
$result{'P_S'}{'pretty_memory'} =
|
$result{'Performance_schema'}{'pretty_memory'} =
|
||||||
hr_bytes_rnd( get_pf_memory() );
|
hr_bytes_rnd( get_pf_memory() );
|
||||||
infoprint "Galera GCache Max memory usage: "
|
infoprint "Galera GCache Max memory usage: "
|
||||||
. hr_bytes_rnd( get_gcache_memory() );
|
. hr_bytes_rnd( get_gcache_memory() );
|
||||||
|
@ -3384,7 +3384,7 @@ sub mysql_stats {
|
||||||
. hr_num( $mystat{'Created_tmp_tables'} )
|
. hr_num( $mystat{'Created_tmp_tables'} )
|
||||||
. " total)";
|
. " total)";
|
||||||
push( @generalrec,
|
push( @generalrec,
|
||||||
"Temporary table size is already large - reduce result set size"
|
"Temporary table size is already large: reduce result set size"
|
||||||
);
|
);
|
||||||
push( @generalrec,
|
push( @generalrec,
|
||||||
"Reduce your SELECT DISTINCT queries without LIMIT clauses" );
|
"Reduce your SELECT DISTINCT queries without LIMIT clauses" );
|
||||||
|
@ -3885,7 +3885,7 @@ sub mysqsl_pfs {
|
||||||
if ( $myvar{'performance_schema'} eq 'ON' ) {
|
if ( $myvar{'performance_schema'} eq 'ON' ) {
|
||||||
infoprint "Performance_schema is activated.";
|
infoprint "Performance_schema is activated.";
|
||||||
debugprint "Performance schema is " . $myvar{'performance_schema'};
|
debugprint "Performance schema is " . $myvar{'performance_schema'};
|
||||||
infoprint "Memory used by P_S: " . hr_bytes( get_pf_memory() );
|
infoprint "Memory used by Performance_schema: " . hr_bytes( get_pf_memory() );
|
||||||
}
|
}
|
||||||
|
|
||||||
unless ( grep /^sys$/, select_array("SHOW DATABASES") ) {
|
unless ( grep /^sys$/, select_array("SHOW DATABASES") ) {
|
||||||
|
@ -6847,7 +6847,7 @@ sub which {
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
headerprint; # Header Print
|
headerprint; # Header Print
|
||||||
|
|
||||||
validate_tuner_version; # Check last version
|
validate_tuner_version; # Check latest version
|
||||||
mysql_setup; # Gotta login first
|
mysql_setup; # Gotta login first
|
||||||
debugprint "MySQL FINAL Client : $mysqlcmd $mysqllogin";
|
debugprint "MySQL FINAL Client : $mysqlcmd $mysqllogin";
|
||||||
debugprint "MySQL Admin FINAL Client : $mysqladmincmd $mysqllogin";
|
debugprint "MySQL Admin FINAL Client : $mysqladmincmd $mysqllogin";
|
||||||
|
@ -6855,22 +6855,22 @@ debugprint "MySQL Admin FINAL Client : $mysqladmincmd $mysqllogin";
|
||||||
#exit(0);
|
#exit(0);
|
||||||
os_setup; # Set up some OS variables
|
os_setup; # Set up some OS variables
|
||||||
get_all_vars; # Toss variables/status into hashes
|
get_all_vars; # Toss variables/status into hashes
|
||||||
get_tuning_info; # Get information about the tuning connexion
|
get_tuning_info; # Get information about the tuning connection
|
||||||
validate_mysql_version; # Check current MySQL version
|
validate_mysql_version; # Check current MySQL version
|
||||||
|
|
||||||
check_architecture; # Suggest 64-bit upgrade
|
check_architecture; # Suggest 64-bit upgrade
|
||||||
system_recommendations; # avoid to many service on the same host
|
system_recommendations; # Avoid too many services on the same host
|
||||||
log_file_recommendations; # check log file content
|
log_file_recommendations; # check log file content
|
||||||
check_storage_engines; # Show enabled storage engines
|
check_storage_engines; # Show enabled storage engines
|
||||||
|
|
||||||
check_metadata_perf; # Show parameter impacting performance during analysis
|
check_metadata_perf; # Show parameter impacting performance during analysis
|
||||||
mysql_databases; # Show informations about databases
|
mysql_databases; # Show information about databases
|
||||||
mysql_tables; # Show informations about table column
|
mysql_tables; # Show information about table column
|
||||||
|
|
||||||
mysql_indexes; # Show informations about indexes
|
mysql_indexes; # Show information about indexes
|
||||||
mysql_views; # Show informations about views
|
mysql_views; # Show information about views
|
||||||
mysql_triggers; # Show informations about triggers
|
mysql_triggers; # Show information about triggers
|
||||||
mysql_routines; # Show informations about routines
|
mysql_routines; # Show information about routines
|
||||||
security_recommendations; # Display some security recommendations
|
security_recommendations; # Display some security recommendations
|
||||||
cve_recommendations; # Display related CVE
|
cve_recommendations; # Display related CVE
|
||||||
calculations; # Calculate everything we need
|
calculations; # Calculate everything we need
|
||||||
|
@ -6905,7 +6905,7 @@ __END__
|
||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
||||||
MySQLTuner 2.0.5 - MySQL High Performance Tuning Script
|
MySQLTuner 2.0.6 - MySQL High Performance Tuning Script
|
||||||
|
|
||||||
=head1 IMPORTANT USAGE GUIDELINES
|
=head1 IMPORTANT USAGE GUIDELINES
|
||||||
|
|
||||||
|
@ -6928,7 +6928,7 @@ You must provide the remote server's total memory when connecting to other serve
|
||||||
--mysqladmin <path> Path to a custom mysqladmin executable
|
--mysqladmin <path> Path to a custom mysqladmin executable
|
||||||
--mysqlcmd <path> Path to a custom mysql executable
|
--mysqlcmd <path> Path to a custom mysql executable
|
||||||
--defaults-file <path> Path to a custom .my.cnf
|
--defaults-file <path> Path to a custom .my.cnf
|
||||||
--server-log <path> Path to explict log file (error_log)
|
--server-log <path> Path to explicit log file (error_log)
|
||||||
|
|
||||||
=head1 PERFORMANCE AND REPORTING OPTIONS
|
=head1 PERFORMANCE AND REPORTING OPTIONS
|
||||||
|
|
||||||
|
@ -6950,7 +6950,7 @@ You must provide the remote server's total memory when connecting to other serve
|
||||||
=head1 OUTPUT OPTIONS
|
=head1 OUTPUT OPTIONS
|
||||||
|
|
||||||
--silent Don't output anything on screen
|
--silent Don't output anything on screen
|
||||||
--verbose Prints out all options (default: no verbose, dbstat, idxstat, sysstat, tbstat, pfstat)
|
--verbose Print out all options (default: no verbose, dbstat, idxstat, sysstat, tbstat, pfstat)
|
||||||
--nocolor Don't print output in color
|
--nocolor Don't print output in color
|
||||||
--nogood Remove OK responses
|
--nogood Remove OK responses
|
||||||
--nobad Remove negative/suggestion responses
|
--nobad Remove negative/suggestion responses
|
||||||
|
@ -6958,20 +6958,20 @@ You must provide the remote server's total memory when connecting to other serve
|
||||||
--debug Print debug information
|
--debug Print debug information
|
||||||
--noprocess Consider no other process is running
|
--noprocess Consider no other process is running
|
||||||
--dbstat Print database information
|
--dbstat Print database information
|
||||||
--nodbstat Don't Print database information
|
--nodbstat Don't print database information
|
||||||
--tbstat Print table information
|
--tbstat Print table information
|
||||||
--notbstat Don't Print table information
|
--notbstat Don't print table information
|
||||||
--colstat Print column information
|
--colstat Print column information
|
||||||
--nocolstat Don't Print column information
|
--nocolstat Don't print column information
|
||||||
--idxstat Print index information
|
--idxstat Print index information
|
||||||
--noidxstat Don't Print index information
|
--noidxstat Don't print index information
|
||||||
--sysstat Print system information
|
--sysstat Print system information
|
||||||
--nosysstat Don't Print system information
|
--nosysstat Don't print system information
|
||||||
--pfstat Print Performance schema
|
--pfstat Print Performance schema
|
||||||
--nopfstat Don't Print Performance schema
|
--nopfstat Don't print Performance schema
|
||||||
--bannedports Ports banned separated by comma (,)
|
--bannedports Ports banned separated by comma (,)
|
||||||
--server-log Define specific error_log to analyze
|
--server-log Define specific error_log to analyze
|
||||||
--maxportallowed Number of ports opened allowed on this host
|
--maxportallowed Number of open ports allowable on this host
|
||||||
--buffers Print global and per-thread buffer values
|
--buffers Print global and per-thread buffer values
|
||||||
|
|
||||||
=head1 PERLDOC
|
=head1 PERLDOC
|
||||||
|
|
Loading…
Reference in a new issue