Incorrect suggestion for ratio InnoDB log file size / InnoDB buffer pool size #322

This commit is contained in:
Jean-Marie RENOUARD 2017-05-17 17:38:17 +02:00
parent f180eae082
commit 21860fe395

View file

@ -302,8 +302,7 @@ sub infoprinthcmd {
# Calculates the number of phyiscal cores considering HyperThreading # Calculates the number of phyiscal cores considering HyperThreading
sub cpu_cores { sub cpu_cores {
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 );
} }
@ -538,8 +537,7 @@ sub validate_tuner_version {
} }
my $update; my $update;
my $url = my $url = "https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl";
"https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl";
my $httpcli = get_http_cli(); my $httpcli = get_http_cli();
if ( $httpcli =~ /curl$/ ) { if ( $httpcli =~ /curl$/ ) {
debugprint "$httpcli is available."; debugprint "$httpcli is available.";
@ -741,8 +739,7 @@ sub mysql_setup {
if ( ( $opt{host} ne "127.0.0.1" ) && ( $opt{host} ne "localhost" ) ) { if ( ( $opt{host} ne "127.0.0.1" ) && ( $opt{host} ne "localhost" ) ) {
$doremote = 1; $doremote = 1;
} }
} } else {
else {
$opt{host}='127.0.0.1'; $opt{host}='127.0.0.1';
} }
@ -872,7 +869,6 @@ sub mysql_setup {
} }
} }
else { else {
# It's not Plesk or debian, we should try a login # It's not Plesk or debian, we should try a login
debugprint "$mysqladmincmd $remotestring ping 2>&1"; debugprint "$mysqladmincmd $remotestring ping 2>&1";
my $loginstatus = `$mysqladmincmd $remotestring ping 2>&1`; my $loginstatus = `$mysqladmincmd $remotestring ping 2>&1`;
@ -1471,8 +1467,7 @@ sub get_kernel_info {
badprint badprint
"Swappiness is > 10, please consider having a value lower than 10"; "Swappiness is > 10, please consider having a value lower than 10";
push @generalrec, "setup swappiness lower or equals to 10"; push @generalrec, "setup swappiness lower or equals to 10";
push @adjvars, push @adjvars, 'vm.swappiness <= 10 (echo 10 > /proc/sys/vm/swappiness)';
'vm.swappiness <= 10 (echo 10 > /proc/sys/vm/swappiness)';
} }
else { else {
infoprint "Swappiness is < 10."; infoprint "Swappiness is < 10.";
@ -2371,9 +2366,8 @@ sub calculations {
} }
if ( $mystat{'Key_write_requests'} > 0 ) { if ( $mystat{'Key_write_requests'} > 0 ) {
$mycalc{'pct_wkeys_from_mem'} = sprintf( "%.1f", $mycalc{'pct_wkeys_from_mem'} = sprintf(
( ( $mystat{'Key_writes'} / $mystat{'Key_write_requests'} ) * 100 ) "%.1f",( ($mystat{'Key_writes'} / $mystat{'Key_write_requests'} ) * 100 ) );
);
} }
else { else {
$mycalc{'pct_wkeys_from_mem'} = 0; $mycalc{'pct_wkeys_from_mem'} = 0;
@ -3152,7 +3146,6 @@ sub mysql_myisam {
} }
} }
else { else {
# No queries have run that would use keys # No queries have run that would use keys
debugprint "Key buffer used: $mycalc{'pct_key_buffer_used'}% (" debugprint "Key buffer used: $mycalc{'pct_key_buffer_used'}% ("
. hr_num( . hr_num(
@ -3212,7 +3205,6 @@ sub mysql_myisam {
} }
} }
else { else {
# No queries have run that would use keys # No queries have run that would use keys
debugprint "Key buffer size / total MyISAM indexes: " debugprint "Key buffer size / total MyISAM indexes: "
. hr_bytes( $myvar{'key_buffer_size'} ) . "/" . hr_bytes( $myvar{'key_buffer_size'} ) . "/"
@ -3237,7 +3229,6 @@ sub mysql_myisam {
} }
} }
else { else {
# No queries have run that would use keys # No queries have run that would use keys
debugprint debugprint
"Write Key buffer hit rate: $mycalc{'pct_wkeys_from_mem'}% (" "Write Key buffer hit rate: $mycalc{'pct_wkeys_from_mem'}% ("
@ -5065,39 +5056,29 @@ having sum(if(c.column_key in ('PRI','UNI'), 1,0)) = 0"
{ {
badprint "gcs.limit should be equal to 5 * wsrep_slave_threads"; badprint "gcs.limit should be equal to 5 * wsrep_slave_threads";
push @adjvars, "gcs.limit= wsrep_slave_threads * 5"; push @adjvars, "gcs.limit= wsrep_slave_threads * 5";
} } else {
else {
goodprint "gcs.limit should be equal to 5 * wsrep_slave_threads"; goodprint "gcs.limit should be equal to 5 * wsrep_slave_threads";
} }
if (get_wsrep_option('wsrep_slave_threads') > 1) { if (get_wsrep_option('wsrep_slave_threads') > 1) {
infoprint infoprint "wsrep parallel slave can cause frequent inconsistency crash.";
"wsrep parallel slave can cause frequent inconsistency crash."; push @adjvars, "Set wsrep_slave_threads to 1 in case of HA_ERR_FOUND_DUPP_KEY crash on slave";
push @adjvars,
"Set wsrep_slave_threads to 1 in case of HA_ERR_FOUND_DUPP_KEY crash on slave";
# check options for parallel slave # check options for parallel slave
if (get_wsrep_option('wsrep_slave_FK_checks') eq "OFF") { if (get_wsrep_option('wsrep_slave_FK_checks') eq "OFF") {
badprint "wsrep_slave_FK_checks is off with parallel slave"; badprint "wsrep_slave_FK_checks is off with parallel slave";
push @adjvars, push @adjvars, "wsrep_slave_FK_checks should be ON when using parallel slave";
"wsrep_slave_FK_checks should be ON when using parallel slave";
} }
# wsrep_slave_UK_checks seems useless in MySQL source code # wsrep_slave_UK_checks seems useless in MySQL source code
if ($myvar{'innodb_autoinc_lock_mode'} != 2) { if ($myvar{'innodb_autoinc_lock_mode'} != 2) {
badprint badprint "innodb_autoinc_lock_mode is incorrect with parallel slave";
"innodb_autoinc_lock_mode is incorrect with parallel slave"; push @adjvars, "innodb_autoinc_lock_mode should be 2 when using parallel slave";
push @adjvars,
"innodb_autoinc_lock_mode should be 2 when using parallel slave";
} }
} }
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"; badprint "gcs.fc_limit should be equal to 5 * wsrep_slave_threads";
push @adjvars, "gcs.fc_limit= wsrep_slave_threads * 5"; push @adjvars, "gcs.fc_limit= wsrep_slave_threads * 5";
} } else {
else {
goodprint "gcs.fc_limit is equal to 5 * wsrep_slave_threads"; goodprint "gcs.fc_limit is equal to 5 * wsrep_slave_threads";
} }
@ -5110,10 +5091,8 @@ having sum(if(c.column_key in ('PRI','UNI'), 1,0)) = 0"
} }
if ( get_wsrep_option('wsrep_flow_control_paused') > 0.02 ) { if ( get_wsrep_option('wsrep_flow_control_paused') > 0.02 ) {
badprint "Fraction of time node pause flow control > 0.02"; badprint "Fraction of time node pause flow control > 0.02";
} } else {
else { goodprint "Flow control fraction seems to be OK (wsrep_flow_control_paused<=0.02)";
goodprint
"Flow control fraction seems to be OK (wsrep_flow_control_paused<=0.02)";
} }
if ( scalar(@primaryKeysNbTables) > 0 ) { if ( scalar(@primaryKeysNbTables) > 0 ) {
@ -5122,8 +5101,7 @@ having sum(if(c.column_key in ('PRI','UNI'), 1,0)) = 0"
badprint "\t$badtable"; badprint "\t$badtable";
push @{ $result{'Tables without PK'} }, $badtable; push @{ $result{'Tables without PK'} }, $badtable;
} }
} } else {
else {
goodprint "All tables get a primary key"; goodprint "All tables get a primary key";
} }
my @nonInnoDBTables = select_array( my @nonInnoDBTables = select_array(
@ -5136,22 +5114,19 @@ having sum(if(c.column_key in ('PRI','UNI'), 1,0)) = 0"
foreach my $badtable (@nonInnoDBTables) { foreach my $badtable (@nonInnoDBTables) {
badprint "\t$badtable"; badprint "\t$badtable";
} }
} } else {
else {
goodprint "All tables are InnoDB tables"; goodprint "All tables are InnoDB tables";
} }
if ( $myvar{'binlog_format'} ne 'ROW' ) { if ( $myvar{'binlog_format'} ne 'ROW' ) {
badprint "Binlog format should be in ROW mode."; badprint "Binlog format should be in ROW mode.";
push @adjvars, "binlog_format = ROW"; push @adjvars, "binlog_format = ROW";
} } else {
else {
goodprint "Binlog format is in ROW mode."; goodprint "Binlog format is in ROW mode.";
} }
if ( $myvar{'innodb_flush_log_at_trx_commit'} != 0 ) { if ( $myvar{'innodb_flush_log_at_trx_commit'} != 0 ) {
badprint "InnoDB flush log at each commit should be disabled."; badprint "InnoDB flush log at each commit should be disabled.";
push @adjvars, "innodb_flush_log_at_trx_commit = 0"; push @adjvars, "innodb_flush_log_at_trx_commit = 0";
} } else {
else {
goodprint "InnoDB flush log at each commit is disabled for Galera."; goodprint "InnoDB flush log at each commit is disabled for Galera.";
} }
@ -5417,7 +5392,7 @@ sub mysql_innodb {
. " should be equal 25%"; . " should be equal 25%";
push( push(
@adjvars, @adjvars,
"innodb_log_file_size * innodb_log_files_in_group should be equals to 1/4 of buffer pool size (=" "innodb_log_file_size * innodb_log_files_in_group should be equal to 1/4 of buffer pool size (="
. hr_bytes_rnd( . hr_bytes_rnd(
$myvar{'innodb_buffer_pool_size'} * $myvar{'innodb_buffer_pool_size'} *
$myvar{'innodb_log_files_in_group'} / 4 $myvar{'innodb_log_files_in_group'} / 4
@ -5942,7 +5917,6 @@ if ( $opt{'template'} ne 0 ) {
$templateModel = file2string( $opt{'template'} ); $templateModel = file2string( $opt{'template'} );
} }
else { else {
# DEFAULT REPORT TEMPLATE # DEFAULT REPORT TEMPLATE
$templateModel = <<'END_TEMPLATE'; $templateModel = <<'END_TEMPLATE';
<!DOCTYPE html> <!DOCTYPE html>
@ -6063,7 +6037,6 @@ close_outputfile; # Close reportfile if needed
1; 1;
__END__ __END__
=pod =pod
=encoding UTF-8 =encoding UTF-8