1
1
# !/usr/bin/env perl
2
- # mysqltuner.pl - Version 1.9.8
2
+ # mysqltuner.pl - Version 1.9.9
3
3
# High Performance MySQL Tuning Script
4
4
# Copyright (C) 2006-2022 Major Hayden - major@mhtx.net
5
5
# Copyright (C) 2006-2022 Jean-Marie Renouard - jmrenouard@gmail.com
@@ -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 = " 1.9.8 " ;
60
+ my $tunerversion = " 1.9.9 " ;
61
61
my ( @adjvars , @generalrec );
62
62
63
63
# Set defaults
@@ -190,24 +190,24 @@ package main;
190
190
191
191
# check if we need to enable verbose mode
192
192
if ( $opt {verbose } ) {
193
- $opt {checkversion } = 1; # Check for updates to MySQLTuner
194
- $opt {dbstat } = 1; # Print database information
195
- $opt {tbstat } = 1; # Print database information
196
- $opt {idxstat } = 1; # Print index information
197
- $opt {sysstat } = 1; # Print index information
198
- $opt {buffers } = 1; # Print global and per-thread buffer values
199
- $opt {pfstat } = 1; # Print performance schema info.
193
+ $opt {checkversion } = 1; # Check for updates to MySQLTuner
194
+ $opt {dbstat } = 1; # Print database information
195
+ $opt {tbstat } = 1; # Print database information
196
+ $opt {idxstat } = 1; # Print index information
197
+ $opt {sysstat } = 1; # Print index information
198
+ $opt {buffers } = 1; # Print global and per-thread buffer values
199
+ $opt {pfstat } = 1; # Print performance schema info.
200
200
$opt {cvefile } = ' vulnerabilities.csv' ; # CVE File for vulnerability checks
201
201
}
202
202
$opt {nocolor } = 1 if defined ( $opt {outputfile } );
203
203
$opt {tbstat } = 0 if ( $opt {notbstat } == 1 ); # Don't Print table information
204
204
$opt {colstat } = 0 if ( $opt {nocolstat } == 1 ); # Don't Print column information
205
205
$opt {dbstat } = 0 if ( $opt {nodbstat } == 1 ); # Don't Print database information
206
206
$opt {noprocess } = 0
207
- if ( $opt {noprocess } == 1 ); # Don't Print process information
207
+ if ( $opt {noprocess } == 1 ); # Don't Print process information
208
208
$opt {sysstat } = 0 if ( $opt {nosysstat } == 1 ); # Don't Print sysstat information
209
209
$opt {pfstat } = 0
210
- if ( $opt {nopfstat } == 1 ); # Don't Print performance schema information
210
+ if ( $opt {nopfstat } == 1 ); # Don't Print performance schema information
211
211
$opt {idxstat } = 0 if ( $opt {noidxstat } == 1 ); # Don't Print index information
212
212
213
213
# for RPM distributions
@@ -995,7 +995,6 @@ sub mysql_setup {
995
995
exit 1;
996
996
}
997
997
}
998
-
999
998
}
1000
999
1001
1000
# MySQL Request Array
@@ -1004,7 +1003,7 @@ sub select_array {
1004
1003
debugprint " PERFORM: $req " ;
1005
1004
my @result = ` $mysqlcmd $mysqllogin -Bse "\\ w$req " 2>>/dev/null` ;
1006
1005
if ( $? != 0 ) {
1007
- badprint " failed to execute: $req " ;
1006
+ badprint " Failed to execute: $req " ;
1008
1007
badprint " FAIL Execute SQL / return code: $? " ;
1009
1008
debugprint " CMD : $mysqlcmd " ;
1010
1009
debugprint " OPTIONS: $mysqllogin " ;
@@ -1029,7 +1028,7 @@ sub select_one {
1029
1028
debugprint " PERFORM: $req " ;
1030
1029
my $result = ` $mysqlcmd $mysqllogin -Bse "\\ w$req " 2>>/dev/null` ;
1031
1030
if ( $? != 0 ) {
1032
- badprint " failed to execute: $req " ;
1031
+ badprint " Failed to execute: $req " ;
1033
1032
badprint " FAIL Execute SQL / return code: $? " ;
1034
1033
debugprint " CMD : $mysqlcmd " ;
1035
1034
debugprint " OPTIONS: $mysqllogin " ;
@@ -1050,7 +1049,7 @@ sub select_one_g {
1050
1049
debugprint " PERFORM: $req " ;
1051
1050
my @result = ` $mysqlcmd $mysqllogin -re "\\ w$req \\ G" 2>>/dev/null` ;
1052
1051
if ( $? != 0 ) {
1053
- badprint " failed to execute: $req " ;
1052
+ badprint " Failed to execute: $req " ;
1054
1053
badprint " FAIL Execute SQL / return code: $? " ;
1055
1054
debugprint " CMD : $mysqlcmd " ;
1056
1055
debugprint " OPTIONS: $mysqllogin " ;
@@ -1377,7 +1376,7 @@ sub log_file_recommendations {
1377
1376
goodprint " Log file $myvar {'log_error'} exists" ;
1378
1377
my $size = ( stat $myvar {' log_error' } )[7];
1379
1378
infoprint " Log file: "
1380
- . $myvar {' log_error' } . " ("
1379
+ . $myvar {' log_error' } . " ("
1381
1380
. hr_bytes_rnd($size ) . " )" ;
1382
1381
1383
1382
if ( $size > 0 ) {
@@ -2414,7 +2413,7 @@ sub check_storage_engines {
2414
2413
}
2415
2414
$result {' Tables' }{' Fragmented tables' } =
2416
2415
[ select_array
2417
- " SELECT CONCAT(CONCAT(TABLE_SCHEMA, '.'), TABLE_NAME),cast(DATA_FREE as signed) FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN ('information_schema','performance_schema', 'mysql') AND DATA_LENGTH/1024/1024>100 AND cast(DATA_FREE as signed)*100/(DATA_LENGTH+INDEX_LENGTH+cast(DATA_FREE as signed)) > 10 AND NOT ENGINE='MEMORY' $not_innodb "
2416
+ " SELECT CONCAT(CONCAT(TABLE_SCHEMA, '.'), TABLE_NAME),cast(DATA_FREE as signed) FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN ('information_schema', 'performance_schema', 'mysql') AND DATA_LENGTH/1024/1024>100 AND cast(DATA_FREE as signed)*100/(DATA_LENGTH+INDEX_LENGTH+cast(DATA_FREE as signed)) > 10 AND NOT ENGINE='MEMORY' $not_innodb "
2418
2417
];
2419
2418
$fragtables = scalar @{ $result {' Tables' }{' Fragmented tables' } };
2420
2419
@@ -3180,7 +3179,7 @@ sub mysql_stats {
3180
3179
}
3181
3180
elsif ( $result {' Variables' }{' skip_name_resolve' } eq ' OFF' ) {
3182
3181
badprint
3183
- " name resolution is active : a reverse name resolution is made for each new connection and can reduce performance" ;
3182
+ " Name resolution is active: a reverse name resolution is made for each new connection and can reduce performance" ;
3184
3183
push ( @generalrec ,
3185
3184
" Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1"
3186
3185
);
@@ -3481,7 +3480,6 @@ sub mysql_stats {
3481
3480
$mystat {' Table_open_cache_misses' } )
3482
3481
. " requests)" ;
3483
3482
}
3484
-
3485
3483
}
3486
3484
}
3487
3485
@@ -3495,19 +3493,19 @@ sub mysql_stats {
3495
3493
. " ) is in autosizing mode" );
3496
3494
}
3497
3495
elsif ( $myvar {' table_definition_cache' } < $nbtables ) {
3498
- badprint " table_definition_cache("
3496
+ badprint " table_definition_cache ("
3499
3497
. $myvar {' table_definition_cache' }
3500
- . " ) is lower than number of tables($nbtables ) " ;
3498
+ . " ) is less than number of tables ($nbtables ) " ;
3501
3499
push ( @adjvars ,
3502
3500
" table_definition_cache("
3503
3501
. $myvar {' table_definition_cache' } . " ) > "
3504
3502
. $nbtables
3505
3503
. " or -1 (autosizing if supported)" );
3506
3504
}
3507
3505
else {
3508
- goodprint " table_definition_cache("
3506
+ goodprint " table_definition_cache ("
3509
3507
. $myvar {' table_definition_cache' }
3510
- . " ) is upper than number of tables($nbtables )" ;
3508
+ . " ) is greater than number of tables ($nbtables )" ;
3511
3509
}
3512
3510
}
3513
3511
else {
@@ -3738,7 +3736,7 @@ sub mysql_myisam {
3738
3736
sub mariadb_threadpool {
3739
3737
subheaderprint " ThreadPool Metrics" ;
3740
3738
3741
- # AriaDB
3739
+ # MariaDB
3742
3740
unless ( defined $myvar {'have_threadpool'}
3743
3741
&& $myvar {'have_threadpool'} eq " YES" )
3744
3742
{
@@ -3988,7 +3986,7 @@ sub mysqsl_pfs {
3988
3986
if ( $nbL == 1 );
3989
3987
3990
3988
# Top user per io
3991
- subheaderprint "Performance schema: Top 5 user per io ";
3989
+ subheaderprint "Performance schema: Top 5 user per IO ";
3992
3990
$nbL = 1;
3993
3991
for my $lQuery (
3994
3992
select_array(
@@ -4003,7 +4001,7 @@ sub mysqsl_pfs {
4003
4001
if ( $nbL == 1 );
4004
4002
4005
4003
# Top user per io latency
4006
- subheaderprint "Performance schema: Top 5 user per io latency";
4004
+ subheaderprint "Performance schema: Top 5 user per IO latency";
4007
4005
$nbL = 1;
4008
4006
for my $lQuery (
4009
4007
select_array(
@@ -4498,7 +4496,7 @@ sub mysqsl_pfs {
4498
4496
if ( $nbL == 1 );
4499
4497
4500
4498
# Latest file IO by latency
4501
- subheaderprint "Performance schema: Latest FILE IO by latency";
4499
+ subheaderprint "Performance schema: Latest File IO by latency";
4502
4500
$nbL = 1;
4503
4501
for my $lQuery (
4504
4502
select_array(
@@ -4513,7 +4511,7 @@ sub mysqsl_pfs {
4513
4511
if ( $nbL == 1 );
4514
4512
4515
4513
# FILE by IO read bytes
4516
- subheaderprint "Performance schema: FILE by IO read bytes";
4514
+ subheaderprint "Performance schema: File by IO read bytes";
4517
4515
$nbL = 1;
4518
4516
for my $lQuery (
4519
4517
select_array(
@@ -4528,7 +4526,7 @@ sub mysqsl_pfs {
4528
4526
if ( $nbL == 1 );
4529
4527
4530
4528
# FILE by IO written bytes
4531
- subheaderprint "Performance schema: FILE by IO written bytes";
4529
+ subheaderprint "Performance schema: File by IO written bytes";
4532
4530
$nbL = 1;
4533
4531
for my $lQuery (
4534
4532
select_array(
@@ -4543,7 +4541,7 @@ sub mysqsl_pfs {
4543
4541
if ( $nbL == 1 );
4544
4542
4545
4543
# file per IO total latency
4546
- subheaderprint "Performance schema: file per IO total latency";
4544
+ subheaderprint "Performance schema: File per IO total latency";
4547
4545
$nbL = 1;
4548
4546
for my $lQuery (
4549
4547
select_array(
@@ -4679,7 +4677,7 @@ sub mysqsl_pfs {
4679
4677
if ( $nbL == 1 );
4680
4678
4681
4679
# TOP 15 most used index
4682
- subheaderprint "Performance schema: TOP 15 most modified indexes";
4680
+ subheaderprint "Performance schema: Top 15 most modified indexes";
4683
4681
$nbL = 1;
4684
4682
for my $lQuery (
4685
4683
select_array(
@@ -4694,7 +4692,7 @@ sub mysqsl_pfs {
4694
4692
if ( $nbL == 1 );
4695
4693
4696
4694
# TOP 15 high read latency index
4697
- subheaderprint "Performance schema: TOP 15 high read latency index";
4695
+ subheaderprint "Performance schema: Top 15 high read latency index";
4698
4696
$nbL = 1;
4699
4697
for my $lQuery (
4700
4698
select_array(
@@ -4709,7 +4707,7 @@ sub mysqsl_pfs {
4709
4707
if ( $nbL == 1 );
4710
4708
4711
4709
# TOP 15 high insert latency index
4712
- subheaderprint "Performance schema: TOP 15 most modified indexes";
4710
+ subheaderprint "Performance schema: Top 15 most modified indexes";
4713
4711
$nbL = 1;
4714
4712
for my $lQuery (
4715
4713
select_array(
@@ -4724,7 +4722,7 @@ sub mysqsl_pfs {
4724
4722
if ( $nbL == 1 );
4725
4723
4726
4724
# TOP 15 high update latency index
4727
- subheaderprint "Performance schema: TOP 15 high update latency index";
4725
+ subheaderprint "Performance schema: Top 15 high update latency index";
4728
4726
$nbL = 1;
4729
4727
for my $lQuery (
4730
4728
select_array(
@@ -4739,7 +4737,7 @@ sub mysqsl_pfs {
4739
4737
if ( $nbL == 1 );
4740
4738
4741
4739
# TOP 15 high delete latency index
4742
- subheaderprint "Performance schema: TOP 15 high delete latency index";
4740
+ subheaderprint "Performance schema: Top 15 high delete latency index";
4743
4741
$nbL = 1;
4744
4742
for my $lQuery (
4745
4743
select_array(
@@ -4769,7 +4767,7 @@ sub mysqsl_pfs {
4769
4767
if ( $nbL == 1 );
4770
4768
4771
4769
# TOP 15 most used tables
4772
- subheaderprint "Performance schema: TOP 15 most modified tables";
4770
+ subheaderprint "Performance schema: Top 15 most modified tables";
4773
4771
$nbL = 1;
4774
4772
for my $lQuery (
4775
4773
select_array(
@@ -4784,7 +4782,7 @@ sub mysqsl_pfs {
4784
4782
if ( $nbL == 1 );
4785
4783
4786
4784
# TOP 15 high read latency tables
4787
- subheaderprint "Performance schema: TOP 15 high read latency tables";
4785
+ subheaderprint "Performance schema: Top 15 high read latency tables";
4788
4786
$nbL = 1;
4789
4787
for my $lQuery (
4790
4788
select_array(
@@ -4799,7 +4797,7 @@ sub mysqsl_pfs {
4799
4797
if ( $nbL == 1 );
4800
4798
4801
4799
# TOP 15 high insert latency tables
4802
- subheaderprint "Performance schema: TOP 15 high insert latency tables";
4800
+ subheaderprint "Performance schema: Top 15 high insert latency tables";
4803
4801
$nbL = 1;
4804
4802
for my $lQuery (
4805
4803
select_array(
@@ -4814,7 +4812,7 @@ sub mysqsl_pfs {
4814
4812
if ( $nbL == 1 );
4815
4813
4816
4814
# TOP 15 high update latency tables
4817
- subheaderprint "Performance schema: TOP 15 high update latency tables";
4815
+ subheaderprint "Performance schema: Top 15 high update latency tables";
4818
4816
$nbL = 1;
4819
4817
for my $lQuery (
4820
4818
select_array(
@@ -4829,7 +4827,7 @@ sub mysqsl_pfs {
4829
4827
if ( $nbL == 1 );
4830
4828
4831
4829
# TOP 15 high delete latency tables
4832
- subheaderprint "Performance schema: TOP 15 high delete latency tables";
4830
+ subheaderprint "Performance schema: Top 15 high delete latency tables";
4833
4831
$nbL = 1;
4834
4832
for my $lQuery (
4835
4833
select_array(
@@ -5930,7 +5928,7 @@ sub mysql_innodb {
5930
5928
or $mycalc {'innodb_log_size_pct'} > 30 )
5931
5929
{
5932
5930
badprint " Ratio InnoDB log file size / InnoDB Buffer pool size ("
5933
- . $mycalc {'innodb_log_size_pct'} . " %): "
5931
+ . $mycalc {'innodb_log_size_pct'} . " %): "
5934
5932
. hr_bytes( $myvar {'innodb_log_file_size'} ) . " * "
5935
5933
. $myvar {'innodb_log_files_in_group'} . " /"
5936
5934
. hr_bytes( $myvar {'innodb_buffer_pool_size'} )
@@ -5942,7 +5940,7 @@ sub mysql_innodb {
5942
5940
$myvar {'innodb_buffer_pool_size'} /
5943
5941
$myvar {'innodb_log_files_in_group'} / 4
5944
5942
)
5945
- . " ) if possible, so InnoDB total log files size equals to 25% of buffer pool size."
5943
+ . " ) if possible, so InnoDB total log files size equals 25% of buffer pool size."
5946
5944
);
5947
5945
if ( mysql_version_le( 5, 6, 2 ) ) {
5948
5946
push( @generalrec ,
@@ -6020,7 +6018,7 @@ sub mysql_innodb {
6020
6018
" InnoDB Buffer Pool Chunk Size not used or defined in your version" ;
6021
6019
}
6022
6020
else {
6023
- infoprint " Number of InnoDB Buffer Pool Chunk : "
6021
+ infoprint " Number of InnoDB Buffer Pool Chunk: "
6024
6022
. int( $myvar {'innodb_buffer_pool_size'} ) /
6025
6023
int( $myvar {'innodb_buffer_pool_chunk_size'} ) . " for "
6026
6024
. $myvar {'innodb_buffer_pool_instances'}
@@ -6380,7 +6378,6 @@ sub mysql_databases {
6380
6378
. " table column(s ) has same collation defined for all text like column(s )." ;
6381
6379
}
6382
6380
}
6383
-
6384
6381
}
6385
6382
6386
6383
# Recommendations for database columns
@@ -6482,14 +6479,12 @@ sub mysql_tables {
6482
6479
" ALTER TABLE \` $dbname \` .\` $tbname \` MODIFY \` $_ \` $optimal_type ;"
6483
6480
);
6484
6481
}
6485
-
6486
6482
}
6487
6483
else {
6488
6484
goodprint "$dbname .$tbname ($_ ) type: $current_type ";
6489
6485
}
6490
6486
}
6491
6487
}
6492
-
6493
6488
}
6494
6489
}
6495
6490
6630
6625
"Skip Index metrics from information schema missing in this version";
6631
6626
return;
6632
6627
}
6633
-
6634
6628
}
6635
6629
6636
6630
sub mysql_routines() {
6640
6634
"Skip Index metrics from information schema missing in this version";
6641
6635
return;
6642
6636
}
6643
-
6644
6637
}
6645
6638
6646
6639
sub mysql_triggers() {
6650
6643
"Skip Index metrics from information schema missing in this version";
6651
6644
return;
6652
6645
}
6653
-
6654
6646
}
6655
6647
6656
6648
# Take the two recommendation arrays and display them at the end of the output
@@ -6875,7 +6867,7 @@ sub which {
6875
6867
6876
6868
=head1 NAME
6877
6869
6878
- MySQLTuner 1.9.8 - MySQL High Performance Tuning Script
6870
+ MySQLTuner 1.9.9 - MySQL High Performance Tuning Script
6879
6871
6880
6872
=head1 IMPORTANT USAGE GUIDELINES
6881
6873
0 commit comments