From 30d1d9ecc61393ec807d2596ef8b5e178a4b52cd Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Tue, 6 Feb 2024 17:58:35 +0100 Subject: [PATCH] Generate 2.5.2 sub version at 2024-02-06T17:58:35+01:00 --- USAGE.md | 2 +- mysqltuner.pl | 104 +++++++++++++++++++++++++++++--------------------- 2 files changed, 62 insertions(+), 44 deletions(-) diff --git a/USAGE.md b/USAGE.md index d344d61..c63d361 100644 --- a/USAGE.md +++ b/USAGE.md @@ -1,6 +1,6 @@ # NAME - MySQLTuner 2.5.1 - MySQL High Performance Tuning Script + MySQLTuner 2.5.2 - MySQL High Performance Tuning Script # IMPORTANT USAGE GUIDELINES diff --git a/mysqltuner.pl b/mysqltuner.pl index a088a11..8c0931d 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -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 - jmrenouard@gmail.com # Copyright (C) 2006-2023 Major Hayden - major@mhtx.net @@ -57,7 +56,7 @@ use Cwd 'abs_path'; #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 @@ -197,7 +196,7 @@ if ( exists $opt{passenv} && exists $ENV{ $opt{passenv} } ) { $opt{pass} = $opt{password} if ( $opt{pass} eq 0 and $opt{password} ne 0 ); if ( $opt{dumpdir} ne '' ) { - $opt{dumpdir} = abs_path( $opt{dumpdir} ); + $opt{dumpdir}= abs_path($opt{dumpdir}); if ( !-d $opt{dumpdir} ) { mkdir $opt{dumpdir} or die "Cannot create directory $opt{dumpdir}: $!"; } @@ -2526,7 +2525,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"; } @@ -3211,6 +3210,11 @@ 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( @@ -6355,46 +6359,60 @@ 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 ) { - if ( defined $myvar{'innodb_redo_log_capacity'} ) { - badprint - "Ratio InnoDB redo log capacity / InnoDB Buffer pool size (" - . $mycalc{'innodb_log_size_pct'} . "%): " - . hr_bytes( $myvar{'innodb_redo_log_capacity'} ) . " / " - . hr_bytes( $myvar{'innodb_buffer_pool_size'} ) - . " should be equal to 25%"; - push( @adjvars, - "innodb_redo_log_capacity should be (=" - . hr_bytes_rnd( $myvar{'innodb_buffer_pool_size'} / 4 ) - . ") if possible, so InnoDB Redo log Capacity equals 25% of buffer pool size." - ); - push( @generalrec, -"Be careful, increasing innodb_redo_log_capacity means higher crash recovery mean time" - ); - } - else { - badprint "Ratio InnoDB log file size / InnoDB Buffer pool size (" - . $mycalc{'innodb_log_size_pct'} . "%): " - . hr_bytes( $myvar{'innodb_log_file_size'} ) . " * " - . $myvar{'innodb_log_files_in_group'} . " / " - . hr_bytes( $myvar{'innodb_buffer_pool_size'} ) - . " should be equal to 25%"; - push( - @adjvars, - "innodb_log_file_size should be (=" - . hr_bytes_rnd( - $myvar{'innodb_buffer_pool_size'} / - $myvar{'innodb_log_files_in_group'} / 4 - ) - . ") if possible, so InnoDB total log file size equals 25% of buffer pool size." - ); - push( @generalrec, -"Be careful, increasing innodb_log_file_size / innodb_log_files_in_group means higher crash recovery mean time" - ); - } - if ( mysql_version_le( 5, 6, 2 ) ) { + if ( defined $myvar{'innodb_redo_log_capacity'} ) { + badprint + "Ratio InnoDB redo log capacity / InnoDB Buffer pool size (" + . $mycalc{'innodb_log_size_pct'} . "%): " + . hr_bytes( $myvar{'innodb_redo_log_capacity'} ) . " / " + . hr_bytes( $myvar{'innodb_buffer_pool_size'} ) + . " should be equal to 25%"; + push( @adjvars, + "innodb_redo_log_capacity should be (=" + . hr_bytes_rnd( $myvar{'innodb_buffer_pool_size'} / 4 ) + . ") if possible, so InnoDB Redo log Capacity equals 25% of buffer pool size." + ); + push( @generalrec, + "Be careful, increasing innodb_redo_log_capacity means higher crash recovery mean time" + ); + } + else { + badprint "Ratio InnoDB log file size / InnoDB Buffer pool size (" + . $mycalc{'innodb_log_size_pct'} . "%): " + . hr_bytes( $myvar{'innodb_log_file_size'} ) . " * " + . $myvar{'innodb_log_files_in_group'} . " / " + . hr_bytes( $myvar{'innodb_buffer_pool_size'} ) + . " should be equal to 25%"; + push( + @adjvars, + "innodb_log_file_size should be (=" + . hr_bytes_rnd( + $myvar{'innodb_buffer_pool_size'} / + $myvar{'innodb_log_files_in_group'} / 4 + ) + . ") if possible, so InnoDB total log file size equals 25% of buffer pool size." + ); + push( @generalrec, + "Be careful, increasing innodb_log_file_size / innodb_log_files_in_group means higher crash recovery mean time" + ); + } + if ( mysql_version_le( 5, 6, 2 ) ) { push( @generalrec, "For MySQL 5.6.2 and lower, total innodb_log_file_size should have a ceiling of (4096MB / log files in group) - 1MB." ); @@ -7371,7 +7389,7 @@ __END__ =head1 NAME - MySQLTuner 2.5.1 - MySQL High Performance Tuning Script + MySQLTuner 2.5.2 - MySQL High Performance Tuning Script =head1 IMPORTANT USAGE GUIDELINES