This commit is contained in:
Jean-Marie RENOUARD 2022-12-29 18:36:06 +01:00
commit 6284e95f18
6 changed files with 164 additions and 336 deletions

2
.gitignore vendored
View file

@ -13,3 +13,5 @@ result_*
result.html
result.txt
reports_*
golang/prog-*
.vscode

View file

@ -143,7 +143,9 @@ For previous MySQL 5.6 version, you can follow this command to create a new data
Optional Performance schema and Sysschema installation for MariaDB 10.x
--
Sysschema is not installed by default under MariaDB prior to 10.6
Sysschema is not installed by default under MariaDB prior to 10.6 [MariaDB sys](https://mariadb.com/kb/en/sys-schema/)
By default, on MariaDB, performance schema is disabled by default. consider activating performance schema across your my.cnf configuration file:
[mysqld]
@ -445,4 +447,3 @@ Simple steps to create a pull request:
- Push it back to your repo
- Click the Compare & pull request button
- Click Create pull request to open a new pull request

View file

@ -1,6 +1,6 @@
# NAME
MySQLTuner2.0.5 - MySQL High Performance Tuning Script
MySQLTuner 2.0.10 - MySQL High Performance Tuning Script
# IMPORTANT USAGE GUIDELINES
@ -23,7 +23,8 @@ You must provide the remote server's total memory when connecting to other serve
--mysqladmin <path> Path to a custom mysqladmin executable
--mysqlcmd <path> Path to a custom mysql executable
--defaults-file <path> Path to a custom .my.cnf
--server-log <path> Path to explict log file (error_log)
--defaults-extra-file <path> Path to a extra custom config file
--server-log <path> Path to explicit log file (error_log)
# PERFORMANCE AND REPORTING OPTIONS
@ -45,7 +46,7 @@ You must provide the remote server's total memory when connecting to other serve
# OUTPUT OPTIONS
--silent Don't output anything on screen
--verbose Prints out all options (default: no verbose, dbstat, idxstat, sysstat, tbstat, pfstat)
--verbose Print out all options (default: no verbose, dbstat, idxstat, sysstat, tbstat, pfstat)
--nocolor Don't print output in color
--nogood Remove OK responses
--nobad Remove negative/suggestion responses
@ -53,20 +54,20 @@ You must provide the remote server's total memory when connecting to other serve
--debug Print debug information
--noprocess Consider no other process is running
--dbstat Print database information
--nodbstat Don't Print database information
--nodbstat Don't print database information
--tbstat Print table information
--notbstat Don't Print table information
--notbstat Don't print table information
--colstat Print column information
--nocolstat Don't Print column information
--nocolstat Don't print column information
--idxstat Print index information
--noidxstat Don't Print index information
--noidxstat Don't print index information
--sysstat Print system information
--nosysstat Don't Print system information
--nosysstat Don't print system information
--pfstat Print Performance schema
--nopfstat Don't Print Performance schema
--nopfstat Don't print Performance schema
--bannedports Ports banned separated by comma (,)
--server-log Define specific error_log to analyze
--maxportallowed Number of ports opened allowed on this host
--maxportallowed Number of open ports allowable on this host
--buffers Print global and per-thread buffer values
# PERLDOC

5
build/installStaff.sh Normal file
View file

@ -0,0 +1,5 @@
#!/bin/bash
apt install -y cpanminus libpod-markdown-perl libwww-mechanize-gzip-perl perltidy dos2unix
cpanm File::Util

View file

@ -1,5 +1,5 @@
#!/usr/bin/env perl
# mysqltuner.pl - Version 2.0.7
# mysqltuner.pl - Version 2.0.10
# High Performance MySQL Tuning Script
# Copyright (C) 2006-2022 Major Hayden - major@mhtx.net
# Copyright (C) 2015-2022 Jean-Marie Renouard - jmrenouard@gmail.com
@ -57,7 +57,7 @@ use Cwd 'abs_path';
#use Env;
# Set up a few variables for use in the script
my $tunerversion = "2.0.7";
my $tunerversion = "2.0.10";
my ( @adjvars, @generalrec );
# Set defaults
@ -917,17 +917,21 @@ sub mysql_setup {
return 1;
}
}
elsif ( $opt{'defaults-extra-file'} ne '' and -r "$opt{'defaults-extra-file'}" ) {
elsif ( $opt{'defaults-extra-file'} ne ''
and -r "$opt{'defaults-extra-file'}" )
{
# defaults-extra-file
debugprint "defaults extra file detected: $opt{'defaults-extra-file'}";
my $mysqlclidefaults = `$mysqlcmd --print-defaults`;
debugprint "MySQL Client Extra Default File: $opt{'defaults-extra-file'}";
debugprint
"MySQL Client Extra Default File: $opt{'defaults-extra-file'}";
$mysqllogin = "--defaults-extra-file=" . $opt{'defaults-extra-file'};
my $loginstatus = `$mysqladmincmd $mysqllogin ping 2>&1`;
if ( $loginstatus =~ /mysqld is alive/ ) {
goodprint "Logged in using credentials from extra defaults file account.";
goodprint
"Logged in using credentials from extra defaults file account.";
return 1;
}
}
@ -2240,7 +2244,10 @@ sub validate_mysql_version {
or mysql_version_eq( 10, 5 )
or mysql_version_eq( 10, 6 )
or mysql_version_eq( 10, 7 )
or mysql_version_eq( 10, 8 ) )
or mysql_version_eq( 10, 8 )
or mysql_version_eq( 10, 9 )
or mysql_version_eq( 10, 10 )
or mysql_version_eq( 10, 11 ) )
{
goodprint "Currently running supported MySQL version "
. $myvar{'version'} . "";
@ -2251,7 +2258,8 @@ sub validate_mysql_version {
. $myvar{'version'}
. " is EOL software. Upgrade soon!";
push( @generalrec,
"You are using an unsupported version for production environments" );
"You are using an unsupported version for production environments"
);
push( @generalrec,
"Upgrade as soon as possible to a supported version !" );
@ -2468,7 +2476,7 @@ sub check_storage_engines {
}
$result{'Tables'}{'Fragmented tables'} =
[ select_array
"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"
"SELECT TABLE_SCHEMA, TABLE_NAME, ENGINE, 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"
];
$fragtables = scalar @{ $result{'Tables'}{'Fragmented tables'} };
@ -2558,21 +2566,27 @@ sub check_storage_engines {
# Fragmented tables
if ( $fragtables > 0 ) {
badprint "Total fragmented tables: $fragtables";
push( @generalrec,
"Run OPTIMIZE TABLE to defragment tables for better performance" );
push @generalrec,
'Run ALTER TABLE ... FORCE or OPTIMIZE TABLE to defragment tables for better performance';
my $total_free = 0;
foreach my $table_line ( @{ $result{'Tables'}{'Fragmented tables'} } ) {
my ( $full_table_name, $data_free ) = split( /\s+/, $table_line );
$data_free = 0 if ( !defined($data_free) or $data_free eq '' );
my ( $table_schema, $table_name, $engine, $data_free ) =
split /\t/msx, $table_line;
$data_free = $data_free / 1024 / 1024;
$total_free += $data_free;
my ( $table_schema, $table_name ) = split( /\./, $full_table_name );
push( @generalrec,
" OPTIMIZE TABLE `$table_schema`.`$table_name`; -- can free $data_free MB"
);
my $generalrec;
if ( $engine eq 'InnoDB' ) {
$generalrec =
" ALTER TABLE `$table_schema`.`$table_name` FORCE;";
}
push( @generalrec,
"Total freed space after theses OPTIMIZE TABLE : $total_free Mb" );
else {
$generalrec = " OPTIMIZE TABLE `$table_schema`.`$table_name`;";
}
$generalrec .= " -- can free $data_free MiB";
push @generalrec, $generalrec;
}
push @generalrec,
"Total freed space after defragmentation : $total_free MiB";
}
else {
goodprint "Total fragmented tables: $fragtables";
@ -2629,8 +2643,7 @@ my %mycalc;
sub calculations {
if ( $mystat{'Questions'} < 1 ) {
badprint
"Your server has not answered any queries: cannot continue...";
badprint "Your server has not answered any queries: cannot continue...";
exit 2;
}
@ -3059,7 +3072,8 @@ sub mysql_stats {
. " global + "
. hr_bytes( $mycalc{'per_thread_buffers'} )
. " per thread ($myvar{'max_connections'} max threads)";
infoprint "Performance_schema Max memory usage: " . hr_bytes_rnd( get_pf_memory() );
infoprint "Performance_schema Max memory usage: "
. hr_bytes_rnd( get_pf_memory() );
$result{'Performance_schema'}{'memory'} = get_pf_memory();
$result{'Performance_schema'}{'pretty_memory'} =
hr_bytes_rnd( get_pf_memory() );
@ -3262,7 +3276,7 @@ sub mysql_stats {
}
elsif ( $mystat{'Com_select'} == 0 ) {
badprint
"Query cache cannot be analyzed - no SELECT statements executed";
"Query cache cannot be analyzed: no SELECT statements executed";
}
else {
badprint
@ -3673,8 +3687,8 @@ sub mysql_myisam {
if ( $mycalc{'pct_key_buffer_used'} < 90 ) {
badprint "Key buffer used: $mycalc{'pct_key_buffer_used'}% ("
. hr_bytes( $myvar{'key_buffer_size'} -
$mystat{'Key_blocks_unused'} *
$myvar{'key_cache_block_size'} )
$mystat{'Key_blocks_unused'} * $myvar{'key_cache_block_size'}
)
. " used / "
. hr_bytes( $myvar{'key_buffer_size'} )
. " cache)";
@ -3692,8 +3706,8 @@ sub mysql_myisam {
else {
goodprint "Key buffer used: $mycalc{'pct_key_buffer_used'}% ("
. hr_bytes( $myvar{'key_buffer_size'} -
$mystat{'Key_blocks_unused'} *
$myvar{'key_cache_block_size'} )
$mystat{'Key_blocks_unused'} * $myvar{'key_cache_block_size'}
)
. " used / "
. hr_bytes( $myvar{'key_buffer_size'} )
. " cache)";
@ -3878,9 +3892,9 @@ sub get_pf_memory {
return 0 unless defined $myvar{'performance_schema'};
return 0 if $myvar{'performance_schema'} eq 'OFF';
my @infoPFSMemory = grep /performance_schema.memory/,
my @infoPFSMemory = grep { /\tperformance_schema[.]memory\t/msx }
select_array("SHOW ENGINE PERFORMANCE_SCHEMA STATUS");
return 0 if scalar(@infoPFSMemory) == 0;
@infoPFSMemory == 1 || return 0;
$infoPFSMemory[0] =~ s/.*\s+(\d+)$/$1/g;
return $infoPFSMemory[0];
}
@ -3901,7 +3915,8 @@ sub mysqsl_pfs {
if ( $myvar{'performance_schema'} eq 'ON' ) {
infoprint "Performance_schema is activated.";
debugprint "Performance schema is " . $myvar{'performance_schema'};
infoprint "Memory used by Performance_schema: " . hr_bytes( get_pf_memory() );
infoprint "Memory used by Performance_schema: "
. hr_bytes( get_pf_memory() );
}
unless ( grep /^sys$/, select_array("SHOW DATABASES") ) {
@ -5448,7 +5463,7 @@ sub mariadb_tokudb {
}
infoprint "TokuDB is enabled.";
# All is to done here
# Not implemented
}
# Recommendations for XtraDB
@ -5465,7 +5480,7 @@ sub mariadb_xtradb {
infoprint "XtraDB is enabled.";
infoprint "Note that MariaDB 10.2 makes use of InnoDB, not XtraDB."
# All is to done here
# Not implemented
}
# Recommendations for RocksDB
@ -5481,7 +5496,7 @@ sub mariadb_rockdb {
}
infoprint "RocksDB is enabled.";
# All is to do here
# Not implemented
}
# Recommendations for Spider
@ -5497,7 +5512,7 @@ sub mariadb_spider {
}
infoprint "Spider is enabled.";
# All is to do here
# Not implemented
}
# Recommendations for Connect
@ -5513,7 +5528,7 @@ sub mariadb_connect {
}
infoprint "Connect is enabled.";
# All is to do here
# Not implemented
}
# Perl trim function to remove whitespace from the start and end of the string
@ -5775,7 +5790,8 @@ having sum(if(c.column_key in ('PRI','UNI'), 1,0)) = 0"
}
else {
badprint "Galera Notify command is not defined.";
push( @adjvars, "set up parameter wsrep_notify_cmd to be notified" );
push( @adjvars,
"set up parameter wsrep_notify_cmd to be notified" );
}
if ( trim( $myvar{'wsrep_sst_method'} ) !~ "^xtrabackup.*"
and trim( $myvar{'wsrep_sst_method'} ) !~ "^mariabackup" )
@ -6925,7 +6941,7 @@ __END__
=head1 NAME
MySQLTuner 2.0.7 - MySQL High Performance Tuning Script
MySQLTuner 2.0.10 - MySQL High Performance Tuning Script
=head1 IMPORTANT USAGE GUIDELINES

File diff suppressed because one or more lines are too long