|
1 | | -#!/usr/bin/env perl |
2 | | -# mysqltuner.pl - Version 2.5.1 |
| 1 | +# mysqltuner.pl - Version 2.5.2 |
3 | 2 | # High Performance MySQL Tuning Script |
4 | 3 | # Copyright (C) 2015-2023 Jean-Marie Renouard - [email protected] |
5 | 4 | # Copyright (C) 2006-2023 Major Hayden - [email protected] |
@@ -57,7 +56,7 @@ package main; |
57 | 56 | #use Env; |
58 | 57 |
|
59 | 58 | # Set up a few variables for use in the script |
60 | | -my $tunerversion = "2.5.1"; |
| 59 | +my $tunerversion = "2.5.2"; |
61 | 60 | my ( @adjvars, @generalrec ); |
62 | 61 |
|
63 | 62 | # Set defaults |
@@ -197,7 +196,7 @@ package main; |
197 | 196 | $opt{pass} = $opt{password} if ( $opt{pass} eq 0 and $opt{password} ne 0 ); |
198 | 197 |
|
199 | 198 | if ( $opt{dumpdir} ne '' ) { |
200 | | - $opt{dumpdir} = abs_path( $opt{dumpdir} ); |
| 199 | + $opt{dumpdir}= abs_path($opt{dumpdir}); |
201 | 200 | if ( !-d $opt{dumpdir} ) { |
202 | 201 | mkdir $opt{dumpdir} or die "Cannot create directory $opt{dumpdir}: $!"; |
203 | 202 | } |
@@ -2526,7 +2525,7 @@ sub check_architecture { |
2526 | 2525 | } |
2527 | 2526 | elsif ( `uname` =~ /Darwin/ && `uname -m` =~ /x86_64/ ) { |
2528 | 2527 |
|
2529 | | -# 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 |
| 2528 | +# 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 |
2530 | 2529 | $arch = 64; |
2531 | 2530 | goodprint "Operating on 64-bit architecture"; |
2532 | 2531 | } |
@@ -3211,6 +3210,11 @@ sub calculations { |
3211 | 3210 | $mystat{'Innodb_buffer_pool_pages_total'} |
3212 | 3211 | ) if defined $mystat{'Innodb_buffer_pool_pages_total'}; |
3213 | 3212 |
|
| 3213 | + $mycalc{'innodb_buffer_alloc_pct'}=select_one( |
| 3214 | + "select round( 100* sum(allocated)/( select VARIABLE_VALUE ". |
| 3215 | + "FROM performance_schema.global_variables " . |
| 3216 | + "WHERE VARIABLE_NAME='innodb_buffer_pool_size' ) ,2)". |
| 3217 | + 'FROM sys.x\$innodb_buffer_stats_by_table;'); |
3214 | 3218 | # Binlog Cache |
3215 | 3219 | if ( $myvar{'log_bin'} ne 'OFF' ) { |
3216 | 3220 | $mycalc{'pct_binlog_cache'} = percentage( |
@@ -6355,46 +6359,60 @@ sub mysql_innodb { |
6355 | 6359 | . hr_bytes( $enginestats{'InnoDB'} ) |
6356 | 6360 | . ") if possible." ); |
6357 | 6361 | } |
| 6362 | + |
| 6363 | + # select round( 100* sum(allocated)/( select VARIABLE_VALUE |
| 6364 | + # FROM performance_schema.global_variables |
| 6365 | + # where VARIABLE_NAME='innodb_buffer_pool_size' ) |
| 6366 | + # ,2) as "PCT ALLOC/BUFFER POOL" |
| 6367 | + #from sys.x$innodb_buffer_stats_by_table; |
| 6368 | + |
| 6369 | + if ($mycalc{innodb_buffer_alloc_pct} < 80) { |
| 6370 | + badprint "Ratio Buffer Pool allocated / Buffer Pool Size: ". |
| 6371 | + $mycalc{'innodb_buffer_alloc_pct'} . '%'; |
| 6372 | + } else { |
| 6373 | + goodprint "Ratio Buffer Pool allocated / Buffer Pool Size: ". |
| 6374 | + $mycalc{'innodb_buffer_alloc_pct'} . '%'; |
| 6375 | + } |
6358 | 6376 | if ( $mycalc{'innodb_log_size_pct'} < 20 |
6359 | 6377 | or $mycalc{'innodb_log_size_pct'} > 30 ) |
6360 | 6378 | { |
6361 | | - if ( defined $myvar{'innodb_redo_log_capacity'} ) { |
6362 | | - badprint |
6363 | | - "Ratio InnoDB redo log capacity / InnoDB Buffer pool size (" |
6364 | | - . $mycalc{'innodb_log_size_pct'} . "%): " |
6365 | | - . hr_bytes( $myvar{'innodb_redo_log_capacity'} ) . " / " |
6366 | | - . hr_bytes( $myvar{'innodb_buffer_pool_size'} ) |
6367 | | - . " should be equal to 25%"; |
6368 | | - push( @adjvars, |
6369 | | - "innodb_redo_log_capacity should be (=" |
6370 | | - . hr_bytes_rnd( $myvar{'innodb_buffer_pool_size'} / 4 ) |
6371 | | - . ") if possible, so InnoDB Redo log Capacity equals 25% of buffer pool size." |
6372 | | - ); |
6373 | | - push( @generalrec, |
6374 | | -"Be careful, increasing innodb_redo_log_capacity means higher crash recovery mean time" |
6375 | | - ); |
6376 | | - } |
6377 | | - else { |
6378 | | - badprint "Ratio InnoDB log file size / InnoDB Buffer pool size (" |
6379 | | - . $mycalc{'innodb_log_size_pct'} . "%): " |
6380 | | - . hr_bytes( $myvar{'innodb_log_file_size'} ) . " * " |
6381 | | - . $myvar{'innodb_log_files_in_group'} . " / " |
6382 | | - . hr_bytes( $myvar{'innodb_buffer_pool_size'} ) |
6383 | | - . " should be equal to 25%"; |
6384 | | - push( |
6385 | | - @adjvars, |
6386 | | - "innodb_log_file_size should be (=" |
6387 | | - . hr_bytes_rnd( |
6388 | | - $myvar{'innodb_buffer_pool_size'} / |
6389 | | - $myvar{'innodb_log_files_in_group'} / 4 |
6390 | | - ) |
6391 | | - . ") if possible, so InnoDB total log file size equals 25% of buffer pool size." |
6392 | | - ); |
6393 | | - push( @generalrec, |
6394 | | -"Be careful, increasing innodb_log_file_size / innodb_log_files_in_group means higher crash recovery mean time" |
6395 | | - ); |
6396 | | - } |
6397 | | - if ( mysql_version_le( 5, 6, 2 ) ) { |
| 6379 | + if ( defined $myvar{'innodb_redo_log_capacity'} ) { |
| 6380 | + badprint |
| 6381 | + "Ratio InnoDB redo log capacity / InnoDB Buffer pool size (" |
| 6382 | + . $mycalc{'innodb_log_size_pct'} . "%): " |
| 6383 | + . hr_bytes( $myvar{'innodb_redo_log_capacity'} ) . " / " |
| 6384 | + . hr_bytes( $myvar{'innodb_buffer_pool_size'} ) |
| 6385 | + . " should be equal to 25%"; |
| 6386 | + push( @adjvars, |
| 6387 | + "innodb_redo_log_capacity should be (=" |
| 6388 | + . hr_bytes_rnd( $myvar{'innodb_buffer_pool_size'} / 4 ) |
| 6389 | + . ") if possible, so InnoDB Redo log Capacity equals 25% of buffer pool size." |
| 6390 | + ); |
| 6391 | + push( @generalrec, |
| 6392 | + "Be careful, increasing innodb_redo_log_capacity means higher crash recovery mean time" |
| 6393 | + ); |
| 6394 | + } |
| 6395 | + else { |
| 6396 | + badprint "Ratio InnoDB log file size / InnoDB Buffer pool size (" |
| 6397 | + . $mycalc{'innodb_log_size_pct'} . "%): " |
| 6398 | + . hr_bytes( $myvar{'innodb_log_file_size'} ) . " * " |
| 6399 | + . $myvar{'innodb_log_files_in_group'} . " / " |
| 6400 | + . hr_bytes( $myvar{'innodb_buffer_pool_size'} ) |
| 6401 | + . " should be equal to 25%"; |
| 6402 | + push( |
| 6403 | + @adjvars, |
| 6404 | + "innodb_log_file_size should be (=" |
| 6405 | + . hr_bytes_rnd( |
| 6406 | + $myvar{'innodb_buffer_pool_size'} / |
| 6407 | + $myvar{'innodb_log_files_in_group'} / 4 |
| 6408 | + ) |
| 6409 | + . ") if possible, so InnoDB total log file size equals 25% of buffer pool size." |
| 6410 | + ); |
| 6411 | + push( @generalrec, |
| 6412 | + "Be careful, increasing innodb_log_file_size / innodb_log_files_in_group means higher crash recovery mean time" |
| 6413 | + ); |
| 6414 | + } |
| 6415 | + if ( mysql_version_le( 5, 6, 2 ) ) { |
6398 | 6416 | push( @generalrec, |
6399 | 6417 | "For MySQL 5.6.2 and lower, total innodb_log_file_size should have a ceiling of (4096MB / log files in group) - 1MB." |
6400 | 6418 | ); |
@@ -7371,7 +7389,7 @@ sub which { |
7371 | 7389 |
|
7372 | 7390 | =head1 NAME |
7373 | 7391 |
|
7374 | | - MySQLTuner 2.5.1 - MySQL High Performance Tuning Script |
| 7392 | + MySQLTuner 2.5.2 - MySQL High Performance Tuning Script |
7375 | 7393 |
|
7376 | 7394 | =head1 IMPORTANT USAGE GUIDELINES |
7377 | 7395 |
|
|
0 commit comments