-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #750 from jmrenouard/master
New version 2.5.2
- Loading branch information
Showing
3 changed files
with
86 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
#!/usr/bin/env perl | ||
# mysqltuner.pl - Version 2.5.1 | ||
# mysqltuner.pl - Version 2.5.2 | ||
# High Performance MySQL Tuning Script | ||
# Copyright (C) 2015-2023 Jean-Marie Renouard - [email protected] | ||
# Copyright (C) 2006-2023 Major Hayden - [email protected] | ||
|
@@ -57,7 +56,7 @@ package main; | |
#use Env; | ||
|
||
# Set up a few variables for use in the script | ||
my $tunerversion = "2.5.1"; | ||
my $tunerversion = "2.5.2"; | ||
my ( @adjvars, @generalrec ); | ||
|
||
# Set defaults | ||
|
@@ -238,8 +237,9 @@ package main; | |
if ( not defined( $opt{structstat} ) or $opt{nostructstat} == 1 ) | ||
; # Don't print table struct information | ||
$opt{myisamstat} = 1 | ||
if ( not defined( $opt{myisamstat} )); | ||
$opt{myisamstat} = 0 if ($opt{nomyisamstat} == 1 ); # Don't print MyISAM table information | ||
if ( not defined( $opt{myisamstat} ) ); | ||
$opt{myisamstat} = 0 | ||
if ( $opt{nomyisamstat} == 1 ); # Don't print MyISAM table information | ||
|
||
# for RPM distributions | ||
$opt{cvefile} = "/usr/share/mysqltuner/vulnerabilities.csv" | ||
|
@@ -815,7 +815,8 @@ sub mysql_setup { | |
if ( $opt{socket} ne 0 ) { | ||
if ( $opt{port} ne 0 ) { | ||
$remotestring = " -S $opt{socket} -P $opt{port}"; | ||
} else { | ||
} | ||
else { | ||
$remotestring = " -S $opt{socket}"; | ||
} | ||
} | ||
|
@@ -1580,7 +1581,9 @@ sub log_file_recommendations { | |
$numLi++; | ||
debugprint "$numLi: $logLi" | ||
if $logLi =~ /warning|error/i and $logLi !~ /Logging to/; | ||
$nbErrLog++ if $logLi =~ /error/i and $logLi !~ /(Logging to|\[Warning\].*ERROR_FOR_DIVISION_BY_ZERO)/; | ||
$nbErrLog++ | ||
if $logLi =~ /error/i | ||
and $logLi !~ /(Logging to|\[Warning\].*ERROR_FOR_DIVISION_BY_ZERO)/; | ||
$nbWarnLog++ if $logLi =~ /warning/i; | ||
push @lastShutdowns, $logLi | ||
if $logLi =~ /Shutdown complete/ and $logLi !~ /Innodb/i; | ||
|
@@ -2526,7 +2529,7 @@ sub check_architecture { | |
} | ||
elsif ( `uname` =~ /Darwin/ && `uname -m` =~ /x86_64/ ) { | ||
|
||
# Darwin gibas.local 12.5.1 Darwin Kernel Version 12.3.0: Sun Jan 6 22:37:10 PST 2013; root:xnu-2050.22.13~1/RELEASE_X86_64 x86_64 | ||
# Darwin gibas.local 12.5.2 Darwin Kernel Version 12.3.0: Sun Jan 6 22:37:10 PST 2013; root:xnu-2050.22.13~1/RELEASE_X86_64 x86_64 | ||
$arch = 64; | ||
goodprint "Operating on 64-bit architecture"; | ||
} | ||
|
@@ -3180,7 +3183,7 @@ sub calculations { | |
unless defined $mystat{'Innodb_buffer_pool_reads'}; | ||
$mycalc{'pct_read_efficiency'} = percentage( | ||
$mystat{'Innodb_buffer_pool_read_requests'}, | ||
( | ||
( | ||
$mystat{'Innodb_buffer_pool_read_requests'} + | ||
$mystat{'Innodb_buffer_pool_reads'} | ||
) | ||
|
@@ -3211,6 +3214,12 @@ sub calculations { | |
$mystat{'Innodb_buffer_pool_pages_total'} | ||
) if defined $mystat{'Innodb_buffer_pool_pages_total'}; | ||
|
||
$mycalc{'innodb_buffer_alloc_pct'} = select_one( | ||
"select round( 100* sum(allocated)/( select VARIABLE_VALUE " | ||
. "FROM performance_schema.global_variables " | ||
. "WHERE VARIABLE_NAME='innodb_buffer_pool_size' ) ,2)" | ||
. 'FROM sys.x\$innodb_buffer_stats_by_table;' ); | ||
|
||
# Binlog Cache | ||
if ( $myvar{'log_bin'} ne 'OFF' ) { | ||
$mycalc{'pct_binlog_cache'} = percentage( | ||
|
@@ -6282,11 +6291,11 @@ sub mysql_innodb { | |
. hr_bytes( $myvar{'innodb_log_buffer_size'} ); | ||
} | ||
if ( defined $mystat{'Innodb_buffer_pool_pages_free'} ) { | ||
infoprint " +-- InnoDB Log Buffer Free: " | ||
infoprint " +-- InnoDB Buffer Free: " | ||
. hr_bytes( $mystat{'Innodb_buffer_pool_pages_free'} ) . ""; | ||
} | ||
if ( defined $mystat{'Innodb_buffer_pool_pages_total'} ) { | ||
infoprint " +-- InnoDB Log Buffer Used: " | ||
infoprint " +-- InnoDB Buffer Used: " | ||
. hr_bytes( $mystat{'Innodb_buffer_pool_pages_total'} ) . ""; | ||
} | ||
} | ||
|
@@ -6355,6 +6364,21 @@ sub mysql_innodb { | |
. hr_bytes( $enginestats{'InnoDB'} ) | ||
. ") if possible." ); | ||
} | ||
|
||
# select round( 100* sum(allocated)/( select VARIABLE_VALUE | ||
# FROM performance_schema.global_variables | ||
# where VARIABLE_NAME='innodb_buffer_pool_size' ) | ||
# ,2) as "PCT ALLOC/BUFFER POOL" | ||
#from sys.x$innodb_buffer_stats_by_table; | ||
|
||
if ( $mycalc{innodb_buffer_alloc_pct} < 80 ) { | ||
badprint "Ratio Buffer Pool allocated / Buffer Pool Size: " | ||
. $mycalc{'innodb_buffer_alloc_pct'} . '%'; | ||
} | ||
else { | ||
goodprint "Ratio Buffer Pool allocated / Buffer Pool Size: " | ||
. $mycalc{'innodb_buffer_alloc_pct'} . '%'; | ||
} | ||
if ( $mycalc{'innodb_log_size_pct'} < 20 | ||
or $mycalc{'innodb_log_size_pct'} > 30 ) | ||
{ | ||
|
@@ -6515,15 +6539,17 @@ sub mysql_innodb { | |
. $mycalc{'pct_read_efficiency'} . "% (" | ||
. $mystat{'Innodb_buffer_pool_read_requests'} | ||
. " hits / " | ||
. ( $mystat{'Innodb_buffer_pool_reads'} + $mystat{'Innodb_buffer_pool_read_requests'} ) | ||
. ( $mystat{'Innodb_buffer_pool_reads'} + | ||
$mystat{'Innodb_buffer_pool_read_requests'} ) | ||
. " total)"; | ||
} | ||
else { | ||
goodprint "InnoDB Read buffer efficiency: " | ||
. $mycalc{'pct_read_efficiency'} . "% (" | ||
. $mystat{'Innodb_buffer_pool_read_requests'} | ||
. " hits / " | ||
. ( $mystat{'Innodb_buffer_pool_reads'} + $mystat{'Innodb_buffer_pool_read_requests'} ) | ||
. ( $mystat{'Innodb_buffer_pool_reads'} + | ||
$mystat{'Innodb_buffer_pool_read_requests'} ) | ||
. " total)"; | ||
} | ||
|
||
|
@@ -6539,7 +6565,7 @@ sub mysql_innodb { | |
. $mystat{'Innodb_log_write_requests'} | ||
. " total)"; | ||
push( @adjvars, | ||
"innodb_log_buffer_size (> " | ||
"innodb_log_buffer_size (> " | ||
. hr_bytes_rnd( $myvar{'innodb_log_buffer_size'} ) | ||
. ")" ); | ||
} | ||
|
@@ -6691,20 +6717,21 @@ sub mysql_databases { | |
percentage( $totaldbinfo[2], $totaldbinfo[3] ) . "%"; | ||
$result{'Databases'}{'All databases'}{'Total Size'} = $totaldbinfo[3]; | ||
print "\n" unless ( $opt{'silent'} or $opt{'json'} ); | ||
my $nbViews=0; | ||
my $nbTables=0; | ||
my $nbViews = 0; | ||
my $nbTables = 0; | ||
|
||
foreach (@dblist) { | ||
my @dbinfo = split /\s/, | ||
select_one( | ||
"SELECT TABLE_SCHEMA, SUM(TABLE_ROWS), SUM(DATA_LENGTH), SUM(INDEX_LENGTH), SUM(DATA_LENGTH+INDEX_LENGTH), COUNT(DISTINCT ENGINE), COUNT(TABLE_NAME), COUNT(DISTINCT(TABLE_COLLATION)), COUNT(DISTINCT(ENGINE)) FROM information_schema.TABLES WHERE TABLE_SCHEMA='$_' GROUP BY TABLE_SCHEMA ORDER BY TABLE_SCHEMA" | ||
); | ||
next unless defined $dbinfo[0]; | ||
infoprint "Database: " . $dbinfo[0] . ""; | ||
$nbTables=select_one( | ||
|
||
infoprint "Database: " . $dbinfo[0] . ""; | ||
$nbTables = select_one( | ||
"SELECT count(*) from information_schema.TABLES WHERE TABLE_TYPE ='BASE TABLE' AND TABLE_SCHEMA='$_'" | ||
); | ||
infoprint " +-- TABLE : $nbTables"; | ||
); | ||
infoprint " +-- TABLE : $nbTables"; | ||
infoprint " +-- VIEW : " | ||
. select_one( | ||
"SELECT count(*) from information_schema.TABLES WHERE TABLE_TYPE ='VIEW' AND TABLE_SCHEMA='$_'" | ||
|
@@ -6760,10 +6787,10 @@ sub mysql_databases { | |
) . " TABLE(s)"; | ||
} | ||
|
||
if ( $nbTables == 0 ) { | ||
badprint " No table in $dbinfo[0] database"; | ||
next; | ||
} | ||
if ( $nbTables == 0 ) { | ||
badprint " No table in $dbinfo[0] database"; | ||
next; | ||
} | ||
badprint "Index size is larger than data size for $dbinfo[0] \n" | ||
if ( $dbinfo[2] ne 'NULL' ) | ||
and ( $dbinfo[3] ne 'NULL' ) | ||
|
@@ -6774,7 +6801,7 @@ sub mysql_databases { | |
. " storage engines. Be careful. \n"; | ||
push @generalrec, | ||
"Select one storage engine (InnoDB is a good choice) for all tables in $dbinfo[0] database ($dbinfo[5] engines detected)"; | ||
} | ||
} | ||
$result{'Databases'}{ $dbinfo[0] }{'Rows'} = $dbinfo[1]; | ||
$result{'Databases'}{ $dbinfo[0] }{'Tables'} = $dbinfo[6]; | ||
$result{'Databases'}{ $dbinfo[0] }{'Collations'} = $dbinfo[7]; | ||
|
@@ -7078,12 +7105,13 @@ sub mysql_indexes { | |
infoprint " +-- COMMENT : " . $info[5] if defined $info[5]; | ||
$found++; | ||
} | ||
my $nbTables=select_one( | ||
my $nbTables = select_one( | ||
"SELECT count(*) from information_schema.TABLES WHERE TABLE_TYPE ='BASE TABLE' AND TABLE_SCHEMA='$dbname'" | ||
); | ||
badprint "No index found for $dbname database" if $found == 0 and $nbTables>1; | ||
); | ||
badprint "No index found for $dbname database" | ||
if $found == 0 and $nbTables > 1; | ||
push @generalrec, "Add indexes on tables from $dbname database" | ||
if $found == 0 and $nbTables>1; | ||
if $found == 0 and $nbTables > 1; | ||
} | ||
return | ||
unless ( defined( $myvar{'performance_schema'} ) | ||
|
@@ -7371,7 +7399,7 @@ sub which { | |
=head1 NAME | ||
MySQLTuner 2.5.1 - MySQL High Performance Tuning Script | ||
MySQLTuner 2.5.2 - MySQL High Performance Tuning Script | ||
=head1 IMPORTANT USAGE GUIDELINES | ||
|
Oops, something went wrong.