Update Vulnerabilities list

Indenting mysqltuner
Update Usage information
This commit is contained in:
Jean-Marie Renouard 2021-07-02 18:31:21 +02:00
parent 8f479b06f6
commit 656a7e51ed
3 changed files with 376 additions and 273 deletions

View file

@ -1,6 +1,6 @@
# NAME # NAME
MySQLTuner 1.7.21 - MySQL High Performance Tuning Script MySQLTuner 1.7.29 - MySQL High Performance Tuning Script
# IMPORTANT USAGE GUIDELINES # IMPORTANT USAGE GUIDELINES
@ -47,6 +47,8 @@ You must provide the remote server's total memory when connecting to other serve
--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
--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
@ -133,7 +135,7 @@ Maintained by Major Hayden (major\\@mhtx.net) - Licensed under GPL
# COPYRIGHT AND LICENSE # COPYRIGHT AND LICENSE
Copyright (C) 2006-2020 Major Hayden - major@mhtx.net Copyright (C) 2006-2021 Major Hayden - major@mhtx.net
For the latest updates, please visit http://mysqltuner.pl/ For the latest updates, please visit http://mysqltuner.pl/

View file

@ -133,7 +133,7 @@ GetOptions(
'color', 'noprocess', 'color', 'noprocess',
'dbstat', 'nodbstat', 'dbstat', 'nodbstat',
'tbstat', 'notbstat', 'tbstat', 'notbstat',
'colstat', 'nocolstat', 'colstat', 'nocolstat',
'sysstat', 'nosysstat', 'sysstat', 'nosysstat',
'pfstat', 'nopfstat', 'pfstat', 'nopfstat',
'idxstat', 'noidxstat', 'idxstat', 'noidxstat',
@ -199,7 +199,7 @@ if ( $opt{verbose} ) {
} }
$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
@ -300,16 +300,16 @@ sub infoprinthcmd {
# Calculates the number of physical cores considering HyperThreading # Calculates the number of physical cores considering HyperThreading
sub cpu_cores { sub cpu_cores {
if ($^O eq 'linux') { if ( $^O eq 'linux' ) {
my $cntCPU = my $cntCPU =
`awk -F: '/^core id/ && !P[\$2] { CORES++; P[\$2]=1 }; /^physical id/ && !N[\$2] { CPUs++; N[\$2]=1 }; END { print CPUs*CORES }' /proc/cpuinfo`; `awk -F: '/^core id/ && !P[\$2] { CORES++; P[\$2]=1 }; /^physical id/ && !N[\$2] { CPUs++; N[\$2]=1 }; END { print CPUs*CORES }' /proc/cpuinfo`;
return ( $cntCPU == 0 ? `nproc` : $cntCPU ); return ( $cntCPU == 0 ? `nproc` : $cntCPU );
} }
if ($^O eq 'freebsd') { if ( $^O eq 'freebsd' ) {
my $cntCPU = `sysctl -n kern.smp.cores`; my $cntCPU = `sysctl -n kern.smp.cores`;
chomp $cntCPU; chomp $cntCPU;
return $cntCPU + 0; return $cntCPU + 0;
} }
return 0; return 0;
} }
@ -1178,22 +1178,24 @@ sub get_all_vars {
debugprint Dumper(@mysqlenginelist); debugprint Dumper(@mysqlenginelist);
my @mysqlslave; my @mysqlslave;
if ( mysql_version_eq( 8 ) or mysql_version_ge( 10, 5 ) ) { if ( mysql_version_eq(8) or mysql_version_ge( 10, 5 ) ) {
@mysqlslave = select_array("SHOW SLAVE STATUS\\G"); @mysqlslave = select_array("SHOW SLAVE STATUS\\G");
} else { }
@mysqlslave = select_array("SHOW REPLICA STATUS\\G"); else {
@mysqlslave = select_array("SHOW REPLICA STATUS\\G");
} }
arr2hash( \%myrepl, \@mysqlslave, ':' ); arr2hash( \%myrepl, \@mysqlslave, ':' );
$result{'Replication'}{'Status'} = \%myrepl; $result{'Replication'}{'Status'} = \%myrepl;
my @mysqlslaves; my @mysqlslaves;
if ( mysql_version_eq( 8 ) or mysql_version_ge( 10, 5 ) ) { if ( mysql_version_eq(8) or mysql_version_ge( 10, 5 ) ) {
@mysqlslaves= select_array "SHOW SLAVE HOSTS"; @mysqlslaves = select_array "SHOW SLAVE HOSTS";
} else { }
@mysqlslaves = select_array("SHOW SLAVE STATUS\\G"); else {
@mysqlslaves = select_array("SHOW SLAVE STATUS\\G");
} }
my @lineitems = (); my @lineitems = ();
foreach my $line (@mysqlslaves) { foreach my $line (@mysqlslaves) {
debugprint "L: $line "; debugprint "L: $line ";
@lineitems = split /\s+/, $line; @lineitems = split /\s+/, $line;
@ -1587,19 +1589,19 @@ sub merge_hash {
} }
sub is_virtual_machine { sub is_virtual_machine {
if ($^O eq 'linux') { if ( $^O eq 'linux' ) {
my $isVm = `grep -Ec '^flags.*\ hypervisor\ ' /proc/cpuinfo`; my $isVm = `grep -Ec '^flags.*\ hypervisor\ ' /proc/cpuinfo`;
return ( $isVm == 0 ? 0 : 1 ); return ( $isVm == 0 ? 0 : 1 );
} }
if ($^O eq 'freebsd') { if ( $^O eq 'freebsd' ) {
my $isVm = `sysctl -n kern.vm_guest`; my $isVm = `sysctl -n kern.vm_guest`;
chomp $isVm; chomp $isVm;
print "FARK DEBUG isVm=[$isVm]"; print "FARK DEBUG isVm=[$isVm]";
return ( $isVm eq 'none' ? 0 : 1); return ( $isVm eq 'none' ? 0 : 1 );
} }
return 0; return 0;
} }
sub infocmd { sub infocmd {
my $cmd = "@_"; my $cmd = "@_";
@ -2739,8 +2741,14 @@ sub calculations {
# Table cache # Table cache
if ( $mystat{'Opened_tables'} > 0 ) { if ( $mystat{'Opened_tables'} > 0 ) {
$mycalc{'table_cache_hit_rate'} = $mycalc{'table_cache_hit_rate'} =
#int( $mystat{'Open_tables'} * 100 / $mystat{'Opened_tables'} ); #int( $mystat{'Open_tables'} * 100 / $mystat{'Opened_tables'} );
int( $mystat{'Table_open_cache_hits'} * 100 / ( $mystat{'Table_open_cache_hits'} + $mystat{'Table_open_cache_misses'} ) ); int(
$mystat{'Table_open_cache_hits'} * 100 / (
$mystat{'Table_open_cache_hits'} +
$mystat{'Table_open_cache_misses'}
)
);
} }
else { else {
@ -3292,9 +3300,10 @@ sub mysql_stats {
if ( $mystat{'Open_tables'} > 0 ) { if ( $mystat{'Open_tables'} > 0 ) {
if ( $mycalc{'table_cache_hit_rate'} < 20 ) { if ( $mycalc{'table_cache_hit_rate'} < 20 ) {
badprint "Table cache hit rate: $mycalc{'table_cache_hit_rate'}% (" badprint "Table cache hit rate: $mycalc{'table_cache_hit_rate'}% ("
. hr_num( $mystat{'Table_open_cache_hits'} ) . hr_num( $mystat{'Table_open_cache_hits'} )
. " hits / " . " hits / "
. hr_num( $mystat{'Table_open_cache_hits'} + $mystat{'Table_open_cache_misses'} ) . hr_num( $mystat{'Table_open_cache_hits'} +
$mystat{'Table_open_cache_misses'} )
. " requests)"; . " requests)";
if ( mysql_version_ge( 5, 1 ) ) { if ( mysql_version_ge( 5, 1 ) ) {
$table_cache_var = "table_open_cache"; $table_cache_var = "table_open_cache";
@ -3337,9 +3346,10 @@ sub mysql_stats {
} }
else { else {
goodprint "Table cache hit rate: $mycalc{'table_cache_hit_rate'}% (" goodprint "Table cache hit rate: $mycalc{'table_cache_hit_rate'}% ("
. hr_num( $mystat{'Table_open_cache_hits'} ) . hr_num( $mystat{'Table_open_cache_hits'} )
. " hits / " . " hits / "
. hr_num( $mystat{'Table_open_cache_hits'} + $mystat{'Table_open_cache_misses'} ) . hr_num( $mystat{'Table_open_cache_hits'} +
$mystat{'Table_open_cache_misses'} )
. " requests)"; . " requests)";
} }
} }
@ -3589,16 +3599,29 @@ sub mariadb_threadpool {
infoprint "Thread Pool Size: " . $myvar{'thread_pool_size'} . " thread(s)."; infoprint "Thread Pool Size: " . $myvar{'thread_pool_size'} . " thread(s).";
if ( $myvar{'version'} =~ /percona/i ) { if ( $myvar{'version'} =~ /percona/i ) {
my $np=cpu_cores; my $np = cpu_cores;
if ($myvar{'thread_pool_size'} >= $np and $myvar{'thread_pool_size'}< ($np *1.5)) { if ( $myvar{'thread_pool_size'} >= $np
goodprint "thread_pool_size for Percona betwwen 1 and 1.5 times nimber of CPUs (".$np. " and ".($np *1.5).")"; and $myvar{'thread_pool_size'} < ( $np * 1.5 ) )
} else { {
badprint "thread_pool_size for Percona betwwen 1 and 1.5 times nimber of CPUs (".$np. " and ".($np *1.5).")"; goodprint
push( @adjvars, "thread_pool_size between ".$np . " and ".($np *1.5)." for InnoDB usage" ); "thread_pool_size for Percona betwwen 1 and 1.5 times nimber of CPUs ("
} . $np . " and "
. ( $np * 1.5 ) . ")";
}
else {
badprint
"thread_pool_size for Percona betwwen 1 and 1.5 times nimber of CPUs ("
. $np . " and "
. ( $np * 1.5 ) . ")";
push( @adjvars,
"thread_pool_size between "
. $np . " and "
. ( $np * 1.5 )
. " for InnoDB usage" );
}
return; return;
} }
if ( $myvar{'version'} =~ /mariadb/i ) { if ( $myvar{'version'} =~ /mariadb/i ) {
infoprint "Using default value is good enough for your version (" infoprint "Using default value is good enough for your version ("
. $myvar{'version'} . ")"; . $myvar{'version'} . ")";
@ -5418,15 +5441,19 @@ having sum(if(c.column_key in ('PRI','UNI'), 1,0)) = 0"
if ( get_wsrep_option('gcs.fc_limit') != $myvar{'wsrep_slave_threads'} * 5 ) if ( get_wsrep_option('gcs.fc_limit') != $myvar{'wsrep_slave_threads'} * 5 )
{ {
badprint "gcs.fc_limit should be equal to 5 * wsrep_slave_threads (=".($myvar{'wsrep_slave_threads'} * 5). ")"; badprint "gcs.fc_limit should be equal to 5 * wsrep_slave_threads (="
push @adjvars, "gcs.fc_limit= wsrep_slave_threads * 5 (=".($myvar{'wsrep_slave_threads'} * 5). ")"; . ( $myvar{'wsrep_slave_threads'} * 5 ) . ")";
push @adjvars, "gcs.fc_limit= wsrep_slave_threads * 5 (="
. ( $myvar{'wsrep_slave_threads'} * 5 ) . ")";
} }
else { else {
goodprint "gcs.fc_limit is equal to 5 * wsrep_slave_threads ( =".get_wsrep_option('gcs.fc_limit') .")"; goodprint "gcs.fc_limit is equal to 5 * wsrep_slave_threads ( ="
. get_wsrep_option('gcs.fc_limit') . ")";
} }
if ( get_wsrep_option('gcs.fc_factor') != 0.8 ) { if ( get_wsrep_option('gcs.fc_factor') != 0.8 ) {
badprint "gcs.fc_factor should be equal to 0.8 (=".get_wsrep_option('gcs.fc_factor').")"; badprint "gcs.fc_factor should be equal to 0.8 (="
. get_wsrep_option('gcs.fc_factor') . ")";
push @adjvars, "gcs.fc_factor=0.8"; push @adjvars, "gcs.fc_factor=0.8";
} }
else { else {
@ -6176,10 +6203,12 @@ sub mysql_tables {
uc($ctype) . ( $isnull eq 'NO' ? " NOT NULL" : "" ); uc($ctype) . ( $isnull eq 'NO' ? " NOT NULL" : "" );
my $optimal_type = ''; my $optimal_type = '';
if ($opt{colstat} == 1) { if ( $opt{colstat} == 1 ) {
$optimal_type = select_str_g( "Optimal_fieldtype", $optimal_type = select_str_g( "Optimal_fieldtype",
"SELECT \\`$_\\` FROM \\`$dbname\\`.\\`$tbname\\` PROCEDURE ANALYSE(100000)" "SELECT \\`$_\\` FROM \\`$dbname\\`.\\`$tbname\\` PROCEDURE ANALYSE(100000)"
) unless ( mysql_version_ge(8) and not mysql_version_eq(10) ); )
unless ( mysql_version_ge(8)
and not mysql_version_eq(10) );
} }
if ( $optimal_type eq '' ) { if ( $optimal_type eq '' ) {
infoprint " Current Fieldtype: $current_type"; infoprint " Current Fieldtype: $current_type";

File diff suppressed because one or more lines are too long