Update Vulnerabilities list
Indenting mysqltuner Update Usage information
This commit is contained in:
parent
8f479b06f6
commit
656a7e51ed
3 changed files with 376 additions and 273 deletions
6
USAGE.md
6
USAGE.md
|
@ -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/
|
||||||
|
|
||||||
|
|
|
@ -300,13 +300,13 @@ 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;
|
||||||
|
@ -1178,18 +1178,20 @@ 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 {
|
}
|
||||||
|
else {
|
||||||
@mysqlslave = select_array("SHOW REPLICA STATUS\\G");
|
@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 {
|
}
|
||||||
|
else {
|
||||||
@mysqlslaves = select_array("SHOW SLAVE STATUS\\G");
|
@mysqlslaves = select_array("SHOW SLAVE STATUS\\G");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 {
|
||||||
|
@ -3294,7 +3302,8 @@ sub mysql_stats {
|
||||||
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";
|
||||||
|
@ -3339,7 +3348,8 @@ sub mysql_stats {
|
||||||
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,12 +3599,25 @@ 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;
|
||||||
}
|
}
|
||||||
|
@ -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
Loading…
Reference in a new issue