Merge pull request #524 from grooverdan/aria_myisam

Aria/MyISAM cleanup
This commit is contained in:
Jean-Marie Renouard 2021-01-27 21:27:12 +01:00 committed by GitHub
commit 3a7bf40c83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -403,7 +403,7 @@ sub pretty_uptime {
} }
# Retrieves the memory installed on this machine # Retrieves the memory installed on this machine
my ( $physical_memory, $swap_memory, $duflags ); my ( $physical_memory, $swap_memory, $duflags, $xargsflags );
sub memerror { sub memerror {
badprint badprint
@ -414,6 +414,7 @@ sub memerror {
sub os_setup { sub os_setup {
my $os = `uname`; my $os = `uname`;
$duflags = ( $os =~ /Linux/ ) ? '-b' : ''; $duflags = ( $os =~ /Linux/ ) ? '-b' : '';
$xargsflags = ( $os =~ /Darwin|SunOS/ ) ? '' : '-r';
if ( $opt{'forcemem'} > 0 ) { if ( $opt{'forcemem'} > 0 ) {
$physical_memory = $opt{'forcemem'} * 1048576; $physical_memory = $opt{'forcemem'} * 1048576;
infoprint "Assuming $opt{'forcemem'} MB of physical memory"; infoprint "Assuming $opt{'forcemem'} MB of physical memory";
@ -2562,9 +2563,12 @@ sub calculations {
my $size = 0; my $size = 0;
$size += (split)[0] $size += (split)[0]
for for
`find $myvar{'datadir'} -name "*.MYI" 2>&1 | xargs du -L $duflags 2>&1`; `find "$myvar{'datadir'}" -name "*.MYI" -print0 2>&1 | xargs $xargsflags -0 du -L $duflags 2>&1`;
$mycalc{'total_myisam_indexes'} = $size; $mycalc{'total_myisam_indexes'} = $size;
$mycalc{'total_aria_indexes'} = 0; $size = 0 + (split)[0]
for
`find "$myvar{'datadir'}" -name "*.MAI" -print0 2>&1 | xargs $xargsflags -0 du -L $duflags 2>&1`;
$mycalc{'total_aria_indexes'} = $size;
} }
elsif ( mysql_version_ge(5) ) { elsif ( mysql_version_ge(5) ) {
$mycalc{'total_myisam_indexes'} = select_one $mycalc{'total_myisam_indexes'} = select_one
@ -2572,20 +2576,10 @@ sub calculations {
$mycalc{'total_aria_indexes'} = select_one $mycalc{'total_aria_indexes'} = select_one
"SELECT IFNULL(SUM(INDEX_LENGTH),0) FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN ('information_schema') AND ENGINE = 'Aria';"; "SELECT IFNULL(SUM(INDEX_LENGTH),0) FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN ('information_schema') AND ENGINE = 'Aria';";
} }
if ( defined $mycalc{'total_myisam_indexes'} if ( defined $mycalc{'total_myisam_indexes'} ) {
and $mycalc{'total_myisam_indexes'} == 0 )
{
$mycalc{'total_myisam_indexes'} = "fail";
}
elsif ( defined $mycalc{'total_myisam_indexes'} ) {
chomp( $mycalc{'total_myisam_indexes'} ); chomp( $mycalc{'total_myisam_indexes'} );
} }
if ( defined $mycalc{'total_aria_indexes'} if ( defined $mycalc{'total_aria_indexes'} ) {
and $mycalc{'total_aria_indexes'} == 0 )
{
$mycalc{'total_aria_indexes'} = 1;
}
elsif ( defined $mycalc{'total_aria_indexes'} ) {
chomp( $mycalc{'total_aria_indexes'} ); chomp( $mycalc{'total_aria_indexes'} );
} }
@ -3390,19 +3384,11 @@ sub mysql_myisam {
} }
# Key buffer # Key buffer
if ( !defined( $mycalc{'total_myisam_indexes'} ) and $doremote == 1 ) { if ( !defined( $mycalc{'total_myisam_indexes'} ) ) {
push( @generalrec, push( @generalrec,
"Unable to calculate MyISAM indexes on remote MySQL server < 5.0.0" "Unable to calculate MyISAM index size on MySQL server < 5.0.0"
); );
} }
elsif ( $mycalc{'total_myisam_indexes'} =~ /^fail$/ ) {
badprint
"Cannot calculate MyISAM index size - re-run script as root user";
}
elsif ( $mycalc{'total_myisam_indexes'} == "0" ) {
badprint
"None of your MyISAM tables are indexed - add indexes immediately";
}
else { else {
if ( $myvar{'key_buffer_size'} < $mycalc{'total_myisam_indexes'} if ( $myvar{'key_buffer_size'} < $mycalc{'total_myisam_indexes'}
&& $mycalc{'pct_keys_from_mem'} < 95 ) && $mycalc{'pct_keys_from_mem'} < 95 )
@ -5032,31 +5018,27 @@ sub mysqsl_pfs {
} }
# Recommendations for Ariadb # Recommendations for Aria Engine
sub mariadb_ariadb { sub mariadb_aria {
subheaderprint "AriaDB Metrics"; subheaderprint "Aria Metrics";
# AriaDB # Aria
unless ( defined $myvar{'have_aria'} if ( ! defined $myvar{'have_aria'} )
and $myvar{'have_aria'} eq "YES" )
{ {
infoprint "AriaDB is disabled."; infoprint "Aria Storage Engine not available.";
return; return;
} }
infoprint "AriaDB is enabled."; if ( $myvar{'have_aria'} ne "YES" )
{
infoprint "Aria Storage Engine is disabled.";
return;
}
infoprint "Aria Storage Engine is enabled.";
# Aria pagecache # Aria pagecache
if ( !defined( $mycalc{'total_aria_indexes'} ) and $doremote == 1 ) { if ( !defined( $mycalc{'total_aria_indexes'} ) ) {
push( @generalrec, push( @generalrec,
"Unable to calculate Aria indexes on remote MySQL server < 5.0.0" ); "Unable to calculate Aria index size on MySQL server" );
}
elsif ( $mycalc{'total_aria_indexes'} =~ /^fail$/ ) {
badprint
"Cannot calculate Aria index size - re-run script as root user";
}
elsif ( $mycalc{'total_aria_indexes'} == "0" ) {
badprint
"None of your Aria tables are indexed - add indexes immediately";
} }
else { else {
if ( if (
@ -6389,7 +6371,7 @@ mysqsl_pfs; # Print Performance schema info
mariadb_threadpool; # Print MariaDB ThreadPool stats mariadb_threadpool; # Print MariaDB ThreadPool stats
mysql_myisam; # Print MyISAM stats mysql_myisam; # Print MyISAM stats
mysql_innodb; # Print InnoDB stats mysql_innodb; # Print InnoDB stats
mariadb_ariadb; # Print MariaDB AriaDB stats mariadb_aria; # Print MariaDB Aria stats
mariadb_tokudb; # Print MariaDB Tokudb stats mariadb_tokudb; # Print MariaDB Tokudb stats
mariadb_xtradb; # Print MariaDB XtraDB stats mariadb_xtradb; # Print MariaDB XtraDB stats