From b052706d74e90628ea39d6d130586749b6a448e3 Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Wed, 25 Sep 2019 20:14:14 +0000 Subject: [PATCH 01/43] Adding dos2unix staff --- build/updateStaff.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/updateStaff.sh b/build/updateStaff.sh index 7a6e777..4dd4761 100644 --- a/build/updateStaff.sh +++ b/build/updateStaff.sh @@ -8,7 +8,7 @@ perltidy -b mysqltuner.pl ) echo "* Update CVE list" perl updateCVElist.pl - +dos2unix ../mysqltuner.pl git add ../vulnerabilities.csv ../mysqltuner.pl ../USAGE.md git commit -m 'Update Vulnerabilities list Indenting mysqltuner From fb421bccd141ad1a4594fadb6a8b47ab775ce3c4 Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Wed, 25 Sep 2019 22:21:02 +0200 Subject: [PATCH 02/43] Update basic_passwords.txt adding one of my prefred password :) --- basic_passwords.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/basic_passwords.txt b/basic_passwords.txt index a0556e7..eedec4a 100644 --- a/basic_passwords.txt +++ b/basic_passwords.txt @@ -601,6 +601,8 @@ mysql MySQL dba mypass +mypasswd +mypassword MyNewPass some_pass admin_pass From ebc6619e4fee0cf98c417f67686fafeb2204604e Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Wed, 25 Sep 2019 23:29:22 +0200 Subject: [PATCH 03/43] Bug fix #453 --- mysqltuner.pl | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/mysqltuner.pl b/mysqltuner.pl index 52158af..1d1e466 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -1,5 +1,5 @@ #!/usr/bin/env perl -# mysqltuner.pl - Version 1.7.15 +# mysqltuner.pl - Version 1.7.16 # High Performance MySQL Tuning Script # Copyright (C) 2006-2018 Major Hayden - major@mhtx.net # @@ -56,7 +56,7 @@ $Data::Dumper::Pair = " : "; #use Env; # Set up a few variables for use in the script -my $tunerversion = "1.7.15"; +my $tunerversion = "1.7.16"; my ( @adjvars, @generalrec ); # Set defaults @@ -1963,26 +1963,27 @@ sub validate_mysql_version { $myvar{'version'} =~ /^(\d+)(?:\.(\d+)|)(?:\.(\d+)|)/; $mysqlverminor ||= 0; $mysqlvermicro ||= 0; - if ( !mysql_version_ge( 5, 1 ) ) { + + if ( mysql_version_eq(8) or mysql_version_eq(5, 6) or mysql_version_eq(5, 7) + or mysql_version_eq(10, 1) or mysql_version_eq(10, 2) or mysql_version_eq(10, 3) + or mysql_version_eq(10, 4) ) + { + goodprint "Currently running supported MySQL version " . $myvar{'version'} . ""; + return; + } + if ( mysql_version_ge( 5 ) or mysql_version_ge( 4 ) or mysql_version_eq(10, 0) ) { badprint "Your MySQL version " . $myvar{'version'} . " is EOL software! Upgrade soon!"; } - elsif ( ( mysql_version_ge(6) and mysql_version_le(9) ) - or mysql_version_ge(12) ) - { - badprint "Currently running unsupported MySQL version " - . $myvar{'version'} . ""; - } - else { - goodprint "Currently running supported MySQL version " - . $myvar{'version'} . ""; - } } # Checks if MySQL version is equal to (major, minor, micro) sub mysql_version_eq { my ( $maj, $min, $mic ) = @_; + my ( $mysqlvermajor, $mysqlverminor, $mysqlvermicro ) = + $myvar{'version'} =~ /^(\d+)(?:\.(\d+)|)(?:\.(\d+)|)/; + return int($mysqlvermajor) == int($maj) if ( !defined($min) && !defined($mic) ); return int($mysqlvermajor) == int($maj) && int($mysqlverminor) == int($min) @@ -1997,6 +1998,9 @@ sub mysql_version_ge { my ( $maj, $min, $mic ) = @_; $min ||= 0; $mic ||= 0; + my ( $mysqlvermajor, $mysqlverminor, $mysqlvermicro ) = + $myvar{'version'} =~ /^(\d+)(?:\.(\d+)|)(?:\.(\d+)|)/; + return int($mysqlvermajor) > int($maj) || ( int($mysqlvermajor) == int($maj) && int($mysqlverminor) > int($min) ) @@ -2010,6 +2014,8 @@ sub mysql_version_le { my ( $maj, $min, $mic ) = @_; $min ||= 0; $mic ||= 0; + my ( $mysqlvermajor, $mysqlverminor, $mysqlvermicro ) = + $myvar{'version'} =~ /^(\d+)(?:\.(\d+)|)(?:\.(\d+)|)/; return int($mysqlvermajor) < int($maj) || ( int($mysqlvermajor) == int($maj) && int($mysqlverminor) < int($min) ) @@ -2021,6 +2027,9 @@ sub mysql_version_le { # Checks if MySQL micro version is lower than equal to (major, minor, micro) sub mysql_micro_version_le { my ( $maj, $min, $mic ) = @_; + my ( $mysqlvermajor, $mysqlverminor, $mysqlvermicro ) = + $myvar{'version'} =~ /^(\d+)(?:\.(\d+)|)(?:\.(\d+)|)/; + return $mysqlvermajor == $maj && ( $mysqlverminor == $min && $mysqlvermicro <= $mic ); @@ -3278,7 +3287,10 @@ sub mysql_stats { # Recommendations for MyISAM sub mysql_myisam { subheaderprint "MyISAM Metrics"; - + if (mysql_version_ge(8) and mysql_version_le(10) ) { + infoprint "MyISAM Metrics are disabled on last MySQL versions."; + return; + } # Key buffer usage if ( defined( $mycalc{'pct_key_buffer_used'} ) ) { if ( $mycalc{'pct_key_buffer_used'} < 90 ) { @@ -6348,7 +6360,7 @@ __END__ =head1 NAME - MySQLTuner 1.7.15 - MySQL High Performance Tuning Script + MySQLTuner 1.7.16 - MySQL High Performance Tuning Script =head1 IMPORTANT USAGE GUIDELINES From 25c002092405d8dd192af90a81889b71c6070afe Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Wed, 25 Sep 2019 23:35:42 +0200 Subject: [PATCH 04/43] Issue importing sys_10.sql #452 Issue importing sys_10.sql #452 --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 0d15b9c..65a50a6 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,11 @@ You can follow this command to create a new database sys containing very useful cd mariadb-sys-master/ mysql -u root -p < ./sys_10.sql +Errors & solutions for performance schema + + ERROR at line 21: Failed to open file './tables/sys_config_data_10.sql -- ported', error: 2 + Have a look at #452 solution given by @ericx + Performance tips -- Metadata statistic updates can impact strongly performance of database servers and MySQLTuner. From 7332f8d5c4086840b9d2be241e7e08d8a04f24f3 Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Wed, 25 Sep 2019 23:50:15 +0200 Subject: [PATCH 05/43] Wrong report of InnoDB Storage engine status #450 Good message is -------- InnoDB Metrics ---------------------------------------------------------------------------- [--] Skipped due to --skipsize option --- mysqltuner.pl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mysqltuner.pl b/mysqltuner.pl index 1d1e466..9a330cd 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -2090,12 +2090,11 @@ sub check_architecture { my ( %enginestats, %enginecount, $fragtables ); sub check_storage_engines { + subheaderprint "Storage Engine Statistics"; if ( $opt{skipsize} eq 1 ) { - subheaderprint "Storage Engine Statistics"; infoprint "Skipped due to --skipsize option"; return; } - subheaderprint "Storage Engine Statistics"; my $engines; if ( mysql_version_ge( 5, 5 ) ) { @@ -5511,6 +5510,10 @@ sub mysql_innodb { && $myvar{'have_innodb'} eq "YES" && defined $enginestats{'InnoDB'} ) { + if ( $opt{skipsize} eq 1 ) { + infoprint "Skipped due to --skipsize option"; + return; + } infoprint "InnoDB is disabled."; if ( mysql_version_ge( 5, 5 ) ) { badprint From b8f191d180cf6430716370a8ca9b57dc38d18c3b Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Thu, 26 Sep 2019 00:41:10 +0200 Subject: [PATCH 06/43] Update error log file analysis --- INTERNALS.md | 11 ++++++++++- README.md | 2 +- mysqltuner.pl | 35 +++++++++++++++++++++++++++++++---- 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/INTERNALS.md b/INTERNALS.md index 31bb2d4..aa6121f 100644 --- a/INTERNALS.md +++ b/INTERNALS.md @@ -6,6 +6,7 @@ * [Get login information steps](#mysqltuner-get-login-information-steps) * [System checks](#mysqltuner-system-checks) * [Server version checks](#mysqltuner-server-version-checks) +* [Error log file checks](#mysql-error-log-file-analysis) * [MySQL Storage engine general information](#mysql-storage-engine-general-information) * [Security checks](#mysqltuner-security-checks) * [CVE checks](#mysqltuner-cve-checks) @@ -39,6 +40,7 @@ * Get information about the tuning connexion * Check current MySQL version * Suggest 64-bit upgrade +* Analyze mysqld error log file * Show enabled storage engines * Show informations about databases (option: --dbstat) * Show informations about indexes (option: --idxstat) @@ -87,6 +89,13 @@ * Currently MySQL < 5.1 are EOF considered. * Using 5.5+ version of MySQL for performance issue (asynchronous IO). +## Mysql error log file analysis +* Look for potential current error log file name +* Check permission on error log file +* Check size on error log file +* Check error and warning on error log file +* Find last start and shutdown on error log file + ## MySQL Storage engine general information * Get storage engine counts/stats @@ -215,7 +224,7 @@ * MySQL needs 1 instance per 1Go of Buffer Pool * innodb_buffer_pool instances = round(innodb_buffer_pool_size / 1Go) * innodb_buffer_pool instances must be equals or lower than 64 - + - A bug in MySQL 5.6 causes SHOW VARIABLES to report an innodb_buffer_pool_instances value of 8 when innodb_buffer_pool_size is less than 1GB and only one buffer pool instance is present (Bug #18343670). * InnoDB Buffer Pool Usage diff --git a/README.md b/README.md index 65a50a6..21a4a79 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ You can follow this command to create a new database sys containing very useful cd mariadb-sys-master/ mysql -u root -p < ./sys_10.sql -Errors & solutions for performance schema +Errors & solutions for performance schema installation ERROR at line 21: Failed to open file './tables/sys_config_data_10.sql -- ported', error: 2 Have a look at #452 solution given by @ericx diff --git a/mysqltuner.pl b/mysqltuner.pl index 9a330cd..0768b79 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -1197,12 +1197,36 @@ sub get_log_file_real_path { if ( -f "$file" ) { return $file; } + elsif ( -f "$hostname.log" ) { + return "$hostname.log"; + } elsif ( -f "$hostname.err" ) { return "$hostname.err"; } - elsif ( $datadir ne "" ) { + elsif ( -f "$datadir$hostname.err" ) { return "$datadir$hostname.err"; } + elsif ( -f "$datadir$hostname.log" ) { + return "$datadir$hostname.log"; + } + elsif ( -f "$datadir"."mysql_error.log" ) { + return "$datadir"."mysql_error.log"; + } + elsif ( -f "/var/log/mysql.log" ) { + return "/var/log/mysql.log"; + } + elsif ( -f "/var/log/mysqld.log" ) { + return "/var/log/mysqld.log"; + } + elsif ( -f "/var/log/mysql/$hostname.err" ) { + return "/var/log/mysql/$hostname.err"; + } + elsif ( -f "/var/log/mysql/$hostname.log" ) { + return "/var/log/mysql/$hostname.log"; + } + elsif ( -f "/var/log/mysql/"."mysql_error.log" ) { + return "/var/log/mysql/"."mysql_error.log"; + } else { return $file; } @@ -1212,16 +1236,19 @@ sub log_file_recommendations { $myvar{'log_error'} = get_log_file_real_path( $myvar{'log_error'}, $myvar{'hostname'}, $myvar{'datadir'} ); + subheaderprint "Log file Recommendations"; - infoprint "Log file: " - . $myvar{'log_error'} . "(" - . hr_bytes_rnd( ( stat $myvar{'log_error'} )[7] ) . ")"; if ( -f "$myvar{'log_error'}" ) { goodprint "Log file $myvar{'log_error'} exists"; } else { badprint "Log file $myvar{'log_error'} doesn't exist"; + return; } + infoprint "Log file: " + . $myvar{'log_error'} . "(" + . hr_bytes_rnd( ( stat $myvar{'log_error'} )[7] ) . ")"; + if ( -r "$myvar{'log_error'}" ) { goodprint "Log file $myvar{'log_error'} is readable."; } From 982410d6e18e71e8ade841bd7832a5ab7f34bf59 Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Thu, 26 Sep 2019 16:39:35 +0000 Subject: [PATCH 07/43] Reordering folder --- bashrc => build/bashrc | 0 runAudit.sh => build/runAudit.sh | 0 sync.sh => build/sync.sh | 0 txt2html.pl => build/txt2html.pl | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename bashrc => build/bashrc (100%) rename runAudit.sh => build/runAudit.sh (100%) rename sync.sh => build/sync.sh (100%) rename txt2html.pl => build/txt2html.pl (100%) diff --git a/bashrc b/build/bashrc similarity index 100% rename from bashrc rename to build/bashrc diff --git a/runAudit.sh b/build/runAudit.sh similarity index 100% rename from runAudit.sh rename to build/runAudit.sh diff --git a/sync.sh b/build/sync.sh similarity index 100% rename from sync.sh rename to build/sync.sh diff --git a/txt2html.pl b/build/txt2html.pl similarity index 100% rename from txt2html.pl rename to build/txt2html.pl From fedc9251117eae838b56496478378dcbc6d73287 Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Thu, 26 Sep 2019 23:51:27 +0200 Subject: [PATCH 08/43] simple load sample manager in command line --- .gitignore | 2 ++ build/fetchDatabase.sh | 25 +++++++++++++++++++++++++ build/manageSamples.sh | 26 ++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 build/fetchDatabase.sh create mode 100644 build/manageSamples.sh diff --git a/.gitignore b/.gitignore index c698ad6..bf0c3bd 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ build/vulnerabilities* Vagrant/Vagrantfile Vagrant/data Vagrant/.vagrant +contents +contents/* diff --git a/build/fetchDatabase.sh b/build/fetchDatabase.sh new file mode 100644 index 0000000..c53a961 --- /dev/null +++ b/build/fetchDatabase.sh @@ -0,0 +1,25 @@ +#!/bin/sh + + +DB_WORLD_URL="https://downloads.mysql.com/docs/world.sql.zip" +DB_WORLDX_URL="https://downloads.mysql.com/docs/world_x-db.zip" +DB_SAKILA_URL="https://downloads.mysql.com/docs/sakila-db.zip" +DB_MESSAGERIE_URL="https://downloads.mysql.com/docs/menagerie-db.zip" +DB_TESTDB_URL="https://github.com/datacharmer/test_db/archive/master.zip" + +getVal() +{ + local vari=$1 + eval "echo \$$vari" +} +case "$1" in + "fetch") + mkdir -p ./contents + wget -O contents/$(basename $(getVal "DB_$2_URL")) $(getVal "DB_$2_URL") + ;; + "load") + ;; + *) + echo "Unknown operation: $1" + ;; +esac \ No newline at end of file diff --git a/build/manageSamples.sh b/build/manageSamples.sh new file mode 100644 index 0000000..888b19f --- /dev/null +++ b/build/manageSamples.sh @@ -0,0 +1,26 @@ +#!/bin/sh + + +DB_WORLD_URL="https://downloads.mysql.com/docs/world.sql.zip" +DB_WORLDX_URL="https://downloads.mysql.com/docs/world_x-db.zip" +DB_SAKILA_URL="https://downloads.mysql.com/docs/sakila-db.zip" +DB_MESSAGERIE_URL="https://downloads.mysql.com/docs/menagerie-db.zip" +DB_TESTDB_URL="https://github.com/datacharmer/test_db/archive/master.zip" + +getVal() +{ + local vari=$1 + eval "echo \$$vari" +} +case "$1" in + "fetch") + set -x + mkdir -p ./contents + wget -O contents/$(basename $(getVal "DB_$2_URL")) $(getVal "DB_$2_URL") + ;; + "load") + ;; + *) + echo "Unknown operation: $1" + ;; +esac \ No newline at end of file From ad8b04b6a4f142228a47bdccbf6047ded7bd1ea3 Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Mon, 30 Sep 2019 20:35:09 +0200 Subject: [PATCH 09/43] support fetchall feature --- build/fetchDatabase.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/build/fetchDatabase.sh b/build/fetchDatabase.sh index c53a961..3b07f8b 100644 --- a/build/fetchDatabase.sh +++ b/build/fetchDatabase.sh @@ -13,11 +13,18 @@ getVal() eval "echo \$$vari" } case "$1" in + "fetchall") + for sample in WORLD WORLDX SAKILA MESSAGERIE TESTDB; do + sh $0 fetch $sample + done + ;; "fetch") + [ -z "$2" ] && exit 1 mkdir -p ./contents wget -O contents/$(basename $(getVal "DB_$2_URL")) $(getVal "DB_$2_URL") ;; "load") + ;; *) echo "Unknown operation: $1" From e2f5c6bdf58ab883df155c1e4b05e97889d390b9 Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Mon, 30 Sep 2019 20:37:42 +0200 Subject: [PATCH 10/43] Renaming staff --- ...tchDatabase.sh => fetchSampleDatabases.sh} | 0 build/manageSamples.sh | 26 ------------------- 2 files changed, 26 deletions(-) rename build/{fetchDatabase.sh => fetchSampleDatabases.sh} (100%) delete mode 100644 build/manageSamples.sh diff --git a/build/fetchDatabase.sh b/build/fetchSampleDatabases.sh similarity index 100% rename from build/fetchDatabase.sh rename to build/fetchSampleDatabases.sh diff --git a/build/manageSamples.sh b/build/manageSamples.sh deleted file mode 100644 index 888b19f..0000000 --- a/build/manageSamples.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh - - -DB_WORLD_URL="https://downloads.mysql.com/docs/world.sql.zip" -DB_WORLDX_URL="https://downloads.mysql.com/docs/world_x-db.zip" -DB_SAKILA_URL="https://downloads.mysql.com/docs/sakila-db.zip" -DB_MESSAGERIE_URL="https://downloads.mysql.com/docs/menagerie-db.zip" -DB_TESTDB_URL="https://github.com/datacharmer/test_db/archive/master.zip" - -getVal() -{ - local vari=$1 - eval "echo \$$vari" -} -case "$1" in - "fetch") - set -x - mkdir -p ./contents - wget -O contents/$(basename $(getVal "DB_$2_URL")) $(getVal "DB_$2_URL") - ;; - "load") - ;; - *) - echo "Unknown operation: $1" - ;; -esac \ No newline at end of file From f7920522ac05d76f6d6b405a0b17531136cbae2e Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Tue, 1 Oct 2019 01:11:38 +0200 Subject: [PATCH 11/43] Tools for test suies based on Docker --- build/bashrc | 36 ++++++++++++++ build/configimg.conf | 15 ++++++ build/createMassDockerImages.sh | 85 +++++++++++++++++++++++++++++++++ build/fetchSampleDatabases.sh | 6 ++- 4 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 build/configimg.conf create mode 100644 build/createMassDockerImages.sh diff --git a/build/bashrc b/build/bashrc index 6913dbb..4bdb844 100644 --- a/build/bashrc +++ b/build/bashrc @@ -6,3 +6,39 @@ alias lh='ls -lsh' alias la='ls -lsa' alias gam='git status | grep "modified" | cut -d: -f2 | xargs -n 1 git add' alias serve="python -m $(python -c 'import sys; print("http.server" if sys.version_info[:2] > (2,7) else "SimpleHTTPServer")')" + + +gen_mysqlalias() +{ + input="$1" + + while IFS='' read -r line + do + [ -z "$line" ] && continue + container_port=$(echo "$line" | cut -d\; -f1) + container_name=$(echo "$line" | cut -d\; -f2) + container_datadir=$(echo "$line" | cut -d\; -f3) + image_name=$(echo "$line" | cut -d\; -f4) + + alias mysql_$container_name="mysql -u root -h 127.0.0.1 -P $container_port" + done < "$input" +} + +exec_mysqls() +{ + input="$1" + db=$2 + sqlfile=$3 + while IFS='' read -r line + do + [ -z "$line" ] && continue + container_port=$(echo "$line" | cut -d\; -f1) + container_name=$(echo "$line" | cut -d\; -f2) + container_datadir=$(echo "$line" | cut -d\; -f3) + image_name=$(echo "$line" | cut -d\; -f4) + + + echo "* Executing $sqlfile on $container_name" + cat $sqlfile | mysql -u root -h 127.0.0.1 -P $container_port + done < "$input" +} \ No newline at end of file diff --git a/build/configimg.conf b/build/configimg.conf new file mode 100644 index 0000000..b641cb7 --- /dev/null +++ b/build/configimg.conf @@ -0,0 +1,15 @@ +3306;mysql80;/var/lib/mysql8;mysql:8.0 +3307;mysql57;/var/lib/mysql57;mysql:5.7 +3308;mysql56;/var/lib/mysql56;mysql:5.6 +3309;mysql55;/var/lib/mysql55;mysql:5.5 + +4306;percona80;/var/lib/percona8;percona/percona-server:8.0 +4307;percona57;/var/lib/percona57;percona/percona-server:5.7 +4308;percona56;/var/lib/percona56;percona/percona-server:5.6 + +5306;mariadb104;/var/lib/mariadb104;mariadb:10.4 +5307;mariadb103;/var/lib/mariadb103;mariadb:10.3 +5308;mariadb102;/var/lib/mariadb102;mariadb:10.2 +5309;mariadb101;/var/lib/mariadb101;mariadb:10.1 +5310;mariadb100;/var/lib/mariadb100;mariadb:10.0 +5311;mariadb55;/var/lib/mariadb55;mariadb:5.5 diff --git a/build/createMassDockerImages.sh b/build/createMassDockerImages.sh new file mode 100644 index 0000000..ceac7df --- /dev/null +++ b/build/createMassDockerImages.sh @@ -0,0 +1,85 @@ +#!/bin/sh + +input="./build/configimg.conf" +default_password="secret" +#rm -f $input +[ -f "$input" ] || echo " +3306;mysql80;/var/lib/mysql8;mysql:8.0 +3307;mysql57;/var/lib/mysql57;mysql:5.7 +3308;mysql56;/var/lib/mysql56;mysql:5.6 +3309;mysql55;/var/lib/mysql55;mysql:5.5 + +4306;percona80;/var/lib/percona8;percona/percona-server:8.0 +4307;percona57;/var/lib/percona57;percona/percona-server:5.7 +4308;percona56;/var/lib/percona56;percona/percona-server:5.6 + +5306;mariadb104;/var/lib/mariadb104;mariadb:10.4 +5307;mariadb103;/var/lib/mariadb103;mariadb:10.3 +5308;mariadb102;/var/lib/mariadb102;mariadb:10.2 +5309;mariadb101;/var/lib/mariadb101;mariadb:10.1 +5310;mariadb100;/var/lib/mariadb100;mariadb:10.0 +5311;mariadb55;/var/lib/mariadb55;mariadb:5.5 +" > $input + + +# + +echo '* PRUNING DOCKER SYSTEM DATA' + +#[ "$1" = "clean" ] || docker system prune -a -f +# download all images +while IFS='' read -r line +do + [ -z "$line" ] && continue + container_port=$(echo "$line" | cut -d\; -f1) + container_name=$(echo "$line" | cut -d\; -f2) + container_datadir=$(echo "$line" | cut -d\; -f3) + image_name=$(echo "$line" | cut -d\; -f4) + + if [ -n "$1" -a "$1" != "clean" ]; then + echo $line | grep -q "$1" + [ $? -eq 0 ] || continue + fi + echo "* PULLING DOCKER IMAGE: $image_name" + docker pull $image_name + + echo "* REMOVING CONTAINER : $image_name" + docker ps -a | grep -qE "$container_name^" + docker rm -f $container_name + + echo "* DELETING DATADIR: $container_datadir" + sudo rm -rf $container_datadir + [ "$1" = "clean" ] && continue + + echo "* CREATING DATADIR: $container_datadir" + sudo mkdir $container_datadir + #sudo chown -R mysql.mysql $container_datadir + sudo chmod 777 $container_datadir + echo "* STARTING CONTAINER: $container_name($container_port/TCP) BASED ON $image_name -> $container_datadir" + set -x + docker run -d -e MYSQL_ROOT_PASSWORD=$default_password -p $container_port:3306 --name $container_name -v $container_datadir:/var/lib/mysql $image_name + set +x + sleep 6s + echo "* LOGS: $container_name" + docker logs $container_name + echo "* LISTING PORTS: $container_name BASED ON $image_name" + docker port $container_name + + echo "* LISTING VOLUMES: $container_name BASED ON $image_name" + docker inspect -f "{{ .Mounts }}" $container_name + + echo "* LISTING $container_datadir" + ls -ls $container_datadir + #break + docker logs $container_name | grep -q "ready for connections" + alias mysql_$container_name="mysql -u root -P $container_port" +done < "$input" + +[ "$1" = "clean" ] || docker system prune -a -f + +echo "* LISTING DOCKER IMAGES" +docker images + +echo "* LISTING DOCKER CONTAINER" +docker ps + diff --git a/build/fetchSampleDatabases.sh b/build/fetchSampleDatabases.sh index 3b07f8b..b0710e7 100644 --- a/build/fetchSampleDatabases.sh +++ b/build/fetchSampleDatabases.sh @@ -21,7 +21,11 @@ case "$1" in "fetch") [ -z "$2" ] && exit 1 mkdir -p ./contents - wget -O contents/$(basename $(getVal "DB_$2_URL")) $(getVal "DB_$2_URL") + [ -f "contents/$(basename $(getVal "DB_$2_URL"))" ] || wget -O contents/$(basename $(getVal "DB_$2_URL")) $(getVal "DB_$2_URL") + [ $? -eq 0 ] && (cd contents;unzip $(basename $(getVal "DB_$2_URL"))) + ;; + "clean") + rm -rf contents ;; "load") From 3fd2e1c3c385b8a2a6ba61c2a4e83e53c6494d8c Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Tue, 1 Oct 2019 01:41:52 +0200 Subject: [PATCH 12/43] Updates on tools for test suites --- build/bashrc | 21 +++++++++++++++++++++ build/createMassDockerImages.sh | 7 +++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/build/bashrc b/build/bashrc index 4bdb844..6fb426a 100644 --- a/build/bashrc +++ b/build/bashrc @@ -24,6 +24,27 @@ gen_mysqlalias() done < "$input" } +exec_mysql() +{ + input="$1" + name=$2 + db=$3 + sqlfile=$4 + while IFS='' read -r line + do + [ -z "$line" ] && continue + echo "$line" | grep -q $name + [ $? -ne 0 ] && continue + container_port=$(echo "$line" | cut -d\; -f1) + container_name=$(echo "$line" | cut -d\; -f2) + container_datadir=$(echo "$line" | cut -d\; -f3) + image_name=$(echo "$line" | cut -d\; -f4) + + + echo "* Executing $sqlfile on $container_name" + cat $sqlfile | mysql -u root -h 127.0.0.1 -P $container_port + done < "$input" +} exec_mysqls() { input="$1" diff --git a/build/createMassDockerImages.sh b/build/createMassDockerImages.sh index ceac7df..9e5d419 100644 --- a/build/createMassDockerImages.sh +++ b/build/createMassDockerImages.sh @@ -47,12 +47,14 @@ do docker ps -a | grep -qE "$container_name^" docker rm -f $container_name + if [ 1 -eq 0 ]; then echo "* DELETING DATADIR: $container_datadir" sudo rm -rf $container_datadir [ "$1" = "clean" ] && continue echo "* CREATING DATADIR: $container_datadir" - sudo mkdir $container_datadir + sudo mkdir -p $container_datadir + fi #sudo chown -R mysql.mysql $container_datadir sudo chmod 777 $container_datadir echo "* STARTING CONTAINER: $container_name($container_port/TCP) BASED ON $image_name -> $container_datadir" @@ -72,11 +74,8 @@ do ls -ls $container_datadir #break docker logs $container_name | grep -q "ready for connections" - alias mysql_$container_name="mysql -u root -P $container_port" done < "$input" -[ "$1" = "clean" ] || docker system prune -a -f - echo "* LISTING DOCKER IMAGES" docker images From a9bed2ffa071aafb9fbab11257197ae27098ffc8 Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Wed, 2 Oct 2019 00:07:46 +0200 Subject: [PATCH 13/43] Percona Server 8.0 - better support Lot of bug fixes for percona. --- Vagrant/Vagrantfile | 136 ++++++++-------------- Vagrant/Vagrantfile_for_MariaDB10-0 | 114 ------------------ Vagrant/Vagrantfile_for_MariaDB10-1 | 114 ------------------ Vagrant/Vagrantfile_for_MariaDB10-2 | 107 ----------------- Vagrant/Vagrantfile_for_MariaDB10-3 | 106 ----------------- Vagrant/Vagrantfile_for_MariaDB10-4 | 109 ----------------- Vagrant/Vagrantfile_for_MariaDB10.4 | 109 ----------------- Vagrant/Vagrantfile_for_MySQL5-6 | 107 ----------------- Vagrant/Vagrantfile_for_MySQL5-7 | 105 ----------------- Vagrant/Vagrantfile_for_MySQL8-0 | 106 ----------------- build/bashrc | 4 + build/createMassDockerImages.sh | 11 +- build/createTestEnvs.sh | 25 ++++ build/fetchSampleDatabases.sh | 12 +- build/runMT.sh | 25 ++++ createTestEnvs.sh | 24 ++++ mysqltuner.pl | 174 +++++++++++++--------------- 17 files changed, 222 insertions(+), 1166 deletions(-) delete mode 100644 Vagrant/Vagrantfile_for_MariaDB10-0 delete mode 100644 Vagrant/Vagrantfile_for_MariaDB10-1 delete mode 100644 Vagrant/Vagrantfile_for_MariaDB10-2 delete mode 100644 Vagrant/Vagrantfile_for_MariaDB10-3 delete mode 100644 Vagrant/Vagrantfile_for_MariaDB10-4 delete mode 100644 Vagrant/Vagrantfile_for_MariaDB10.4 delete mode 100644 Vagrant/Vagrantfile_for_MySQL5-6 delete mode 100644 Vagrant/Vagrantfile_for_MySQL5-7 delete mode 100644 Vagrant/Vagrantfile_for_MySQL8-0 create mode 100644 build/createTestEnvs.sh create mode 100644 build/runMT.sh create mode 100644 createTestEnvs.sh diff --git a/Vagrant/Vagrantfile b/Vagrant/Vagrantfile index 99ac1aa..5b82ca7 100644 --- a/Vagrant/Vagrantfile +++ b/Vagrant/Vagrantfile @@ -1,105 +1,71 @@ # -*- mode: ruby -*- # vi: set ft=ruby : -# All Vagrant configuration is done below. The "2" in Vagrant.configure -# configures the configuration version (we support older styles for -# backwards compatibility). Please don't change it unless you know what -# you're doing. -Vagrant.configure(2) do |config| - # The most common configuration options are documented and commented below. - # For a complete reference, please see the online documentation at - # https://docs.vagrantup.com. +Vagrant.configure("2") do |config| + config.vm.box = "generic/fedora30" + config.vm.network "private_network", ip: "192.168.50.10", virtualbox__intnet: false - # Every Vagrant development environment requires a box. You can search for - # boxes at https://atlas.hashicorp.com/search. - - config.vm.box = "centos/7" - # Disable automatic box update checking. If you disable this, then - # boxes will only be checked for updates when the user runs - # `vagrant box outdated`. This is not recommended. - # config.vm.box_check_update = false - #config.vbguest.auto_update = true - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine. In the example below, - # accessing "localhost:8080" will access port 80 on the guest machine. - # config.vm.network "forwarded_port", guest: 80, host: 8080 - - # Create a private network, which allows host-only access to the machine - # using a specific IP. - # config.vm.network "private_network", ip: "192.168.0.115" + if Vagrant.has_plugin? "vagrant-vbguest" + config.vbguest.no_install = true + config.vbguest.auto_update = false + config.vbguest.no_remote = true +end config.hostmanager.enabled = true - config.hostmanager.manage_host = true + config.hostmanager.manage_host = false + config.hostmanager.manage_guest = true config.hostmanager.ignore_private_ip = false config.hostmanager.include_offline = true - - # Create a public network, which generally matched to bridged network. - # Bridged networks make the machine appear as another physical device on - # your network. + config.vm.network "public_network" - config.vm.hostname = 'mysql57' - config.hostmanager.aliases = %w(mysql57.localdomain mysql57.local) - # Share an additional folder to the guest VM. The first argument is - # the path on the host to the actual folder. The second argument is - # the path on the guest to mount the folder. And the optional third - # argument is a set of non-required options. - # config.vm.synced_folder '.', '/vagrant', disabled: true - config.vm.synced_folder "./data", "/data" + config.vm.hostname = 'fedora-generic' + config.hostmanager.aliases = %w(fedora-generic.localdomain fedora-generic.local fcg.local) + + config.vm.synced_folder "/home/jmren/VagrantMachines/VagrantData", "/data" - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # config.vm.provider "virtualbox" do |vb| - vb.name = "mysql57" - vb.memory = "2048" - vb.cpus = 2 + vb.name="fedora-generic" + vb.gui = false + vb.memory = "3036" + vb.cpus = 4 end - # - # View the documentation for the provider you are using for more - # information on available options. - # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies - # such as FTP and Heroku are also available. See the documentation at - # https://docs.vagrantup.com/v2/push/atlas.html for more information. - # config.push.define "atlas" do |push| - # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" - # end - - # Enable provisioning with a shell script. Additional provisioners such as - # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the - # documentation for more information about their specific syntax and use. config.vm.provision "shell", inline: <<-SHELL - sudo yum -y update echo "secret" | sudo passwd --stdin root + echo "secret" | sudo passwd --stdin vagrant sudo cp -pr ~vagrant/.ssh /root sudo chown -R root.root /root/.ssh - sudo yum -y install git python - sudo pip install --upgrade pip - if [ ! -d "/data/MySQLTuner-perl" ]; then - cd /data - sudo git clone https://github.com/major/MySQLTuner-perl.git - fi - - sudo rpm -ivh https://dev.mysql.com/get/mysql57-community-release-fc23-7.noarch.rpm - sudo yum -y install perl-WWW-Mechanize-GZip perl-App-cpanminus perl-List-MoreUtils - sudo cpanm install File::Util - sudo yum -y install mysql-community-server mysql-community-client wget - sudo systemctl start mysqld.service - PASSWORD=$(sudo grep -i "temporary password" /var/log/mysqld.log | cut -d':' -f4 | xargs -n 1 echo) - echo "PASSWORD: $PASSWORD" - mysql -uroot -p$PASSWORD --connect-expired-password -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'MySqlSecr3t#'" - mysql -uroot -psecret -e 'select version();' - cd /data - [ -f "employees_db-full-1.0.6.tar.bz2" ] || sudo wget "https://launchpad.net/test-db/employees-db-1/1.0.6/+download/employees_db-full-1.0.6.tar.bz2" - sudo tar xvjf employees_db-full-1.0.6.tar.bz2 - cd employees_db - cat employees.sql | mysql -uroot -pMySqlSecr3t# + sudo dnf -y update + sudo dnf -y install telnet vim-enhanced net-tools git python python2-pip python34-PyYAML moreutils net-tools python-psutil perl-WWW-Mechanize-GZip perl-App-cpanminus perl-List-MoreUtils vim-enhanced unzip zip jq youtube-dl ffmpeg make mariadb psmisc PyYAML tofrodos python3 chromedriver wget + sudo dnf -y install python34-pip moreutils net-tools python-psutil perl-WWW-Mechanize-GZip perl-App-cpanminus perl-List-MoreUtils vim-enhanced unzip zip jq youtube-dl ffmpeg make mariadb psmisc PyYAML tofrodos python3 wget python-beautifulsoup4 npm rclone golang yum-utils device-mapper-persistent-data lvm2 docker - cd .. - cd MySQLTuner-perl + echo "alias h='function hdi(){ howdoi \$* -c -n 5; }; hdi'" >> /tmp/util.sh + echo "alias s=sudo" >> /tmp/util.sh + echo "alias h=history" >> /tmp/util.sh + echo "alias hserver='python -m http.server 8000'" >> /tmp/util.sh + sudo cp /tmp/util.sh /etc/profile.d + cat /tmp/util.sh - perl mysqltuner.pl --user root --pass MySqlSecr3t# --idxstat --dbstat - SHELL - config.vm.provision :hostmanager + sudo dnf install -y yum-utils device-mapper-persistent-data lvm2 + sudo dnf -y install dnf-plugins-core + sudo dnf config-manager \ + --add-repo \ + https://download.docker.com/linux/fedora/docker-ce.repo + + sudo dnf -y install docker-ce docker-ce-cli containerd.io + dnf list docker-ce --showduplicates | sort -r + + sudo systemctl start docker + sudo systemctl enable docker + sudo usermod -aG docker vagrant + sudo systemctl daemon-reload + + true + +########################################## +# Install container + sudo systemctl restart docker +SHELL + config.vm.provision :hostmanager end + diff --git a/Vagrant/Vagrantfile_for_MariaDB10-0 b/Vagrant/Vagrantfile_for_MariaDB10-0 deleted file mode 100644 index 9794a92..0000000 --- a/Vagrant/Vagrantfile_for_MariaDB10-0 +++ /dev/null @@ -1,114 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# All Vagrant configuration is done below. The "2" in Vagrant.configure -# configures the configuration version (we support older styles for -# backwards compatibility). Please don't change it unless you know what -# you're doing. -Vagrant.configure(2) do |config| - # The most common configuration options are documented and commented below. - # For a complete reference, please see the online documentation at - # https://docs.vagrantup.com. - - # Every Vagrant development environment requires a box. You can search for - # boxes at https://atlas.hashicorp.com/search. - config.vm.box = "centos/7" - # config.vm.box_check_update = false - # config.vbguest.auto_update = true - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine. In the example below, - # accessing "localhost:8080" will access port 80 on the guest machine. - # config.vm.network "forwarded_port", guest: 80, host: 8080 - - if Vagrant.has_plugin?("vagrant-proxyconfx") - config.proxy.http = "http://10.195.50.51:3128/" - config.proxy.https = "http://10.195.50.51:3128/" - config.proxy.no_proxy = "localhost,127.0.0.1,.example.com" - end - - # Create a private network, which allows host-only access to the machine - # using a specific IP. - # config.vm.network "private_network", ip: "192.168.0.100" - config.hostmanager.enabled = true - config.hostmanager.manage_host = true - config.hostmanager.ignore_private_ip = false - config.hostmanager.include_offline = true - - # Create a public network, which generally matched to bridged network. - # Bridged networks make the machine appear as another physical device on - # your network. - config.vm.network "public_network" - config.vm.hostname = 'maria100' - config.hostmanager.aliases = %w(maria100.localdomain maria100.local) - # Share an additional folder to the guest VM. The first argument is - # the path on the host to the actual folder. The second argument is - # the path on the guest to mount the folder. And the optional third - # argument is a set of non-required options. - config.vm.synced_folder "./data", "/data" - - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # - config.vm.provider "virtualbox" do |vb| - # # Display the VirtualBox GUI when booting the machine - # vb.gui = false - # - # # Customize the amount of memory on the VM: - vb.memory = "1024" - end - # - # View the documentation for the provider you are using for more - # information on available options. - - # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies - # such as FTP and Heroku are also available. See the documentation at - # https://docs.vagrantup.com/v2/push/atlas.html for more information. - # config.push.define "atlas" do |push| - # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" - # end - - # Enable provisioning with a shell script. Additional provisioners such as - # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the - # documentation for more information about their specific syntax and use. - config.vm.provision "shell", inline: <<-SHELL - sudo yum -y update - echo "secret" | sudo passwd --stdin root - sudo cp -pr ~vagrant/.ssh /root - sudo chown -R root.root /root/.ssh - - sudo yum-config-manager --enable base - -echo "[mariadb]" >/tmp/mariadb.repo -echo "name = MariaDB" >>/tmp/mariadb.repo -echo "baseurl = http://yum.mariadb.org/10.0/centos7-amd64" >> /tmp/mariadb.repo -echo "gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB" >> /tmp/mariadb.repo -echo "gpgcheck=1" >> /tmp/mariadb.repo -sudo cp /tmp/mariadb.repo /etc/yum.repos.d/ - - sudo rpm -Uvh http://mirrors.ircam.fr/pub/fedora/epel/7/x86_64/e/epel-release-latest.noarch.rpm - - - sudo yum -y install python2-pip git python perl-WWW-Mechanize-GZip perl-App-cpanminus perl-List-MoreUtils MariaDB-server MariaDB-Client wget - - sudo pip install --upgrade pip - if [ ! -d "/data/MySQLTuner-perl" ]; then - cd /data - sudo git clone https://github.com/major/MySQLTuner-perl.git - fi - sudo cpanm install File::Util - - #sudo systemctl start mariadb.service - sudo service mysql start - mysql -e 'select version();' - cd /data - sudo wget "https://launchpad.net/test-db/employees-db-1/1.0.6/+download/employees_db-full-1.0.6.tar.bz2" - sudo tar xvjf employees_db-full-1.0.6.tar.bz2 - cd employees_db - cat employees.sql | mysql - cd .. - cd MySQLTuner-perl - perl mysqltuner.pl --idxstat --dbstat - SHELL - config.vm.provision :hostmanager -end diff --git a/Vagrant/Vagrantfile_for_MariaDB10-1 b/Vagrant/Vagrantfile_for_MariaDB10-1 deleted file mode 100644 index 238e12e..0000000 --- a/Vagrant/Vagrantfile_for_MariaDB10-1 +++ /dev/null @@ -1,114 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# All Vagrant configuration is done below. The "2" in Vagrant.configure -# configures the configuration version (we support older styles for -# backwards compatibility). Please don't change it unless you know what -# you're doing. -Vagrant.configure(2) do |config| - # The most common configuration options are documented and commented below. - # For a complete reference, please see the online documentation at - # https://docs.vagrantup.com. - - # Every Vagrant development environment requires a box. You can search for - # boxes at https://atlas.hashicorp.com/search. - config.vm.box = "centos/7" - # config.vm.box_check_update = false - config.vbguest.auto_update = true - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine. In the example below, - # accessing "localhost:8080" will access port 80 on the guest machine. - # config.vm.network "forwarded_port", guest: 80, host: 8080 - - if Vagrant.has_plugin?("vagrant-proxyconf") - config.proxy.http = "http://10.195.50.51:3128/" - config.proxy.https = "http://10.195.50.51:3128/" - config.proxy.no_proxy = "localhost,127.0.0.1,.example.com" - end - - # Create a private network, which allows host-only access to the machine - # using a specific IP. - # config.vm.network "private_network", ip: "192.168.0.115" - config.hostmanager.enabled = true - config.hostmanager.manage_host = true - config.hostmanager.ignore_private_ip = false - config.hostmanager.include_offline = true - - # Create a public network, which generally matched to bridged network. - # Bridged networks make the machine appear as another physical device on - # your network. - config.vm.network "public_network" - config.vm.hostname = 'dev.app' - config.hostmanager.aliases = %w(dev.app.localdomain dev.app.local) - # Share an additional folder to the guest VM. The first argument is - # the path on the host to the actual folder. The second argument is - # the path on the guest to mount the folder. And the optional third - # argument is a set of non-required options. - config.vm.synced_folder "./data", "/data" - - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # - config.vm.provider "virtualbox" do |vb| - # # Display the VirtualBox GUI when booting the machine - # vb.gui = false - # - # # Customize the amount of memory on the VM: - vb.memory = "1024" - end - # - # View the documentation for the provider you are using for more - # information on available options. - - # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies - # such as FTP and Heroku are also available. See the documentation at - # https://docs.vagrantup.com/v2/push/atlas.html for more information. - # config.push.define "atlas" do |push| - # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" - # end - - # Enable provisioning with a shell script. Additional provisioners such as - # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the - # documentation for more information about their specific syntax and use. - config.vm.provision "shell", inline: <<-SHELL - sudo yum -y update - echo "secret" | sudo passwd --stdin root - sudo cp -pr ~vagrant/.ssh /root - sudo chown -R root.root /root/.ssh - - sudo yum-config-manager --enable base - -echo "[mariadb]" >/tmp/mariadb.repo -echo "name = MariaDB" >>/tmp/mariadb.repo -echo "baseurl = http://yum.mariadb.org/10.1/centos7-amd64" >> /tmp/mariadb.repo -echo "gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB" >> /tmp/mariadb.repo -echo "gpgcheck=1" >> /tmp/mariadb.repo -sudo cp /tmp/mariadb.repo /etc/yum.repos.d/ - - sudo rpm -Uvh http://mirrors.ircam.fr/pub/fedora/epel/7/x86_64/e/epel-release-7-10.noarch.rpm - - - sudo yum -y install python2-pip git python perl-WWW-Mechanize-GZip perl-App-cpanminus perl-List-MoreUtils MariaDB-server MariaDB-Client wget - - sudo pip install --upgrade pip - if [ ! -d "/data/MySQLTuner-perl" ]; then - cd /data - sudo git clone https://github.com/major/MySQLTuner-perl.git - fi - sudo cpanm install File::Util - - #sudo systemctl start mariadb.service - sudo service mysql start - mysql -e 'select version();' - cd /data - sudo wget "https://launchpad.net/test-db/employees-db-1/1.0.6/+download/employees_db-full-1.0.6.tar.bz2" - sudo tar xvjf employees_db-full-1.0.6.tar.bz2 - cd employees_db - cat employees.sql | mysql - cd .. - cd MySQLTuner-perl - perl mysqltuner.pl --idxstat --dbstat - SHELL - config.vm.provision :hostmanager -end diff --git a/Vagrant/Vagrantfile_for_MariaDB10-2 b/Vagrant/Vagrantfile_for_MariaDB10-2 deleted file mode 100644 index 5739af0..0000000 --- a/Vagrant/Vagrantfile_for_MariaDB10-2 +++ /dev/null @@ -1,107 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# All Vagrant configuration is done below. The "2" in Vagrant.configure -# configures the configuration version (we support older styles for -# backwards compatibility). Please don't change it unless you know what -# you're doing. -Vagrant.configure(2) do |config| - # The most common configuration options are documented and commented below. - # For a complete reference, please see the online documentation at - # https://docs.vagrantup.com. - - # Every Vagrant development environment requires a box. You can search for - # boxes at https://atlas.hashicorp.com/search. - config.vm.box = "fc23-mariadb10-1" - config.vm.box_url = "https://download.fedoraproject.org/pub/fedora/linux/releases/23/Cloud/x86_64/Images/Fedora-Cloud-Base-Vagrant-23-20151030.x86_64.vagrant-virtualbox.box" - # Disable automatic box update checking. If you disable this, then - # boxes will only be checked for updates when the user runs - # `vagrant box outdated`. This is not recommended. - # config.vm.box_check_update = false - config.vbguest.auto_update = true - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine. In the example below, - # accessing "localhost:8080" will access port 80 on the guest machine. - # config.vm.network "forwarded_port", guest: 80, host: 8080 - - # Create a private network, which allows host-only access to the machine - # using a specific IP. - # config.vm.network "private_network", ip: "192.168.0.115" - config.hostmanager.enabled = true - config.hostmanager.manage_host = true - config.hostmanager.ignore_private_ip = false - config.hostmanager.include_offline = true - - # Create a public network, which generally matched to bridged network. - # Bridged networks make the machine appear as another physical device on - # your network. - config.vm.network "public_network" - config.vm.hostname = 'dev.app' - config.hostmanager.aliases = %w(dev.app.localdomain dev.app.local) - # Share an additional folder to the guest VM. The first argument is - # the path on the host to the actual folder. The second argument is - # the path on the guest to mount the folder. And the optional third - # argument is a set of non-required options. - config.vm.synced_folder "./data", "/data" - - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # - config.vm.provider "virtualbox" do |vb| - # # Display the VirtualBox GUI when booting the machine - # vb.gui = false - # - # # Customize the amount of memory on the VM: - vb.memory = "1024" - end - # - # View the documentation for the provider you are using for more - # information on available options. - - # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies - # such as FTP and Heroku are also available. See the documentation at - # https://docs.vagrantup.com/v2/push/atlas.html for more information. - # config.push.define "atlas" do |push| - # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" - # end - - # Enable provisioning with a shell script. Additional provisioners such as - # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the - # documentation for more information about their specific syntax and use. - config.vm.provision "shell", inline: <<-SHELL - sudo yum -y update - echo "secret" | sudo passwd --stdin root - sudo cp -pr ~vagrant/.ssh /root - sudo chown -R root.root /root/.ssh - sudo yum -y install git python - sudo pip install --upgrade pip - if [ ! -d "/data/MySQLTuner-perl" ]; then - cd /data - sudo git clone https://github.com/major/MySQLTuner-perl.git - fi - - echo "# MariaDB 10.1 Fedora repository list - created 2016-01-25 13:11 UTC -# http://mariadb.org/mariadb/repositories/ -[mariadb] -name = MariaDB -baseurl = http://yum.mariadb.org/10.2/fedora23-amd64 -gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB -gpgcheck=1" >> /etc/yum.repos.d/mariadb.repo - sudo yum -y install perl-WWW-Mechanize-GZip perl-App-cpanminus perl-List-MoreUtils - sudo cpanm install File::Util - - sudo yum -y install MariaDB-server MariaDB-client wget - sudo systemctl start mariadb.service - mysql -e 'select version();' - cd /data - sudo wget "https://launchpad.net/test-db/employees-db-1/1.0.6/+download/employees_db-full-1.0.6.tar.bz2" - sudo tar xvjf employees_db-full-1.0.6.tar.bz2 - cd employees_db - cat employees.sql | mysql - cd .. - cd MySQLTuner-perl - perl mysqltuner.pl --idxstat --dbstat - SHELL - config.vm.provision :hostmanager -end diff --git a/Vagrant/Vagrantfile_for_MariaDB10-3 b/Vagrant/Vagrantfile_for_MariaDB10-3 deleted file mode 100644 index a754112..0000000 --- a/Vagrant/Vagrantfile_for_MariaDB10-3 +++ /dev/null @@ -1,106 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# All Vagrant configuration is done below. The "2" in Vagrant.configure -# configures the configuration version (we support older styles for -# backwards compatibility). Please don't change it unless you know what -# you're doing. -Vagrant.configure(2) do |config| - # The most common configuration options are documented and commented below. - # For a complete reference, please see the online documentation at - # https://docs.vagrantup.com. - - # Every Vagrant development environment requires a box. You can search for - # boxes at https://atlas.hashicorp.com/search. - config.vm.box = "centos/7" - # Disable automatic box update checking. If you disable this, then - # boxes will only be checked for updates when the user runs - # `vagrant box outdated`. This is not recommended. - # config.vm.box_check_update = false - config.vbguest.auto_update = true - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine. In the example below, - # accessing "localhost:8080" will access port 80 on the guest machine. - # config.vm.network "forwarded_port", guest: 80, host: 8080 - - # Create a private network, which allows host-only access to the machine - # using a specific IP. - # config.vm.network "private_network", ip: "192.168.0.115" - config.hostmanager.enabled = true - config.hostmanager.manage_host = true - config.hostmanager.ignore_private_ip = false - config.hostmanager.include_offline = true - - # Create a public network, which generally matched to bridged network. - # Bridged networks make the machine appear as another physical device on - # your network. - config.vm.network "public_network" - config.vm.hostname = 'dev.app' - config.hostmanager.aliases = %w(dev.app.localdomain dev.app.local) - # Share an additional folder to the guest VM. The first argument is - # the path on the host to the actual folder. The second argument is - # the path on the guest to mount the folder. And the optional third - # argument is a set of non-required options. - config.vm.synced_folder "./data", "/data" - - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # - config.vm.provider "virtualbox" do |vb| - # # Display the VirtualBox GUI when booting the machine - # vb.gui = false - # - # # Customize the amount of memory on the VM: - vb.memory = "1024" - end - # - # View the documentation for the provider you are using for more - # information on available options. - - # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies - # such as FTP and Heroku are also available. See the documentation at - # https://docs.vagrantup.com/v2/push/atlas.html for more information. - # config.push.define "atlas" do |push| - # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" - # end - - # Enable provisioning with a shell script. Additional provisioners such as - # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the - # documentation for more information about their specific syntax and use. - config.vm.provision "shell", inline: <<-SHELL - sudo yum -y update - echo "secret" | sudo passwd --stdin root - sudo cp -pr ~vagrant/.ssh /root - sudo chown -R root.root /root/.ssh - sudo yum -y install git python - sudo pip install --upgrade pip - if [ ! -d "/data/MySQLTuner-perl" ]; then - cd /data - sudo git clone https://github.com/major/MySQLTuner-perl.git - fi - - echo "# MariaDB 10.1 Fedora repository list - created 2016-01-25 13:11 UTC -# http://mariadb.org/mariadb/repositories/ -[mariadb] -name = MariaDB -baseurl = http://yum.mariadb.org/10.3/fedora23-amd64 -gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB -gpgcheck=1" >> /etc/yum.repos.d/mariadb.repo - sudo yum -y install perl-WWW-Mechanize-GZip perl-App-cpanminus perl-List-MoreUtils - sudo cpanm install File::Util - - sudo yum -y install MariaDB-server MariaDB-client wget - sudo systemctl start mariadb.service - mysql -e 'select version();' - cd /data - sudo wget "https://launchpad.net/test-db/employees-db-1/1.0.6/+download/employees_db-full-1.0.6.tar.bz2" - sudo tar xvjf employees_db-full-1.0.6.tar.bz2 - cd employees_db - cat employees.sql | mysql - cd .. - cd MySQLTuner-perl - perl mysqltuner.pl --idxstat --dbstat - SHELL - config.vm.provision :hostmanager -end diff --git a/Vagrant/Vagrantfile_for_MariaDB10-4 b/Vagrant/Vagrantfile_for_MariaDB10-4 deleted file mode 100644 index 53b36fc..0000000 --- a/Vagrant/Vagrantfile_for_MariaDB10-4 +++ /dev/null @@ -1,109 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# All Vagrant configuration is done below. The "2" in Vagrant.configure -# configures the configuration version (we support older styles for -# backwards compatibility). Please don't change it unless you know what -# you're doing. -Vagrant.configure(2) do |config| - # The most common configuration options are documented and commented below. - # For a complete reference, please see the online documentation at - # https://docs.vagrantup.com. - - # Every Vagrant development environment requires a box. You can search for - # boxes at https://atlas.hashicorp.com/search. - config.vm.box = "centos/7" - # Disable automatic box update checking. If you disable this, then - # boxes will only be checked for updates when the user runs - # `vagrant box outdated`. This is not recommended. - # config.vm.box_check_update = false - config.vbguest.auto_update = true - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine. In the example below, - # accessing "localhost:8080" will access port 80 on the guest machine. - # config.vm.network "forwarded_port", guest: 80, host: 8080 - - # Create a private network, which allows host-only access to the machine - # using a specific IP. - # config.vm.network "private_network", ip: "192.168.0.115" - config.hostmanager.enabled = true - config.hostmanager.manage_host = true - config.hostmanager.ignore_private_ip = false - config.hostmanager.include_offline = true - - # Create a public network, which generally matched to bridged network. - # Bridged networks make the machine appear as another physical device on - # your network. - config.vm.network "public_network" - config.vm.hostname = 'maria104' - config.hostmanager.aliases = %w(maria104.localdomain maria104.local) - # Share an additional folder to the guest VM. The first argument is - # the path on the host to the actual folder. The second argument is - # the path on the guest to mount the folder. And the optional third - # argument is a set of non-required options. - # config.vm.synced_folder '.', '/vagrant', disabled: true - config.vm.synced_folder "./data", "/data" - - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # - config.vm.provider "virtualbox" do |vb| - # # Display the VirtualBox GUI when booting the machine - # vb.gui = false - # - # # Customize the amount of memory on the VM: - vb.name = "maria104" - vb.memory = "2048" - vb.cpus = 2 - end - # - # View the documentation for the provider you are using for more - # information on available options. - - # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies - # such as FTP and Heroku are also available. See the documentation at - # https://docs.vagrantup.com/v2/push/atlas.html for more information. - # config.push.define "atlas" do |push| - # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" - # end - - # Enable provisioning with a shell script. Additional provisioners such as - # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the - # documentation for more information about their specific syntax and use. - config.vm.provision "shell", inline: <<-SHELL - sudo yum -y update - echo "secret" | sudo passwd --stdin root - sudo cp -pr ~vagrant/.ssh /root - sudo chown -R root.root /root/.ssh - sudo yum -y install git python - sudo pip install --upgrade pip - if [ ! -d "/data/MySQLTuner-perl" ]; then - cd /data - sudo git clone https://github.com/major/MySQLTuner-perl.git - fi - - echo "# MariaDB 10.1 Fedora repository list - created 2016-01-25 13:11 UTC -# http://mariadb.org/mariadb/repositories/ -[mariadb] -name = MariaDB -baseurl = http://yum.mariadb.org/10.4/rhel7-amd64 -gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB -gpgcheck=1" >> /etc/yum.repos.d/mariadb.repo - sudo yum -y install perl-WWW-Mechanize-GZip perl-App-cpanminus perl-List-MoreUtils - sudo cpanm install File::Util - - sudo yum -y install MariaDB-server MariaDB-client wget - sudo systemctl start mariadb.service - mysql -e 'select version();' - cd /data - sudo wget "https://launchpad.net/test-db/employees-db-1/1.0.6/+download/employees_db-full-1.0.6.tar.bz2" - sudo tar xvjf employees_db-full-1.0.6.tar.bz2 - cd employees_db - cat employees.sql | mysql - cd .. - cd MySQLTuner-perl - perl mysqltuner.pl --idxstat --dbstat - SHELL - config.vm.provision :hostmanager -end diff --git a/Vagrant/Vagrantfile_for_MariaDB10.4 b/Vagrant/Vagrantfile_for_MariaDB10.4 deleted file mode 100644 index 53b36fc..0000000 --- a/Vagrant/Vagrantfile_for_MariaDB10.4 +++ /dev/null @@ -1,109 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# All Vagrant configuration is done below. The "2" in Vagrant.configure -# configures the configuration version (we support older styles for -# backwards compatibility). Please don't change it unless you know what -# you're doing. -Vagrant.configure(2) do |config| - # The most common configuration options are documented and commented below. - # For a complete reference, please see the online documentation at - # https://docs.vagrantup.com. - - # Every Vagrant development environment requires a box. You can search for - # boxes at https://atlas.hashicorp.com/search. - config.vm.box = "centos/7" - # Disable automatic box update checking. If you disable this, then - # boxes will only be checked for updates when the user runs - # `vagrant box outdated`. This is not recommended. - # config.vm.box_check_update = false - config.vbguest.auto_update = true - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine. In the example below, - # accessing "localhost:8080" will access port 80 on the guest machine. - # config.vm.network "forwarded_port", guest: 80, host: 8080 - - # Create a private network, which allows host-only access to the machine - # using a specific IP. - # config.vm.network "private_network", ip: "192.168.0.115" - config.hostmanager.enabled = true - config.hostmanager.manage_host = true - config.hostmanager.ignore_private_ip = false - config.hostmanager.include_offline = true - - # Create a public network, which generally matched to bridged network. - # Bridged networks make the machine appear as another physical device on - # your network. - config.vm.network "public_network" - config.vm.hostname = 'maria104' - config.hostmanager.aliases = %w(maria104.localdomain maria104.local) - # Share an additional folder to the guest VM. The first argument is - # the path on the host to the actual folder. The second argument is - # the path on the guest to mount the folder. And the optional third - # argument is a set of non-required options. - # config.vm.synced_folder '.', '/vagrant', disabled: true - config.vm.synced_folder "./data", "/data" - - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # - config.vm.provider "virtualbox" do |vb| - # # Display the VirtualBox GUI when booting the machine - # vb.gui = false - # - # # Customize the amount of memory on the VM: - vb.name = "maria104" - vb.memory = "2048" - vb.cpus = 2 - end - # - # View the documentation for the provider you are using for more - # information on available options. - - # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies - # such as FTP and Heroku are also available. See the documentation at - # https://docs.vagrantup.com/v2/push/atlas.html for more information. - # config.push.define "atlas" do |push| - # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" - # end - - # Enable provisioning with a shell script. Additional provisioners such as - # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the - # documentation for more information about their specific syntax and use. - config.vm.provision "shell", inline: <<-SHELL - sudo yum -y update - echo "secret" | sudo passwd --stdin root - sudo cp -pr ~vagrant/.ssh /root - sudo chown -R root.root /root/.ssh - sudo yum -y install git python - sudo pip install --upgrade pip - if [ ! -d "/data/MySQLTuner-perl" ]; then - cd /data - sudo git clone https://github.com/major/MySQLTuner-perl.git - fi - - echo "# MariaDB 10.1 Fedora repository list - created 2016-01-25 13:11 UTC -# http://mariadb.org/mariadb/repositories/ -[mariadb] -name = MariaDB -baseurl = http://yum.mariadb.org/10.4/rhel7-amd64 -gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB -gpgcheck=1" >> /etc/yum.repos.d/mariadb.repo - sudo yum -y install perl-WWW-Mechanize-GZip perl-App-cpanminus perl-List-MoreUtils - sudo cpanm install File::Util - - sudo yum -y install MariaDB-server MariaDB-client wget - sudo systemctl start mariadb.service - mysql -e 'select version();' - cd /data - sudo wget "https://launchpad.net/test-db/employees-db-1/1.0.6/+download/employees_db-full-1.0.6.tar.bz2" - sudo tar xvjf employees_db-full-1.0.6.tar.bz2 - cd employees_db - cat employees.sql | mysql - cd .. - cd MySQLTuner-perl - perl mysqltuner.pl --idxstat --dbstat - SHELL - config.vm.provision :hostmanager -end diff --git a/Vagrant/Vagrantfile_for_MySQL5-6 b/Vagrant/Vagrantfile_for_MySQL5-6 deleted file mode 100644 index 7d4b230..0000000 --- a/Vagrant/Vagrantfile_for_MySQL5-6 +++ /dev/null @@ -1,107 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# All Vagrant configuration is done below. The "2" in Vagrant.configure -# configures the configuration version (we support older styles for -# backwards compatibility). Please don't change it unless you know what -# you're doing. -Vagrant.configure(2) do |config| - # The most common configuration options are documented and commented below. - # For a complete reference, please see the online documentation at - # https://docs.vagrantup.com. - - # Every Vagrant development environment requires a box. You can search for - # boxes at https://atlas.hashicorp.com/search. - config.vm.box = "fc23-mysql5-6" - config.vm.box_url = "https://download.fedoraproject.org/pub/fedora/linux/releases/23/Cloud/x86_64/Images/Fedora-Cloud-Base-Vagrant-23-20151030.x86_64.vagrant-virtualbox.box" - # Disable automatic box update checking. If you disable this, then - # boxes will only be checked for updates when the user runs - # `vagrant box outdated`. This is not recommended. - # config.vm.box_check_update = false - config.vbguest.auto_update = true - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine. In the example below, - # accessing "localhost:8080" will access port 80 on the guest machine. - # config.vm.network "forwarded_port", guest: 80, host: 8080 - - # Create a private network, which allows host-only access to the machine - # using a specific IP. - # config.vm.network "private_network", ip: "192.168.0.115" - config.hostmanager.enabled = true - config.hostmanager.manage_host = true - config.hostmanager.ignore_private_ip = false - config.hostmanager.include_offline = true - - # Create a public network, which generally matched to bridged network. - # Bridged networks make the machine appear as another physical device on - # your network. - config.vm.network "public_network" - config.vm.hostname = 'dev.app' - config.hostmanager.aliases = %w(dev.app.localdomain dev.app.local) - # Share an additional folder to the guest VM. The first argument is - # the path on the host to the actual folder. The second argument is - # the path on the guest to mount the folder. And the optional third - # argument is a set of non-required options. - config.vm.synced_folder "./data", "/data" - - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # - config.vm.provider "virtualbox" do |vb| - # # Display the VirtualBox GUI when booting the machine - # vb.gui = false - # - # # Customize the amount of memory on the VM: - vb.memory = "1024" - end - # - # View the documentation for the provider you are using for more - # information on available options. - - # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies - # such as FTP and Heroku are also available. See the documentation at - # https://docs.vagrantup.com/v2/push/atlas.html for more information. - # config.push.define "atlas" do |push| - # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" - # end - - # Enable provisioning with a shell script. Additional provisioners such as - # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the - # documentation for more information about their specific syntax and use. - config.vm.provision "shell", inline: <<-SHELL - sudo yum -y update - echo "secret" | sudo passwd --stdin root - sudo cp -pr ~vagrant/.ssh /root - sudo chown -R root.root /root/.ssh - sudo yum -y install git python yum-utils - sudo pip install --upgrade pip - if [ ! -d "/data/MySQLTuner-perl" ]; then - cd /data - sudo git clone https://github.com/major/MySQLTuner-perl.git - fi - - sudo rpm -ivh https://dev.mysql.com/get/mysql57-community-release-fc23-7.noarch.rpm - sudo yum -y install perl-WWW-Mechanize-GZip perl-App-cpanminus perl-List-MoreUtils - sudo cpanm install File::Util - - sudo yum-config-manager --disable mysql57-community - sudo yum-config-manager --enable mysql56-community - - sudo yum -y install mysql-community-server mysql-community-client wget - sudo systemctl start mysqld.service - - mysql -uroot -e 'select version();' - cd /data - [ -f "employees_db-full-1.0.6.tar.bz2" ] || sudo wget "https://launchpad.net/test-db/employees-db-1/1.0.6/+download/employees_db-full-1.0.6.tar.bz2" - sudo tar xvjf employees_db-full-1.0.6.tar.bz2 - cd employees_db - cat employees.sql | mysql - - cd .. - cd MySQLTuner-perl - - perl mysqltuner.pl --idxstat --dbstat - SHELL - config.vm.provision :hostmanager -end diff --git a/Vagrant/Vagrantfile_for_MySQL5-7 b/Vagrant/Vagrantfile_for_MySQL5-7 deleted file mode 100644 index 04436c0..0000000 --- a/Vagrant/Vagrantfile_for_MySQL5-7 +++ /dev/null @@ -1,105 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# All Vagrant configuration is done below. The "2" in Vagrant.configure -# configures the configuration version (we support older styles for -# backwards compatibility). Please don't change it unless you know what -# you're doing. -Vagrant.configure(2) do |config| - # The most common configuration options are documented and commented below. - # For a complete reference, please see the online documentation at - # https://docs.vagrantup.com. - - # Every Vagrant development environment requires a box. You can search for - # boxes at https://atlas.hashicorp.com/search. - - config.vm.box = "centos/7" - # Disable automatic box update checking. If you disable this, then - # boxes will only be checked for updates when the user runs - # `vagrant box outdated`. This is not recommended. - # config.vm.box_check_update = false - #config.vbguest.auto_update = true - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine. In the example below, - # accessing "localhost:8080" will access port 80 on the guest machine. - # config.vm.network "forwarded_port", guest: 80, host: 8080 - - # Create a private network, which allows host-only access to the machine - # using a specific IP. - # config.vm.network "private_network", ip: "192.168.0.115" - config.hostmanager.enabled = true - config.hostmanager.manage_host = true - config.hostmanager.ignore_private_ip = false - config.hostmanager.include_offline = true - - # Create a public network, which generally matched to bridged network. - # Bridged networks make the machine appear as another physical device on - # your network. - config.vm.network "public_network" - config.vm.hostname = 'mysql57' - config.hostmanager.aliases = %w(mysql57.localdomain mysql57.local) - # Share an additional folder to the guest VM. The first argument is - # the path on the host to the actual folder. The second argument is - # the path on the guest to mount the folder. And the optional third - # argument is a set of non-required options. - # config.vm.synced_folder '.', '/vagrant', disabled: true - config.vm.synced_folder "./data", "/data" - - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # - config.vm.provider "virtualbox" do |vb| - vb.name = "mysql57" - vb.memory = "2048" - vb.cpus = 2 - end - # - # View the documentation for the provider you are using for more - # information on available options. - - # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies - # such as FTP and Heroku are also available. See the documentation at - # https://docs.vagrantup.com/v2/push/atlas.html for more information. - # config.push.define "atlas" do |push| - # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" - # end - - # Enable provisioning with a shell script. Additional provisioners such as - # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the - # documentation for more information about their specific syntax and use. - config.vm.provision "shell", inline: <<-SHELL - sudo yum -y update - echo "secret" | sudo passwd --stdin root - sudo cp -pr ~vagrant/.ssh /root - sudo chown -R root.root /root/.ssh - sudo yum -y install git python - sudo pip install --upgrade pip - if [ ! -d "/data/MySQLTuner-perl" ]; then - cd /data - sudo git clone https://github.com/major/MySQLTuner-perl.git - fi - - sudo rpm -ivh https://dev.mysql.com/get/mysql57-community-release-fc23-7.noarch.rpm - sudo yum -y install perl-WWW-Mechanize-GZip perl-App-cpanminus perl-List-MoreUtils - sudo cpanm install File::Util - - sudo yum -y install mysql-community-server mysql-community-client wget - sudo systemctl start mysqld.service - PASSWORD=$(sudo grep -i "temporary password" /var/log/mysqld.log | cut -d':' -f4 | xargs -n 1 echo) - echo "PASSWORD: $PASSWORD" - mysql -uroot -p$PASSWORD --connect-expired-password -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'MySqlSecr3t#'" - mysql -uroot -psecret -e 'select version();' - cd /data - [ -f "employees_db-full-1.0.6.tar.bz2" ] || sudo wget "https://launchpad.net/test-db/employees-db-1/1.0.6/+download/employees_db-full-1.0.6.tar.bz2" - sudo tar xvjf employees_db-full-1.0.6.tar.bz2 - cd employees_db - cat employees.sql | mysql -uroot -pMySqlSecr3t# - - cd .. - cd MySQLTuner-perl - - perl mysqltuner.pl --user root --pass MySqlSecr3t# --idxstat --dbstat - SHELL - config.vm.provision :hostmanager -end diff --git a/Vagrant/Vagrantfile_for_MySQL8-0 b/Vagrant/Vagrantfile_for_MySQL8-0 deleted file mode 100644 index e8dfe99..0000000 --- a/Vagrant/Vagrantfile_for_MySQL8-0 +++ /dev/null @@ -1,106 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# All Vagrant configuration is done below. The "2" in Vagrant.configure -# configures the configuration version (we support older styles for -# backwards compatibility). Please don't change it unless you know what -# you're doing. -Vagrant.configure(2) do |config| - # The most common configuration options are documented and commented below. - # For a complete reference, please see the online documentation at - # https://docs.vagrantup.com. - - # Every Vagrant development environment requires a box. You can search for - # boxes at https://atlas.hashicorp.com/search. - config.vm.box = "fc23-mysql5-7" - config.vm.box_url = "https://download.fedoraproject.org/pub/fedora/linux/releases/23/Cloud/x86_64/Images/Fedora-Cloud-Base-Vagrant-23-20151030.x86_64.vagrant-virtualbox.box" - # Disable automatic box update checking. If you disable this, then - # boxes will only be checked for updates when the user runs - # `vagrant box outdated`. This is not recommended. - # config.vm.box_check_update = false - config.vbguest.auto_update = true - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine. In the example below, - # accessing "localhost:8080" will access port 80 on the guest machine. - # config.vm.network "forwarded_port", guest: 80, host: 8080 - - # Create a private network, which allows host-only access to the machine - # using a specific IP. - # config.vm.network "private_network", ip: "192.168.0.115" - config.hostmanager.enabled = true - config.hostmanager.manage_host = true - config.hostmanager.ignore_private_ip = false - config.hostmanager.include_offline = true - - # Create a public network, which generally matched to bridged network. - # Bridged networks make the machine appear as another physical device on - # your network. - config.vm.network "public_network" - config.vm.hostname = 'dev.app' - config.hostmanager.aliases = %w(dev.app.localdomain dev.app.local) - # Share an additional folder to the guest VM. The first argument is - # the path on the host to the actual folder. The second argument is - # the path on the guest to mount the folder. And the optional third - # argument is a set of non-required options. - config.vm.synced_folder "./data", "/data" - - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # - config.vm.provider "virtualbox" do |vb| - # # Display the VirtualBox GUI when booting the machine - # vb.gui = false - # - # # Customize the amount of memory on the VM: - vb.memory = "1024" - end - # - # View the documentation for the provider you are using for more - # information on available options. - - # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies - # such as FTP and Heroku are also available. See the documentation at - # https://docs.vagrantup.com/v2/push/atlas.html for more information. - # config.push.define "atlas" do |push| - # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" - # end - - # Enable provisioning with a shell script. Additional provisioners such as - # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the - # documentation for more information about their specific syntax and use. - config.vm.provision "shell", inline: <<-SHELL - sudo yum -y update - echo "secret" | sudo passwd --stdin root - sudo cp -pr ~vagrant/.ssh /root - sudo chown -R root.root /root/.ssh - sudo yum -y install git python - sudo pip install --upgrade pip - if [ ! -d "/data/MySQLTuner-perl" ]; then - cd /data - sudo git clone https://github.com/major/MySQLTuner-perl.git - fi - - sudo rpm -ivh https://dev.mysql.com/get/mysql80-community-release-fc23-7.noarch.rpm - sudo yum -y install perl-WWW-Mechanize-GZip perl-App-cpanminus perl-List-MoreUtils - sudo cpanm install File::Util - - sudo yum -y install mysql-community-server mysql-community-client wget - sudo systemctl start mysqld.service - PASSWORD=$(sudo grep -i "temporary password" /var/log/mysqld.log | cut -d':' -f4 | xargs -n 1 echo) - echo "PASSWORD: $PASSWORD" - mysql -uroot -p$PASSWORD --connect-expired-password -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'MySqlSecr3t#'" - mysql -uroot -psecret -e 'select version();' - cd /data - [ -f "employees_db-full-1.0.6.tar.bz2" ] || sudo wget "https://launchpad.net/test-db/employees-db-1/1.0.6/+download/employees_db-full-1.0.6.tar.bz2" - sudo tar xvjf employees_db-full-1.0.6.tar.bz2 - cd employees_db - cat employees.sql | mysql -uroot -pMySqlSecr3t# - - cd .. - cd MySQLTuner-perl - - #perl mysqltuner.pl --user root --pass MySqlSecr3t# --idxstat --dbstat - SHELL - config.vm.provision :hostmanager -end diff --git a/build/bashrc b/build/bashrc index 6fb426a..18344a8 100644 --- a/build/bashrc +++ b/build/bashrc @@ -7,6 +7,10 @@ alias la='ls -lsa' alias gam='git status | grep "modified" | cut -d: -f2 | xargs -n 1 git add' alias serve="python -m $(python -c 'import sys; print("http.server" if sys.version_info[:2] > (2,7) else "SimpleHTTPServer")')" +dcmd() +{ + docker exec -i -t $1 bash +} gen_mysqlalias() { diff --git a/build/createMassDockerImages.sh b/build/createMassDockerImages.sh index 9e5d419..a100dab 100644 --- a/build/createMassDockerImages.sh +++ b/build/createMassDockerImages.sh @@ -2,7 +2,13 @@ input="./build/configimg.conf" default_password="secret" -#rm -f $input + +eco "[client] +user=root +password=$default_password" > $HOME/.my.cnf + +chmod 600 $HOME/.my.cnf + [ -f "$input" ] || echo " 3306;mysql80;/var/lib/mysql8;mysql:8.0 3307;mysql57;/var/lib/mysql57;mysql:5.7 @@ -21,10 +27,9 @@ default_password="secret" 5311;mariadb55;/var/lib/mariadb55;mariadb:5.5 " > $input - # -echo '* PRUNING DOCKER SYSTEM DATA' +#echo '* PRUNING DOCKER SYSTEM DATA' #[ "$1" = "clean" ] || docker system prune -a -f # download all images diff --git a/build/createTestEnvs.sh b/build/createTestEnvs.sh new file mode 100644 index 0000000..7cc3f2e --- /dev/null +++ b/build/createTestEnvs.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +source build/bashrc +sudo dnf install -y yum-utils device-mapper-persistent-data lvm2 +sudo dnf -y install dnf-plugins-core +sudo dnf config-manager \ +--add-repo \ +https://download.docker.com/linux/fedora/docker-ce.repo + +sudo dnf -y install docker-ce docker-ce-cli containerd.io +dnf list docker-ce --showduplicates | sort -r + +sudo systemctl start docker +sudo systemctl enable docker +sudo usermod -aG docker vagrant +sudo systemctl daemon-reload + + +sh build/createMassDockerImages.sh + +sh build/fetchSampleDatabases.sh clean +sh build/fetchSampleDatabases.sh fetchall + +exec_mysqls build/configimg.conf mysql contents/sakila-db/sakila-schema.sql +exec_mysqls build/configimg.conf mysql contents/sakila-db/sakila-data.sql \ No newline at end of file diff --git a/build/fetchSampleDatabases.sh b/build/fetchSampleDatabases.sh index b0710e7..7116965 100644 --- a/build/fetchSampleDatabases.sh +++ b/build/fetchSampleDatabases.sh @@ -22,15 +22,17 @@ case "$1" in [ -z "$2" ] && exit 1 mkdir -p ./contents [ -f "contents/$(basename $(getVal "DB_$2_URL"))" ] || wget -O contents/$(basename $(getVal "DB_$2_URL")) $(getVal "DB_$2_URL") - [ $? -eq 0 ] && (cd contents;unzip $(basename $(getVal "DB_$2_URL"))) + if [ $? -eq 0 ];then + ( + cd contents + unzip $(basename $(getVal "DB_$2_URL"))) + ) + fi ;; "clean") rm -rf contents ;; - "load") - - ;; - *) + *) echo "Unknown operation: $1" ;; esac \ No newline at end of file diff --git a/build/runMT.sh b/build/runMT.sh new file mode 100644 index 0000000..2bf658d --- /dev/null +++ b/build/runMT.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +input="./build/configimg.conf" + +while IFS='' read -r line +do + [ -z "$line" ] && continue + container_port=$(echo "$line" | cut -d\; -f1) + container_name=$(echo "$line" | cut -d\; -f2) + container_datadir=$(echo "$line" | cut -d\; -f3) + image_name=$(echo "$line" | cut -d\; -f4) + + if [ -n "$1" -a "$1" != "$container_name" ]; then + continue + fi + #set -x + sudo rm -f /var/lib/mysql + sudo ln -sf $container_datadir /var/lib/mysql + sudo chmod 777 /var/lib/mysql + + #sudo docker logs $container_name > /tmp/mysqld.log + ls -ls /var/lib | grep -E 'mysql$' + #set +x + perl mysqltuner.pl --verbose --host 127.0.0.1 --port $container_port +done < "$input" diff --git a/createTestEnvs.sh b/createTestEnvs.sh new file mode 100644 index 0000000..f99a792 --- /dev/null +++ b/createTestEnvs.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +source build/bashrc +sudo dnf install -y yum-utils device-mapper-persistent-data lvm2 +sudo dnf -y install dnf-plugins-core +sudo dnf config-manager \ +--add-repo \ +https://download.docker.com/linux/fedora/docker-ce.repo + +sudo dnf -y install docker-ce docker-ce-cli containerd.io +dnf list docker-ce --showduplicates | sort -r + +sudo systemctl start docker +sudo systemctl enable docker +sudo usermod -aG docker vagrant +sudo systemctl daemon-reload + + +sh build/createMassDockerImages.sh + +sh build/fetchSampleDatabases.sh fetchall + +exec_mysqls build/configimg.conf mysql contents/sakila-db/sakila-schema.sql +exec_mysqls build/configimg.conf mysql contents/sakila-db/sakila-data.sql \ No newline at end of file diff --git a/mysqltuner.pl b/mysqltuner.pl index 0768b79..3e05f28 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -1,5 +1,5 @@ #!/usr/bin/env perl -# mysqltuner.pl - Version 1.7.16 +# mysqltuner.pl - Version 1.7.17 # High Performance MySQL Tuning Script # Copyright (C) 2006-2018 Major Hayden - major@mhtx.net # @@ -56,7 +56,7 @@ $Data::Dumper::Pair = " : "; #use Env; # Set up a few variables for use in the script -my $tunerversion = "1.7.16"; +my $tunerversion = "1.7.17"; my ( @adjvars, @generalrec ); # Set defaults @@ -1238,6 +1238,10 @@ sub log_file_recommendations { $myvar{'datadir'} ); subheaderprint "Log file Recommendations"; + if ( "$myvar{'log_error'}" eq "stderr" ) { + badprint "log_error is set to $myvar{'log_error'} MT can't read stderr"; + return + } if ( -f "$myvar{'log_error'}" ) { goodprint "Log file $myvar{'log_error'} exists"; } @@ -3953,11 +3957,11 @@ sub mysqsl_pfs { if ( $nbL == 1 ); # InnoDB Buffer Pool by table - subheaderprint "Performance schema: InnoDB Buffer Pool by table"; + subheaderprint "Performance schema: 40 InnoDB Buffer Pool by table"; $nbL = 1; for my $lQuery ( select_array( -'select object_schema, object_name, allocated,data, pages from sys.x\\$innodb_buffer_stats_by_table ORDER BY pages DESC' +'select object_schema, object_name, allocated,data, pages from sys.x\\$innodb_buffer_stats_by_table ORDER BY pages DESC LIMIT 40' ) ) { @@ -4013,11 +4017,11 @@ sub mysqsl_pfs { if ( $nbL == 1 ); # High Cost SQL statements - subheaderprint "Performance schema: Top 5 Most latency statements"; + subheaderprint "Performance schema: Top 15 Most latency statements"; $nbL = 1; for my $lQuery ( select_array( -'select query, avg_latency from sys.x\\$statement_analysis order by avg_latency desc LIMIT 5' +'select LEFT(query, 120), avg_latency from sys.x\\$statement_analysis order by avg_latency desc LIMIT 15' ) ) { @@ -4028,11 +4032,11 @@ sub mysqsl_pfs { if ( $nbL == 1 ); # Top 5% slower queries - subheaderprint "Performance schema: Top 5 slower queries"; + subheaderprint "Performance schema: Top 15 slower queries"; $nbL = 1; for my $lQuery ( select_array( -'select query, exec_count from sys.x\\$statements_with_runtimes_in_95th_percentile order by exec_count desc LIMIT 5' +'select LEFT(query, 120), exec_count from sys.x\\$statements_with_runtimes_in_95th_percentile order by exec_count desc LIMIT 15' ) ) { @@ -4043,11 +4047,11 @@ sub mysqsl_pfs { if ( $nbL == 1 ); # Top 10 nb statement type - subheaderprint "Performance schema: Top 10 nb statement type"; + subheaderprint "Performance schema: Top 15 nb statement type"; $nbL = 1; for my $lQuery ( select_array( -'use sys;select statement, sum(total) as total from sys.x\\$host_summary_by_statement_type group by statement order by total desc LIMIT 10;' +'use sys;select statement, sum(total) as total from sys.x\\$host_summary_by_statement_type group by statement order by total desc LIMIT 15;' ) ) { @@ -4058,11 +4062,11 @@ sub mysqsl_pfs { if ( $nbL == 1 ); # Top statement by total latency - subheaderprint "Performance schema: Top statement by total latency"; + subheaderprint "Performance schema: Top 15 statement by total latency"; $nbL = 1; for my $lQuery ( select_array( -'use sys;select statement, sum(total_latency) as total from sys.x\\$host_summary_by_statement_type group by statement order by total desc LIMIT 10;' +'use sys;select statement, sum(total_latency) as total from sys.x\\$host_summary_by_statement_type group by statement order by total desc LIMIT 15;' ) ) { @@ -4073,11 +4077,11 @@ sub mysqsl_pfs { if ( $nbL == 1 ); # Top statement by lock latency - subheaderprint "Performance schema: Top statement by lock latency"; + subheaderprint "Performance schema: Top 15 statement by lock latency"; $nbL = 1; for my $lQuery ( select_array( -'use sys;select statement, sum(lock_latency) as total from sys.x\\$host_summary_by_statement_type group by statement order by total desc LIMIT 10;' +'use sys;select statement, sum(lock_latency) as total from sys.x\\$host_summary_by_statement_type group by statement order by total desc LIMIT 15;' ) ) { @@ -4088,11 +4092,11 @@ sub mysqsl_pfs { if ( $nbL == 1 ); # Top statement by full scans - subheaderprint "Performance schema: Top statement by full scans"; + subheaderprint "Performance schema: Top 15 statement by full scans"; $nbL = 1; for my $lQuery ( select_array( -'use sys;select statement, sum(full_scans) as total from sys.x\\$host_summary_by_statement_type group by statement order by total desc LIMIT 10;' +'use sys;select statement, sum(full_scans) as total from sys.x\\$host_summary_by_statement_type group by statement order by total desc LIMIT 15;' ) ) { @@ -4103,11 +4107,11 @@ sub mysqsl_pfs { if ( $nbL == 1 ); # Top statement by rows sent - subheaderprint "Performance schema: Top statement by rows sent"; + subheaderprint "Performance schema: Top 15 statement by rows sent"; $nbL = 1; for my $lQuery ( select_array( -'use sys;select statement, sum(rows_sent) as total from sys.x\\$host_summary_by_statement_type group by statement order by total desc LIMIT 10;' +'use sys;select statement, sum(rows_sent) as total from sys.x\\$host_summary_by_statement_type group by statement order by total desc LIMIT 15;' ) ) { @@ -4118,11 +4122,11 @@ sub mysqsl_pfs { if ( $nbL == 1 ); # Top statement by rows modified - subheaderprint "Performance schema: Top statement by rows modified"; + subheaderprint "Performance schema: Top 15 statement by rows modified"; $nbL = 1; for my $lQuery ( select_array( -'use sys;select statement, sum(rows_affected) as total from sys.x\\$host_summary_by_statement_type group by statement order by total desc LIMIT 10;' +'use sys;select statement, sum(rows_affected) as total from sys.x\\$host_summary_by_statement_type group by statement order by total desc LIMIT 15;' ) ) { @@ -4133,11 +4137,11 @@ sub mysqsl_pfs { if ( $nbL == 1 ); # Use temporary tables - subheaderprint "Performance schema: Some queries using temp table"; + subheaderprint "Performance schema: 15 sample queries using temp table"; $nbL = 1; for my $lQuery ( select_array( -'use sys;select query from sys.x\\$statements_with_temp_tables LIMIT 20' +'use sys;select left(query, 120) from sys.x\\$statements_with_temp_tables LIMIT 15' ) ) { @@ -4150,7 +4154,7 @@ sub mysqsl_pfs { # Unused Indexes subheaderprint "Performance schema: Unused indexes"; $nbL = 1; - for my $lQuery ( select_array('select * from sys.schema_unused_indexes') ) { + for my $lQuery ( select_array("select \* from sys.schema_unused_indexes where object_schema not in ('performance_schema')" )) { infoprint " +-- $nbL: $lQuery"; $nbL++; } @@ -4530,33 +4534,6 @@ sub mysqsl_pfs { infoprint "No information found or indicators deactivated." if ( $nbL == 1 ); - subheaderprint "Performance schema: Tables not using InnoDB buffer"; - $nbL = 1; - for my $lQuery ( - select_array( -' Select table_schema, table_name from sys.x\\$schema_table_statistics_with_buffer where innodb_buffer_allocated IS NULL;' - ) - ) - { - infoprint " +-- $nbL: $lQuery"; - $nbL++; - } - infoprint "No information found or indicators deactivated." - if ( $nbL == 1 ); - - subheaderprint "Performance schema: Table not using InnoDB buffer"; - $nbL = 1; - for my $lQuery ( - select_array( -' Select table_schema, table_name from sys.x\\$schema_table_statistics_with_buffer where innodb_buffer_allocated IS NULL;' - ) - ) - { - infoprint " +-- $nbL: $lQuery"; - $nbL++; - } - infoprint "No information found or indicators deactivated." - if ( $nbL == 1 ); subheaderprint "Performance schema: Table not using InnoDB buffer"; $nbL = 1; for my $lQuery ( @@ -4603,7 +4580,7 @@ sub mysqsl_pfs { $nbL = 1; for my $lQuery ( select_array( -'select db, query, exec_count from sys.x\\$statement_analysis order by exec_count DESC LIMIT 15;' +'select db, LEFT(query, 120), exec_count from sys.x\\$statement_analysis order by exec_count DESC LIMIT 15;' ) ) { @@ -4618,7 +4595,7 @@ sub mysqsl_pfs { $nbL = 1; for my $lQuery ( select_array( -'select query, last_seen from sys.x\\$statements_with_errors_or_warnings ORDER BY last_seen LIMIT 100;' +'select LEFT(query, 120), last_seen from sys.x\\$statements_with_errors_or_warnings ORDER BY last_seen LIMIT 40;' ) ) { @@ -4632,7 +4609,7 @@ sub mysqsl_pfs { $nbL = 1; for my $lQuery ( select_array( -'select db, query, exec_count from sys.x\\$statements_with_full_table_scans order BY exec_count DESC LIMIT 20;' +'select db, LEFT(query, 120), exec_count from sys.x\\$statements_with_full_table_scans order BY exec_count DESC LIMIT 20;' ) ) { @@ -4646,7 +4623,7 @@ sub mysqsl_pfs { $nbL = 1; for my $lQuery ( select_array( -'select db, query, last_seen from sys.x\\$statements_with_full_table_scans order BY last_seen DESC LIMIT 50;' +'select db, LEFT(query, 120), last_seen from sys.x\\$statements_with_full_table_scans order BY last_seen DESC LIMIT 50;' ) ) { @@ -4660,7 +4637,7 @@ sub mysqsl_pfs { $nbL = 1; for my $lQuery ( select_array( -'use sys;select db, query , rows_sent from sys.x\\$statements_with_runtimes_in_95th_percentile ORDER BY ROWs_sent DESC LIMIT 15;' +'use sys;select db, LEFT(query, 120), rows_sent from sys.x\\$statements_with_runtimes_in_95th_percentile ORDER BY ROWs_sent DESC LIMIT 15;' ) ) { @@ -4675,7 +4652,7 @@ sub mysqsl_pfs { $nbL = 1; for my $lQuery ( select_array( -'use sys;select db, query, rows_examined AS search from sys.x\\$statements_with_runtimes_in_95th_percentile ORDER BY rows_examined DESC LIMIT 15;' +'use sys;select db, LEFT(query, 120), rows_examined AS search from sys.x\\$statements_with_runtimes_in_95th_percentile ORDER BY rows_examined DESC LIMIT 15;' ) ) { @@ -4690,7 +4667,7 @@ sub mysqsl_pfs { $nbL = 1; for my $lQuery ( select_array( -'use sys;select db, query, total_latency AS search from sys.x\\$statements_with_runtimes_in_95th_percentile ORDER BY total_latency DESC LIMIT 15;' +'use sys;select db, LEFT(query, 120), total_latency AS search from sys.x\\$statements_with_runtimes_in_95th_percentile ORDER BY total_latency DESC LIMIT 15;' ) ) { @@ -4705,7 +4682,7 @@ sub mysqsl_pfs { $nbL = 1; for my $lQuery ( select_array( -'use sys;select db, query, max_latency AS search from sys.x\\$statements_with_runtimes_in_95th_percentile ORDER BY max_latency DESC LIMIT 15;' +'use sys;select db, LEFT(query, 120), max_latency AS search from sys.x\\$statements_with_runtimes_in_95th_percentile ORDER BY max_latency DESC LIMIT 15;' ) ) { @@ -4720,7 +4697,7 @@ sub mysqsl_pfs { $nbL = 1; for my $lQuery ( select_array( -'use sys;select db, query, avg_latency AS search from sys.x\\$statements_with_runtimes_in_95th_percentile ORDER BY avg_latency DESC LIMIT 15;' +'use sys;select db, LEFT(query, 120), avg_latency AS search from sys.x\\$statements_with_runtimes_in_95th_percentile ORDER BY avg_latency DESC LIMIT 15;' ) ) { @@ -4734,7 +4711,7 @@ sub mysqsl_pfs { $nbL = 1; for my $lQuery ( select_array( -'select db, query, exec_count from sys.x\\$statements_with_sorting order BY exec_count DESC LIMIT 20;' +'select db, LEFT(query, 120), exec_count from sys.x\\$statements_with_sorting order BY exec_count DESC LIMIT 20;' ) ) { @@ -4748,7 +4725,7 @@ sub mysqsl_pfs { $nbL = 1; for my $lQuery ( select_array( -'select db, query, last_seen from sys.x\\$statements_with_sorting order BY last_seen DESC LIMIT 50;' +'select db, LEFT(query, 120), last_seen from sys.x\\$statements_with_sorting order BY last_seen DESC LIMIT 50;' ) ) { @@ -4762,7 +4739,7 @@ sub mysqsl_pfs { $nbL = 1; for my $lQuery ( select_array( -'use sys;select db, query , rows_sorted from sys.x\\$statements_with_sorting ORDER BY ROWs_sorted DESC LIMIT 15;' +'use sys;select db, LEFT(query, 120), rows_sorted from sys.x\\$statements_with_sorting ORDER BY ROWs_sorted DESC LIMIT 15;' ) ) { @@ -4776,7 +4753,7 @@ sub mysqsl_pfs { $nbL = 1; for my $lQuery ( select_array( -'use sys;select db, query, total_latency AS search from sys.x\\$statements_with_sorting ORDER BY total_latency DESC LIMIT 15;' +'use sys;select db, LEFT(query, 120), total_latency AS search from sys.x\\$statements_with_sorting ORDER BY total_latency DESC LIMIT 15;' ) ) { @@ -4790,7 +4767,7 @@ sub mysqsl_pfs { $nbL = 1; for my $lQuery ( select_array( -'use sys;select db, query, sort_merge_passes AS search from sys.x\\$statements_with_sorting ORDER BY sort_merge_passes DESC LIMIT 15;' +'use sys;select db, LEFT(query, 120), sort_merge_passes AS search from sys.x\\$statements_with_sorting ORDER BY sort_merge_passes DESC LIMIT 15;' ) ) { @@ -4805,7 +4782,7 @@ sub mysqsl_pfs { $nbL = 1; for my $lQuery ( select_array( -'select db, query, avg_sort_merges AS search from sys.x\\$statements_with_sorting ORDER BY avg_sort_merges DESC LIMIT 15;' +'select db, LEFT(query, 120), avg_sort_merges AS search from sys.x\\$statements_with_sorting ORDER BY avg_sort_merges DESC LIMIT 15;' ) ) { @@ -4819,7 +4796,7 @@ sub mysqsl_pfs { $nbL = 1; for my $lQuery ( select_array( -'use sys;select db, query, sorts_using_scans AS search from sys.x\\$statements_with_sorting ORDER BY sorts_using_scans DESC LIMIT 15;' +'use sys;select db, LEFT(query, 120), sorts_using_scans AS search from sys.x\\$statements_with_sorting ORDER BY sorts_using_scans DESC LIMIT 15;' ) ) { @@ -4833,7 +4810,7 @@ sub mysqsl_pfs { $nbL = 1; for my $lQuery ( select_array( -'use sys;select db, query, sort_using_range AS search from sys.x\\$statements_with_sorting ORDER BY sort_using_range DESC LIMIT 15;' +'use sys;select db, LEFT(query, 120), sort_using_range AS search from sys.x\\$statements_with_sorting ORDER BY sort_using_range DESC LIMIT 15;' ) ) { @@ -4869,7 +4846,7 @@ sub mysqsl_pfs { $nbL = 1; for my $lQuery ( select_array( -'select db, query, exec_count from sys.x\\$statements_with_temp_tables order BY exec_count DESC LIMIT 20;' +'select db, LEFT(query, 120), exec_count from sys.x\\$statements_with_temp_tables order BY exec_count DESC LIMIT 20;' ) ) { @@ -4883,7 +4860,7 @@ sub mysqsl_pfs { $nbL = 1; for my $lQuery ( select_array( -'select db, query, last_seen from sys.x\\$statements_with_temp_tables order BY last_seen DESC LIMIT 50;' +'select db, LEFT(query, 120), last_seen from sys.x\\$statements_with_temp_tables order BY last_seen DESC LIMIT 50;' ) ) { @@ -4898,7 +4875,7 @@ sub mysqsl_pfs { $nbL = 1; for my $lQuery ( select_array( -'select db, query, total_latency AS search from sys.x\\$statements_with_temp_tables ORDER BY total_latency DESC LIMIT 15;' +'select db, LEFT(query, 120), total_latency AS search from sys.x\\$statements_with_temp_tables ORDER BY total_latency DESC LIMIT 15;' ) ) { @@ -4912,7 +4889,7 @@ sub mysqsl_pfs { $nbL = 1; for my $lQuery ( select_array( -'use sys;select db, query, disk_tmp_tables from sys.x\\$statements_with_temp_tables ORDER BY disk_tmp_tables DESC LIMIT 15;' +'use sys;select db, LEFT(query, 120), disk_tmp_tables from sys.x\\$statements_with_temp_tables ORDER BY disk_tmp_tables DESC LIMIT 15;' ) ) { @@ -6019,6 +5996,9 @@ sub mysql_tables { "Skip Database metrics from information schema missing in this version"; return; } + if (mysql_version_ge(8) and not mysql_version_eq(10)) { + infoprint "MySQL and Percona version 8 and greater have remove PROCEDURE ANALYSE feature" + } my @dblist = select_array( "SELECT DISTINCT TABLE_SCHEMA FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN ( 'mysql', 'performance_schema', 'information_schema', 'sys' );" ); @@ -6042,15 +6022,17 @@ sub mysql_tables { my $isnull = select_one( "SELECT IS_NULLABLE FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='$dbname' AND TABLE_NAME='$tbname' AND COLUMN_NAME='$_' " ); + infoprint " +-- Column $tbname.$_:"; my $current_type = uc($ctype) . ( $isnull eq 'NO' ? " NOT NULL" : "" ); - my $optimal_type = select_str_g( "Optimal_fieldtype", + my $optimal_type=''; + $optimal_type = select_str_g( "Optimal_fieldtype", "SELECT \\`$_\\` FROM \\`$dbname\\`.\\`$tbname\\` PROCEDURE ANALYSE(100000)" - ); - if ( not defined($optimal_type) or $optimal_type eq '' ) { + ) unless (mysql_version_ge(8) and not mysql_version_eq(10)); + if ( $optimal_type eq '' ) { infoprint " Current Fieldtype: $current_type"; - infoprint " Optimal Fieldtype: Not available"; + #infoprint " Optimal Fieldtype: Not available"; } elsif ( $current_type ne $optimal_type ) { infoprint " Current Fieldtype: $current_type"; @@ -6159,7 +6141,7 @@ FROM performance_schema.table_io_waits_summary_by_index_usage WHERE index_name IS NOT NULL AND count_star =0 AND index_name <> 'PRIMARY' -AND object_schema != 'mysql' +AND object_schema NOT IN ( 'mysql', 'performance_schema', 'information_schema' ) ORDER BY count_star, object_schema, object_name; ENDSQL @idxinfo = select_array($selIdxReq); @@ -6341,19 +6323,19 @@ debugprint "MySQL FINAL Client : $mysqlcmd $mysqllogin"; debugprint "MySQL Admin FINAL Client : $mysqladmincmd $mysqllogin"; #exit(0); -os_setup; # Set up some OS variables -get_all_vars; # Toss variables/status into hashes -get_tuning_info; # Get information about the tuning connexion -validate_mysql_version; # Check current MySQL version +os_setup; # Set up some OS variables +get_all_vars; # Toss variables/status into hashes +get_tuning_info; # Get information about the tuning connexion +validate_mysql_version; # Check current MySQL version -check_architecture; # Suggest 64-bit upgrade -system_recommendations; # avoid to many service on the same host -log_file_recommendations; # check log file content -check_storage_engines; # Show enabled storage engines +check_architecture; # Suggest 64-bit upgrade +system_recommendations; # avoid to many service on the same host +log_file_recommendations; # check log file content +check_storage_engines; # Show enabled storage engines -check_metadata_perf; # Show parameter impacting performance during analysis -mysql_databases; # Show informations about databases -mysql_tables; # Show informations about table column +check_metadata_perf; # Show parameter impacting performance during analysis +mysql_databases; # Show informations about databases +mysql_tables; # Show informations about table column mysql_indexes; # Show informations about indexes security_recommendations; # Display some security recommendations @@ -6368,14 +6350,14 @@ mariadb_ariadb; # Print MariaDB AriaDB stats mariadb_tokudb; # Print MariaDB Tokudb stats mariadb_xtradb; # Print MariaDB XtraDB stats -#mariadb_rockdb; # Print MariaDB RockDB stats -#mariadb_spider; # Print MariaDB Spider stats -#mariadb_connect; # Print MariaDB Connect stats -mariadb_galera; # Print MariaDB Galera Cluster stats -get_replication_status; # Print replication info -make_recommendations; # Make recommendations based on stats -dump_result; # Dump result if debug is on -close_outputfile; # Close reportfile if needed +#mariadb_rockdb; # Print MariaDB RockDB stats +#mariadb_spider; # Print MariaDB Spider stats +#mariadb_connect; # Print MariaDB Connect stats +mariadb_galera; # Print MariaDB Galera Cluster stats +get_replication_status; # Print replication info +make_recommendations; # Make recommendations based on stats +dump_result; # Dump result if debug is on +close_outputfile; # Close reportfile if needed # --------------------------------------------------------------------------- # END 'MAIN' @@ -6390,7 +6372,7 @@ __END__ =head1 NAME - MySQLTuner 1.7.16 - MySQL High Performance Tuning Script + MySQLTuner 1.7.17 - MySQL High Performance Tuning Script =head1 IMPORTANT USAGE GUIDELINES From f18a3ef33f9a7891dc7688a9b69ea4d392feac2a Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Wed, 2 Oct 2019 00:44:54 +0200 Subject: [PATCH 14/43] Update mysqltuner.pl FAIL Execute SQL / return code: 256 #442 disable column type to ENUM suggestion #356 --- mysqltuner.pl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mysqltuner.pl b/mysqltuner.pl index 3e05f28..18bc625 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -6034,14 +6034,19 @@ sub mysql_tables { infoprint " Current Fieldtype: $current_type"; #infoprint " Optimal Fieldtype: Not available"; } - elsif ( $current_type ne $optimal_type ) { + elsif ( $current_type ne $optimal_type and $current_type !~ /.*DATETIME.*/ and $current_type !~ /.*TIMESTAMP.*/) { infoprint " Current Fieldtype: $current_type"; - infoprint " Optimal Fieldtype: $optimal_type"; - badprint + if ($optimal_type =~ /.*ENUM\(.*/ ) { + $optimal_type ="ENUM( ... )"; + } + infoprint " Optimal Fieldtype: $optimal_type "; + if ($optimal_type !~ /.*ENUM\(.*/ ) { + badprint "Consider changing type for column $_ in table $dbname.$tbname"; push( @generalrec, "ALTER TABLE \`$dbname\`.\`$tbname\` MODIFY \`$_\` $optimal_type;" ); + } } else { From d1f39e9a0005600bed25a2412844a760953dd735 Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Wed, 2 Oct 2019 01:13:34 +0200 Subject: [PATCH 15/43] Script is failing on MySQL 5.6.10(AWS Aurora) #435 --- mysqltuner.pl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mysqltuner.pl b/mysqltuner.pl index 18bc625..30ac304 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -1,5 +1,5 @@ #!/usr/bin/env perl -# mysqltuner.pl - Version 1.7.17 +# mysqltuner.pl - Version 1.7.18 # High Performance MySQL Tuning Script # Copyright (C) 2006-2018 Major Hayden - major@mhtx.net # @@ -56,7 +56,7 @@ $Data::Dumper::Pair = " : "; #use Env; # Set up a few variables for use in the script -my $tunerversion = "1.7.17"; +my $tunerversion = "1.7.18"; my ( @adjvars, @generalrec ); # Set defaults @@ -2704,7 +2704,10 @@ sub calculations { $myvar{'innodb_log_files_in_group'} * 100 / $myvar{'innodb_buffer_pool_size'} ); } - + if( !defined $myvar{'innodb_buffer_pool_size'}) { + $mycalc{'innodb_log_size_pct'} = 0; + $myvar{'innodb_buffer_pool_size'} = 0; + } # InnoDB Buffer pool read cache efficiency ( $mystat{'Innodb_buffer_pool_read_requests'}, @@ -6377,7 +6380,7 @@ __END__ =head1 NAME - MySQLTuner 1.7.17 - MySQL High Performance Tuning Script + MySQLTuner 1.7.18 - MySQL High Performance Tuning Script =head1 IMPORTANT USAGE GUIDELINES From 84f61be841a45b27087643ee42ce087abeca116d Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Wed, 2 Oct 2019 01:31:25 +0200 Subject: [PATCH 16/43] update documentation for tests --- CONTRIBUTING.md | 2 +- README.md | 59 +++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 48 insertions(+), 13 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 68fcbaf..6608810 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -181,7 +181,7 @@ Copy of the license is available at [LICENSE] ## MySQLTuner Code Conventions 1. Check code convention using **perltidy** and **perlcritic** -2. Don't manually update the version number in `mysqltuner.pl`. +2. Don't manually update the version number in `mysqltuner.pl`. [Enhancement issue]:https://github.com/major/MySQLTuner-perl/labels/enhancement diff --git a/README.md b/README.md index 21a4a79..b5bcc3c 100644 --- a/README.md +++ b/README.md @@ -37,10 +37,12 @@ Test result are available here: [Travis CI/MySQLTuner-perl](https://travis-ci.or * MySQL 8 (partial support, password checks don't work) * MySQL 5.7 (full support) * MySQL 5.6 (full support) +* MySQL 5.5 (full support) * MariaDB 10.3 (full support) * MariaDB 10.2 (full support) * MariaDB 10.1 (full support) * MariaDB 10.0 (full support, 6 last month support) +* MariaDB 5.5 (no more support) * Percona Server 5.7 (full support) * Percona Server 5.6 (full support) * Percona XtraDB cluster (full support) @@ -267,14 +269,10 @@ Yes! `brew install mysqltuner` can be used to install this application using [ho MySQLTuner and Vagrant -- **MySQLTuner** contains following Vagrant configurations: -* Fedora Core 23 / MariaDB 10.0 -* Fedora Core 23 / MariaDB 10.1 -* Fedora Core 23 / MySQL 5.6 -* Fedora Core 23 / MySQL 5.7 +* Fedora Core 30 / Docker -**Vagrant File** are stored in Vagrant subdirectory. -* Follow this 2 steps after vagrant installation: -* Rename VagrantFile_for_Mxxx into Vagrantfile +**Vagrant File** is stored in Vagrant subdirectory. +* Follow following step after vagrant installation: * vagrant up **MySQLTuner** contains a Vagrant configurations for test purpose and development @@ -287,13 +285,50 @@ MySQLTuner and Vagrant * vagrant plugin install vagrant-hostmanager * vagrant plugin install vagrant-vbguest * Add Fedora Core 23 box for official Fedora Download Website - * vagrant box add --name fc23 https://download.fedoraproject.org/pub/fedora/linux/releases/23/Cloud/x86_64/Images/Fedora-Cloud-Base-Vagrant-23-20151030.x86_64.vagrant-virtualbox.box + * vagrant box add --name generic/fedora30 * Create a data directory * mkdir data -* Rename Vagrantfile_MariaDB10.0 into Vagrantfile - * cp MySQLTuner-perl/Vagrant/Vagrantfile_for_MariaDB10.0 Vagrantfile -* Start vagrant - * vagrant up + + +## setup test environments + + $ sh build/createTestEnvs.sh + + $ source build/bashrc + $ mysql_percona80 sakila + sakila> ... + +$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE +mariadb 10.1 fc612450e1f1 12 days ago 352MB +mariadb 10.2 027b7c57b8c6 12 days ago 340MB +mariadb 10.3 47dff68107c4 12 days ago 343MB +mariadb 10.4 92495405fc36 12 days ago 356MB +mysql 5.6 95e0fc47b096 2 weeks ago 257MB +mysql 5.7 383867b75fd2 2 weeks ago 373MB +mysql 8.0 b8fd9553f1f0 2 weeks ago 445MB +percona/percona-server 5.7 ddd245ed3496 5 weeks ago 585MB +percona/percona-server 5.6 ed0a36e0cf1b 6 weeks ago 421MB +percona/percona-server 8.0 390ae97d57c6 6 weeks ago 697MB +mariadb 5.5 c7bf316a4325 4 months ago 352MB +mariadb 10.0 d1bde56970c6 4 months ago 353MB +mysql 5.5 d404d78aa797 4 months ago 205MB + +$ docker ps +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +da2be9b050c9 mariadb:5.5 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:5311->3306/tcp mariadb55 +5deca25d5ac8 mariadb:10.0 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:5310->3306/tcp mariadb100 +73aaeb37e2c2 mariadb:10.1 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:5309->3306/tcp mariadb101 +72ffa77e01ec mariadb:10.2 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:5308->3306/tcp mariadb102 +f5996f2041df mariadb:10.3 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:5307->3306/tcp mariadb103 +4890c52372bb mariadb:10.4 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:5306->3306/tcp mariadb104 +6b9dc078e921 percona/percona-server:5.6 "/docker-entrypoint.…" 7 hours ago Up 7 hours 0.0.0.0:4308->3306/tcp percona56 +3a4c7c826d4c percona/percona-server:5.7 "/docker-entrypoint.…" 7 hours ago Up 7 hours 0.0.0.0:4307->3306/tcp percona57 +3dda408c91b0 percona/percona-server:8.0 "/docker-entrypoint.…" 7 hours ago Up 7 hours 33060/tcp, 0.0.0.0:4306->3306/tcp percona80 +600a4e7e9dcd mysql:5.5 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:3309->3306/tcp mysql55 +4bbe54342e5d mysql:5.6 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:3308->3306/tcp mysql56 +a49783249a11 mysql:5.7 "docker-entrypoint.s…" 7 hours ago Up 7 hours 33060/tcp, 0.0.0.0:3307->3306/tcp mysql57 +d985820667c2 mysql:8.0 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:3306->3306/tcp, 33060/tcp mysql80 + MySQLTuner needs you -- From 86bb9b0508a0057e291f620da3728c5ea63387fa Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Wed, 2 Oct 2019 01:33:29 +0200 Subject: [PATCH 17/43] update readme.md --- README.md | 64 +++++++++++++++++++++++++++---------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index b5bcc3c..2fab1ab 100644 --- a/README.md +++ b/README.md @@ -273,7 +273,7 @@ MySQLTuner and Vagrant **Vagrant File** is stored in Vagrant subdirectory. * Follow following step after vagrant installation: -* vagrant up + $ vagrant up **MySQLTuner** contains a Vagrant configurations for test purpose and development * Install VirtualBox and Vagrant @@ -292,40 +292,40 @@ MySQLTuner and Vagrant ## setup test environments - $ sh build/createTestEnvs.sh + $ sh build/createTestEnvs.sh - $ source build/bashrc - $ mysql_percona80 sakila - sakila> ... + $ source build/bashrc + $ mysql_percona80 sakila + sakila> ... -$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE -mariadb 10.1 fc612450e1f1 12 days ago 352MB -mariadb 10.2 027b7c57b8c6 12 days ago 340MB -mariadb 10.3 47dff68107c4 12 days ago 343MB -mariadb 10.4 92495405fc36 12 days ago 356MB -mysql 5.6 95e0fc47b096 2 weeks ago 257MB -mysql 5.7 383867b75fd2 2 weeks ago 373MB -mysql 8.0 b8fd9553f1f0 2 weeks ago 445MB -percona/percona-server 5.7 ddd245ed3496 5 weeks ago 585MB -percona/percona-server 5.6 ed0a36e0cf1b 6 weeks ago 421MB -percona/percona-server 8.0 390ae97d57c6 6 weeks ago 697MB -mariadb 5.5 c7bf316a4325 4 months ago 352MB -mariadb 10.0 d1bde56970c6 4 months ago 353MB -mysql 5.5 d404d78aa797 4 months ago 205MB + $ docker images + mariadb 10.1 fc612450e1f1 12 days ago 352MB + mariadb 10.2 027b7c57b8c6 12 days ago 340MB + mariadb 10.3 47dff68107c4 12 days ago 343MB + mariadb 10.4 92495405fc36 12 days ago 356MB + mysql 5.6 95e0fc47b096 2 weeks ago 257MB + mysql 5.7 383867b75fd2 2 weeks ago 373MB + mysql 8.0 b8fd9553f1f0 2 weeks ago 445MB + percona/percona-server 5.7 ddd245ed3496 5 weeks ago 585MB + percona/percona-server 5.6 ed0a36e0cf1b 6 weeks ago 421MB + percona/percona-server 8.0 390ae97d57c6 6 weeks ago 697MB + mariadb 5.5 c7bf316a4325 4 months ago 352MB + mariadb 10.0 d1bde56970c6 4 months ago 353MB + mysql 5.5 d404d78aa797 4 months ago 205MB -$ docker ps -CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES -da2be9b050c9 mariadb:5.5 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:5311->3306/tcp mariadb55 -5deca25d5ac8 mariadb:10.0 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:5310->3306/tcp mariadb100 -73aaeb37e2c2 mariadb:10.1 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:5309->3306/tcp mariadb101 -72ffa77e01ec mariadb:10.2 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:5308->3306/tcp mariadb102 -f5996f2041df mariadb:10.3 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:5307->3306/tcp mariadb103 -4890c52372bb mariadb:10.4 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:5306->3306/tcp mariadb104 -6b9dc078e921 percona/percona-server:5.6 "/docker-entrypoint.…" 7 hours ago Up 7 hours 0.0.0.0:4308->3306/tcp percona56 -3a4c7c826d4c percona/percona-server:5.7 "/docker-entrypoint.…" 7 hours ago Up 7 hours 0.0.0.0:4307->3306/tcp percona57 -3dda408c91b0 percona/percona-server:8.0 "/docker-entrypoint.…" 7 hours ago Up 7 hours 33060/tcp, 0.0.0.0:4306->3306/tcp percona80 -600a4e7e9dcd mysql:5.5 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:3309->3306/tcp mysql55 -4bbe54342e5d mysql:5.6 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:3308->3306/tcp mysql56 + $ docker ps + CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES + da2be9b050c9 mariadb:5.5 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:5311->3306/tcp mariadb55 + 5deca25d5ac8 mariadb:10.0 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:5310->3306/tcp mariadb100 + 73aaeb37e2c2 mariadb:10.1 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:5309->3306/tcp mariadb101 + 72ffa77e01ec mariadb:10.2 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:5308->3306/tcp mariadb102 + f5996f2041df mariadb:10.3 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:5307->3306/tcp mariadb103 + 4890c52372bb mariadb:10.4 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:5306->3306/tcp mariadb104 + 6b9dc078e921 percona/percona-server:5.6 "/docker-entrypoint.…" 7 hours ago Up 7 hours 0.0.0.0:4308->3306/tcp percona56 + 3a4c7c826d4c percona/percona-server:5.7 "/docker-entrypoint.…" 7 hours ago Up 7 hours 0.0.0.0:4307->3306/tcp percona57 + 3dda408c91b0 percona/percona-server:8.0 "/docker-entrypoint.…" 7 hours ago Up 7 hours 33060/tcp, 0.0.0.0:4306->3306/tcp percona80 + 600a4e7e9dcd mysql:5.5 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:3309->3306/tcp mysql55 + 4bbe54342e5d mysql:5.6 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:3308->3306/tcp mysql56 a49783249a11 mysql:5.7 "docker-entrypoint.s…" 7 hours ago Up 7 hours 33060/tcp, 0.0.0.0:3307->3306/tcp mysql57 d985820667c2 mysql:8.0 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:3306->3306/tcp, 33060/tcp mysql80 From 46b5dc33983ed031575a14510b4099efc59eb47d Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Wed, 2 Oct 2019 01:34:41 +0200 Subject: [PATCH 18/43] Reformatting readme.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2fab1ab..54604d4 100644 --- a/README.md +++ b/README.md @@ -326,8 +326,8 @@ MySQLTuner and Vagrant 3dda408c91b0 percona/percona-server:8.0 "/docker-entrypoint.…" 7 hours ago Up 7 hours 33060/tcp, 0.0.0.0:4306->3306/tcp percona80 600a4e7e9dcd mysql:5.5 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:3309->3306/tcp mysql55 4bbe54342e5d mysql:5.6 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:3308->3306/tcp mysql56 -a49783249a11 mysql:5.7 "docker-entrypoint.s…" 7 hours ago Up 7 hours 33060/tcp, 0.0.0.0:3307->3306/tcp mysql57 -d985820667c2 mysql:8.0 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:3306->3306/tcp, 33060/tcp mysql80 + a49783249a11 mysql:5.7 "docker-entrypoint.s…" 7 hours ago Up 7 hours 33060/tcp, 0.0.0.0:3307->3306/tcp mysql57 + d985820667c2 mysql:8.0 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:3306->3306/tcp, 33060/tcp mysql 8 0 MySQLTuner needs you From 80deeff141bcb8c7b6471d4037f1ca605c851047 Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Wed, 2 Oct 2019 01:35:37 +0200 Subject: [PATCH 19/43] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 54604d4..7087d44 100644 --- a/README.md +++ b/README.md @@ -284,7 +284,7 @@ MySQLTuner and Vagrant * Install Vagrant plugins vagrant-hostmanager and vagrant-vbguest * vagrant plugin install vagrant-hostmanager * vagrant plugin install vagrant-vbguest -* Add Fedora Core 23 box for official Fedora Download Website +* Add Fedora Core 30 box for official Fedora Download Website * vagrant box add --name generic/fedora30 * Create a data directory * mkdir data From 7050e47a8c22d497266cf3222387b07f11565685 Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Wed, 2 Oct 2019 19:01:51 +0000 Subject: [PATCH 20/43] Removing misplaced file --- createTestEnvs.sh | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 createTestEnvs.sh diff --git a/createTestEnvs.sh b/createTestEnvs.sh deleted file mode 100644 index f99a792..0000000 --- a/createTestEnvs.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh - -source build/bashrc -sudo dnf install -y yum-utils device-mapper-persistent-data lvm2 -sudo dnf -y install dnf-plugins-core -sudo dnf config-manager \ ---add-repo \ -https://download.docker.com/linux/fedora/docker-ce.repo - -sudo dnf -y install docker-ce docker-ce-cli containerd.io -dnf list docker-ce --showduplicates | sort -r - -sudo systemctl start docker -sudo systemctl enable docker -sudo usermod -aG docker vagrant -sudo systemctl daemon-reload - - -sh build/createMassDockerImages.sh - -sh build/fetchSampleDatabases.sh fetchall - -exec_mysqls build/configimg.conf mysql contents/sakila-db/sakila-schema.sql -exec_mysqls build/configimg.conf mysql contents/sakila-db/sakila-data.sql \ No newline at end of file From 3e30c984cf8e37237027844a8de9b77f520c78d7 Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Wed, 2 Oct 2019 20:37:54 +0000 Subject: [PATCH 21/43] Adding clear all mysql containers --- build/clearContainer.sh | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 build/clearContainer.sh diff --git a/build/clearContainer.sh b/build/clearContainer.sh new file mode 100644 index 0000000..410a071 --- /dev/null +++ b/build/clearContainer.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +docker ps | awk '{ print $NF}' |grep -v NAMES | xargs -n 1 docker kill +docker ps -a | awk '{ print $NF}' |grep -v NAMES | xargs -n 1 docker rm +docker ps -a From a421f73e2677b70fdb9c5f7b5a489a717373ef9a Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Thu, 3 Oct 2019 21:04:12 +0200 Subject: [PATCH 22/43] Add note about join_buffer_size #434 --- build/createMassDockerImages.sh | 7 ++++--- build/createTestEnvs.sh | 25 ++++++++++++++----------- build/fetchSampleDatabases.sh | 5 +---- mysqltuner.pl | 4 +++- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/build/createMassDockerImages.sh b/build/createMassDockerImages.sh index a100dab..543d860 100644 --- a/build/createMassDockerImages.sh +++ b/build/createMassDockerImages.sh @@ -3,7 +3,7 @@ input="./build/configimg.conf" default_password="secret" -eco "[client] +echo "[client] user=root password=$default_password" > $HOME/.my.cnf @@ -25,7 +25,7 @@ chmod 600 $HOME/.my.cnf 5309;mariadb101;/var/lib/mariadb101;mariadb:10.1 5310;mariadb100;/var/lib/mariadb100;mariadb:10.0 5311;mariadb55;/var/lib/mariadb55;mariadb:5.5 -" > $input +" > "$input" # @@ -46,7 +46,8 @@ do [ $? -eq 0 ] || continue fi echo "* PULLING DOCKER IMAGE: $image_name" - docker pull $image_name + docker images | grep -E " $image_name$" + [ $? -ne 0 ] && docker pull $image_name echo "* REMOVING CONTAINER : $image_name" docker ps -a | grep -qE "$container_name^" diff --git a/build/createTestEnvs.sh b/build/createTestEnvs.sh index 7cc3f2e..e9addee 100644 --- a/build/createTestEnvs.sh +++ b/build/createTestEnvs.sh @@ -1,20 +1,23 @@ #!/bin/sh source build/bashrc -sudo dnf install -y yum-utils device-mapper-persistent-data lvm2 -sudo dnf -y install dnf-plugins-core -sudo dnf config-manager \ ---add-repo \ -https://download.docker.com/linux/fedora/docker-ce.repo -sudo dnf -y install docker-ce docker-ce-cli containerd.io -dnf list docker-ce --showduplicates | sort -r +systemctl status docker &>/dev/null +if [ $? -ne 0 ];then + sudo dnf install -y yum-utils device-mapper-persistent-data lvm2 + sudo dnf -y install dnf-plugins-core + sudo dnf config-manager \ + --add-repo \ + https://download.docker.com/linux/fedora/docker-ce.repo -sudo systemctl start docker -sudo systemctl enable docker -sudo usermod -aG docker vagrant -sudo systemctl daemon-reload + sudo dnf -y install docker-ce docker-ce-cli containerd.io + dnf list docker-ce --showduplicates | sort -r + sudo systemctl start docker + sudo systemctl enable docker + sudo usermod -aG docker vagrant + sudo systemctl daemon-reload +fi sh build/createMassDockerImages.sh diff --git a/build/fetchSampleDatabases.sh b/build/fetchSampleDatabases.sh index 7116965..b580a1d 100644 --- a/build/fetchSampleDatabases.sh +++ b/build/fetchSampleDatabases.sh @@ -23,10 +23,7 @@ case "$1" in mkdir -p ./contents [ -f "contents/$(basename $(getVal "DB_$2_URL"))" ] || wget -O contents/$(basename $(getVal "DB_$2_URL")) $(getVal "DB_$2_URL") if [ $? -eq 0 ];then - ( - cd contents - unzip $(basename $(getVal "DB_$2_URL"))) - ) + (cd contents; unzip $( basename $(getVal "DB_$2_URL")) ) fi ;; "clean") diff --git a/mysqltuner.pl b/mysqltuner.pl index 30ac304..48ba9d9 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -3079,7 +3079,9 @@ sub mysql_stats { . hr_bytes( $myvar{'join_buffer_size'} ) . ", or always use indexes with JOINs)" ); push( @generalrec, - "Adjust your join queries to always utilize indexes" ); + "We will suggest raising the 'join_buffer_size' until JOINs not using indexes are found. + See https://dev.mysql.com/doc/internals/en/join-buffer-size.html + (specially the conclusions at the bottom of the page)."); } else { goodprint "No joins without indexes"; From 143b80b3a6d6a13f7d0a5f271b4e59ffbf223b7e Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Thu, 3 Oct 2019 21:29:03 +0200 Subject: [PATCH 23/43] Add recommendation on table_definition_cache #433 --- INTERNALS.md | 1 + mysqltuner.pl | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/INTERNALS.md b/INTERNALS.md index aa6121f..9f2090b 100644 --- a/INTERNALS.md +++ b/INTERNALS.md @@ -167,6 +167,7 @@ * Thread cache (=4) * Thread cache hit ratio (>50%) if thread_handling is different of pools-of-threads * Table cache hit ratio(>2°%) +* Table cache definition should be upper that total number of tables or in autoresizing mode * Percentage of open file and open file limit(<85%) * Percentage of table locks (<95%) * Percentage of binlog cache lock (<90%) diff --git a/mysqltuner.pl b/mysqltuner.pl index 48ba9d9..13ea9a6 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -3238,6 +3238,23 @@ sub mysql_stats { } } + # Table definition cache + my $nbtables=select_one('SELECT COUNT(*) FROM information_schema.tables'); + if ( defined $myvar{'table_definition_cache'} ) { + if ( $myvar{'table_definition_cache'} == -1 ) { + infoprint ("table_definition_cache(".$myvar{'table_definition_cache'} .") is in autosizing mode"); + } elsif ($myvar{'table_definition_cache'} < $nbtables ) { + badprint "table_definition_cache(".$myvar{'table_definition_cache'} .") is lower than number of tables($nbtables) "; + push( @adjvars, + "table_definition_cache(".$myvar{'table_definition_cache'} .") > " . $$nbtables . " or -1 (autosizing if supported)" ); + } + else { + goodprint "table_definition_cache(".$myvar{'table_definition_cache'} .") is upper than number of tables($nbtables)"; + } + } else { + infoprint "No table_definition_cache variable found."; + } + # Open files if ( defined $mycalc{'pct_files_open'} ) { if ( $mycalc{'pct_files_open'} > 85 ) { From 6aa887d5a5e10d7dbcc7fd0e24908301fe33ae82 Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Thu, 3 Oct 2019 21:52:30 +0200 Subject: [PATCH 24/43] Use of uninitialized value $engine in concatenation (.) or string #350 --- mysqltuner.pl | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/mysqltuner.pl b/mysqltuner.pl index 13ea9a6..2e7497e 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -1,5 +1,5 @@ #!/usr/bin/env perl -# mysqltuner.pl - Version 1.7.18 +# mysqltuner.pl - Version 1.7.19 # High Performance MySQL Tuning Script # Copyright (C) 2006-2018 Major Hayden - major@mhtx.net # @@ -56,7 +56,7 @@ $Data::Dumper::Pair = " : "; #use Env; # Set up a few variables for use in the script -my $tunerversion = "1.7.18"; +my $tunerversion = "1.7.19"; my ( @adjvars, @generalrec ); # Set defaults @@ -2198,11 +2198,12 @@ sub check_storage_engines { ( $engine, $size, $count, $dsize, $isize ) = $line =~ /([a-zA-Z_]+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/; debugprint "Engine Found: $engine"; - next unless ( defined($engine) ); - $size = 0 unless defined($size); - $isize = 0 unless defined($isize); - $dsize = 0 unless defined($dsize); - $count = 0 unless defined($count); + trim $engine; + next unless ( defined($engine) or trim($engine) eq '' ); + $size = 0 unless ( defined($size) or trim($engine) eq '' ); + $isize = 0 unless ( defined($isize) or trim($engine) eq '' ); + $dsize = 0 unless ( defined($dsize) or trim($engine) eq '' ); + $count = 0 unless ( defined($count) or trim($engine) eq '' ); $enginestats{$engine} = $size; $enginecount{$engine} = $count; $result{'Engine'}{$engine}{'Table Number'} = $count; @@ -2255,9 +2256,9 @@ sub check_storage_engines { foreach my $tbl (@tblist) { debugprint "Data dump " . Dumper(@$tbl); my ( $engine, $size, $datafree ) = @$tbl; - next if $engine eq 'NULL'; - $size = 0 if $size eq 'NULL'; - $datafree = 0 if $datafree eq 'NULL'; + next if $engine eq 'NULL' or not defined($engine); + $size = 0 if $size eq 'NULL' or not defined($size); + $datafree = 0 if $datafree eq 'NULL' or not defined($datafree); if ( defined $enginestats{$engine} ) { $enginestats{$engine} += $size; $enginecount{$engine} += 1; @@ -6399,7 +6400,7 @@ __END__ =head1 NAME - MySQLTuner 1.7.18 - MySQL High Performance Tuning Script + MySQLTuner 1.7.19 - MySQL High Performance Tuning Script =head1 IMPORTANT USAGE GUIDELINES From 792b46b03c84bafa66e7059520d6f5d77df87d2e Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Thu, 3 Oct 2019 22:06:51 +0200 Subject: [PATCH 25/43] About innodb_log_file_size changing recommendation #408 --- mysqltuner.pl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mysqltuner.pl b/mysqltuner.pl index 2e7497e..2b46008 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -5645,6 +5645,11 @@ sub mysql_innodb { ) . ") if possible, so InnoDB total log files size equals to 25% of buffer pool size." ); + if (mysql_version_le(5 ,6 , 2)) { + push( + @adjvars, + "For MySQL 5.6.2 and lower, Max combined innodb_log_file_size should have a ceiling of (4096MB / log files in group) - 1MB."); + } push( @generalrec, "Before changing innodb_log_file_size and/or innodb_log_files_in_group read this: https://bit.ly/2TcGgtU" ); From 66f2ee40be623887ab5e7f9ce2cc206ba7be8629 Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Thu, 3 Oct 2019 22:10:18 +0200 Subject: [PATCH 26/43] About innodb_log_file_size changing recommendation #408 --- mysqltuner.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysqltuner.pl b/mysqltuner.pl index 2b46008..8aad0fe 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -5647,7 +5647,7 @@ sub mysql_innodb { ); if (mysql_version_le(5 ,6 , 2)) { push( - @adjvars, + @generalrec, "For MySQL 5.6.2 and lower, Max combined innodb_log_file_size should have a ceiling of (4096MB / log files in group) - 1MB."); } push( @generalrec, From 851cd817de07c65ee56ec05b8dd1bd88cf9f7643 Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Thu, 3 Oct 2019 22:33:22 +0200 Subject: [PATCH 27/43] Update version command #428 --- README.md | 4 ++++ build/runMT.sh | 4 ++-- mysqltuner.pl | 7 +++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7087d44..7a18e95 100644 --- a/README.md +++ b/README.md @@ -178,6 +178,10 @@ __Usage:__ Enable debugging information perl mysqltuner.pl --debug +__Usage:__ Update MySQLTuner and data files (password and cve) if needed + + perl mysqltuner.pl --checkversion --updateversion + FAQ -- diff --git a/build/runMT.sh b/build/runMT.sh index 2bf658d..ae9f796 100644 --- a/build/runMT.sh +++ b/build/runMT.sh @@ -13,7 +13,7 @@ do if [ -n "$1" -a "$1" != "$container_name" ]; then continue fi - #set -x + shift sudo rm -f /var/lib/mysql sudo ln -sf $container_datadir /var/lib/mysql sudo chmod 777 /var/lib/mysql @@ -21,5 +21,5 @@ do #sudo docker logs $container_name > /tmp/mysqld.log ls -ls /var/lib | grep -E 'mysql$' #set +x - perl mysqltuner.pl --verbose --host 127.0.0.1 --port $container_port + perl mysqltuner.pl $* --host 127.0.0.1 --port $container_port done < "$input" diff --git a/mysqltuner.pl b/mysqltuner.pl index 8aad0fe..e9549d7 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -517,7 +517,7 @@ sub get_http_cli { # Checks for updates to MySQLTuner sub validate_tuner_version { - if ( $opt{'checkversion'} eq 0 and $opt{'updateversion'} eq 0 ) { + if ( $opt{'checkversion'} eq 0 ) { print "\n" unless ( $opt{'silent'} or $opt{'json'} ); infoprint "Skipped version check for MySQLTuner script"; return; @@ -626,8 +626,8 @@ sub update_tuner_version { else { badprint "Couldn't update MySQLTuner script"; } - - #exit 0; + infoprint "Stopping program: MySQLTuner has be updated."; + exit 0; } sub compare_tuner_version { @@ -2198,7 +2198,6 @@ sub check_storage_engines { ( $engine, $size, $count, $dsize, $isize ) = $line =~ /([a-zA-Z_]+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/; debugprint "Engine Found: $engine"; - trim $engine; next unless ( defined($engine) or trim($engine) eq '' ); $size = 0 unless ( defined($size) or trim($engine) eq '' ); $isize = 0 unless ( defined($isize) or trim($engine) eq '' ); From 6f6130b12bbdf756fd350282fa6e4139d0261581 Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Thu, 3 Oct 2019 23:15:31 +0200 Subject: [PATCH 28/43] Missing password is not recognized #412 --- build/runMT.sh | 1 + mysqltuner.pl | 25 +++++++++++++------------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/build/runMT.sh b/build/runMT.sh index ae9f796..d41fe7d 100644 --- a/build/runMT.sh +++ b/build/runMT.sh @@ -22,4 +22,5 @@ do ls -ls /var/lib | grep -E 'mysql$' #set +x perl mysqltuner.pl $* --host 127.0.0.1 --port $container_port + exit $? done < "$input" diff --git a/mysqltuner.pl b/mysqltuner.pl index e9549d7..6c49f06 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -875,7 +875,6 @@ sub mysql_setup { } } else { - # It's not Plesk or Debian, we should try a login debugprint "$mysqladmincmd $remotestring ping 2>&1"; my $loginstatus = `$mysqladmincmd $remotestring ping 2>&1`; @@ -1798,6 +1797,8 @@ sub security_recommendations { "Remove Anonymous User accounts - there are " . scalar(@mysqlstatlist) . " anonymous accounts." ); + push( @generalrec, + "DELETE FROM ymsql.user WHERE user ='';" ); } else { goodprint "There are no anonymous accounts for any database users"; @@ -1821,10 +1822,8 @@ sub security_recommendations { foreach my $line ( sort @mysqlstatlist ) { chomp($line); badprint "User '" . $line . "' has no password set."; + push (@generalrec, "Set up a Secure Password for $line user: SET PASSWORD FOR '".(split /@/, $line)[0]."'\@'SpecificDNSorIp' = PASSWORD('secure_password');") } - push( @generalrec, -"Set up a Password for user with the following SQL statement ( SET PASSWORD FOR 'user'\@'SpecificDNSorIp' = PASSWORD('secure_password'); )" - ); } else { goodprint "All database users have passwords assigned"; @@ -1848,10 +1847,8 @@ sub security_recommendations { foreach my $line ( sort @mysqlstatlist ) { chomp($line); badprint "User '" . $line . "' has user name as password."; + push (@generalrec, "Set up a Secure Password for $line user: SET PASSWORD FOR '".(split /@/, $line)[0]."'\@'SpecificDNSorIp' = PASSWORD('secure_password');"); } - push( @generalrec, -"Set up a Secure Password for user\@host ( SET PASSWORD FOR 'user'\@'SpecificDNSorIp' = PASSWORD('secure_password'); )" - ); } @mysqlstatlist = select_array @@ -1859,11 +1856,13 @@ sub security_recommendations { if (@mysqlstatlist) { foreach my $line ( sort @mysqlstatlist ) { chomp($line); - badprint "User '" . $line - . "' does not specify hostname restrictions."; + my $luser = (split /@/, $line)[0]; + badprint "User '" . $line. "' does not specify hostname restrictions."; + push( @generalrec, + "Restrict Host for '$luser'\@% to $luser\@SpecificDNSorIp" ); + push( @generalrec, + "UPDATE mysql.user SET host ='SpecificDNSorIp' WHERE user='" . $luser. "' AND host ='%'; FLUSH PRIVILEGES;" ); } - push( @generalrec, - "Restrict Host for user\@% to user\@SpecificDNSorIp" ); } unless ( -f $basic_password_files ) { @@ -1905,6 +1904,8 @@ sub security_recommendations { chomp($line); badprint "User '" . $line . "' is using weak password: $pass in a lower, upper or capitalize derivative version."; + + push (@generalrec, "Set up a Secure Password for $line user: SET PASSWORD FOR '" . (split /@/, $line)[0] . "'\@'".(split /@/, $line)[1]."' = PASSWORD('secure_password');"); $nbins++; } } @@ -1913,7 +1914,7 @@ sub security_recommendations { } } if ( $nbins > 0 ) { - push( @generalrec, $nbins . " user(s) used basic or weak password." ); + push( @generalrec, $nbins . " user(s) used basic or weak password from basic dictionary." ); } } From cb9308ac2abdf323bc54f8aeba36d82e00f73a2f Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Thu, 3 Oct 2019 23:58:06 +0200 Subject: [PATCH 29/43] Update README.md --- README.md | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7a18e95..060d861 100644 --- a/README.md +++ b/README.md @@ -34,24 +34,37 @@ MySQLTuner needs you: Compatibility ==== Test result are available here: [Travis CI/MySQLTuner-perl](https://travis-ci.org/major/MySQLTuner-perl) -* MySQL 8 (partial support, password checks don't work) +* MySQL 8 (full support, password checks don't work) * MySQL 5.7 (full support) * MySQL 5.6 (full support) * MySQL 5.5 (full support) +* MariaDB 10.4 (full support) * MariaDB 10.3 (full support) * MariaDB 10.2 (full support) * MariaDB 10.1 (full support) * MariaDB 10.0 (full support, 6 last month support) -* MariaDB 5.5 (no more support) +* MariaDB 5.5 (full support, no more MariaDB support) +* Percona Server 8.0 (full support, password checks don't work) * Percona Server 5.7 (full support) * Percona Server 5.6 (full support) -* Percona XtraDB cluster (full support) + +* Percona XtraDB cluster (partial support, no test environment) +* Mysql Replications (partial support, no test environment) +* Galera replication (partial support, no test environment) + * MySQL 3.23, 4.0, 4.1, 5.0, 5.1, 5.5 (partial support - deprecated version) + +*** UNSUPPORTED ENVIRONMENTS - NEED HELP FOR THAT :) *** +* Windows is not supported at this time (Help wanted !!!!!) +* Cloud based is not supported at this time (Help wanted !!!!!) + +* CVE vulnerabilities detection support from [https://cve.mitre.org](https://cve.mitre.org) + +*** MINIMAL REQUIREMENTS *** + * Perl 5.6 or later (with [perl-doc](http://search.cpan.org/~dapm/perl-5.14.4/pod/perldoc.pod) package) * Unix/Linux based operating system (tested on Linux, BSD variants, and Solaris variants) -* Windows is not supported at this time (Help wanted !!!!!) * Unrestricted read access to the MySQL server (OS root access recommended for MySQL < 5.1) -* CVE vulnerabilities detection support from [https://cve.mitre.org](https://cve.mitre.org) ***WARNING*** -- From 155da8c074a426c261e246875a7797564b6bf20c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C2=B2?= Date: Fri, 4 Oct 2019 12:10:16 +0200 Subject: [PATCH 30/43] SCALAR ref while strict refs --- mysqltuner.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysqltuner.pl b/mysqltuner.pl index 6c49f06..489ddaf 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -3247,7 +3247,7 @@ sub mysql_stats { } elsif ($myvar{'table_definition_cache'} < $nbtables ) { badprint "table_definition_cache(".$myvar{'table_definition_cache'} .") is lower than number of tables($nbtables) "; push( @adjvars, - "table_definition_cache(".$myvar{'table_definition_cache'} .") > " . $$nbtables . " or -1 (autosizing if supported)" ); + "table_definition_cache(".$myvar{'table_definition_cache'} .") > " . $nbtables . " or -1 (autosizing if supported)" ); } else { goodprint "table_definition_cache(".$myvar{'table_definition_cache'} .") is upper than number of tables($nbtables)"; From 084591fdc7b51e280221dea0dc0666900cef71e4 Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Wed, 16 Oct 2019 19:53:15 +0200 Subject: [PATCH 31/43] Update .travis.yml removing perlcritic for some error --- .travis.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index def1fcf..6938b5d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,7 +44,7 @@ matrix: - mysql-server - mysql-client name: "MySQL 5.7/Perl 5.24" - perl: "5.24" + perl: "5.24" - addons: apt: sources: @@ -95,7 +95,7 @@ matrix: - mysql-server - mysql-client name: "MySQL 5.7/Perl 5.16" - perl: "5.16" + perl: "5.16" - addons: apt: sources: @@ -146,7 +146,7 @@ matrix: - mysql-server - mysql-client name: "MySQL 5.7/Perl 5.10" - perl: "5.10" + perl: "5.10" - addons: apt: sources: @@ -156,7 +156,7 @@ matrix: - mysql-client name: "MySQL 8/Perl 5.10" perl: "5.10" - + before_install: - git clone git://github.com/haarg/perl-travis-helper - source perl-travis-helper/init @@ -178,8 +178,8 @@ before_script: - cd .. script: - - perlcritic --exclude InputOutput::ProhibitInteractiveTest mysqltuner.pl - - ./mysqltuner.pl --verbose --tbstat 2>stderr.txt | tee -a "stdout.txt" +# - perlcritic --exclude InputOutput::ProhibitInteractiveTest mysqltuner.pl + - ./mysqltuner.pl --verbose --tbstat 2>stderr.txt | tee -a "stdout.txt" after_script: - echo "Standard Output: $(cat stdout.txt)" From a1c1624b81815ffa8b1d89c00d9575df1a52a8a7 Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Wed, 16 Oct 2019 20:02:43 +0200 Subject: [PATCH 32/43] Update .travis.yml --- .travis.yml | 103 ---------------------------------------------------- 1 file changed, 103 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6938b5d..fd032c7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -55,108 +55,6 @@ matrix: name: "MySQL 8/Perl 5.24" perl: "5.24" - - addons: - mariadb: "5.5" - name: "MariaDB 5.5/Perl 5.16" - perl: "5.16" - - addons: - mariadb: "10.0" - name: "MariaDB 10.0/Perl 5.16" - perl: "5.16" - - addons: - mariadb: "10.1" - name: "MariaDB 10.1/Perl 5.16" - perl: "5.16" - - addons: - mariadb: "10.2" - name: "MariaDB 10.2/Perl 5.16" - perl: "5.16" - - addons: - mariadb: "10.3" - name: "MariaDB 10.3/Perl 5.16" - perl: "5.16" - - addons: - mariadb: "10.4" - name: "MariaDB 10.4/Perl 5.16" - perl: "5.16" - - addons: - mysql: "5.5" - name: "MySQL 5.5/Perl 5.16" - perl: "5.16" - - addons: - mysql: "5.6" - name: "MySQL 5.6/Perl 5.16" - perl: "5.16" - - addons: - apt: - sources: - - mysql-5.7-trusty - packages: - - mysql-server - - mysql-client - name: "MySQL 5.7/Perl 5.16" - perl: "5.16" - - addons: - apt: - sources: - - mysql-8.0-trusty - packages: - - mysql-server - - mysql-client - name: "MySQL 8/Perl 5.16" - perl: "5.16" - - - addons: - mariadb: "5.5" - name: "MariaDB 5.5/Perl 5.10" - perl: "5.10" - - addons: - mariadb: "10.0" - name: "MariaDB 10.0/Perl 5.10" - perl: "5.10" - - addons: - mariadb: "10.1" - name: "MariaDB 10.1/Perl 5.10" - perl: "5.10" - - addons: - mariadb: "10.2" - name: "MariaDB 10.2/Perl 5.10" - perl: "5.10" - - addons: - mariadb: "10.3" - name: "MariaDB 10.3/Perl 5.10" - perl: "5.10" - - addons: - mariadb: "10.4" - name: "MariaDB 10.4/Perl 5.10" - perl: "5.10" - - addons: - mysql: "5.5" - name: "MySQL 5.5/Perl 5.10" - perl: "5.10" - - addons: - mysql: "5.6" - name: "MySQL 5.6/Perl 5.10" - perl: "5.10" - - addons: - apt: - sources: - - mysql-5.7-trusty - packages: - - mysql-server - - mysql-client - name: "MySQL 5.7/Perl 5.10" - perl: "5.10" - - addons: - apt: - sources: - - mysql-8.0-trusty - packages: - - mysql-server - - mysql-client - name: "MySQL 8/Perl 5.10" - perl: "5.10" - before_install: - git clone git://github.com/haarg/perl-travis-helper - source perl-travis-helper/init @@ -178,7 +76,6 @@ before_script: - cd .. script: -# - perlcritic --exclude InputOutput::ProhibitInteractiveTest mysqltuner.pl - ./mysqltuner.pl --verbose --tbstat 2>stderr.txt | tee -a "stdout.txt" after_script: From e1891570e3faca2d5c803c5d0484b70830c78730 Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Wed, 16 Oct 2019 20:11:59 +0200 Subject: [PATCH 33/43] Validate YAML format --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index fd032c7..e32c38b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -81,5 +81,5 @@ script: after_script: - echo "Standard Output: $(cat stdout.txt)" - echo "Standard Error : $(cat stderr.txt)" - - [ "0" = "$(wl -l stderr.txt)" ] || exit 2 +# - [ "0" = "$(wl -l stderr.txt)" ] || exit 2 From f6fae6713d67bb764b21b982306eaf399582a655 Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Wed, 16 Oct 2019 20:14:33 +0200 Subject: [PATCH 34/43] Update .travis.yml --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index e32c38b..792163c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -72,7 +72,7 @@ before_script: - chmod 600 .my.cnf - git clone https://github.com/datacharmer/test_db.git - cd test_db - - cat employees.sql | grep -v 'storage_engine' | mysql + - "cat employees.sql | grep -v 'storage_engine' | mysql" - cd .. script: @@ -81,5 +81,3 @@ script: after_script: - echo "Standard Output: $(cat stdout.txt)" - echo "Standard Error : $(cat stderr.txt)" -# - [ "0" = "$(wl -l stderr.txt)" ] || exit 2 - From 95ed36c1ee7f8a8aac1ebc721249fffaca86b031 Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Wed, 16 Oct 2019 20:22:03 +0200 Subject: [PATCH 35/43] Update .travis.yml --- .travis.yml | 83 +++++++++++++++++++++++++++-------------------------- 1 file changed, 42 insertions(+), 41 deletions(-) diff --git a/.travis.yml b/.travis.yml index 792163c..5fa0633 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,18 +4,19 @@ language: perl matrix: include: - - addons: - mariadb: "5.5" - name: "MariaDB 5.5/Perl 5.24" - perl: "5.24" - - addons: - mariadb: "10.0" - name: "MariaDB 10.0/Perl 5.24" - perl: "5.24" - - addons: - mariadb: "10.1" name: "MariaDB 10.1/Perl 5.24" - perl: "5.24" +# - addons: +# mariadb: "5.5" +# name: "MariaDB 5.5/Perl 5.24" +# perl: "5.24" +# - addons: +# mariadb: "10.0" +# name: "MariaDB 10.0/Perl 5.24" +# perl: "5.24" +# - addons: +# mariadb: "10.1" +# name: "MariaDB 10.1/Perl 5.24" +# perl: "5.24" - addons: mariadb: "10.2" name: "MariaDB 10.2/Perl 5.24" @@ -24,36 +25,36 @@ matrix: mariadb: "10.3" name: "MariaDB 10.3/Perl 5.24" perl: "5.24" - - addons: - mariadb: "10.4" - name: "MariaDB 10.4/Perl 5.24" - perl: "5.24" - - addons: - mysql: "5.5" - name: "MySQL 5.5/Perl 5.24" - perl: "5.24" - - addons: - mysql: "5.6" - name: "MySQL 5.6/Perl 5.24" - perl: "5.24" - - addons: - apt: - sources: - - mysql-5.7-trusty - packages: - - mysql-server - - mysql-client - name: "MySQL 5.7/Perl 5.24" - perl: "5.24" - - addons: - apt: - sources: - - mysql-8.0-trusty - packages: - - mysql-server - - mysql-client - name: "MySQL 8/Perl 5.24" - perl: "5.24" +# - addons: +# mariadb: "10.4" +# name: "MariaDB 10.4/Perl 5.24" +# perl: "5.24" +# - addons: +# mysql: "5.5" +# name: "MySQL 5.5/Perl 5.24" +# perl: "5.24" +# - addons: +# mysql: "5.6" +# name: "MySQL 5.6/Perl 5.24" +# perl: "5.24" +# - addons: +# apt: +# sources: +# - mysql-5.7-trusty +# packages: +# - mysql-server +# - mysql-client +# name: "MySQL 5.7/Perl 5.24" +# perl: "5.24" +# - addons: +# apt: +# sources: +# - mysql-8.0-trusty +# packages: +# - mysql-server +# - mysql-client +# name: "MySQL 8/Perl 5.24" +# perl: "5.24" before_install: - git clone git://github.com/haarg/perl-travis-helper From 216a0a98895173c584a49b16c53e2f53457a775c Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Wed, 16 Oct 2019 20:22:50 +0200 Subject: [PATCH 36/43] Update .travis.yml --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5fa0633..ccd9974 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,6 @@ language: perl matrix: include: - name: "MariaDB 10.1/Perl 5.24" # - addons: # mariadb: "5.5" # name: "MariaDB 5.5/Perl 5.24" From 345bf1ae246e0a2740ffc75064532991fa605faf Mon Sep 17 00:00:00 2001 From: Jean-Marie Renouard Date: Thu, 17 Oct 2019 17:39:45 +0200 Subject: [PATCH 37/43] Issue Typo in commit 6f6130b (ymsql => mysql) (#459) --- mysqltuner.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysqltuner.pl b/mysqltuner.pl index 489ddaf..9323ff4 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -1798,7 +1798,7 @@ sub security_recommendations { . scalar(@mysqlstatlist) . " anonymous accounts." ); push( @generalrec, - "DELETE FROM ymsql.user WHERE user ='';" ); + "DELETE FROM mysql.user WHERE user ='';" ); } else { goodprint "There are no anonymous accounts for any database users"; From c5765f02133259b40d9932eb7d35ba5c1665bad9 Mon Sep 17 00:00:00 2001 From: jfcoz Date: Thu, 12 Dec 2019 13:31:23 +0100 Subject: [PATCH 38/43] Include max_allowed_packet in thread memory size Fix https://github.com/major/MySQLTuner-perl/issues/378 Fix https://github.com/major/MySQLTuner-perl/issues/456 --- mysqltuner.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/mysqltuner.pl b/mysqltuner.pl index 9323ff4..a4d3686 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -2393,6 +2393,7 @@ sub calculations { $myvar{'read_rnd_buffer_size'} + $myvar{'sort_buffer_size'} + $myvar{'thread_stack'} + + $myvar{'max_allowed_packet'} + $myvar{'join_buffer_size'}; } else { From 3555142ead4e2347f72dd3dc0d511ff4522bfc86 Mon Sep 17 00:00:00 2001 From: Ruzgfpegk Date: Thu, 9 Jan 2020 15:04:04 +0900 Subject: [PATCH 39/43] Suggest using mariadb-sys from FromDual in script Follows #443 and #444. --- mysqltuner.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysqltuner.pl b/mysqltuner.pl index a4d3686..81d861d 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -3577,7 +3577,7 @@ sub mysqsl_pfs { "Consider installing Sys schema from https://github.com/mysql/mysql-sys for MySQL" ) unless ( mysql_version_le( 5, 6 ) ); push( @generalrec, -"Consider installing Sys schema from https://github.com/good-dba/mariadb-sys for MariaDB" +"Consider installing Sys schema from https://github.com/FromDual/mariadb-sys for MariaDB" ) unless ( mysql_version_eq( 10, 0 ) or mysql_version_eq( 5, 5 ) ); return; From 8ffd81475af539bffa9f729603123dbc12411352 Mon Sep 17 00:00:00 2001 From: Ruzgfpegk Date: Thu, 9 Jan 2020 15:53:56 +0900 Subject: [PATCH 40/43] Updates link to MyISAM table_cache scalability doc Fixes #465 . --- mysqltuner.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysqltuner.pl b/mysqltuner.pl index a4d3686..a2c7f17 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -3208,7 +3208,7 @@ sub mysql_stats { push( @generalrec, "Read this before increasing " . $table_cache_var - . " over 64: https://bit.ly/1mi7c4C" ); + . " over 64: https://bit.ly/2Fulv7r" ); push( @generalrec, "Read this before increasing for MariaDB" . " https://mariadb.com/kb/en/library/optimizing-table_open_cache/" From d3ab6db64194977719dacfed49e028894e247496 Mon Sep 17 00:00:00 2001 From: Sergei A Mamonov Date: Mon, 20 Jan 2020 21:04:32 +0300 Subject: [PATCH 41/43] Update README.ru.md --- README.ru.md | 159 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 130 insertions(+), 29 deletions(-) diff --git a/README.ru.md b/README.ru.md index d4dfdee..ce44d55 100644 --- a/README.ru.md +++ b/README.ru.md @@ -37,22 +37,38 @@ MySQLTuner нуждается в вас: Совместимость ==== +Результаты тестов: [Travis CI/MySQLTuner-perl](https://travis-ci.org/major/MySQLTuner-perl) +* MySQL 8 (полная поддержка, проверка пароля не работает) * MySQL 5.7 (полная поддержка) * MySQL 5.6 (полная поддержка) * MySQL 5.5 (полная поддержка) +* MariaDB 10.4 (полная поддержка) * MariaDB 10.3 (полная поддержка) * MariaDB 10.2 (полная поддержка) * MariaDB 10.1 (полная поддержка) -* MariaDB 10.0 (полная поддержка) +* MariaDB 10.0 (полная поддержка, последние 6 месяцeв) +* MariaDB 5.5 (полная поддержка, но без поддержки от MariaDB) +* Percona Server 8.0 (полная поддержка, проверка пароля не работает) * Percona Server 5.7 (полная поддержка) * Percona Server 5.6 (полная поддержка) -* Percona XtraDB cluster (полная поддержка) -* MySQL 3.23, 4.0, 4.1, 5.0, 5.1 (частичная поддержка - устаревшие версии) +* Percona XtraDB cluster (частичная поддержка, нет тестового окружения) + +* Mysql Replications (частичная поддержка, нет тестового окружения) +* Galera replication (частичная поддержка, нет тестового окружения) + +* MySQL 3.23, 4.0, 4.1, 5.0, 5.1, 5.5 (частичная поддержка - устаревшие версии) + +*** НЕ ПОДДЕРЖИВАЕМЫЕ ОКРУЖЕНИЯ - НУЖНА ПОМОЩЬ С НИМИ :) *** +* Windows не поддерживается на данное время (Необходима помощь!!!!!) +* Облачные сервисы(cloud based) не поддерживаются на данное время (Необходима помощь!!!!!) + +* Поддержка детектирования CVE уязвимостей из [https://cve.mitre.org](https://cve.mitre.org) + +*** МИНИМАЛЬНЫЕ ТРЕБОВАНИЯ *** + * Perl 5.6 или более поздний (с пакетом [perl-doc](http://search.cpan.org/~dapm/perl-5.14.4/pod/perldoc.pod)) * Операционная система семейства Unix/Linux (протестировано на Linux, различных вариациях BSD и Solaris) -* Windows не поддерживается на данное время (Необходима помощь!!!!!) * Неограниченный доступ на чтение для MySQL-сервера (Для работы с MySQL < 5.1 требуется root-доступ к серверу) -* Поддержка детектирования CVE уязвимостей из [https://cve.mitre.org](https://cve.mitre.org) Пожалуйста, прочитайте раздел ЧаВо, который расположен чуть ниже. @@ -67,6 +83,8 @@ MySQLTuner нуждается в вас: и всегда будьте готовы к тому, что улучшения в одной области могут иметь отрицательный эфект в работе MySQL в другой области. +Так же **важно** подождать, что бы сервер баз данных отработал хотя бы день, для получения точных реультатов. Запуск **mysqltuner** на только что перезапущенном сервере баз данных, по факту полностью бесполезен. + **Серьезно - прочитайте раздел ЧаВо, который расположен чуть ниже.** @@ -85,22 +103,69 @@ MySQLTuner нуждается в вас: Загрузка/Установка -- -Вы можете скачать весь репозиторий с помощью 'git clone' c URL текущего репозитория. Самый простой и короткий метод: +Доступны несколько методов: +1) Прямая загрузка скрипта(самый простой и короткий метод): +``` +wget http://mysqltuner.pl/ -O mysqltuner.pl +wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/basic_passwords.txt -O basic_passwords.txt +wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/vulnerabilities.csv -O vulnerabilities.csv +``` - wget http://mysqltuner.pl/ -O mysqltuner.pl - wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/basic_passwords.txt -O basic_passwords.txt - wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/vulnerabilities.csv -O vulnerabilities.csv - perl mysqltuner.pl +2) Вы можете скачать весь репозиторий с помощью `git clone` или `git clone --depth 1 -b master` c URL текущего репозитория. -Конечно, вам нужно будет добавить права на выполнение скрипта (chmod +x mysqltuner.pl), если вы хотите запускать его напрямую, без указания perl. +Оциональная установка Sysschema для MySQL 5.6 +-- + +Sysschema по умолчанию установлена на MySQL 5.7 и MySQL 8 от Oracle. +В MySQL 5.6/5.7/8 по умолчанию performance schema включена. +Для версий старше 5.6 вы можете создать новую базу данных sys, содержащую очень полезный взгляд на Performance schema следующими командами: + + curl "https://codeload.github.com/mysql/mysql-sys/zip/master" > sysschema.zip + # check zip file + unzip -l sysschema.zip + unzip sysschema.zip + cd mysql-sys-master + mysql -uroot -p < sys_56.sql + +Опциональная установка Performance schema и Sysschema для MariaDB 10.x +-- + +Sysschema не установлена по умолчанию на MariaDB 10.x. +А performance schema по умолчанию отключена в MariaDB. Для активации ее требуется включить в конфигурационном файле my.cnf: + + [mysqld] + performance_schema = on + +Вы можете создать новую базу данных sys, содержащую очень полезный взгляд на Performance schema следующими командами: + + curl "https://codeload.github.com/FromDual/mariadb-sys/zip/master" > mariadb-sys.zip + # check zip file + unzip -l mariadb-sys.zip + unzip mariadb-sys.zip + cd mariadb-sys-master/ + mysql -u root -p < ./sys_10.sql + +Ошибки и их решения при установке performance schema + + ERROR at line 21: Failed to open file './tables/sys_config_data_10.sql -- ported', error: 2 + Посмотрите на #452 решение, данное @ericx + +Советы по производительности +-- +Обновление статистики метадаты могут очень сильно влиять на производительсноить сервера баз данных и MySQLTuner. +Убедитесь, что innodb_stats_on_metadata отключен. + + set global innodb_stats_on_metadata = 0; Примеры использования -- __Пример:__ Минимальный локальный запуск - perl mysqltuner.pl + perl mysqltuner.pl --host 127.0.0.1 + +Конечно, вам нужно будет добавить права на выполнение скрипта (chmod +x mysqltuner.pl), если вы хотите запускать его напрямую, без указания perl. __Пример:__ Минимальный удаленный запуск @@ -109,7 +174,7 @@ __Пример:__ Минимальный удаленный запуск __Пример:__ Включение максимамльного вывода информации о MySQL/MariaDb без отладочной информации perl mysqltuner.pl --verbose - perl mysqltuner.pl --buffers --dbstat --idxstat --sysstat --pfstat + perl mysqltuner.pl --buffers --dbstat --idxstat --sysstat --pfstat --tbstat __Пример:__ Включение проверки на CVE уязвимости для MariaDB или MySQL @@ -132,6 +197,10 @@ __Пример:__ Включение вывода отладочной инфо perl mysqltuner.pl --debug +__Пример:__ Обновление MySQLTuner и файлов с данными (пароль и cve), если необходимо. + + perl mysqltuner.pl --checkversion --updateversion + ЧаВо -- @@ -149,7 +218,7 @@ __Пример:__ Включение вывода отладочной инфо [client] user=distributions - pass=thatuserspassword + password=thatuserspassword Сразу после создания файла убедитесь, что его владельцем является ваш пользователь, а права на файл - 0600. Это защитит ваш логин и пароль от базы данных от любопытных глаз в нормальных условиях. Но у вас не будет выбора, если появится [T-1000 в униформе полицейского из Лос-Анджелеса](https://ru.wikipedia.org/wiki/T-1000) и потребует доступы от вашей базы данных. @@ -171,7 +240,7 @@ __Пример:__ Включение вывода отладочной инфо **Вопрос: Какие минимальные привелегии нужны для специального пользователя базы данных mysqltuner?** - mysql>GRANT SELECT, PROCESS,EXECUTE, REPLICATION CLIENT,SHOW DATABASES,SHOW VIEW ON *.* FOR 'mysqltuner'@'localhost' identified by pwd1234; + mysql>GRANT SELECT, PROCESS,EXECUTE, REPLICATION CLIENT,SHOW DATABASES,SHOW VIEW ON *.* TO 'mysqltuner'@'localhost' identified by pwd1234; **Вопрос: Это не работает на моей ОС! Что делать?!** @@ -222,15 +291,11 @@ __Пример:__ Включение вывода отладочной инфо MySQLTuner и Vagrant -- **MySQLTuner** содержится в следующих конфигурациях Vagrant: -* Fedora Core 23 / MariaDB 10.0 -* Fedora Core 23 / MariaDB 10.1 -* Fedora Core 23 / MySQL 5.6 -* Fedora Core 23 / MySQL 5.7 +* Fedora Core 10 / Docker -**Vagrant File** are stored in Vagrant subdirectory. -* Follow this 2 steps after vagrant installation: -* Rename VagrantFile_for_Mxxx into Vagrantfile -* vagrant up +**Vagrant File** is stored in Vagrant subdirectory. +* Follow following step after vagrant installation: + $ vagrant up **MySQLTuner** contains a Vagrant configurations for test purpose and development * Install VirtualBox and Vagrant @@ -241,14 +306,50 @@ MySQLTuner и Vagrant * Install Vagrant plugins vagrant-hostmanager and vagrant-vbguest * vagrant plugin install vagrant-hostmanager * vagrant plugin install vagrant-vbguest -* Add Fedora Core 23 box for official Fedora Download Website - * vagrant box add --name fc23 https://download.fedoraproject.org/pub/fedora/linux/releases/23/Cloud/x86_64/Images/Fedora-Cloud-Base-Vagrant-23-20151030.x86_64.vagrant-virtualbox.box +* Add Fedora Core 30 box for official Fedora Download Website + * vagrant box add --name generic/fedora30 * Create a data directory * mkdir data -* Rename Vagrantfile_MariaDB10.0 into Vagrantfile - * cp MySQLTuner-perl/Vagrant/Vagrantfile_for_MariaDB10.0 Vagrantfile -* Start vagrant - * vagrant up + + +## Настройка тестовых окружений + + $ sh build/createTestEnvs.sh + + $ source build/bashrc + $ mysql_percona80 sakila + sakila> ... + + $ docker images + mariadb 10.1 fc612450e1f1 12 days ago 352MB + mariadb 10.2 027b7c57b8c6 12 days ago 340MB + mariadb 10.3 47dff68107c4 12 days ago 343MB + mariadb 10.4 92495405fc36 12 days ago 356MB + mysql 5.6 95e0fc47b096 2 weeks ago 257MB + mysql 5.7 383867b75fd2 2 weeks ago 373MB + mysql 8.0 b8fd9553f1f0 2 weeks ago 445MB + percona/percona-server 5.7 ddd245ed3496 5 weeks ago 585MB + percona/percona-server 5.6 ed0a36e0cf1b 6 weeks ago 421MB + percona/percona-server 8.0 390ae97d57c6 6 weeks ago 697MB + mariadb 5.5 c7bf316a4325 4 months ago 352MB + mariadb 10.0 d1bde56970c6 4 months ago 353MB + mysql 5.5 d404d78aa797 4 months ago 205MB + + $ docker ps + CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES + da2be9b050c9 mariadb:5.5 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:5311->3306/tcp mariadb55 + 5deca25d5ac8 mariadb:10.0 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:5310->3306/tcp mariadb100 + 73aaeb37e2c2 mariadb:10.1 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:5309->3306/tcp mariadb101 + 72ffa77e01ec mariadb:10.2 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:5308->3306/tcp mariadb102 + f5996f2041df mariadb:10.3 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:5307->3306/tcp mariadb103 + 4890c52372bb mariadb:10.4 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:5306->3306/tcp mariadb104 + 6b9dc078e921 percona/percona-server:5.6 "/docker-entrypoint.…" 7 hours ago Up 7 hours 0.0.0.0:4308->3306/tcp percona56 + 3a4c7c826d4c percona/percona-server:5.7 "/docker-entrypoint.…" 7 hours ago Up 7 hours 0.0.0.0:4307->3306/tcp percona57 + 3dda408c91b0 percona/percona-server:8.0 "/docker-entrypoint.…" 7 hours ago Up 7 hours 33060/tcp, 0.0.0.0:4306->3306/tcp percona80 + 600a4e7e9dcd mysql:5.5 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:3309->3306/tcp mysql55 + 4bbe54342e5d mysql:5.6 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:3308->3306/tcp mysql56 + a49783249a11 mysql:5.7 "docker-entrypoint.s…" 7 hours ago Up 7 hours 33060/tcp, 0.0.0.0:3307->3306/tcp mysql57 + d985820667c2 mysql:8.0 "docker-entrypoint.s…" 7 hours ago Up 7 hours 0.0.0.0:3306->3306/tcp, 33060/tcp mysql 8 0 MySQLTuner нуждается в Вас: === From dc4aa248c81d0bba31091d8a3238180caa8593f3 Mon Sep 17 00:00:00 2001 From: Kovalkov Dmitrii Date: Thu, 23 Jan 2020 11:24:56 +0300 Subject: [PATCH 42/43] Ignore 200122 12:09:15 mysqld_safe Logging to '/var/log/mysql/error.log'. when we count errors in log --- mysqltuner.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysqltuner.pl b/mysqltuner.pl index 76c4fc0..927a62a 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -1289,7 +1289,7 @@ sub log_file_recommendations { chomp $logLi; $numLi++; debugprint "$numLi: $logLi" if $logLi =~ /warning|error/i; - $nbErrLog++ if $logLi =~ /error/i; + $nbErrLog++ if $logLi =~ /error/i and $logLi !~ /Logging to/; $nbWarnLog++ if $logLi =~ /warning/i; push @lastShutdowns, $logLi if $logLi =~ /Shutdown complete/ and $logLi !~ /Innodb/i; From e7609d7a91614c0dc9a0b21487b33b7437636bed Mon Sep 17 00:00:00 2001 From: Kovalkov Dmitrii Date: Thu, 23 Jan 2020 16:37:45 +0300 Subject: [PATCH 43/43] And for debug line ignore these lines --- mysqltuner.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysqltuner.pl b/mysqltuner.pl index 927a62a..cc87c22 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -1288,8 +1288,8 @@ sub log_file_recommendations { while ( my $logLi = <$fh> ) { chomp $logLi; $numLi++; - debugprint "$numLi: $logLi" if $logLi =~ /warning|error/i; - $nbErrLog++ if $logLi =~ /error/i and $logLi !~ /Logging to/; + debugprint "$numLi: $logLi" if $logLi =~ /warning|error/i and $logLi !~ /Logging to/; + $nbErrLog++ if $logLi =~ /error/i and $logLi !~ /Logging to/; $nbWarnLog++ if $logLi =~ /warning/i; push @lastShutdowns, $logLi if $logLi =~ /Shutdown complete/ and $logLi !~ /Innodb/i;