clean end line

This commit is contained in:
Jean-Marie Renouard 2021-09-27 11:55:22 +02:00
parent 447652d325
commit 467e999a17
21 changed files with 1562 additions and 1562 deletions

22
.gitignore vendored
View file

@ -1,11 +1,11 @@
build/mysqltuner-* build/mysqltuner-*
build/mysqltuner.spec build/mysqltuner.spec
build/build.log build/build.log
build/cve* build/cve*
build/vulnerabilities* build/vulnerabilities*
*.bak *.bak
Vagrant/Vagrantfile Vagrant/Vagrantfile
Vagrant/data Vagrant/data
Vagrant/.vagrant Vagrant/.vagrant
contents contents
contents/* contents/*

View file

@ -1,19 +1,19 @@
--backup-and-modify-in-place --backup-and-modify-in-place
--backup-file-extension=beforeTidy --backup-file-extension=beforeTidy
--block-brace-tightness=2 --block-brace-tightness=2
--brace-tightness=2 --brace-tightness=2
--closing-token-indentation=1 --closing-token-indentation=1
--continuation-indentation=4 --continuation-indentation=4
--indent-columns=4 --indent-columns=4
--maximum-line-length=134 --maximum-line-length=134
--cuddled-else --cuddled-else
--opening-sub-brace-on-new-line --opening-sub-brace-on-new-line
--noopening-brace-on-new-line --noopening-brace-on-new-line
--nooutdent-labels --nooutdent-labels
--paren-tightness=2 --paren-tightness=2
--square-bracket-tightness=2 --square-bracket-tightness=2
--vertical-tightness=0 --vertical-tightness=0
--vertical-tightness-closing=0 --vertical-tightness-closing=0
--break-at-old-comma-breakpoints --break-at-old-comma-breakpoints
--entab-leading-whitespace=4 --entab-leading-whitespace=4
--tabs --tabs

View file

@ -1,417 +1,417 @@
## MySQLTuner Internals ## MySQLTuner Internals
## Table of contents ## Table of contents
* [MySQLTuner steps](#mysqltuner-steps) * [MySQLTuner steps](#mysqltuner-steps)
* [Get login information steps](#mysqltuner-get-login-information-steps) * [Get login information steps](#mysqltuner-get-login-information-steps)
* [System checks](#mysqltuner-system-checks) * [System checks](#mysqltuner-system-checks)
* [Server version checks](#mysqltuner-server-version-checks) * [Server version checks](#mysqltuner-server-version-checks)
* [Error log file checks](#mysql-error-log-file-analysis) * [Error log file checks](#mysql-error-log-file-analysis)
* [MySQL Storage engine general information](#mysql-storage-engine-general-information) * [MySQL Storage engine general information](#mysql-storage-engine-general-information)
* [Security checks](#mysqltuner-security-checks) * [Security checks](#mysqltuner-security-checks)
* [CVE checks](#mysqltuner-cve-checks) * [CVE checks](#mysqltuner-cve-checks)
* [Database information](#mysqltuner-database-information) * [Database information](#mysqltuner-database-information)
* [Index information](#mysqltuner-index-information) * [Index information](#mysqltuner-index-information)
* [Connections information](#mysqltuner-connections-information) * [Connections information](#mysqltuner-connections-information)
* [Server information](#mysqltuner-server-information) * [Server information](#mysqltuner-server-information)
* [Sort, join and temp table information](#mysqltuner-sort-join-and-temp-table-information) * [Sort, join and temp table information](#mysqltuner-sort-join-and-temp-table-information)
* [Global buffer information](#mysqltuner-global-buffer-information) * [Global buffer information](#mysqltuner-global-buffer-information)
* [Query cache checks](#mysqltuner-query-cache-checks) * [Query cache checks](#mysqltuner-query-cache-checks)
* [Slow queries checks](#mysqltuner-slow-queries-checks) * [Slow queries checks](#mysqltuner-slow-queries-checks)
* [ThreadPool information](#mysqltuner-threadpool-information) * [ThreadPool information](#mysqltuner-threadpool-information)
* [Replication checks](#mysqltuner-replication-checks) * [Replication checks](#mysqltuner-replication-checks)
* [InnoDB information](#mysqltuner-innodb-information) * [InnoDB information](#mysqltuner-innodb-information)
* [MYISAM information](#mysqltuner-myisam-information) * [MYISAM information](#mysqltuner-myisam-information)
* [ARIADB information](#mysqltuner-ariadb-information) * [ARIADB information](#mysqltuner-ariadb-information)
* [XTRADB information](#mysqltuner-xtradb-information) * [XTRADB information](#mysqltuner-xtradb-information)
* [TOKUDB information](#mysqltuner-tokudb-information) * [TOKUDB information](#mysqltuner-tokudb-information)
* [ROCKDB information](#mysqltuner-rockdb-information) * [ROCKDB information](#mysqltuner-rockdb-information)
* [CONNECT information](#mysqltuner-connect-information) * [CONNECT information](#mysqltuner-connect-information)
* [SPIDER information](#mysqltuner-spider-information) * [SPIDER information](#mysqltuner-spider-information)
* [GALERA information](#mysqltuner-galera-information) * [GALERA information](#mysqltuner-galera-information)
* [Performance Schema information](#mysqltuner-performance-schema-and-sysschema-information) * [Performance Schema information](#mysqltuner-performance-schema-and-sysschema-information)
## MySQLTuner steps ## MySQLTuner steps
* Header Print * Header Print
* Get login information * Get login information
* Set up some OS variables * Set up some OS variables
* Toss variables/status into hashes * Toss variables/status into hashes
* Get information about the tuning connexion * Get information about the tuning connexion
* Check current MySQL version * Check current MySQL version
* Suggest 64-bit upgrade * Suggest 64-bit upgrade
* Analyze mysqld error log file * Analyze mysqld error log file
* Show enabled storage engines * Show enabled storage engines
* Show informations about databases (option: --dbstat) * Show informations about databases (option: --dbstat)
* Show informations about indexes (option: --idxstat) * Show informations about indexes (option: --idxstat)
* Display some security recommendations * Display some security recommendations
* Calculate everything we need * Calculate everything we need
* Print the server stats * Print the server stats
* Print MyISAM stats * Print MyISAM stats
* Print InnoDB stats * Print InnoDB stats
* Print AriaDB stats * Print AriaDB stats
* Print replication info * Print replication info
* Make recommendations based on stats * Make recommendations based on stats
* Close reportfile if needed * Close reportfile if needed
* Dump result if debug is on * Dump result if debug is on
## MySQLTuner get login information steps ## MySQLTuner get login information steps
* Is a login possible? * Is a login possible?
* Force socket? * Force socket?
* Remote connection? * Remote connection?
* _Specifying available RAM is required_ * _Specifying available RAM is required_
* Got user/pass on command line? * Got user/pass on command line?
* mysql-quickbackup credentials available? * mysql-quickbackup credentials available?
* Plesk credentials available? * Plesk credentials available?
* DirectAdmin credentials available? * DirectAdmin credentials available?
* Debian maintenance account credentials available? * Debian maintenance account credentials available?
* Just try a login * Just try a login
* If working, and .my.cnf isn't there, **WARNING** * If working, and .my.cnf isn't there, **WARNING**
* If working, and .my.cnf is there, okay * If working, and .my.cnf is there, okay
* Prompt for creds on the console * Prompt for creds on the console
## MySQLTuner system checks ## MySQLTuner system checks
* 32-bit w/>2GB RAM check * 32-bit w/>2GB RAM check
* Check number of opened ports (warning if more than 9 ports opened) * Check number of opened ports (warning if more than 9 ports opened)
* Check 80, 8080, 443 and 8443 ports if warning are raised if there are opened * Check 80, 8080, 443 and 8443 ports if warning are raised if there are opened
* Check if some banned ports are not opened (option --bannedports separated by comma) * Check if some banned ports are not opened (option --bannedports separated by comma)
* Check if non kernel and user process except mysqld are not using more than 15% of total physical memory) * Check if non kernel and user process except mysqld are not using more than 15% of total physical memory)
* Check vm.swapiness * Check vm.swapiness
* Check /etc/security/limit.conf * Check /etc/security/limit.conf
* Check sysctl entries: sunrpc.tcp_slot_entries, vm.swappiness, fs.aio-fs-nr * Check sysctl entries: sunrpc.tcp_slot_entries, vm.swappiness, fs.aio-fs-nr
* Check mount point * Check mount point
* Check Ethernet card * Check Ethernet card
* Check load average * Check load average
## MySQLTuner Server version checks ## MySQLTuner Server version checks
* EOL MySQL version check * EOL MySQL version check
* Currently MySQL < 5.1 are EOF considered. * Currently MySQL < 5.1 are EOF considered.
* Using 5.5+ version of MySQL for performance issue (asynchronous IO). * Using 5.5+ version of MySQL for performance issue (asynchronous IO).
## Mysql error log file analysis ## Mysql error log file analysis
* Look for potential current error log file name * Look for potential current error log file name
* Check permission on error log file * Check permission on error log file
* Check size on error log file * Check size on error log file
* Check error and warning on error log file * Check error and warning on error log file
* Find last start and shutdown on error log file * Find last start and shutdown on error log file
## MySQL Storage engine general information ## MySQL Storage engine general information
* Get storage engine counts/stats * Get storage engine counts/stats
* Check for DB engines that are enabled but unused * Check for DB engines that are enabled but unused
* Look for fragmented tables * Look for fragmented tables
* Look for auto-increments near capacity * Look for auto-increments near capacity
* Look for table with autoincrement with value near max capacity * Look for table with autoincrement with value near max capacity
## MySQLTuner security checks ## MySQLTuner security checks
* Is anonymous user present? * Is anonymous user present?
* Users without passwords * Users without passwords
* Users w/username as password * Users w/username as password
* Users w/o host restriction * Users w/o host restriction
* Weak password check (possibly using cracklib later?) * Weak password check (possibly using cracklib later?)
* Using basic_passwords.txt as password database * Using basic_passwords.txt as password database
* Password list checks can be avoid (option: --skippassword) * Password list checks can be avoid (option: --skippassword)
## MySQLTuner CVE vulnerabilities detection ## MySQLTuner CVE vulnerabilities detection
* option: --cvefile * option: --cvefile
* Check if your MariaDB or MySQL version contains CVE bulletins. * Check if your MariaDB or MySQL version contains CVE bulletins.
## MySQLTuner database information ## MySQLTuner database information
* Performance analysis parameter checks * Performance analysis parameter checks
* Per database information * Per database information
* Tables number * Tables number
* Rows number * Rows number
* Total size * Total size
* Data size * Data size
* Percentage of data size * Percentage of data size
* Index size * Index size
* Percentage of index size * Percentage of index size
* Collation number * Collation number
* Check that there is only one collation for all table in a database * Check that there is only one collation for all table in a database
* Check that there is only one collation for ll table columns in a database * Check that there is only one collation for ll table columns in a database
* Check that there is only one storage engine per user database * Check that there is only one storage engine per user database
## MySQLTuner index information ## MySQLTuner index information
* Top 10 worth selectivity index * Top 10 worth selectivity index
* Per index information * Per index information
* Index Cardinality * Index Cardinality
* Index Selectivity * Index Selectivity
* Misc information about index definition * Misc information about index definition
* Misc information about index size * Misc information about index size
## MySQLTuner Connections information ## MySQLTuner Connections information
* Highest usage of available connections * Highest usage of available connections
* Percentage of used connections (<85%) * Percentage of used connections (<85%)
* Percentage of aborted connections (<3%) * Percentage of aborted connections (<3%)
## MySQLTuner server information ## MySQLTuner server information
* Uptime: If MySQL started within last 24 hours * Uptime: If MySQL started within last 24 hours
* Bytes received and sent * Bytes received and sent
* Number of connections * Number of connections
* Percentage between reads and writes * Percentage between reads and writes
* Is binary log activated ? * Is binary log activated ?
* Is GTID mode activated ? * Is GTID mode activated ?
## MySQLTuner sort, join and temp table information ## MySQLTuner sort, join and temp table information
* Max memory temporary table size allowed. * Max memory temporary table size allowed.
* Percentage of sort using temporary table (<10%) * Percentage of sort using temporary table (<10%)
* Number of join performed without using indexes (<250) * Number of join performed without using indexes (<250)
* Percentage of temporary table written on disk(<25%) * Percentage of temporary table written on disk(<25%)
* Thread cache (=4) * Thread cache (=4)
* Thread cache hit ratio (>50%) if thread_handling is different of pools-of-threads * Thread cache hit ratio (>50%) if thread_handling is different of pools-of-threads
* Table cache hit ratio(>2°%) * Table cache hit ratio(>2°%)
* Table cache definition should be upper that total number of tables or in autoresizing mode * 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 open file and open file limit(<85%)
* Percentage of table locks (<95%) * Percentage of table locks (<95%)
* Percentage of binlog cache lock (<90%) * Percentage of binlog cache lock (<90%)
## MySQLTuner global buffer information ## MySQLTuner global buffer information
* Key Buffer * Key Buffer
* Max Tmp Table * Max Tmp Table
* Per Thread Buffer * Per Thread Buffer
* Read Buffer * Read Buffer
* Read RND Buffer * Read RND Buffer
* Sort Buffer * Sort Buffer
* Thread stack * Thread stack
* Join Buffer * Join Buffer
* Binlog Cache Buffers size if activated * Binlog Cache Buffers size if activated
## MySQLTuner query cache checks ## MySQLTuner query cache checks
* Is Query cache activated ? * Is Query cache activated ?
* Query Cache Buffers * Query Cache Buffers
* Query Cache DISABLED, ALL REQUEST or ON DEMAND * Query Cache DISABLED, ALL REQUEST or ON DEMAND
* Query Cache Size * Query Cache Size
* Query cache hit ratio (cache efficiency) * Query cache hit ratio (cache efficiency)
## MySQLTuner memory checks ## MySQLTuner memory checks
* Get total RAM/swap * Get total RAM/swap
* Is there enough memory for max connections reached by MySQL ? * Is there enough memory for max connections reached by MySQL ?
* Is there enough memory for max connections allowed by MySQL ? * Is there enough memory for max connections allowed by MySQL ?
* Max percentage of memory used(<85%) * Max percentage of memory used(<85%)
## MySQLTuner slow queries checks ## MySQLTuner slow queries checks
* Percentage of Slow queries (<5%) * Percentage of Slow queries (<5%)
## MySQLTuner replication checks ## MySQLTuner replication checks
* Is server replication configured as slave ? * Is server replication configured as slave ?
* SQL replication thread running ? * SQL replication thread running ?
* IO replication thread running ? * IO replication thread running ?
* Replication lag in seconds (Seconds_behind_master) * Replication lag in seconds (Seconds_behind_master)
* Is Slave configured in read only ? * Is Slave configured in read only ?
* replication type ROW, MIX, STMT * replication type ROW, MIX, STMT
* replication Semisync master * replication Semisync master
* replication Semisync slave * replication Semisync slave
* XA support activated * XA support activated
* replication started ? * replication started ?
## MySQLTuner InnoDB information ## MySQLTuner InnoDB information
* InnoDB Buffer Pool Size * InnoDB Buffer Pool Size
* If possible, innodb_buffer_pool_size should be greater data and index size for Innodb Table * If possible, innodb_buffer_pool_size should be greater data and index size for Innodb Table
* Innodb_buffer_pool_size should around 75 to 80 % of the available system memory. * Innodb_buffer_pool_size should around 75 to 80 % of the available system memory.
* InnoDB Buffer Pool Instances * InnoDB Buffer Pool Instances
* MySQL needs 1 instance per 1Go of Buffer Pool * MySQL needs 1 instance per 1Go of Buffer Pool
* innodb_buffer_pool instances = round(innodb_buffer_pool_size / 1Go) * innodb_buffer_pool instances = round(innodb_buffer_pool_size / 1Go)
* innodb_buffer_pool instances must be equals or lower than 64 * 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). - 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 * InnoDB Buffer Pool Usage
* If more than 20% of InnoDB buffer pool is not used, MySQLTuner raise an alert. * If more than 20% of InnoDB buffer pool is not used, MySQLTuner raise an alert.
* InnoDB Buffer Pool Log Size * InnoDB Buffer Pool Log Size
* InnoDB total log file size should be 25% of innodb_buffer_pool_size * InnoDB total log file size should be 25% of innodb_buffer_pool_size
* InnoDB Read efficiency * InnoDB Read efficiency
* Ratio of read without locks * Ratio of read without locks
* InnoDB Write efficiency * InnoDB Write efficiency
* Ratio of write without locks * Ratio of write without locks
* InnoDB Log Waits * InnoDB Log Waits
* Checks that no lock is used on Innodb Log. * Checks that no lock is used on Innodb Log.
* InnoDB Chunk Size * InnoDB Chunk Size
* Check InnoDB Buffer Pool size is a multiple of InnoDB Buffer Pool chunk size * InnoDB Buffer Pool instances * Check InnoDB Buffer Pool size is a multiple of InnoDB Buffer Pool chunk size * InnoDB Buffer Pool instances
## MySQLTuner ARIADB information ## MySQLTuner ARIADB information
* Is Aria indexes size is greater than page cache size ? * Is Aria indexes size is greater than page cache size ?
* Page cache read hit ratio (>95%) * Page cache read hit ratio (>95%)
* Page cache write hit ratio (>95%) * Page cache write hit ratio (>95%)
## MySQLTuner MYISAM information ## MySQLTuner MYISAM information
* Key buffer usage (>90%) * Key buffer usage (>90%)
* Is MyISAM indexes size is greater than key buffer size ? * Is MyISAM indexes size is greater than key buffer size ?
* Key buffer read hit ratio (>95%) * Key buffer read hit ratio (>95%)
* Key buffer write hit ratio (>95%) * Key buffer write hit ratio (>95%)
## MySQLTuner Galera information ## MySQLTuner Galera information
* wsrep_ready cluster is ready * wsrep_ready cluster is ready
* wsrep_connected node is connected to other nodes * wsrep_connected node is connected to other nodes
* wsrep_cluster_name is defined. * wsrep_cluster_name is defined.
* wsrep_node_name is defined. * wsrep_node_name is defined.
* Check thet notification script wsrep_notify_cmd is defined * Check thet notification script wsrep_notify_cmd is defined
* wsrep_cluster_status PRIMARY /NON PRIMARY. * wsrep_cluster_status PRIMARY /NON PRIMARY.
* PRIMARY : Coherent cluster * PRIMARY : Coherent cluster
* NO PRIMARY : cluster gets several states * NO PRIMARY : cluster gets several states
* wsrep_ local_state_comment: Node state * wsrep_ local_state_comment: Node state
* SYNCED (uptodate), * SYNCED (uptodate),
* DONOR(sending information to another node) * DONOR(sending information to another node)
* Joiner(Try to reach cluster group) * Joiner(Try to reach cluster group)
* SYNCED state able to read/write * SYNCED state able to read/write
* wsrep_cluster_conf_id configuration level must be identical in all nodes * wsrep_cluster_conf_id configuration level must be identical in all nodes
* wsrep_slave_thread is between 3 or 4 times number of CPU core. * wsrep_slave_thread is between 3 or 4 times number of CPU core.
* gcs.limit should be equal to wsrep_slave_threads * 5 * gcs.limit should be equal to wsrep_slave_threads * 5
* gcs.fc_factor should be equal to 0.8 * gcs.fc_factor should be equal to 0.8
* Flow control fraction should be lower than 0.02 (wsrep_flow_control_paused < 0.02) * Flow control fraction should be lower than 0.02 (wsrep_flow_control_paused < 0.02)
* wsrep_last_commited committed level must be identical in all nodes * wsrep_last_commited committed level must be identical in all nodes
* Look for tables without primary keys * Look for tables without primary keys
* Look for non InnoDB tables for Galera * Look for non InnoDB tables for Galera
* Variable innodb_flush_log_at_trx_commit should be set to 0. * Variable innodb_flush_log_at_trx_commit should be set to 0.
* Check that there is 3 or 5 members in Galera cluster. * Check that there is 3 or 5 members in Galera cluster.
* Check that xtrabackup is used for SST method with wsrep_sst_method variable. * Check that xtrabackup is used for SST method with wsrep_sst_method variable.
* Check variables wsrep_OSU_method is defined to TOI for updates. * Check variables wsrep_OSU_method is defined to TOI for updates.
* Check that there is no certification failures controlling wsrep_local_cert_failures status. * Check that there is no certification failures controlling wsrep_local_cert_failures status.
## MySQLTuner TokuDB information ## MySQLTuner TokuDB information
* tokudb_cache_size * tokudb_cache_size
* tokudb_directio * tokudb_directio
* tokudb_empty_scan * tokudb_empty_scan
* tokudb_read_block_size * tokudb_read_block_size
* tokudb_commit_sync * tokudb_commit_sync
* tokudb_checkpointing_period * tokudb_checkpointing_period
* tokudb_block_size * tokudb_block_size
* tokudb_cleaner_iterations * tokudb_cleaner_iterations
* tokudb_fanout * tokudb_fanout
## MySQLTuner XtraDB information ## MySQLTuner XtraDB information
* Nothing for the moment * Nothing for the moment
## MySQLTuner Connect information ## MySQLTuner Connect information
* Nothing for the moment * Nothing for the moment
## MySQLTuner Spider information ## MySQLTuner Spider information
* Nothing for the moment * Nothing for the moment
## MySQLTuner RocksDb information ## MySQLTuner RocksDb information
* Nothing for the moment * Nothing for the moment
## MySQLTuner Thread pool information ## MySQLTuner Thread pool information
* thread_pool_size between 16 to 36 for Innodb usage * thread_pool_size between 16 to 36 for Innodb usage
* thread_pool_size between 4 to 8 for MyIsam usage * thread_pool_size between 4 to 8 for MyIsam usage
## MySQLTuner performance schema and sysschema information ## MySQLTuner performance schema and sysschema information
* Check that Performance schema is activated for 5.6+ version * Check that Performance schema is activated for 5.6+ version
* Check that Performance schema is deactivated for 5.5- version * Check that Performance schema is deactivated for 5.5- version
* Check that Sys schema is installed * Check that Sys schema is installed
* sys Schema version * sys Schema version
* Top user per connection * Top user per connection
* Top user per statement * Top user per statement
* Top user per statement latency * Top user per statement latency
* Top user per lock latency * Top user per lock latency
* Top user per full scans * Top user per full scans
* Top user per row_sent * Top user per row_sent
* Top user per row modified * Top user per row modified
* Top user per io * Top user per io
* Top user per io latency * Top user per io latency
* Top host per connection * Top host per connection
* Top host per statement * Top host per statement
* Top host per statement latency * Top host per statement latency
* Top host per lock latency * Top host per lock latency
* Top host per full scans * Top host per full scans
* Top host per rows sent * Top host per rows sent
* Top host per rows modified * Top host per rows modified
* Top host per io * Top host per io
* Top 5 host per io latency * Top 5 host per io latency
* Top IO type order by total io * Top IO type order by total io
* Top IO type order by total latency * Top IO type order by total latency
* Top IO type order by max latency * Top IO type order by max latency
* Top Stages order by total io * Top Stages order by total io
* Top Stages order by total latency * Top Stages order by total latency
* Top Stages order by avg latency * Top Stages order by avg latency
* Top host per table scans * Top host per table scans
* InnoDB Buffer Pool by schema * InnoDB Buffer Pool by schema
* InnoDB Buffer Pool by table * InnoDB Buffer Pool by table
* Process per allocated memory * Process per allocated memory
* InnoDB Lock Waits * InnoDB Lock Waits
* Threads IO Latency * Threads IO Latency
* High Cost SQL statements * High Cost SQL statements
* Top 5% slower queries * Top 5% slower queries
* Top 10 nb statement type * Top 10 nb statement type
* Top statement by total latency * Top statement by total latency
* Top statement by lock latency * Top statement by lock latency
* Top statement by full scans * Top statement by full scans
* Top statement by rows sent * Top statement by rows sent
* Top statement by rows modified * Top statement by rows modified
* Use temporary tables * Use temporary tables
* Unused Indexes * Unused Indexes
* Full table scans * Full table scans
* Latest file IO by latency * Latest file IO by latency
* File by IO read bytes * File by IO read bytes
* File by IO written bytes * File by IO written bytes
* File per IO total latency * File per IO total latency
* File per IO read latency * File per IO read latency
* File per IO write latency * File per IO write latency
* Event Wait by read bytes * Event Wait by read bytes
* Event Wait by write bytes * Event Wait by write bytes
* Event per wait total latency * Event per wait total latency
* Event per wait read latency * Event per wait read latency
* Event per wait write latency * Event per wait write latency
* TOP 15 most read indexes * TOP 15 most read indexes
* TOP 15 most modified indexes * TOP 15 most modified indexes
* TOP 15 high select latency index * TOP 15 high select latency index
* TOP 15 high insert latency index * TOP 15 high insert latency index
* TOP 15 high update latency index * TOP 15 high update latency index
* TOP 15 high delete latency index * TOP 15 high delete latency index
* TOP 15 most read tables * TOP 15 most read tables
* TOP 15 most modified tables * TOP 15 most modified tables
* TOP 15 high select latency tables * TOP 15 high select latency tables
* TOP 15 high insert latency tables * TOP 15 high insert latency tables
* TOP 15 high update latency tables * TOP 15 high update latency tables
* TOP 15 high delete latency tables * TOP 15 high delete latency tables
* Redundant indexes * Redundant indexes
* Tables not using InnoDb buffer * Tables not using InnoDb buffer
* Top 15 Tables using InnoDb buffer * Top 15 Tables using InnoDb buffer
* Top 15 Tables with InnoDb buffer free * Top 15 Tables with InnoDb buffer free
* Top 15 Most executed queries * Top 15 Most executed queries
* Latest SQL queries in errors or warnings * Latest SQL queries in errors or warnings
* Top 20 queries with full table scans * Top 20 queries with full table scans
* TOP 15 reader queries (95% percentile) * TOP 15 reader queries (95% percentile)
* TOP 15 row look queries (95% percentile) * TOP 15 row look queries (95% percentile)
* TOP 15 total latency queries (95% percentile) * TOP 15 total latency queries (95% percentile)
* TOP 15 max latency queries (95% percentile) * TOP 15 max latency queries (95% percentile)
* TOP 15 average latency queries (95% percentile) * TOP 15 average latency queries (95% percentile)
* Top 20 queries with sort * Top 20 queries with sort
* Last 50 queries with sort * Last 50 queries with sort
* TOP 15 row sorting queries with sort * TOP 15 row sorting queries with sort
* TOP 15 total latency queries with sort * TOP 15 total latency queries with sort
* TOP 15 merge queries with sort * TOP 15 merge queries with sort
* TOP 15 average sort merges queries with sort * TOP 15 average sort merges queries with sort
* TOP 15 scans queries with sort * TOP 15 scans queries with sort
* TOP 15 range queries with sort * TOP 15 range queries with sort
* Top 20 queries with temp table * Top 20 queries with temp table
* Last 50 queries with temp table * Last 50 queries with temp table
* TOP 15 total latency queries with temp table * TOP 15 total latency queries with temp table
* TOP 15 queries with temp table to disk * TOP 15 queries with temp table to disk
* TOP 15 class events by number * TOP 15 class events by number
* TOP 30 events by number * TOP 30 events by number
* TOP 15 class events by total latency * TOP 15 class events by total latency
* TOP 30 events by total latency * TOP 30 events by total latency
* TOP 15 class events by max latency * TOP 15 class events by max latency
* TOP 30 events by max latency * TOP 30 events by max latency

View file

@ -1,236 +1,236 @@
MySQLTuner-perl MySQLTuner-perl
==== ====
[![Build Status - Master](https://travis-ci.org/major/MySQLTuner-perl.svg?branch=master)](https://travis-ci.org/major/MySQLTuner-perl) [![Build Status - Master](https://travis-ci.org/major/MySQLTuner-perl.svg?branch=master)](https://travis-ci.org/major/MySQLTuner-perl)
[![Project Status](http://opensource.box.com/badges/active.svg)](http://opensource.box.com/badges) [![Project Status](http://opensource.box.com/badges/active.svg)](http://opensource.box.com/badges)
[![Project Status](http://opensource.box.com/badges/maintenance.svg)](http://opensource.box.com/badges) [![Project Status](http://opensource.box.com/badges/maintenance.svg)](http://opensource.box.com/badges)
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/major/MySQLTuner-perl.svg)](http://isitmaintained.com/project/major/MySQLTuner-perl "Average time to resolve an issue") [![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/major/MySQLTuner-perl.svg)](http://isitmaintained.com/project/major/MySQLTuner-perl "Average time to resolve an issue")
[![Percentage of issues still open](http://isitmaintained.com/badge/open/major/MySQLTuner-perl.svg)](http://isitmaintained.com/project/major/MySQLTuner-perl "Percentage of issues still open") [![Percentage of issues still open](http://isitmaintained.com/badge/open/major/MySQLTuner-perl.svg)](http://isitmaintained.com/project/major/MySQLTuner-perl "Percentage of issues still open")
[![GPL Licence](https://badges.frapsoft.com/os/gpl/gpl.png?v=103)](https://opensource.org/licenses/GPL-3.0/) [![GPL Licence](https://badges.frapsoft.com/os/gpl/gpl.png?v=103)](https://opensource.org/licenses/GPL-3.0/)
**MySQLTuner** est un script écrit en Perl qui permet d'effectuer une revue de configuration pour MySQL/MAriaDB/PerconaDB rapidement et propose des ajustements pour améliorer la performance et la stabilité du serveur. L'état des variables et statuts est analysé et présenté de manière synthétique et structurée ainsi que plusieurs suggestions basiques concernant la performance. **MySQLTuner** est un script écrit en Perl qui permet d'effectuer une revue de configuration pour MySQL/MAriaDB/PerconaDB rapidement et propose des ajustements pour améliorer la performance et la stabilité du serveur. L'état des variables et statuts est analysé et présenté de manière synthétique et structurée ainsi que plusieurs suggestions basiques concernant la performance.
**MySQLTuner** supporte dans a dernière version plus de ~300 indicators pour MySQL/MariaDB/Percona Server. **MySQLTuner** supporte dans a dernière version plus de ~300 indicators pour MySQL/MariaDB/Percona Server.
**MySQLTuner** is maintained and indicator collect is increasing week after week supporting a lot of configuration sush as ![Galera Cluster](http://galeracluster.com/), ![TokuDB](https://www.percona.com/software/mysql-database/percona-tokudb), ![ Performance schema](https://github.com/mysql/mysql-sys), Linux OS metrics, ![InnoDB](http://dev.mysql.com/doc/refman/5.7/en/innodb-storage-engine.html), ![MyISAM](http://dev.mysql.com/doc/refman/5.7/en/myisam-storage-engine.html), ![Aria](https://mariadb.com/kb/en/mariadb/aria/), ... **MySQLTuner** is maintained and indicator collect is increasing week after week supporting a lot of configuration sush as ![Galera Cluster](http://galeracluster.com/), ![TokuDB](https://www.percona.com/software/mysql-database/percona-tokudb), ![ Performance schema](https://github.com/mysql/mysql-sys), Linux OS metrics, ![InnoDB](http://dev.mysql.com/doc/refman/5.7/en/innodb-storage-engine.html), ![MyISAM](http://dev.mysql.com/doc/refman/5.7/en/myisam-storage-engine.html), ![Aria](https://mariadb.com/kb/en/mariadb/aria/), ...
You can found more details on this indicators You can found more details on this indicators
![Indicators description](https://github.com/major/MySQLTuner-perl/blob/master/INTERNALS.md). ![Indicators description](https://github.com/major/MySQLTuner-perl/blob/master/INTERNALS.md).
![MysqlTuner](https://github.com/major/MySQLTuner-perl/blob/master/mysqltuner.png) ![MysqlTuner](https://github.com/major/MySQLTuner-perl/blob/master/mysqltuner.png)
MySQLTuner needs you: MySQLTuner needs you:
=== ===
**MySQLTuner** needs contributors for documentation, code and feedbacks.. **MySQLTuner** needs contributors for documentation, code and feedbacks..
* Please join us on issue track at [GitHub tracker](https://github.com/major/MySQLTuner-perl/issues)</a>. * Please join us on issue track at [GitHub tracker](https://github.com/major/MySQLTuner-perl/issues)</a>.
* Contribution guide is avalaible following [MySQLTuner contributing guide](https://github.com/major/MySQLTuner-perl/blob/master/CONTRIBUTING.md) * Contribution guide is avalaible following [MySQLTuner contributing guide](https://github.com/major/MySQLTuner-perl/blob/master/CONTRIBUTING.md)
* Star **MySQLTuner project** at [MySQLTuner Git Hub Project](https://github.com/major/MySQLTuner-perl) * Star **MySQLTuner project** at [MySQLTuner Git Hub Project](https://github.com/major/MySQLTuner-perl)
Compatibility: Compatibility:
==== ====
* MySQL 5.7 (full support) * MySQL 5.7 (full support)
* MySQL 5.6 (full support) * MySQL 5.6 (full support)
* MySQL 5.5 (full support) * MySQL 5.5 (full support)
* MariaDB 10.1 (full support) * MariaDB 10.1 (full support)
* MariaDB 10.0 (full support) * MariaDB 10.0 (full support)
* Percona Server 5.6 (full support) * Percona Server 5.6 (full support)
* Percona XtraDB cluster (full support) * Percona XtraDB cluster (full support)
* MySQL 3.23, 4.0, 4.1, 5.0, 5.1 (partial support - deprecated version) * MySQL 3.23, 4.0, 4.1, 5.0, 5.1 (partial support - deprecated version)
* Perl 5.6 or later (with [perl-doc](http://search.cpan.org/~dapm/perl-5.14.4/pod/perldoc.pod) package) * 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) * Unix/Linux based operating system (tested on Linux, BSD variants, and Solaris variants)
* Windows is not supported at this time (Help wanted !!!!!) * Windows is not supported at this time (Help wanted !!!!!)
* Unrestricted read access to the MySQL server (OS root access recommended for MySQL < 5.1) * Unrestricted read access to the MySQL server (OS root access recommended for MySQL < 5.1)
* CVE vulnerabilites detection support from [https://cve.mitre.org](https://cve.mitre.org) * CVE vulnerabilites detection support from [https://cve.mitre.org](https://cve.mitre.org)
***WARNING*** ***WARNING***
-- --
It is **extremely important** for you to fully understand each change It is **extremely important** for you to fully understand each change
you make to a MySQL database server. If you don't understand portions you make to a MySQL database server. If you don't understand portions
of the script's output, or if you don't understand the recommendations, of the script's output, or if you don't understand the recommendations,
**you should consult** a knowledgeable DBA or system administrator **you should consult** a knowledgeable DBA or system administrator
that you trust. **Always** test your changes on staging environments, and that you trust. **Always** test your changes on staging environments, and
always keep in mind that improvements in one area can **negatively affect** always keep in mind that improvements in one area can **negatively affect**
MySQL in other areas. MySQL in other areas.
**Seriously - please review the FAQ section below.** **Seriously - please review the FAQ section below.**
What MySQLTuner is checking exactly ? What MySQLTuner is checking exactly ?
-- --
All checks done by **MySQLTuner** are documented in [MySQLTuner Internals](https://github.com/major/MySQLTuner-perl/blob/master/INTERNALS.md) documentation. All checks done by **MySQLTuner** are documented in [MySQLTuner Internals](https://github.com/major/MySQLTuner-perl/blob/master/INTERNALS.md) documentation.
Download/Installation Download/Installation
-- --
You can download the entire repository by using 'git clone' followed by the cloning URL above. The simplest and shortest method is: You can download the entire repository by using 'git clone' followed by the cloning URL above. The simplest and shortest method is:
wget http://mysqltuner.pl/ -O mysqltuner.pl 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/basic_passwords.txt -O basic_passwords.txt
wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/vulnerabilities.csv -O vulnerabilities.csv wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/vulnerabilities.csv -O vulnerabilities.csv
perl mysqltuner.pl perl mysqltuner.pl
Of course, you can add the execute bit (`chmod +x mysqltuner.pl`) so you can execute it without calling perl directly. Of course, you can add the execute bit (`chmod +x mysqltuner.pl`) so you can execute it without calling perl directly.
Specific usage Specific usage
-- --
__Usage:__ Minimal usage locally __Usage:__ Minimal usage locally
perl mysqltuner.pl perl mysqltuner.pl
__Usage:__ Minimal usage remotely __Usage:__ Minimal usage remotely
perl mysqltuner.pl --host targetDNS_IP --user admin_user --pass admin_password perl mysqltuner.pl --host targetDNS_IP --user admin_user --pass admin_password
__Usage:__ Enable maximum output information around MySQL/MariaDb without debugging __Usage:__ Enable maximum output information around MySQL/MariaDb without debugging
perl mysqltuner.pl --verbose perl mysqltuner.pl --verbose
perl mysqltuner.pl --buffers --dbstat --idxstat --sysstat --pfstat perl mysqltuner.pl --buffers --dbstat --idxstat --sysstat --pfstat
__Usage:__ Enable CVE vulnerabilities check for your MariaDB or MySQL version __Usage:__ Enable CVE vulnerabilities check for your MariaDB or MySQL version
perl mysqltuner.pl --cvefile=vulnerabilities.csv perl mysqltuner.pl --cvefile=vulnerabilities.csv
__Usage:__ Write your result in a file with information displayed __Usage:__ Write your result in a file with information displayed
perl mysqltuner.pl --outputfile /tmp/result_mysqltuner.txt perl mysqltuner.pl --outputfile /tmp/result_mysqltuner.txt
__Usage:__ Write your result in a file **without outputting information** __Usage:__ Write your result in a file **without outputting information**
perl mysqltuner.pl --silent --outputfile /tmp/result_mysqltuner.txt perl mysqltuner.pl --silent --outputfile /tmp/result_mysqltuner.txt
__Usage:__ Using template model to customize your reporting file based on [Text::Template](https://metacpan.org/pod/Text::Template) syntax. __Usage:__ Using template model to customize your reporting file based on [Text::Template](https://metacpan.org/pod/Text::Template) syntax.
perl mysqltuner.pl --silent --reportfile /tmp/result_mysqltuner.txt --template=/tmp/mymodel.tmpl perl mysqltuner.pl --silent --reportfile /tmp/result_mysqltuner.txt --template=/tmp/mymodel.tmpl
__Usage:__ Enable debugging information __Usage:__ Enable debugging information
perl mysqltuner.pl --debug perl mysqltuner.pl --debug
FAQ FAQ
-- --
**Question: Will MySQLTuner fix my slow MySQL server?** **Question: Will MySQLTuner fix my slow MySQL server?**
**No.** MySQLTuner is a read only script. It won't write to any configuration files, change the status of any daemons, or call your mother to wish her a happy birthday. It will give you an overview of your server's performance and make some basic recommendations about improvements that you can make after it completes. *Make sure you read the warning above prior to following any recommendations.* **No.** MySQLTuner is a read only script. It won't write to any configuration files, change the status of any daemons, or call your mother to wish her a happy birthday. It will give you an overview of your server's performance and make some basic recommendations about improvements that you can make after it completes. *Make sure you read the warning above prior to following any recommendations.*
**Question: Can I fire my DBA now?** **Question: Can I fire my DBA now?**
**MySQLTuner will not replace your DBA in any form or fashion.** If your DBA constantly takes your parking spot and steals your lunch from the fridge, then you may want to consider it - but that's your call. **MySQLTuner will not replace your DBA in any form or fashion.** If your DBA constantly takes your parking spot and steals your lunch from the fridge, then you may want to consider it - but that's your call.
**Question: Why does MySQLTuner keep asking me the login credentials for MySQL over and over?** **Question: Why does MySQLTuner keep asking me the login credentials for MySQL over and over?**
The script will try its best to log in via any means possible. It will check for ~/.my.cnf files, Plesk password files, and empty password root logins. If none of those are available, then you'll be prompted for a password. If you'd like the script to run in an automated fashion without user intervention, then create a .my.cnf file in your home directory which contains: The script will try its best to log in via any means possible. It will check for ~/.my.cnf files, Plesk password files, and empty password root logins. If none of those are available, then you'll be prompted for a password. If you'd like the script to run in an automated fashion without user intervention, then create a .my.cnf file in your home directory which contains:
[client] [client]
user=someusername user=someusername
pass=thatuserspassword pass=thatuserspassword
Once you create it, make sure it's owned by your user and the mode on the file is 0600. This should prevent the prying eyes from getting your database login credentials under normal conditions. If a [T-1000 shows up in a LAPD uniform](https://en.wikipedia.org/wiki/T-1000) and demands your database credentials, you won't have much of an option. Once you create it, make sure it's owned by your user and the mode on the file is 0600. This should prevent the prying eyes from getting your database login credentials under normal conditions. If a [T-1000 shows up in a LAPD uniform](https://en.wikipedia.org/wiki/T-1000) and demands your database credentials, you won't have much of an option.
**Question: Is there another way to secure credentials on latest MySQL and MariaDB distributions ?** **Question: Is there another way to secure credentials on latest MySQL and MariaDB distributions ?**
You could use mysql_config_editor utilities. You could use mysql_config_editor utilities.
$ mysql_config_editor set --login-path=client --user=someusername --password --host=localhost $ mysql_config_editor set --login-path=client --user=someusername --password --host=localhost
Enter passord: ******** Enter passord: ********
$ $
At this time, ~/.mylogin.cnf has been written with appropriated rigth access. At this time, ~/.mylogin.cnf has been written with appropriated rigth access.
To get information about stored credentials, use the following command: To get information about stored credentials, use the following command:
$mysql_config_editor print $mysql_config_editor print
[client] [client]
user = someusername user = someusername
password = ***** password = *****
host = localhost host = localhost
**Question: What's minimum privileges needed by a specific mysqltuner user in database ?** **Question: What's minimum privileges needed by a specific mysqltuner user in database ?**
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 *.* FOR 'mysqltuner'@'localhost' identified by pwd1234;
**Question: It's not working on my OS! What gives?!** **Question: It's not working on my OS! What gives?!**
These kinds of things are bound to happen. Here are the details I need from you in order to research the problem thoroughly: These kinds of things are bound to happen. Here are the details I need from you in order to research the problem thoroughly:
* OS and OS version * OS and OS version
* Architecture (x86, x86_64, IA64, Commodore 64) * Architecture (x86, x86_64, IA64, Commodore 64)
* Exact MySQL version * Exact MySQL version
* Where you obtained your MySQL version (OS package, source, etc) * Where you obtained your MySQL version (OS package, source, etc)
* The full text of the error * The full text of the error
* A copy of SHOW VARIABLES and SHOW GLOBAL STATUS output (if possible) * A copy of SHOW VARIABLES and SHOW GLOBAL STATUS output (if possible)
**Question: How to perform a CVE vulneralibity checks ?** **Question: How to perform a CVE vulneralibity checks ?**
* Download vulnerabilities.csv from this repository. * Download vulnerabilities.csv from this repository.
* use option --cvefile to perform CVE checks * use option --cvefile to perform CVE checks
**Question: How to use mysqltuner from remote host ?** **Question: How to use mysqltuner from remote host ?**
Thanks to [@rolandomysqldba](http://dba.stackexchange.com/users/877/rolandomysqldba) Thanks to [@rolandomysqldba](http://dba.stackexchange.com/users/877/rolandomysqldba)
* You will still have to connect like a mysql client: * You will still have to connect like a mysql client:
Connection and Authentication Connection and Authentication
--host <hostname> Connect to a remote host to perform tests (default: localhost) --host <hostname> Connect to a remote host to perform tests (default: localhost)
--socket <socket> Use a different socket for a local connection --socket <socket> Use a different socket for a local connection
--port <port> Port to use for connection (default: 3306) --port <port> Port to use for connection (default: 3306)
--user <username> Username to use for authentication --user <username> Username to use for authentication
--pass <password> Password to use for authentication --pass <password> Password to use for authentication
--defaults-file <path> defaulfs file for credentials --defaults-file <path> defaulfs file for credentials
Since you are using a remote host, use parameters to supply values from the OS Since you are using a remote host, use parameters to supply values from the OS
--forcemem <size> Amount of RAM installed in megabytes --forcemem <size> Amount of RAM installed in megabytes
--forceswap <size> Amount of swap memory configured in megabytes --forceswap <size> Amount of swap memory configured in megabytes
* You may have to contact your remote SysAdmin to ask how much RAM and swap you have * You may have to contact your remote SysAdmin to ask how much RAM and swap you have
If the database has too many tables, or very large table, use this: If the database has too many tables, or very large table, use this:
--skipsize Don't enumerate tables and their types/sizes (default: on) --skipsize Don't enumerate tables and their types/sizes (default: on)
(Recommended for servers with many tables) (Recommended for servers with many tables)
MySQLTuner and Vagrant MySQLTuner and Vagrant
-- --
**MySQLTuner** contains following Vagrant configurations: **MySQLTuner** contains following Vagrant configurations:
* Fedora Core 23 / MariaDB 10.0 * Fedora Core 23 / MariaDB 10.0
* Fedora Core 23 / MariaDB 10.1 * Fedora Core 23 / MariaDB 10.1
* Fedora Core 23 / MySQL 5.6 * Fedora Core 23 / MySQL 5.6
* Fedora Core 23 / MySQL 5.7 * Fedora Core 23 / MySQL 5.7
**Vagrant File** are stored in Vagrant subdirectory. **Vagrant File** are stored in Vagrant subdirectory.
* Follow this 2 steps after vagrant installation: * Follow this 2 steps after vagrant installation:
* Rename VagrantFile_for_Mxxx into Vagrantfile * Rename VagrantFile_for_Mxxx into Vagrantfile
* vagrant up * vagrant up
**MySQLTuner** contains a Vagrant configurations for test purpose and development **MySQLTuner** contains a Vagrant configurations for test purpose and development
* Install VirtualBox and Vagrant * Install VirtualBox and Vagrant
* https://www.virtualbox.org/wiki/Downloads * https://www.virtualbox.org/wiki/Downloads
* https://www.vagrantup.com/downloads.html * https://www.vagrantup.com/downloads.html
* Clone repository * Clone repository
* git clone https://github.com/major/MySQLTuner-perl.git * git clone https://github.com/major/MySQLTuner-perl.git
* Install Vagrant plugins vagrant-hostmanager and vagrant-vbguest * Install Vagrant plugins vagrant-hostmanager and vagrant-vbguest
* vagrant plugin install vagrant-hostmanager * vagrant plugin install vagrant-hostmanager
* vagrant plugin install vagrant-vbguest * vagrant plugin install vagrant-vbguest
* Add Fedora Core 23 box for official Fedora Download Website * 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 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
* Create a data directory * Create a data directory
* mkdir data * mkdir data
* Rename Vagrantfile_MariaDB10.0 into Vagrantfile * Rename Vagrantfile_MariaDB10.0 into Vagrantfile
* cp MySQLTuner-perl/Vagrant/Vagrantfile_for_MariaDB10.0 Vagrantfile * cp MySQLTuner-perl/Vagrant/Vagrantfile_for_MariaDB10.0 Vagrantfile
* Start vagrant * Start vagrant
* vagrant up * vagrant up
MySQLTuner a besoin de vous MySQLTuner a besoin de vous
-- --
**MySQLTuner** a besoin de contributeurs pour la documentation, le code, des tests et des retours d'expérience. **MySQLTuner** a besoin de contributeurs pour la documentation, le code, des tests et des retours d'expérience.
* Rejoignez-nous sur le suivi de ticket à [GitHub tracker](https://github.com/major/MySQLTuner-perl/issues)</a>. * Rejoignez-nous sur le suivi de ticket à [GitHub tracker](https://github.com/major/MySQLTuner-perl/issues)</a>.
* Le guide de contribution en anglais est disponible ici [MySQLTuner contributing guide](https://github.com/major/MySQLTuner-perl/blob/master/CONTRIBUTING.md) * Le guide de contribution en anglais est disponible ici [MySQLTuner contributing guide](https://github.com/major/MySQLTuner-perl/blob/master/CONTRIBUTING.md)
* Ajouter une étoile à **MySQLTuner project** ici [MySQLTuner Git Hub Project](https://github.com/major/MySQLTuner-perl) * Ajouter une étoile à **MySQLTuner project** ici [MySQLTuner Git Hub Project](https://github.com/major/MySQLTuner-perl)

746
README.md
View file

@ -1,373 +1,373 @@
![MySQLTuner-perl](https://github.com/major/MySQLTuner-perl/blob/master/mtlogo.png) ![MySQLTuner-perl](https://github.com/major/MySQLTuner-perl/blob/master/mtlogo.png)
==== ====
[![Build Status - Master](https://travis-ci.org/major/MySQLTuner-perl.svg?branch=master)](https://travis-ci.org/major/MySQLTuner-perl) [![Build Status - Master](https://travis-ci.org/major/MySQLTuner-perl.svg?branch=master)](https://travis-ci.org/major/MySQLTuner-perl)
[![Project Status](http://opensource.box.com/badges/active.svg)](http://opensource.box.com/badges) [![Project Status](http://opensource.box.com/badges/active.svg)](http://opensource.box.com/badges)
[![Project Status](http://opensource.box.com/badges/maintenance.svg)](http://opensource.box.com/badges) [![Project Status](http://opensource.box.com/badges/maintenance.svg)](http://opensource.box.com/badges)
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/major/MySQLTuner-perl.svg)](http://isitmaintained.com/project/major/MySQLTuner-perl "Average time to resolve an issue") [![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/major/MySQLTuner-perl.svg)](http://isitmaintained.com/project/major/MySQLTuner-perl "Average time to resolve an issue")
[![Percentage of open issues](http://isitmaintained.com/badge/open/major/MySQLTuner-perl.svg)](http://isitmaintained.com/project/major/MySQLTuner-perl "Percentage of issues still open") [![Percentage of open issues](http://isitmaintained.com/badge/open/major/MySQLTuner-perl.svg)](http://isitmaintained.com/project/major/MySQLTuner-perl "Percentage of issues still open")
[![GPL License](https://badges.frapsoft.com/os/gpl/gpl.png?v=103)](https://opensource.org/licenses/GPL-3.0/) [![GPL License](https://badges.frapsoft.com/os/gpl/gpl.png?v=103)](https://opensource.org/licenses/GPL-3.0/)
**MySQLTuner** is a script written in Perl that allows you to review a MySQL installation quickly and make adjustments to increase performance and stability. The current configuration variables and status data is retrieved and presented in a brief format along with some basic performance suggestions. **MySQLTuner** is a script written in Perl that allows you to review a MySQL installation quickly and make adjustments to increase performance and stability. The current configuration variables and status data is retrieved and presented in a brief format along with some basic performance suggestions.
**MySQLTuner** supports ~300 indicators for MySQL/MariaDB/Percona Server in this last version. **MySQLTuner** supports ~300 indicators for MySQL/MariaDB/Percona Server in this last version.
**MySQLTuner** is maintained and indicator collect is increasing week after week supporting a lot of configuration such as [Galera Cluster](http://galeracluster.com/), [TokuDB](https://www.percona.com/software/mysql-database/percona-tokudb), [Performance schema](https://github.com/mysql/mysql-sys), Linux OS metrics, [InnoDB](http://dev.mysql.com/doc/refman/5.7/en/innodb-storage-engine.html), [MyISAM](http://dev.mysql.com/doc/refman/5.7/en/myisam-storage-engine.html), [Aria](https://mariadb.com/kb/en/mariadb/aria/), ... **MySQLTuner** is maintained and indicator collect is increasing week after week supporting a lot of configuration such as [Galera Cluster](http://galeracluster.com/), [TokuDB](https://www.percona.com/software/mysql-database/percona-tokudb), [Performance schema](https://github.com/mysql/mysql-sys), Linux OS metrics, [InnoDB](http://dev.mysql.com/doc/refman/5.7/en/innodb-storage-engine.html), [MyISAM](http://dev.mysql.com/doc/refman/5.7/en/myisam-storage-engine.html), [Aria](https://mariadb.com/kb/en/mariadb/aria/), ...
You can find more details on these indicators here: You can find more details on these indicators here:
[Indicators description](https://github.com/major/MySQLTuner-perl/blob/master/INTERNALS.md). [Indicators description](https://github.com/major/MySQLTuner-perl/blob/master/INTERNALS.md).
![MysqlTuner](https://github.com/major/MySQLTuner-perl/blob/master/mysqltuner.png) ![MysqlTuner](https://github.com/major/MySQLTuner-perl/blob/master/mysqltuner.png)
MySQLTuner needs you: MySQLTuner needs you:
=== ===
**MySQLTuner** needs contributors for documentation, code and feedback.. **MySQLTuner** needs contributors for documentation, code and feedback..
* Please join us on issue track at [GitHub tracker](https://github.com/major/MySQLTuner-perl/issues). * Please join us on issue track at [GitHub tracker](https://github.com/major/MySQLTuner-perl/issues).
* Contribution guide is available following [MySQLTuner contributing guide](https://github.com/major/MySQLTuner-perl/blob/master/CONTRIBUTING.md) * Contribution guide is available following [MySQLTuner contributing guide](https://github.com/major/MySQLTuner-perl/blob/master/CONTRIBUTING.md)
* Star **MySQLTuner project** at [MySQLTuner Git Hub Project](https://github.com/major/MySQLTuner-perl) * Star **MySQLTuner project** at [MySQLTuner Git Hub Project](https://github.com/major/MySQLTuner-perl)
## Stargazers over time ## Stargazers over time
[![Stargazers over time](https://starcharts.herokuapp.com/major/MySQLTuner-perl.svg)](https://starcharts.herokuapp.com/major/MySQLTuner-perl) [![Stargazers over time](https://starcharts.herokuapp.com/major/MySQLTuner-perl.svg)](https://starcharts.herokuapp.com/major/MySQLTuner-perl)
Compatibility Compatibility
==== ====
Test result are available here: [Travis CI/MySQLTuner-perl](https://travis-ci.org/major/MySQLTuner-perl) Test result are available here: [Travis CI/MySQLTuner-perl](https://travis-ci.org/major/MySQLTuner-perl)
* MySQL 8.0 (partial support, password checks don't work) * MySQL 8.0 (partial support, password checks don't work)
* MySQL 5.7 (full support) * MySQL 5.7 (full support)
* MySQL 5.6 (full support, no more MySQL support) * MySQL 5.6 (full support, no more MySQL support)
* MySQL 5.5 (full support, no more MySQL support) * MySQL 5.5 (full support, no more MySQL support)
* MariaDB 10.5 (full support) * MariaDB 10.5 (full support)
* MariaDB 10.4 (full support) * MariaDB 10.4 (full support)
* MariaDB 10.3 (full support) * MariaDB 10.3 (full support)
* MariaDB 10.2 (full support) * MariaDB 10.2 (full support)
* MariaDB 10.1 (full support, no more MariaDB support) * MariaDB 10.1 (full support, no more MariaDB support)
* MariaDB 10.0 (full support, no more MariaDB support) * MariaDB 10.0 (full support, no more MariaDB support)
* MariaDB 5.5 (full support, no more MariaDB support) * MariaDB 5.5 (full support, no more MariaDB support)
* Percona Server 8.0 (partial support, password checks don't work) * Percona Server 8.0 (partial support, password checks don't work)
* Percona Server 5.7 (full support) * Percona Server 5.7 (full support)
* Percona Server 5.6 (full support) * Percona Server 5.6 (full support)
* Percona XtraDB cluster (partial support, no test environment) * Percona XtraDB cluster (partial support, no test environment)
* Mysql Replications (partial support, no test environment) * Mysql Replications (partial support, no test environment)
* Galera replication (partial support, no test environment) * Galera replication (partial support, no test environment)
* MySQL 3.23, 4.0, 4.1, 5.0, 5.1 (partial support - deprecated version) * MySQL 3.23, 4.0, 4.1, 5.0, 5.1 (partial support - deprecated version)
*** UNSUPPORTED ENVIRONMENTS - NEED HELP FOR THAT :) *** *** UNSUPPORTED ENVIRONMENTS - NEED HELP FOR THAT :) ***
* Windows is not supported at this time (Help wanted !!!!!) * Windows is not supported at this time (Help wanted !!!!!)
* Cloud based 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) * CVE vulnerabilities detection support from [https://cve.mitre.org](https://cve.mitre.org)
*** MINIMAL REQUIREMENTS *** *** MINIMAL REQUIREMENTS ***
* Perl 5.6 or later (with [perl-doc](http://search.cpan.org/~dapm/perl-5.14.4/pod/perldoc.pod) package) * 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) * Unix/Linux based operating system (tested on Linux, BSD variants, and Solaris variants)
* Unrestricted read access to the MySQL server (OS root access recommended for MySQL < 5.1) * Unrestricted read access to the MySQL server (OS root access recommended for MySQL < 5.1)
***WARNING*** ***WARNING***
-- --
It is **extremely important** for you to fully understand each change It is **extremely important** for you to fully understand each change
you make to a MySQL database server. If you don't understand portions you make to a MySQL database server. If you don't understand portions
of the script's output, or if you don't understand the recommendations, of the script's output, or if you don't understand the recommendations,
**you should consult** a knowledgeable DBA or system administrator **you should consult** a knowledgeable DBA or system administrator
that you trust. **Always** test your changes on staging environments, and that you trust. **Always** test your changes on staging environments, and
always keep in mind that improvements in one area can **negatively affect** always keep in mind that improvements in one area can **negatively affect**
MySQL in other areas. MySQL in other areas.
It's **also important** to wait at least a day of uptime to get accurate results. In fact, running It's **also important** to wait at least a day of uptime to get accurate results. In fact, running
**mysqltuner** on a fresh restarted server is completely useless. **mysqltuner** on a fresh restarted server is completely useless.
**Seriously - please review the FAQ section below.** **Seriously - please review the FAQ section below.**
Security recommendations Security recommendations
-- --
Hi directadmin user! Hi directadmin user!
We detected that you run mysqltuner with da_admin's credentials taken from `/usr/local/directadmin/conf/my.cnf`, which might bring to a password discovery! We detected that you run mysqltuner with da_admin's credentials taken from `/usr/local/directadmin/conf/my.cnf`, which might bring to a password discovery!
Read link for more details [Issue #289](https://github.com/major/MySQLTuner-perl/issues/289). Read link for more details [Issue #289](https://github.com/major/MySQLTuner-perl/issues/289).
What MySQLTuner is checking exactly ? What MySQLTuner is checking exactly ?
-- --
All checks done by **MySQLTuner** are documented in [MySQLTuner Internals](https://github.com/major/MySQLTuner-perl/blob/master/INTERNALS.md) documentation. All checks done by **MySQLTuner** are documented in [MySQLTuner Internals](https://github.com/major/MySQLTuner-perl/blob/master/INTERNALS.md) documentation.
Download/Installation Download/Installation
-- --
Choose one of these methods: Choose one of these methods:
1) Script direct download (the simplest and shortest method): 1) Script direct download (the simplest and shortest method):
``` ```
wget http://mysqltuner.pl/ -O mysqltuner.pl 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/basic_passwords.txt -O basic_passwords.txt
wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/vulnerabilities.csv -O vulnerabilities.csv wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/vulnerabilities.csv -O vulnerabilities.csv
``` ```
2) You can download the entire repository by using `git clone` or `git clone --depth 1 -b master` followed by the cloning URL above. 2) You can download the entire repository by using `git clone` or `git clone --depth 1 -b master` followed by the cloning URL above.
Optional Sysschema installation for MySQL 5.6 Optional Sysschema installation for MySQL 5.6
-- --
Sysschema is installed by default under MySQL 5.7 and MySQL 8 from Oracle. Sysschema is installed by default under MySQL 5.7 and MySQL 8 from Oracle.
By default, on MySQL 5.6/5.7/8, performance schema is enabled by default. By default, on MySQL 5.6/5.7/8, performance schema is enabled by default.
For previous 5.6 version, you can follow this command to create a new database sys containing very useful view on Performance schema: For previous 5.6 version, you can follow this command to create a new database sys containing very useful view on Performance schema:
curl "https://codeload.github.com/mysql/mysql-sys/zip/master" > sysschema.zip curl "https://codeload.github.com/mysql/mysql-sys/zip/master" > sysschema.zip
# check zip file # check zip file
unzip -l sysschema.zip unzip -l sysschema.zip
unzip sysschema.zip unzip sysschema.zip
cd mysql-sys-master cd mysql-sys-master
mysql -uroot -p < sys_56.sql mysql -uroot -p < sys_56.sql
Optional Performance schema and Sysschema installation for MariaDB 10.x Optional Performance schema and Sysschema installation for MariaDB 10.x
-- --
Sysschema is not installed by default under MariaDB 10.x. Sysschema is not installed by default under MariaDB 10.x.
By default, on MariaDB, performance schema is disabled by default. consider activating performance schema across your my.cnf configuration file: By default, on MariaDB, performance schema is disabled by default. consider activating performance schema across your my.cnf configuration file:
[mysqld] [mysqld]
performance_schema = on performance_schema = on
You can follow this command to create a new database sys containing very useful view on Performance schema: You can follow this command to create a new database sys containing very useful view on Performance schema:
curl "https://codeload.github.com/FromDual/mariadb-sys/zip/master" > mariadb-sys.zip curl "https://codeload.github.com/FromDual/mariadb-sys/zip/master" > mariadb-sys.zip
# check zip file # check zip file
unzip -l mariadb-sys.zip unzip -l mariadb-sys.zip
unzip mariadb-sys.zip unzip mariadb-sys.zip
cd mariadb-sys-master/ cd mariadb-sys-master/
mysql -u root -p < ./sys_10.sql mysql -u root -p < ./sys_10.sql
Errors & solutions for performance schema installation Errors & solutions for performance schema installation
ERROR at line 21: Failed to open file './tables/sys_config_data_10.sql -- ported', error: 2 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 Have a look at #452 solution given by @ericx
Performance tips Performance tips
-- --
Metadata statistic updates can impact strongly performance of database servers and MySQLTuner. Metadata statistic updates can impact strongly performance of database servers and MySQLTuner.
Be sure that innodb_stats_on_metadata is disabled. Be sure that innodb_stats_on_metadata is disabled.
set global innodb_stats_on_metadata = 0; set global innodb_stats_on_metadata = 0;
Specific usage Specific usage
-- --
__Usage:__ Minimal usage locally __Usage:__ Minimal usage locally
perl mysqltuner.pl --host 127.0.0.1 perl mysqltuner.pl --host 127.0.0.1
Of course, you can add the execute bit (`chmod +x mysqltuner.pl`) so you can execute it without calling perl directly. Of course, you can add the execute bit (`chmod +x mysqltuner.pl`) so you can execute it without calling perl directly.
__Usage:__ Minimal usage remotely __Usage:__ Minimal usage remotely
perl mysqltuner.pl --host targetDNS_IP --user admin_user --pass admin_password perl mysqltuner.pl --host targetDNS_IP --user admin_user --pass admin_password
__Usage:__ Enable maximum output information around MySQL/MariaDb without debugging __Usage:__ Enable maximum output information around MySQL/MariaDb without debugging
perl mysqltuner.pl --verbose perl mysqltuner.pl --verbose
perl mysqltuner.pl --buffers --dbstat --idxstat --sysstat --pfstat --tbstat perl mysqltuner.pl --buffers --dbstat --idxstat --sysstat --pfstat --tbstat
__Usage:__ Enable CVE vulnerabilities check for your MariaDB or MySQL version __Usage:__ Enable CVE vulnerabilities check for your MariaDB or MySQL version
perl mysqltuner.pl --cvefile=vulnerabilities.csv perl mysqltuner.pl --cvefile=vulnerabilities.csv
__Usage:__ Write your result in a file with information displayed __Usage:__ Write your result in a file with information displayed
perl mysqltuner.pl --outputfile /tmp/result_mysqltuner.txt perl mysqltuner.pl --outputfile /tmp/result_mysqltuner.txt
__Usage:__ Write your result in a file **without outputting information** __Usage:__ Write your result in a file **without outputting information**
perl mysqltuner.pl --silent --outputfile /tmp/result_mysqltuner.txt perl mysqltuner.pl --silent --outputfile /tmp/result_mysqltuner.txt
__Usage:__ Using template model to customize your reporting file based on [Text::Template](https://metacpan.org/pod/Text::Template) syntax. __Usage:__ Using template model to customize your reporting file based on [Text::Template](https://metacpan.org/pod/Text::Template) syntax.
perl mysqltuner.pl --silent --reportfile /tmp/result_mysqltuner.txt --template=/tmp/mymodel.tmpl perl mysqltuner.pl --silent --reportfile /tmp/result_mysqltuner.txt --template=/tmp/mymodel.tmpl
__Usage:__ Enable debugging information __Usage:__ Enable debugging information
perl mysqltuner.pl --debug perl mysqltuner.pl --debug
__Usage:__ Update MySQLTuner and data files (password and cve) if needed __Usage:__ Update MySQLTuner and data files (password and cve) if needed
perl mysqltuner.pl --checkversion --updateversion perl mysqltuner.pl --checkversion --updateversion
FAQ FAQ
-- --
**Question: Will MySQLTuner fix my slow MySQL server?** **Question: Will MySQLTuner fix my slow MySQL server?**
**No.** MySQLTuner is a read only script. It won't write to any configuration files, change the status of any daemons, or call your mother to wish her a happy birthday. It will give you an overview of your server's performance and make some basic recommendations for improvements that you can make after it completes. *Make sure you read the warning above prior to following any recommendations.* **No.** MySQLTuner is a read only script. It won't write to any configuration files, change the status of any daemons, or call your mother to wish her a happy birthday. It will give you an overview of your server's performance and make some basic recommendations for improvements that you can make after it completes. *Make sure you read the warning above prior to following any recommendations.*
**Question: Can I fire my DBA now?** **Question: Can I fire my DBA now?**
**MySQLTuner will not replace your DBA in any form or fashion.** If your DBA constantly takes your parking spot and steals your lunch from the fridge, then you may want to consider it - but that's your call. **MySQLTuner will not replace your DBA in any form or fashion.** If your DBA constantly takes your parking spot and steals your lunch from the fridge, then you may want to consider it - but that's your call.
**Question: Why does MySQLTuner keep asking me the login credentials for MySQL over and over?** **Question: Why does MySQLTuner keep asking me the login credentials for MySQL over and over?**
The script will try its best to log in via any means possible. It will check for ~/.my.cnf files, Plesk password files, and empty password root logins. If none of those are available, then you'll be prompted for a password. If you'd like the script to run in an automated fashion without user intervention, then create a .my.cnf file in your home directory which contains: The script will try its best to log in via any means possible. It will check for ~/.my.cnf files, Plesk password files, and empty password root logins. If none of those are available, then you'll be prompted for a password. If you'd like the script to run in an automated fashion without user intervention, then create a .my.cnf file in your home directory which contains:
[client] [client]
user=someusername user=someusername
password=thatuserspassword password=thatuserspassword
Once you create it, make sure it's owned by your user and the mode on the file is 0600. This should prevent the prying eyes from getting your database login credentials under normal conditions. If a [T-1000 shows up in a LAPD uniform](https://en.wikipedia.org/wiki/T-1000) and demands your database credentials, you won't have much of an option. Once you create it, make sure it's owned by your user and the mode on the file is 0600. This should prevent the prying eyes from getting your database login credentials under normal conditions. If a [T-1000 shows up in a LAPD uniform](https://en.wikipedia.org/wiki/T-1000) and demands your database credentials, you won't have much of an option.
**Question: Is there another way to secure credentials on latest MySQL and MariaDB distributions ?** **Question: Is there another way to secure credentials on latest MySQL and MariaDB distributions ?**
You could use mysql_config_editor utilities. You could use mysql_config_editor utilities.
~~~bash ~~~bash
$ mysql_config_editor set --login-path=client --user=someusername --password --host=localhost $ mysql_config_editor set --login-path=client --user=someusername --password --host=localhost
Enter password: ******** Enter password: ********
~~~ ~~~
After which, `~/.mylogin.cnf` will be created with the appropriate access. After which, `~/.mylogin.cnf` will be created with the appropriate access.
To get information about stored credentials, use the following command: To get information about stored credentials, use the following command:
$mysql_config_editor print $mysql_config_editor print
[client] [client]
user = someusername user = someusername
password = ***** password = *****
host = localhost host = localhost
**Question: What's minimum privileges needed by a specific mysqltuner user in database ?** **Question: What's minimum privileges needed by a specific mysqltuner user in database ?**
mysql>GRANT SELECT, PROCESS,EXECUTE, REPLICATION CLIENT,SHOW DATABASES,SHOW VIEW ON *.* TO 'mysqltuner'@'localhost' identified by pwd1234; mysql>GRANT SELECT, PROCESS,EXECUTE, REPLICATION CLIENT,SHOW DATABASES,SHOW VIEW ON *.* TO 'mysqltuner'@'localhost' identified by pwd1234;
**Question: It's not working on my OS! What gives?!** **Question: It's not working on my OS! What gives?!**
These kinds of things are bound to happen. Here are the details I need from you in order to research the problem thoroughly: These kinds of things are bound to happen. Here are the details I need from you in order to research the problem thoroughly:
* OS and OS version * OS and OS version
* Architecture (x86, x86_64, IA64, Commodore 64) * Architecture (x86, x86_64, IA64, Commodore 64)
* Exact MySQL version * Exact MySQL version
* Where you obtained your MySQL version (OS package, source, etc) * Where you obtained your MySQL version (OS package, source, etc)
* The full text of the error * The full text of the error
* A copy of SHOW VARIABLES and SHOW GLOBAL STATUS output (if possible) * A copy of SHOW VARIABLES and SHOW GLOBAL STATUS output (if possible)
**Question: How to perform CVE vulnerability checks?** **Question: How to perform CVE vulnerability checks?**
* Download vulnerabilities.csv from this repository. * Download vulnerabilities.csv from this repository.
* use option --cvefile to perform CVE checks * use option --cvefile to perform CVE checks
**Question: How to use mysqltuner from a remote host?** **Question: How to use mysqltuner from a remote host?**
Thanks to [@rolandomysqldba](http://dba.stackexchange.com/users/877/rolandomysqldba) Thanks to [@rolandomysqldba](http://dba.stackexchange.com/users/877/rolandomysqldba)
* You will still have to connect like a mysql client: * You will still have to connect like a mysql client:
Connection and Authentication Connection and Authentication
--host <hostname> Connect to a remote host to perform tests (default: localhost) --host <hostname> Connect to a remote host to perform tests (default: localhost)
--socket <socket> Use a different socket for a local connection --socket <socket> Use a different socket for a local connection
--port <port> Port to use for connection (default: 3306) --port <port> Port to use for connection (default: 3306)
--user <username> Username to use for authentication --user <username> Username to use for authentication
--pass <password> Password to use for authentication --pass <password> Password to use for authentication
--defaults-file <path> defaults file for credentials --defaults-file <path> defaults file for credentials
Since you are using a remote host, use parameters to supply values from the OS Since you are using a remote host, use parameters to supply values from the OS
--forcemem <size> Amount of RAM installed in megabytes --forcemem <size> Amount of RAM installed in megabytes
--forceswap <size> Amount of swap memory configured in megabytes --forceswap <size> Amount of swap memory configured in megabytes
* You may have to contact your remote SysAdmin to ask how much RAM and swap you have * You may have to contact your remote SysAdmin to ask how much RAM and swap you have
If the database has too many tables, or very large table, use this: If the database has too many tables, or very large table, use this:
--skipsize Don't enumerate tables and their types/sizes (default: on) --skipsize Don't enumerate tables and their types/sizes (default: on)
(Recommended for servers with many tables) (Recommended for servers with many tables)
**Question: Can I install this project using homebrew on Apple Macintosh?** **Question: Can I install this project using homebrew on Apple Macintosh?**
Yes! `brew install mysqltuner` can be used to install this application using [homebrew](https://brew.sh/) on Apple Macintosh. Yes! `brew install mysqltuner` can be used to install this application using [homebrew](https://brew.sh/) on Apple Macintosh.
MySQLTuner and Vagrant MySQLTuner and Vagrant
-- --
**MySQLTuner** contains following Vagrant configurations: **MySQLTuner** contains following Vagrant configurations:
* Fedora Core 30 / Docker * Fedora Core 30 / Docker
**Vagrant File** is stored in Vagrant subdirectory. **Vagrant File** is stored in Vagrant subdirectory.
* Follow following step after vagrant installation: * Follow following step after vagrant installation:
$ vagrant up $ vagrant up
**MySQLTuner** contains a Vagrant configurations for test purpose and development **MySQLTuner** contains a Vagrant configurations for test purpose and development
* Install VirtualBox and Vagrant * Install VirtualBox and Vagrant
* https://www.virtualbox.org/wiki/Downloads * https://www.virtualbox.org/wiki/Downloads
* https://www.vagrantup.com/downloads.html * https://www.vagrantup.com/downloads.html
* Clone repository * Clone repository
* git clone https://github.com/major/MySQLTuner-perl.git * git clone https://github.com/major/MySQLTuner-perl.git
* Install Vagrant plugins vagrant-hostmanager and vagrant-vbguest * Install Vagrant plugins vagrant-hostmanager and vagrant-vbguest
* vagrant plugin install vagrant-hostmanager * vagrant plugin install vagrant-hostmanager
* vagrant plugin install vagrant-vbguest * vagrant plugin install vagrant-vbguest
* Add Fedora Core 30 box for official Fedora Download Website * Add Fedora Core 30 box for official Fedora Download Website
* vagrant box add --name generic/fedora30 * vagrant box add --name generic/fedora30
* Create a data directory * Create a data directory
* mkdir data * mkdir data
## setup test environments ## setup test environments
$ sh build/createTestEnvs.sh $ sh build/createTestEnvs.sh
$ source build/bashrc $ source build/bashrc
$ mysql_percona80 sakila $ mysql_percona80 sakila
sakila> ... sakila> ...
$ docker images $ docker images
mariadb 10.1 fc612450e1f1 12 days ago 352MB mariadb 10.1 fc612450e1f1 12 days ago 352MB
mariadb 10.2 027b7c57b8c6 12 days ago 340MB mariadb 10.2 027b7c57b8c6 12 days ago 340MB
mariadb 10.3 47dff68107c4 12 days ago 343MB mariadb 10.3 47dff68107c4 12 days ago 343MB
mariadb 10.4 92495405fc36 12 days ago 356MB mariadb 10.4 92495405fc36 12 days ago 356MB
mysql 5.6 95e0fc47b096 2 weeks ago 257MB mysql 5.6 95e0fc47b096 2 weeks ago 257MB
mysql 5.7 383867b75fd2 2 weeks ago 373MB mysql 5.7 383867b75fd2 2 weeks ago 373MB
mysql 8.0 b8fd9553f1f0 2 weeks ago 445MB mysql 8.0 b8fd9553f1f0 2 weeks ago 445MB
percona/percona-server 5.7 ddd245ed3496 5 weeks ago 585MB percona/percona-server 5.7 ddd245ed3496 5 weeks ago 585MB
percona/percona-server 5.6 ed0a36e0cf1b 6 weeks ago 421MB percona/percona-server 5.6 ed0a36e0cf1b 6 weeks ago 421MB
percona/percona-server 8.0 390ae97d57c6 6 weeks ago 697MB percona/percona-server 8.0 390ae97d57c6 6 weeks ago 697MB
mariadb 5.5 c7bf316a4325 4 months ago 352MB mariadb 5.5 c7bf316a4325 4 months ago 352MB
mariadb 10.0 d1bde56970c6 4 months ago 353MB mariadb 10.0 d1bde56970c6 4 months ago 353MB
mysql 5.5 d404d78aa797 4 months ago 205MB mysql 5.5 d404d78aa797 4 months ago 205MB
$ docker ps $ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 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 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 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 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 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 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 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 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 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 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 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 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 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 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 MySQLTuner needs you
-- --
**MySQLTuner** needs contributors for documentation, code and feedback.. **MySQLTuner** needs contributors for documentation, code and feedback..
* Please join us on issue track at [GitHub tracker](https://github.com/major/MySQLTuner-perl/issues). * Please join us on issue track at [GitHub tracker](https://github.com/major/MySQLTuner-perl/issues).
* Contribution guide is available following [MySQLTuner contributing guide](https://github.com/major/MySQLTuner-perl/blob/master/CONTRIBUTING.md) * Contribution guide is available following [MySQLTuner contributing guide](https://github.com/major/MySQLTuner-perl/blob/master/CONTRIBUTING.md)
* Star **MySQLTuner project** at [MySQLTuner Git Hub Project](https://github.com/major/MySQLTuner-perl) * Star **MySQLTuner project** at [MySQLTuner Git Hub Project](https://github.com/major/MySQLTuner-perl)
Contributions welcome ! Contributions welcome !
-- --
How to contribute using Pull Request ? Follow this guide : [Pull request creation](https://opensource.com/article/19/7/create-pull-request-github) How to contribute using Pull Request ? Follow this guide : [Pull request creation](https://opensource.com/article/19/7/create-pull-request-github)
Simple steps to create a pull request: Simple steps to create a pull request:
-- --
- Fork this Github project - Fork this Github project
- Clone it to your local system - Clone it to your local system
- Make a new branch - Make a new branch
- Make your changes - Make your changes
- Push it back to your repo - Push it back to your repo
- Click the Compare & pull request button - Click the Compare & pull request button
- Click Create pull request to open a new pull request - Click Create pull request to open a new pull request

View file

@ -1,9 +1,9 @@
#!/bin/sh #!/bin/sh
VERSION=${1:-"10.4"} VERSION=${1:-"10.4"}
rm -f Vagrantfile rm -f Vagrantfile
cp Vagrantfile_for_MariaDB${VERSION} Vagrantfile cp Vagrantfile_for_MariaDB${VERSION} Vagrantfile
mkdir data mkdir data
vagrant plugin install vagrant-hostmanager vagrant plugin install vagrant-hostmanager
vagrant plugin install vagrant-vbguest vagrant plugin install vagrant-vbguest
vagrant plugin install vagrant-proxyconf vagrant plugin install vagrant-proxyconf
vagrant --provision up vagrant --provision up

View file

@ -1,69 +1,69 @@
alias gst='git status' alias gst='git status'
alias gcm='git commit -m' alias gcm='git commit -m'
alias gmh='git log --follow -p --' alias gmh='git log --follow -p --'
alias ll='ls -ls' alias ll='ls -ls'
alias lh='ls -lsh' alias lh='ls -lsh'
alias la='ls -lsa' alias la='ls -lsa'
alias gam='git status | grep "modified" | cut -d: -f2 | xargs -n 1 git add' 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")')" alias serve="python -m $(python -c 'import sys; print("http.server" if sys.version_info[:2] > (2,7) else "SimpleHTTPServer")')"
dcmd() dcmd()
{ {
docker exec -i -t $1 bash docker exec -i -t $1 bash
} }
gen_mysqlalias() gen_mysqlalias()
{ {
input="$1" input="$1"
while IFS='' read -r line while IFS='' read -r line
do do
[ -z "$line" ] && continue [ -z "$line" ] && continue
container_port=$(echo "$line" | cut -d\; -f1) container_port=$(echo "$line" | cut -d\; -f1)
container_name=$(echo "$line" | cut -d\; -f2) container_name=$(echo "$line" | cut -d\; -f2)
container_datadir=$(echo "$line" | cut -d\; -f3) container_datadir=$(echo "$line" | cut -d\; -f3)
image_name=$(echo "$line" | cut -d\; -f4) image_name=$(echo "$line" | cut -d\; -f4)
alias mysql_$container_name="mysql -u root -h 127.0.0.1 -P $container_port" alias mysql_$container_name="mysql -u root -h 127.0.0.1 -P $container_port"
done < "$input" done < "$input"
} }
exec_mysql() exec_mysql()
{ {
input="$1" input="$1"
name=$2 name=$2
db=$3 db=$3
sqlfile=$4 sqlfile=$4
while IFS='' read -r line while IFS='' read -r line
do do
[ -z "$line" ] && continue [ -z "$line" ] && continue
echo "$line" | grep -q $name echo "$line" | grep -q $name
[ $? -ne 0 ] && continue [ $? -ne 0 ] && continue
container_port=$(echo "$line" | cut -d\; -f1) container_port=$(echo "$line" | cut -d\; -f1)
container_name=$(echo "$line" | cut -d\; -f2) container_name=$(echo "$line" | cut -d\; -f2)
container_datadir=$(echo "$line" | cut -d\; -f3) container_datadir=$(echo "$line" | cut -d\; -f3)
image_name=$(echo "$line" | cut -d\; -f4) image_name=$(echo "$line" | cut -d\; -f4)
echo "* Executing $sqlfile on $container_name" echo "* Executing $sqlfile on $container_name"
cat $sqlfile | mysql -u root -h 127.0.0.1 -P $container_port cat $sqlfile | mysql -u root -h 127.0.0.1 -P $container_port
done < "$input" done < "$input"
} }
exec_mysqls() exec_mysqls()
{ {
input="$1" input="$1"
db=$2 db=$2
sqlfile=$3 sqlfile=$3
while IFS='' read -r line while IFS='' read -r line
do do
[ -z "$line" ] && continue [ -z "$line" ] && continue
container_port=$(echo "$line" | cut -d\; -f1) container_port=$(echo "$line" | cut -d\; -f1)
container_name=$(echo "$line" | cut -d\; -f2) container_name=$(echo "$line" | cut -d\; -f2)
container_datadir=$(echo "$line" | cut -d\; -f3) container_datadir=$(echo "$line" | cut -d\; -f3)
image_name=$(echo "$line" | cut -d\; -f4) image_name=$(echo "$line" | cut -d\; -f4)
echo "* Executing $sqlfile on $container_name" echo "* Executing $sqlfile on $container_name"
cat $sqlfile | mysql -u root -h 127.0.0.1 -P $container_port cat $sqlfile | mysql -u root -h 127.0.0.1 -P $container_port
done < "$input" done < "$input"
} }

View file

@ -1,18 +1,18 @@
#!/bin/sh #!/bin/sh
BUILD_DIR=`dirname $(readlink -f $0)` BUILD_DIR=`dirname $(readlink -f $0)`
VERSION=$(grep -Ei 'my \$tunerversion' $BUILD_DIR/../mysqltuner.pl | grep = | cut -d\" -f2) VERSION=$(grep -Ei 'my \$tunerversion' $BUILD_DIR/../mysqltuner.pl | grep = | cut -d\" -f2)
cd $BUILD_DIR cd $BUILD_DIR
sh ./clean.sh sh ./clean.sh
perl -pe "s/%VERSION%/$VERSION/g" mysqltuner.spec.tpl > mysqltuner.spec perl -pe "s/%VERSION%/$VERSION/g" mysqltuner.spec.tpl > mysqltuner.spec
mkdir -p $BUILD_DIR/mysqltuner-$VERSION mkdir -p $BUILD_DIR/mysqltuner-$VERSION
cp $BUILD_DIR/../mysqltuner.pl mysqltuner.spec $BUILD_DIR/../LICENSE $BUILD_DIR/../basic_passwords.txt $BUILD_DIR/../*.csv $BUILD_DIR/mysqltuner-$VERSION cp $BUILD_DIR/../mysqltuner.pl mysqltuner.spec $BUILD_DIR/../LICENSE $BUILD_DIR/../basic_passwords.txt $BUILD_DIR/../*.csv $BUILD_DIR/mysqltuner-$VERSION
pod2man $BUILD_DIR/../mysqltuner.pl | gzip > $BUILD_DIR/mysqltuner-$VERSION/mysqltuner.1.gz pod2man $BUILD_DIR/../mysqltuner.pl | gzip > $BUILD_DIR/mysqltuner-$VERSION/mysqltuner.1.gz
tar czf $BUILD_DIR/mysqltuner-${VERSION}.tgz mysqltuner-$VERSION tar czf $BUILD_DIR/mysqltuner-${VERSION}.tgz mysqltuner-$VERSION
rpmbuild -ta mysqltuner-${VERSION}.tgz 2>&1 | tee -a ./build.log rpmbuild -ta mysqltuner-${VERSION}.tgz 2>&1 | tee -a ./build.log
set -x set -x
grep --color=never -E '(Wrote|crit)\S*:' $BUILD_DIR/build.log | cut -d: -f2 | xargs -I{} mv {} . grep --color=never -E '(Wrote|crit)\S*:' $BUILD_DIR/build.log | cut -d: -f2 | xargs -I{} mv {} .
#rm -rf mysqltuner-$VERSION ./build.log #rm -rf mysqltuner-$VERSION ./build.log

View file

@ -1,3 +1,3 @@
#!/bin/sh #!/bin/sh
rm -rf mysqltuner-* mysqltuner.spec *.log rm -rf mysqltuner-* mysqltuner.spec *.log

View file

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
docker ps | awk '{ print $NF}' |grep -v NAMES | xargs -n 1 docker kill 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 | awk '{ print $NF}' |grep -v NAMES | xargs -n 1 docker rm
docker ps -a docker ps -a

View file

@ -1,15 +1,15 @@
3306;mysql80;/var/lib/mysql8;mysql:8.0 3306;mysql80;/var/lib/mysql8;mysql:8.0
3307;mysql57;/var/lib/mysql57;mysql:5.7 3307;mysql57;/var/lib/mysql57;mysql:5.7
3308;mysql56;/var/lib/mysql56;mysql:5.6 3308;mysql56;/var/lib/mysql56;mysql:5.6
3309;mysql55;/var/lib/mysql55;mysql:5.5 3309;mysql55;/var/lib/mysql55;mysql:5.5
4306;percona80;/var/lib/percona8;percona/percona-server:8.0 4306;percona80;/var/lib/percona8;percona/percona-server:8.0
4307;percona57;/var/lib/percona57;percona/percona-server:5.7 4307;percona57;/var/lib/percona57;percona/percona-server:5.7
4308;percona56;/var/lib/percona56;percona/percona-server:5.6 4308;percona56;/var/lib/percona56;percona/percona-server:5.6
5306;mariadb104;/var/lib/mariadb104;mariadb:10.4 5306;mariadb104;/var/lib/mariadb104;mariadb:10.4
5307;mariadb103;/var/lib/mariadb103;mariadb:10.3 5307;mariadb103;/var/lib/mariadb103;mariadb:10.3
5308;mariadb102;/var/lib/mariadb102;mariadb:10.2 5308;mariadb102;/var/lib/mariadb102;mariadb:10.2
5309;mariadb101;/var/lib/mariadb101;mariadb:10.1 5309;mariadb101;/var/lib/mariadb101;mariadb:10.1
5310;mariadb100;/var/lib/mariadb100;mariadb:10.0 5310;mariadb100;/var/lib/mariadb100;mariadb:10.0
5311;mariadb55;/var/lib/mariadb55;mariadb:5.5 5311;mariadb55;/var/lib/mariadb55;mariadb:5.5

View file

@ -1,90 +1,90 @@
#!/bin/sh #!/bin/sh
input="./build/configimg.conf" input="./build/configimg.conf"
default_password="secret" default_password="secret"
echo "[client] echo "[client]
user=root user=root
password=$default_password" > $HOME/.my.cnf password=$default_password" > $HOME/.my.cnf
chmod 600 $HOME/.my.cnf chmod 600 $HOME/.my.cnf
[ -f "$input" ] || echo " [ -f "$input" ] || echo "
3306;mysql80;/var/lib/mysql8;mysql:8.0 3306;mysql80;/var/lib/mysql8;mysql:8.0
3307;mysql57;/var/lib/mysql57;mysql:5.7 3307;mysql57;/var/lib/mysql57;mysql:5.7
3308;mysql56;/var/lib/mysql56;mysql:5.6 3308;mysql56;/var/lib/mysql56;mysql:5.6
3309;mysql55;/var/lib/mysql55;mysql:5.5 3309;mysql55;/var/lib/mysql55;mysql:5.5
4306;percona80;/var/lib/percona8;percona/percona-server:8.0 4306;percona80;/var/lib/percona8;percona/percona-server:8.0
4307;percona57;/var/lib/percona57;percona/percona-server:5.7 4307;percona57;/var/lib/percona57;percona/percona-server:5.7
4308;percona56;/var/lib/percona56;percona/percona-server:5.6 4308;percona56;/var/lib/percona56;percona/percona-server:5.6
5306;mariadb104;/var/lib/mariadb104;mariadb:10.4 5306;mariadb104;/var/lib/mariadb104;mariadb:10.4
5307;mariadb103;/var/lib/mariadb103;mariadb:10.3 5307;mariadb103;/var/lib/mariadb103;mariadb:10.3
5308;mariadb102;/var/lib/mariadb102;mariadb:10.2 5308;mariadb102;/var/lib/mariadb102;mariadb:10.2
5309;mariadb101;/var/lib/mariadb101;mariadb:10.1 5309;mariadb101;/var/lib/mariadb101;mariadb:10.1
5310;mariadb100;/var/lib/mariadb100;mariadb:10.0 5310;mariadb100;/var/lib/mariadb100;mariadb:10.0
5311;mariadb55;/var/lib/mariadb55;mariadb:5.5 5311;mariadb55;/var/lib/mariadb55;mariadb:5.5
" > "$input" " > "$input"
# #
#echo '* PRUNING DOCKER SYSTEM DATA' #echo '* PRUNING DOCKER SYSTEM DATA'
#[ "$1" = "clean" ] || docker system prune -a -f #[ "$1" = "clean" ] || docker system prune -a -f
# download all images # download all images
while IFS='' read -r line while IFS='' read -r line
do do
[ -z "$line" ] && continue [ -z "$line" ] && continue
container_port=$(echo "$line" | cut -d\; -f1) container_port=$(echo "$line" | cut -d\; -f1)
container_name=$(echo "$line" | cut -d\; -f2) container_name=$(echo "$line" | cut -d\; -f2)
container_datadir=$(echo "$line" | cut -d\; -f3) container_datadir=$(echo "$line" | cut -d\; -f3)
image_name=$(echo "$line" | cut -d\; -f4) image_name=$(echo "$line" | cut -d\; -f4)
if [ -n "$1" -a "$1" != "clean" ]; then if [ -n "$1" -a "$1" != "clean" ]; then
echo $line | grep -q "$1" echo $line | grep -q "$1"
[ $? -eq 0 ] || continue [ $? -eq 0 ] || continue
fi fi
echo "* PULLING DOCKER IMAGE: $image_name" echo "* PULLING DOCKER IMAGE: $image_name"
docker images | grep -E " $image_name$" docker images | grep -E " $image_name$"
[ $? -ne 0 ] && docker pull $image_name [ $? -ne 0 ] && docker pull $image_name
echo "* REMOVING CONTAINER : $image_name" echo "* REMOVING CONTAINER : $image_name"
docker ps -a | grep -qE "$container_name^" docker ps -a | grep -qE "$container_name^"
docker rm -f $container_name docker rm -f $container_name
if [ 1 -eq 0 ]; then if [ 1 -eq 0 ]; then
echo "* DELETING DATADIR: $container_datadir" echo "* DELETING DATADIR: $container_datadir"
sudo rm -rf $container_datadir sudo rm -rf $container_datadir
[ "$1" = "clean" ] && continue [ "$1" = "clean" ] && continue
echo "* CREATING DATADIR: $container_datadir" echo "* CREATING DATADIR: $container_datadir"
sudo mkdir -p $container_datadir sudo mkdir -p $container_datadir
fi fi
#sudo chown -R mysql.mysql $container_datadir #sudo chown -R mysql.mysql $container_datadir
sudo chmod 777 $container_datadir sudo chmod 777 $container_datadir
echo "* STARTING CONTAINER: $container_name($container_port/TCP) BASED ON $image_name -> $container_datadir" echo "* STARTING CONTAINER: $container_name($container_port/TCP) BASED ON $image_name -> $container_datadir"
set -x 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 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 set +x
sleep 6s sleep 6s
echo "* LOGS: $container_name" echo "* LOGS: $container_name"
docker logs $container_name docker logs $container_name
echo "* LISTING PORTS: $container_name BASED ON $image_name" echo "* LISTING PORTS: $container_name BASED ON $image_name"
docker port $container_name docker port $container_name
echo "* LISTING VOLUMES: $container_name BASED ON $image_name" echo "* LISTING VOLUMES: $container_name BASED ON $image_name"
docker inspect -f "{{ .Mounts }}" $container_name docker inspect -f "{{ .Mounts }}" $container_name
echo "* LISTING $container_datadir" echo "* LISTING $container_datadir"
ls -ls $container_datadir ls -ls $container_datadir
#break #break
docker logs $container_name | grep -q "ready for connections" docker logs $container_name | grep -q "ready for connections"
done < "$input" done < "$input"
echo "* LISTING DOCKER IMAGES" echo "* LISTING DOCKER IMAGES"
docker images docker images
echo "* LISTING DOCKER CONTAINER" echo "* LISTING DOCKER CONTAINER"
docker ps docker ps

View file

@ -1,28 +1,28 @@
#!/bin/sh #!/bin/sh
source build/bashrc source build/bashrc
systemctl status docker &>/dev/null systemctl status docker &>/dev/null
if [ $? -ne 0 ];then if [ $? -ne 0 ];then
sudo dnf install -y yum-utils device-mapper-persistent-data lvm2 sudo dnf install -y yum-utils device-mapper-persistent-data lvm2
sudo dnf -y install dnf-plugins-core sudo dnf -y install dnf-plugins-core
sudo dnf config-manager \ sudo dnf config-manager \
--add-repo \ --add-repo \
https://download.docker.com/linux/fedora/docker-ce.repo https://download.docker.com/linux/fedora/docker-ce.repo
sudo dnf -y install docker-ce docker-ce-cli containerd.io sudo dnf -y install docker-ce docker-ce-cli containerd.io
dnf list docker-ce --showduplicates | sort -r dnf list docker-ce --showduplicates | sort -r
sudo systemctl start docker sudo systemctl start docker
sudo systemctl enable docker sudo systemctl enable docker
sudo usermod -aG docker vagrant sudo usermod -aG docker vagrant
sudo systemctl daemon-reload sudo systemctl daemon-reload
fi fi
sh build/createMassDockerImages.sh sh build/createMassDockerImages.sh
sh build/fetchSampleDatabases.sh clean sh build/fetchSampleDatabases.sh clean
sh build/fetchSampleDatabases.sh fetchall 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-schema.sql
exec_mysqls build/configimg.conf mysql contents/sakila-db/sakila-data.sql exec_mysqls build/configimg.conf mysql contents/sakila-db/sakila-data.sql

View file

@ -1,12 +1,12 @@
#!/bin/bash #!/bin/bash
set -xv set -xv
_DIR=$(dirname `readlink -f $0`) _DIR=$(dirname `readlink -f $0`)
ssh $1 mkdir /images/mysqltuner ssh $1 mkdir /images/mysqltuner
rsync -avz ${_DIR}/.. $1:/images/mysqltuner rsync -avz ${_DIR}/.. $1:/images/mysqltuner
if [ "$2" = "run" ];then if [ "$2" = "run" ];then
ssh $1 "su - mysql -c 'cd /images/mysqltuner; source /opt/mysql/myqenv myserver1;perl mysqltuner.pl --verbose --color'" ssh $1 "su - mysql -c 'cd /images/mysqltuner; source /opt/mysql/myqenv myserver1;perl mysqltuner.pl --verbose --color'"
fi fi

View file

@ -1,35 +1,35 @@
#!/bin/sh #!/bin/sh
DB_WORLD_URL="https://downloads.mysql.com/docs/world.sql.zip" DB_WORLD_URL="https://downloads.mysql.com/docs/world.sql.zip"
DB_WORLDX_URL="https://downloads.mysql.com/docs/world_x-db.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_SAKILA_URL="https://downloads.mysql.com/docs/sakila-db.zip"
DB_MESSAGERIE_URL="https://downloads.mysql.com/docs/menagerie-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" DB_TESTDB_URL="https://github.com/datacharmer/test_db/archive/master.zip"
getVal() getVal()
{ {
local vari=$1 local vari=$1
eval "echo \$$vari" eval "echo \$$vari"
} }
case "$1" in case "$1" in
"fetchall") "fetchall")
for sample in WORLD WORLDX SAKILA MESSAGERIE TESTDB; do for sample in WORLD WORLDX SAKILA MESSAGERIE TESTDB; do
sh $0 fetch $sample sh $0 fetch $sample
done done
;; ;;
"fetch") "fetch")
[ -z "$2" ] && exit 1 [ -z "$2" ] && exit 1
mkdir -p ./contents mkdir -p ./contents
[ -f "contents/$(basename $(getVal "DB_$2_URL"))" ] || 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")
if [ $? -eq 0 ];then if [ $? -eq 0 ];then
(cd contents; unzip $( basename $(getVal "DB_$2_URL")) ) (cd contents; unzip $( basename $(getVal "DB_$2_URL")) )
fi fi
;; ;;
"clean") "clean")
rm -rf contents rm -rf contents
;; ;;
*) *)
echo "Unknown operation: $1" echo "Unknown operation: $1"
;; ;;
esac esac

View file

@ -1,51 +1,51 @@
Summary: High Performance MySQL Tuning Script Summary: High Performance MySQL Tuning Script
Name: mysqltuner Name: mysqltuner
Version: %VERSION% Version: %VERSION%
Release: 1 Release: 1
License: GPL v3+ License: GPL v3+
Group: Applications Group: Applications
Source0: https://github.com/build/MySQLTuner-perl/build/%{name}-%{version}.tgz Source0: https://github.com/build/MySQLTuner-perl/build/%{name}-%{version}.tgz
URL: https://github.com/major/MySQLTuner-perl URL: https://github.com/major/MySQLTuner-perl
Requires: mysql Requires: mysql
BuildArch: noarch BuildArch: noarch
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
%description %description
MySQLTuner is a high-performance MySQL tuning script written in Perl MySQLTuner is a high-performance MySQL tuning script written in Perl
that will provide you with a snapshot of a MySQL server's health. that will provide you with a snapshot of a MySQL server's health.
Based on the statistics gathered, specific recommendations will be Based on the statistics gathered, specific recommendations will be
provided that will increase a MySQL server's efficiency and provided that will increase a MySQL server's efficiency and
performance. The script gives you automated MySQL tuning that is on performance. The script gives you automated MySQL tuning that is on
the level of what you would receive from a MySQL DBA. the level of what you would receive from a MySQL DBA.
This script has been derived from many of the ideas in Matthew This script has been derived from many of the ideas in Matthew
Montgomery's MySQL tuning primer script. Montgomery's MySQL tuning primer script.
%prep %prep
%setup -q %setup -q
%install %install
rm -rf $RPM_BUILD_ROOT rm -rf $RPM_BUILD_ROOT
install -d $RPM_BUILD_ROOT%{_bindir} install -d $RPM_BUILD_ROOT%{_bindir}
install -d $RPM_BUILD_ROOT%{_datarootdir} install -d $RPM_BUILD_ROOT%{_datarootdir}
install -d $RPM_BUILD_ROOT/%{_mandir}/man1 install -d $RPM_BUILD_ROOT/%{_mandir}/man1
install -p %{name}.pl $RPM_BUILD_ROOT%{_bindir}/%{name} install -p %{name}.pl $RPM_BUILD_ROOT%{_bindir}/%{name}
install -d $RPM_BUILD_ROOT%{_datarootdir}/%{name} install -d $RPM_BUILD_ROOT%{_datarootdir}/%{name}
install -p LICENSE $RPM_BUILD_ROOT%{_datarootdir}/%{name} install -p LICENSE $RPM_BUILD_ROOT%{_datarootdir}/%{name}
install -p basic_passwords.txt $RPM_BUILD_ROOT%{_datarootdir}/%{name} install -p basic_passwords.txt $RPM_BUILD_ROOT%{_datarootdir}/%{name}
install -p vulnerabilities.csv $RPM_BUILD_ROOT%{_datarootdir}/%{name} install -p vulnerabilities.csv $RPM_BUILD_ROOT%{_datarootdir}/%{name}
install -p %{name}.1.gz $RPM_BUILD_ROOT/%{_mandir}/man1 install -p %{name}.1.gz $RPM_BUILD_ROOT/%{_mandir}/man1
%clean %clean
rm -rf $RPM_BUILD_ROOT rm -rf $RPM_BUILD_ROOT
%files %files
%defattr(644,root,root,755) %defattr(644,root,root,755)
%doc %{_datarootdir}/%{name} %doc %{_datarootdir}/%{name}
%attr(755,root,root) %{_bindir}/%{name} %attr(755,root,root) %{_bindir}/%{name}
%{_mandir}/man1/* %{_mandir}/man1/*
%changelog %changelog
* Thu Apr 14 2016 Jean-Marie RENOUARD <jmrenouard@gmail.com> %VERSION%-1 * Thu Apr 14 2016 Jean-Marie RENOUARD <jmrenouard@gmail.com> %VERSION%-1
- Initial RPM release - Initial RPM release

View file

@ -1,116 +1,116 @@
#!/bin/bash #!/bin/bash
server=$1 server=$1
_DIR=$(dirname `readlink -f $0`) _DIR=$(dirname `readlink -f $0`)
#SSH_OPTIONS="-i utilities/id_rsa" #SSH_OPTIONS="-i utilities/id_rsa"
SSH_OPTIONS="${SSH_OPTIONS:-""} SSH_OPTIONS="${SSH_OPTIONS:-""}
export SSH_CLIENT="ssh -q $SSH_OPTIONS -o TCPKeepAlive=yes -o ServerAliveInterval=50 -o strictHostKeyChecking=no" export SSH_CLIENT="ssh -q $SSH_OPTIONS -o TCPKeepAlive=yes -o ServerAliveInterval=50 -o strictHostKeyChecking=no"
export SCP_CLIENT="scp -q $SSH_OPTIONS -o TCPKeepAlive=yes -o ServerAliveInterval=50 -o strictHostKeyChecking=no" export SCP_CLIENT="scp -q $SSH_OPTIONS -o TCPKeepAlive=yes -o ServerAliveInterval=50 -o strictHostKeyChecking=no"
_DIR="$(dirname "`readlink -f $0`")" _DIR="$(dirname "`readlink -f $0`")"
echo "* CLEANUP OLD RESULT FILES" echo "* CLEANUP OLD RESULT FILES"
rm -f mysqltuner_${server}.txt pt-*_${server}.txt innotop_${server}.txt rm -f mysqltuner_${server}.txt pt-*_${server}.txt innotop_${server}.txt
echo "* RUNNNING MYSQLTUNER" echo "* RUNNNING MYSQLTUNER"
$SSH_CLIENT root@${server} "mysqltuner --verbose --outputfile /tmp/mysqltuner_${server}.txt" $SSH_CLIENT root@${server} "mysqltuner --verbose --outputfile /tmp/mysqltuner_${server}.txt"
[ $? -ne 0 ] && exit 1 [ $? -ne 0 ] && exit 1
echo "* RUNNNING PERCONA SUMMARY" echo "* RUNNNING PERCONA SUMMARY"
$SSH_CLIENT root@${server} "pt-summary> /tmp/pt-summary_${server}.txt" $SSH_CLIENT root@${server} "pt-summary> /tmp/pt-summary_${server}.txt"
[ $? -ne 0 ] && exit 1 [ $? -ne 0 ] && exit 1
echo "* RUNNNING PERCONA MYSQL SUMMARY" echo "* RUNNNING PERCONA MYSQL SUMMARY"
$SSH_CLIENT root@${server} "pt-mysql-summary> /tmp/pt-mysql-summary_${server}.txt" $SSH_CLIENT root@${server} "pt-mysql-summary> /tmp/pt-mysql-summary_${server}.txt"
[ $? -ne 0 ] && exit 1 [ $? -ne 0 ] && exit 1
echo "* RUNNNING INNOTOP" echo "* RUNNNING INNOTOP"
$SSH_CLIENT root@${server} "innotop -C -d1 --count 5 -n>> /tmp/innotop_${server}.txt" $SSH_CLIENT root@${server} "innotop -C -d1 --count 5 -n>> /tmp/innotop_${server}.txt"
[ $? -ne 0 ] && exit 1 [ $? -ne 0 ] && exit 1
echo "* IMPORTING RESULT TXT" echo "* IMPORTING RESULT TXT"
$SCP_CLIENT root@${server}:/tmp/mysqltuner_${server}.txt . $SCP_CLIENT root@${server}:/tmp/mysqltuner_${server}.txt .
$SCP_CLIENT root@${server}:/tmp/pt-*_${server}.txt . $SCP_CLIENT root@${server}:/tmp/pt-*_${server}.txt .
$SCP_CLIENT root@${server}:/tmp/innotop_${server}.txt . $SCP_CLIENT root@${server}:/tmp/innotop_${server}.txt .
[ $? -ne 0 ] && exit 1 [ $? -ne 0 ] && exit 1
REPORT_NAME=audit.html REPORT_NAME=audit.html
echo "* GENERATING HTML RESULT" echo "* GENERATING HTML RESULT"
( (
DATE="$(date)" DATE="$(date)"
cat<<EOF cat<<EOF
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>MySQL/MariaDB Audit report - $DATE</title> <title>MySQL/MariaDB Audit report - $DATE</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css"> <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.4.0/Chart.bundle.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.4.0/Chart.bundle.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head> </head>
<body> <body>
<h1>MySQL/MariaDB Audit report - $DATE</h1> <h1>MySQL/MariaDB Audit report - $DATE</h1>
<div id="tabs"> <div id="tabs">
<ul> <ul>
<li><a href="#mysqltuner">Tuner</a></li> <li><a href="#mysqltuner">Tuner</a></li>
<li><a href="#pt-summary">Linux</a></li> <li><a href="#pt-summary">Linux</a></li>
<li><a href="#pt-mysql-summary">Percona</a></li> <li><a href="#pt-mysql-summary">Percona</a></li>
<li><a href="#innotop">InnoTop</a></li> <li><a href="#innotop">InnoTop</a></li>
</ul> </ul>
<div id="mysqltuner"> <div id="mysqltuner">
<pre> <pre>
EOF EOF
) > ${REPORT_NAME} ) > ${REPORT_NAME}
perl ${_DIR}/txt2Html.pl - mysqltuner_${server}.txt >> ${REPORT_NAME} perl ${_DIR}/txt2Html.pl - mysqltuner_${server}.txt >> ${REPORT_NAME}
( (
cat << 'EOF' cat << 'EOF'
</pre></div> </pre></div>
<div id='pt-summary'> <div id='pt-summary'>
<pre> <pre>
EOF EOF
) >> ${REPORT_NAME} ) >> ${REPORT_NAME}
perl ${_DIR}/txt2Html.pl \# pt-summary_${server}.txt >> ${REPORT_NAME} perl ${_DIR}/txt2Html.pl \# pt-summary_${server}.txt >> ${REPORT_NAME}
( (
cat << 'EOF' cat << 'EOF'
</pre></div> </pre></div>
<div id='pt-mysql-summary'> <div id='pt-mysql-summary'>
<pre> <pre>
EOF EOF
) >> ${REPORT_NAME} ) >> ${REPORT_NAME}
perl ${_DIR}/txt2Html.pl \# pt-mysql-summary_${server}.txt >> ${REPORT_NAME} perl ${_DIR}/txt2Html.pl \# pt-mysql-summary_${server}.txt >> ${REPORT_NAME}
( (
cat << 'EOF' cat << 'EOF'
</pre></div> </pre></div>
<div id='innotop'> <div id='innotop'>
<pre> <pre>
EOF EOF
) >> ${REPORT_NAME} ) >> ${REPORT_NAME}
cat innotop_${server}.txt >> ${REPORT_NAME} cat innotop_${server}.txt >> ${REPORT_NAME}
( (
cat << 'EOF' cat << 'EOF'
</pre></div> </pre></div>
</div> </div>
<script> <script>
$(function(){ $(function(){
$('#tabs').tabs({ active: 0 }); $('#tabs').tabs({ active: 0 });
}); });
</script> </script>
</body> </body>
</html> </html>
EOF EOF
) >> ${REPORT_NAME} ) >> ${REPORT_NAME}
echo "* ALL IS OK" echo "* ALL IS OK"
exit 0 exit 0

View file

@ -1,26 +1,26 @@
#!/bin/sh #!/bin/sh
input="./build/configimg.conf" input="./build/configimg.conf"
while IFS='' read -r line while IFS='' read -r line
do do
[ -z "$line" ] && continue [ -z "$line" ] && continue
container_port=$(echo "$line" | cut -d\; -f1) container_port=$(echo "$line" | cut -d\; -f1)
container_name=$(echo "$line" | cut -d\; -f2) container_name=$(echo "$line" | cut -d\; -f2)
container_datadir=$(echo "$line" | cut -d\; -f3) container_datadir=$(echo "$line" | cut -d\; -f3)
image_name=$(echo "$line" | cut -d\; -f4) image_name=$(echo "$line" | cut -d\; -f4)
if [ -n "$1" -a "$1" != "$container_name" ]; then if [ -n "$1" -a "$1" != "$container_name" ]; then
continue continue
fi fi
shift shift
sudo rm -f /var/lib/mysql sudo rm -f /var/lib/mysql
sudo ln -sf $container_datadir /var/lib/mysql sudo ln -sf $container_datadir /var/lib/mysql
sudo chmod 777 /var/lib/mysql sudo chmod 777 /var/lib/mysql
#sudo docker logs $container_name > /tmp/mysqld.log #sudo docker logs $container_name > /tmp/mysqld.log
ls -ls /var/lib | grep -E 'mysql$' ls -ls /var/lib | grep -E 'mysql$'
#set +x #set +x
perl mysqltuner.pl $* --host 127.0.0.1 --port $container_port perl mysqltuner.pl $* --host 127.0.0.1 --port $container_port
exit $? exit $?
done < "$input" done < "$input"

View file

@ -1,17 +1,17 @@
#!/bin/sh #!/bin/sh
# Used to sync the original project with local project. # Used to sync the original project with local project.
#Save existing working #Save existing working
git stash git stash
#add project url to current repository as upstream-live #add project url to current repository as upstream-live
git remote add upstream-live https://github.com/major/MySQLTuner-perl git remote add upstream-live https://github.com/major/MySQLTuner-perl
#Fetch updated code #Fetch updated code
git fetch upstream-live git fetch upstream-live
#Going back to the master branch for mearging latest code #Going back to the master branch for mearging latest code
git checkout master git checkout master
#Merge latest code with master branch. #Merge latest code with master branch.
git merge upstream-live/master git merge upstream-live/master

View file

@ -1,15 +1,15 @@
#!/bin/sh #!/bin/sh
(cd .. (cd ..
echo "* GENERATING USAGE FILE" echo "* GENERATING USAGE FILE"
pod2markdown mysqltuner.pl >USAGE.md pod2markdown mysqltuner.pl >USAGE.md
echo "* TIDYFY SCRIPT" echo "* TIDYFY SCRIPT"
perltidy -b mysqltuner.pl perltidy -b mysqltuner.pl
) )
echo "* Update CVE list" echo "* Update CVE list"
perl updateCVElist.pl perl updateCVElist.pl
dos2unix ../mysqltuner.pl dos2unix ../mysqltuner.pl
git add ../vulnerabilities.csv ../mysqltuner.pl ../USAGE.md git add ../vulnerabilities.csv ../mysqltuner.pl ../USAGE.md
git commit -m 'Update Vulnerabilities list git commit -m 'Update Vulnerabilities list
Indenting mysqltuner Indenting mysqltuner
Update Usage information' Update Usage information'

View file

@ -30,7 +30,7 @@
# Everett Barnes Tom Krouper Gary Barrueto # Everett Barnes Tom Krouper Gary Barrueto
# Simon Greenaway Adam Stein Isart Montane # Simon Greenaway Adam Stein Isart Montane
# Baptiste M. Cole Turner Major Hayden # Baptiste M. Cole Turner Major Hayden
# Joe Ashcraft JeSan-Marie Renouard Christian Loos # Joe Ashcraft Jean-Marie Renouard Christian Loos
# Julien Francoz Daniel Black # Julien Francoz Daniel Black
# #
# Inspired by Matthew Montgomery's tuning-primer.sh script: # Inspired by Matthew Montgomery's tuning-primer.sh script: