|
1 | 1 | #!/usr/bin/env perl
|
2 |
| -# mysqltuner.pl - Version 2.5.3 |
| 2 | +# mysqltuner.pl - Version 2.5.4 |
3 | 3 | # High Performance MySQL Tuning Script
|
4 | 4 | # Copyright (C) 2015-2023 Jean-Marie Renouard - [email protected]
|
5 | 5 | # Copyright (C) 2006-2023 Major Hayden - [email protected]
|
@@ -57,7 +57,7 @@ package main;
|
57 | 57 | #use Env;
|
58 | 58 |
|
59 | 59 | # Set up a few variables for use in the script
|
60 |
| -my $tunerversion = "2.5.3"; |
| 60 | +my $tunerversion = "2.5.4"; |
61 | 61 | my ( @adjvars, @generalrec );
|
62 | 62 |
|
63 | 63 | # Set defaults
|
@@ -215,7 +215,7 @@ package main;
|
215 | 215 | # Activate debug variables
|
216 | 216 | #if ( $opt{debug} ne '' ) { $opt{debug} = 2; }
|
217 | 217 | # Activate experimental calculations and analysis
|
218 |
| - #if ( $opt{experimental} ne '' ) { $opt{experimental} = 1; } |
| 218 | +#if ( $opt{experimental} ne '' ) { $opt{experimental} = 1; } |
219 | 219 |
|
220 | 220 | # check if we need to enable verbose mode
|
221 | 221 | if ( $opt{feature} ne '' ) { $opt{verbose} = 1; }
|
@@ -595,6 +595,8 @@ sub os_setup {
|
595 | 595 | chomp($physical_memory);
|
596 | 596 | chomp($swap_memory);
|
597 | 597 | chomp($os);
|
| 598 | + $physical_memory = $opt{forcemem} |
| 599 | + if ( defined( $opt{forcemem} ) and $opt{forcemem} gt 0 ); |
598 | 600 | $result{'OS'}{'OS Type'} = $os;
|
599 | 601 | $result{'OS'}{'Physical Memory'}{'bytes'} = $physical_memory;
|
600 | 602 | $result{'OS'}{'Physical Memory'}{'pretty'} = hr_bytes($physical_memory);
|
@@ -2054,27 +2056,28 @@ sub system_recommendations {
|
2054 | 2056 | infoprint "User process except mysqld used "
|
2055 | 2057 | . hr_bytes_rnd($omem) . " RAM.";
|
2056 | 2058 | if ( ( 0.15 * $physical_memory ) < $omem ) {
|
2057 |
| - if ( $opt{nondedicated}) { |
2058 |
| - infoprint "No warning with --nondedicated option"; |
2059 |
| - infoprint |
| 2059 | + if ( $opt{nondedicated} ) { |
| 2060 | + infoprint "No warning with --nondedicated option"; |
| 2061 | + infoprint |
2060 | 2062 | "Other user process except mysqld used more than 15% of total physical memory "
|
2061 |
| - . percentage( $omem, $physical_memory ) . "% (" |
2062 |
| - . hr_bytes_rnd($omem) . " / " |
2063 |
| - . hr_bytes_rnd($physical_memory) . ")"; |
2064 |
| - } else { |
| 2063 | + . percentage( $omem, $physical_memory ) . "% (" |
| 2064 | + . hr_bytes_rnd($omem) . " / " |
| 2065 | + . hr_bytes_rnd($physical_memory) . ")"; |
| 2066 | + } |
| 2067 | + else { |
2065 | 2068 |
|
2066 |
| - badprint |
| 2069 | + badprint |
2067 | 2070 | "Other user process except mysqld used more than 15% of total physical memory "
|
2068 |
| - . percentage( $omem, $physical_memory ) . "% (" |
2069 |
| - . hr_bytes_rnd($omem) . " / " |
2070 |
| - . hr_bytes_rnd($physical_memory) . ")"; |
2071 |
| - push( @generalrec, |
| 2071 | + . percentage( $omem, $physical_memory ) . "% (" |
| 2072 | + . hr_bytes_rnd($omem) . " / " |
| 2073 | + . hr_bytes_rnd($physical_memory) . ")"; |
| 2074 | + push( @generalrec, |
2072 | 2075 | "Consider stopping or dedicate server for additional process other than mysqld."
|
2073 |
| - ); |
2074 |
| - push( @adjvars, |
| 2076 | + ); |
| 2077 | + push( @adjvars, |
2075 | 2078 | "DON'T APPLY SETTINGS BECAUSE THERE ARE TOO MANY PROCESSES RUNNING ON THIS SERVER. OOM KILL CAN OCCUR!"
|
2076 |
| - ); |
2077 |
| - } |
| 2079 | + ); |
| 2080 | + } |
2078 | 2081 | }
|
2079 | 2082 | else {
|
2080 | 2083 | infoprint
|
@@ -2548,7 +2551,7 @@ sub check_architecture {
|
2548 | 2551 | }
|
2549 | 2552 | elsif ( `uname` =~ /Darwin/ && `uname -m` =~ /x86_64/ ) {
|
2550 | 2553 |
|
2551 |
| -# Darwin gibas.local 12.5.3 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 |
| 2554 | +# Darwin gibas.local 12.5.4 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 |
2552 | 2555 | $arch = 64;
|
2553 | 2556 | goodprint "Operating on 64-bit architecture";
|
2554 | 2557 | }
|
@@ -3233,12 +3236,14 @@ sub calculations {
|
3233 | 3236 | $mystat{'Innodb_buffer_pool_pages_total'}
|
3234 | 3237 | ) if defined $mystat{'Innodb_buffer_pool_pages_total'};
|
3235 | 3238 |
|
3236 |
| - my $lreq= "select ROUND( 100* sum(allocated)/ ". |
3237 |
| - $myvar{'innodb_buffer_pool_size'} . |
3238 |
| - ',1) FROM sys.x\$innodb_buffer_stats_by_table;'; |
3239 |
| - debugprint("lreq: $lreq"); |
3240 |
| - $mycalc{'innodb_buffer_alloc_pct'} = select_one( $lreq ) |
3241 |
| - if ($opt{experimental}); |
| 3239 | + my $lreq = |
| 3240 | + "select ROUND( 100* sum(allocated)/ " |
| 3241 | + . $myvar{'innodb_buffer_pool_size'} |
| 3242 | + . ',1) FROM sys.x\$innodb_buffer_stats_by_table;'; |
| 3243 | + debugprint("lreq: $lreq"); |
| 3244 | + $mycalc{'innodb_buffer_alloc_pct'} = select_one($lreq) |
| 3245 | + if ( $opt{experimental} ); |
| 3246 | + |
3242 | 3247 | # Binlog Cache
|
3243 | 3248 | if ( $myvar{'log_bin'} ne 'OFF' ) {
|
3244 | 3249 | $mycalc{'pct_binlog_cache'} = percentage(
|
@@ -3378,22 +3383,25 @@ sub mysql_stats {
|
3378 | 3383 | . " ($mycalc{'pct_max_physical_memory'}% of installed RAM)";
|
3379 | 3384 | }
|
3380 | 3385 |
|
3381 |
| - |
3382 | 3386 | if ( $physical_memory <
|
3383 |
| - ( $mycalc{'max_peak_memory'} + get_other_process_memory() ) ) |
| 3387 | + ( $mycalc{'max_peak_memory'} + get_other_process_memory() ) ) |
3384 | 3388 | {
|
3385 |
| - if ( $opt{nondedicated}) { |
3386 |
| - infoprint "No warning with --nondedicated option"; |
3387 |
| - infoprint "Overall possible memory usage with other process exceeded memory"; |
3388 |
| - } else { |
3389 |
| - badprint |
3390 |
| - "Overall possible memory usage with other process exceeded memory"; |
3391 |
| - push( @generalrec, |
3392 |
| - "Dedicate this server to your database for highest performance." ); |
3393 |
| - } |
3394 |
| - } else { |
3395 |
| - goodprint |
3396 |
| - "Overall possible memory usage with other process is compatible with memory available"; |
| 3389 | + if ( $opt{nondedicated} ) { |
| 3390 | + infoprint "No warning with --nondedicated option"; |
| 3391 | + infoprint |
| 3392 | +"Overall possible memory usage with other process exceeded memory"; |
| 3393 | + } |
| 3394 | + else { |
| 3395 | + badprint |
| 3396 | +"Overall possible memory usage with other process exceeded memory"; |
| 3397 | + push( @generalrec, |
| 3398 | + "Dedicate this server to your database for highest performance." |
| 3399 | + ); |
| 3400 | + } |
| 3401 | + } |
| 3402 | + else { |
| 3403 | + goodprint |
| 3404 | +"Overall possible memory usage with other process is compatible with memory available"; |
3397 | 3405 | }
|
3398 | 3406 |
|
3399 | 3407 | # Slow queries
|
@@ -6390,24 +6398,27 @@ sub mysql_innodb {
|
6390 | 6398 | }
|
6391 | 6399 |
|
6392 | 6400 | # select round( 100* sum(allocated)/( select VARIABLE_VALUE
|
6393 |
| - # FROM performance_schema.global_variables |
| 6401 | + # FROM information_schema.global_variables |
6394 | 6402 | # where VARIABLE_NAME='innodb_buffer_pool_size' )
|
6395 | 6403 | # ,2) as "PCT ALLOC/BUFFER POOL"
|
6396 | 6404 | #from sys.x$innodb_buffer_stats_by_table;
|
6397 | 6405 |
|
6398 | 6406 | if ( $opt{experimental} ) {
|
6399 |
| - debugprint ('innodb_buffer_alloc_pct: "'.$mycalc{innodb_buffer_alloc_pct}.'"'); |
6400 |
| - if (defined $mycalc{innodb_buffer_alloc_pct} and |
6401 |
| - $mycalc{innodb_buffer_alloc_pct} ne '' ) { |
6402 |
| - if ( $mycalc{innodb_buffer_alloc_pct} < 80 ) { |
6403 |
| - badprint "Ratio Buffer Pool allocated / Buffer Pool Size: " |
6404 |
| - . $mycalc{'innodb_buffer_alloc_pct'} . '%'; |
6405 |
| - } |
6406 |
| - else { |
6407 |
| - goodprint "Ratio Buffer Pool allocated / Buffer Pool Size: " |
6408 |
| - . $mycalc{'innodb_buffer_alloc_pct'} . '%'; |
| 6407 | + debugprint( 'innodb_buffer_alloc_pct: "' |
| 6408 | + . $mycalc{innodb_buffer_alloc_pct} |
| 6409 | + . '"' ); |
| 6410 | + if ( defined $mycalc{innodb_buffer_alloc_pct} |
| 6411 | + and $mycalc{innodb_buffer_alloc_pct} ne '' ) |
| 6412 | + { |
| 6413 | + if ( $mycalc{innodb_buffer_alloc_pct} < 80 ) { |
| 6414 | + badprint "Ratio Buffer Pool allocated / Buffer Pool Size: " |
| 6415 | + . $mycalc{'innodb_buffer_alloc_pct'} . '%'; |
| 6416 | + } |
| 6417 | + else { |
| 6418 | + goodprint "Ratio Buffer Pool allocated / Buffer Pool Size: " |
| 6419 | + . $mycalc{'innodb_buffer_alloc_pct'} . '%'; |
| 6420 | + } |
6409 | 6421 | }
|
6410 |
| - } |
6411 | 6422 | }
|
6412 | 6423 | if ( $mycalc{'innodb_log_size_pct'} < 20
|
6413 | 6424 | or $mycalc{'innodb_log_size_pct'} > 30 )
|
@@ -6435,7 +6446,7 @@ sub mysql_innodb {
|
6435 | 6446 | . $myvar{'innodb_log_files_in_group'} . " / "
|
6436 | 6447 | . hr_bytes( $myvar{'innodb_buffer_pool_size'} )
|
6437 | 6448 | . " should be equal to 25%";
|
6438 |
| - push( |
| 6449 | + push( |
6439 | 6450 | @adjvars,
|
6440 | 6451 | "innodb_log_file_size should be (="
|
6441 | 6452 | . hr_bytes_rnd(
|
@@ -7228,8 +7239,8 @@ sub headerprint {
|
7228 | 7239 | . "\t * Major Hayden <major\@mhtx.net>\n"
|
7229 | 7240 | . " >> Bug reports, feature requests, and downloads at http://mysqltuner.pl/\n"
|
7230 | 7241 | . " >> Run with '--help' for additional options and output filtering";
|
7231 |
| - debugprint("Debug: ".$opt{debug}); |
7232 |
| - debugprint("Experimental: ".$opt{experimental}); |
| 7242 | + debugprint( "Debug: " . $opt{debug} ); |
| 7243 | + debugprint( "Experimental: " . $opt{experimental} ); |
7233 | 7244 | }
|
7234 | 7245 |
|
7235 | 7246 | sub string2file {
|
@@ -7431,7 +7442,7 @@ sub which {
|
7431 | 7442 |
|
7432 | 7443 | =head1 NAME
|
7433 | 7444 |
|
7434 |
| - MySQLTuner 2.5.3 - MySQL High Performance Tuning Script |
| 7445 | + MySQLTuner 2.5.4 - MySQL High Performance Tuning Script |
7435 | 7446 |
|
7436 | 7447 | =head1 IMPORTANT USAGE GUIDELINES
|
7437 | 7448 |
|
|
0 commit comments