mysql参数调整参考(mysqltuner)

脚本获取
# wget -c https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl 

脚本执行
# chmod +x mysqltuner.pl

# ./mysqltuner.pl 


执行结果分析:

[root@holly1 backup]# ./mysqltuner.pl 
 >>  MySQLTuner 1.7.9 - Major Hayden <[email protected]>
 >>  Bug reports, feature requests, and downloads at http://mysqltuner.com/
 >>  Run with '--help' for additional options and output filtering

[--] Skipped version check for MySQLTuner script
Please enter your MySQL administrative login: root
Please enter your MySQL administrative password: [OK] Currently running supported MySQL version 5.6.28-log
[OK] Operating on 64-bit architecture
 
-------- Log file Recommendations ------------------------------------------------------------------
[--] Log file: /var/lib/mysql/holly1.err(397M)
[OK] Log file /var/lib/mysql/holly1.err exists
[OK] Log file /var/lib/mysql/holly1.err is readable.
[OK] Log file /var/lib/mysql/holly1.err is not empty
[!!] Log file /var/lib/mysql/holly1.err is bigger than 32 Mb
[!!] /var/lib/mysql/holly1.err contains 996282 warning(s).
[!!] /var/lib/mysql/holly1.err contains 320438 error(s).
[--] 40 start(s) detected in /var/lib/mysql/holly1.err
[--] 1) 2018-06-01 16:29:17 21697 [Note] /usr/sbin/mysqld: ready for connections.
[--] 2) 2018-06-01 16:27:01 20915 [Note] /usr/sbin/mysqld: ready for connections.
[--] 3) 2018-05-30 18:02:43 31909 [Note] /usr/sbin/mysqld: ready for connections.
[--] 4) 2018-05-30 17:54:22 30310 [Note] /usr/sbin/mysqld: ready for connections.
[--] 5) 2018-05-14 14:07:42 22486 [Note] /usr/sbin/mysqld: ready for connections.
[--] 6) 2018-05-13 13:35:33 14067 [Note] /usr/sbin/mysqld: ready for connections.
[--] 7) 2018-05-10 17:50:22 19055 [Note] /usr/sbin/mysqld: ready for connections.
[--] 8) 2018-04-25 17:34:43 25895 [Note] /usr/sbin/mysqld: ready for connections.
[--] 9) 2018-04-25 15:53:02 12317 [Note] /usr/sbin/mysqld: ready for connections.
[--] 10) 2018-03-20 10:13:44 14087 [Note] /usr/sbin/mysqld: ready for connections.
[--] 32 shutdown(s) detected in /var/lib/mysql/holly1.err
[--] 1) 2018-06-01 16:29:15 20915 [Note] /usr/sbin/mysqld: Shutdown complete
[--] 2) 2018-06-01 16:26:59 31909 [Note] /usr/sbin/mysqld: Shutdown complete
[--] 3) 2018-05-30 18:02:41 30310 [Note] /usr/sbin/mysqld: Shutdown complete
[--] 4) 2018-05-30 17:54:19 22486 [Note] /usr/sbin/mysqld: Shutdown complete
[--] 5) 2018-05-14 14:07:41 14067 [Note] /usr/sbin/mysqld: Shutdown complete
[--] 6) 2018-05-10 17:50:19 25895 [Note] /usr/sbin/mysqld: Shutdown complete
[--] 7) 2018-04-25 17:34:41 12317 [Note] /usr/sbin/mysqld: Shutdown complete
[--] 8) 2018-04-25 15:52:58 14087 [Note] /usr/sbin/mysqld: Shutdown complete
[--] 9) 2018-03-20 10:12:23 14053 [Note] /usr/sbin/mysqld: Shutdown complete
[--] 10) 2018-03-14 11:41:26 14046 [Note] /usr/sbin/mysqld: Shutdown complete
 
-------- Storage Engine Statistics -----------------------------------------------------------------
[--] Status: +ARCHIVE +BLACKHOLE +CSV -FEDERATED +InnoDB +MEMORY +MRG_MYISAM +MyISAM +PERFORMANCE_SCHEMA 
[--] Data in MyISAM tables: 7G (Tables: 59)
[--] Data in InnoDB tables: 69G (Tables: 1321)
[OK] Total fragmented tables: 0
 
-------- Security Recommendations ------------------------------------------------------------------
[OK] There are no anonymous accounts for any database users
[OK] All database users have passwords assigned
[!!] User 'backup@%' has user name as password.
[!!] User 'dxh@%' has user name as password.
[!!] User 'hive@%' has user name as password.
[!!] User 'mengb@%' has user name as password.
[!!] User 'mengb@localhost' has user name as password.
[!!] User 'root@%' has user name as password.
[!!] User 'root@localhost' has user name as password.
[!!] User 'spark@%' has user name as password.
[!!] User 'spark@host8' has user name as password.
[!!] User 'ylcf@%' has user name as password.
[!!] User 'ylcf@localhost' has user name as password.
[!!] User 'backup@%' does not specify hostname restrictions.
[!!] User 'dxh@%' does not specify hostname restrictions.
[!!] User 'hive@%' does not specify hostname restrictions.
[!!] User 'mengb@%' does not specify hostname restrictions.
[!!] User 'qiubo@%' does not specify hostname restrictions.
[!!] User 'repl_user@%' does not specify hostname restrictions.
[!!] User 'root@%' does not specify hostname restrictions.
[!!] User 'spark@%' does not specify hostname restrictions.
[!!] User 'st@%' does not specify hostname restrictions.
[!!] User 'ylcf@%' does not specify hostname restrictions.
[!!] There is no basic password file list!
 
-------- CVE Security Recommendations --------------------------------------------------------------
[--] Skipped due to --cvefile option undefined
 
-------- Performance Metrics -----------------------------------------------------------------------
[--] Up for: 23d 19h 21m 47s (564M q [274.471 qps], 93K conn, TX: 775G, RX: 150G)
[--] Reads / Writes: 98% / 2%
[--] Binary logging is enabled (GTID MODE: OFF)
[--] Physical Memory     : 23.4G
[--] Max MySQL memory    : 27.4G
[--] Other process memory: 23.3G
[--] Total buffers: 10.0G global + 4.6M per thread (3600 max threads)
[--] P_S Max memory usage: 1G
[--] Galera GCache Max memory usage: 0B
[OK] Maximum reached memory usage: 11.8G (50.37% of installed RAM)
[!!] Maximum possible memory usage: 27.4G (117.06% of installed RAM)
[!!] Overall possible memory usage with other process exceeded memory
[OK] Slow queries: 0% (1K/564M)
[OK] Highest usage of available connections: 3% (143/3600)
[OK] Aborted connections: 0.01%  (9/93601)
[!!] name resolution is active : a reverse name resolution is made for each new connection and can reduce performance
[!!] Query cache may be disabled by default due to mutex contention.
[!!] Query cache efficiency: 0.0% (0 cached / 553M selects)
[OK] Query cache prunes per day: 0
[OK] Sorts requiring temporary tables: 1% (24K temp sorts / 2M sorts)
[!!] Joins performed without indexes: 134273
[OK] Temporary tables created on disk: 0% (20K on disk / 5M total)
[OK] Thread cache hit rate: 99% (318 created / 93K connections)
[!!] Table cache hit rate: 1% (79 open / 6K opened)
[OK] Open file limit used: 0% (11/40K)
[OK] Table locks acquired immediately: 99% (561M immediate / 561M locks)
[OK] Binlog cache memory access: 99.95% (6740335 Memory / 6743679 Total)
 
-------- Performance schema ------------------------------------------------------------------------
[--] Memory used by P_S: 1.1G
[--] Sys schema isn't installed.
 
-------- ThreadPool Metrics ------------------------------------------------------------------------
[--] ThreadPool stat is disabled.
 
-------- MyISAM Metrics ----------------------------------------------------------------------------
[!!] Key buffer used: 18.3% (1M used / 8M cache)
[OK] Key buffer size / total MyISAM indexes: 8.0M/1.6G
[OK] Read Key buffer hit rate: 99.7% (1B cached / 4M reads)
[!!] Write Key buffer hit rate: 1.7% (417M cached / 7M writes)
 
-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is enabled.
[--] InnoDB Thread Concurrency: 0
[OK] InnoDB File per table is activated
[!!] InnoDB buffer pool / data size: 10.0G/69.4G
[!!] Ratio InnoDB log file size / InnoDB Buffer pool size (5 %): 256.0M * 2/10.0G should be equal 25%
[!!] InnoDB buffer pool instances: 8
[--] InnoDB Buffer Pool Chunk Size not used or defined in your version
[OK] InnoDB Read buffer efficiency: 100.00% (91878755808 hits/ 91878992815 total)
[!!] InnoDB Write Log efficiency: 73.87% (18540881 hits/ 25099183 total)
[OK] InnoDB log waits: 0.00% (0 waits / 6558302 writes)
 
-------- AriaDB Metrics ----------------------------------------------------------------------------
[--] AriaDB is disabled.
 
-------- TokuDB Metrics ----------------------------------------------------------------------------
[--] TokuDB is disabled.
 
-------- XtraDB Metrics ----------------------------------------------------------------------------
[--] XtraDB is disabled.
 
-------- RocksDB Metrics ---------------------------------------------------------------------------
[--] RocksDB is disabled.
 
-------- Spider Metrics ----------------------------------------------------------------------------
[--] Spider is disabled.
 
-------- Connect Metrics ---------------------------------------------------------------------------
[--] Connect is disabled.
 
-------- Galera Metrics ----------------------------------------------------------------------------
[--] Galera is disabled.
 
-------- Replication Metrics -----------------------------------------------------------------------
[--] Galera Synchronous replication: NO
[--] No replication slave(s) for this server.
[--] Binlog format: STATEMENT
[--] XA support enabled: ON
[--] Semi synchronous replication Master: Not Activated
[--] Semi synchronous replication Slave: ON
[!!] This replication slave is not running but seems to be configured.
 
-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
    /var/lib/mysql/holly1.err is > 32Mb, you should analyze why or implement a rotation log strategy such as logrotate!
    Control warning line(s) into /var/lib/mysql/holly1.err file
    Control error line(s) into /var/lib/mysql/holly1.err file
    Set up a Secure Password for user@host ( SET PASSWORD FOR 'user'@'SpecificDNSorIp' = PASSWORD('secure_password'); )
    Restrict Host for user@% to user@SpecificDNSorIp
    Reduce your overall MySQL memory footprint for system stability
    Dedicate this server to your database for highest performance.
    Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1
    Adjust your join queries to always utilize indexes
    Increase table_open_cache gradually to avoid file descriptor limits
    Read this before increasing table_open_cache over 64: http://bit.ly/1mi7c4C
    This is MyISAM only table_cache scalability problem, InnoDB not affected.
    See more details here: https://bugs.mysql.com/bug.php?id=49177
    This bug already fixed in MySQL 5.7.9 and newer MySQL versions.
    Beware that open_files_limit (40480) variable 
    should be greater than table_open_cache (8000)
    Consider installing Sys schema from https://github.com/mysql/mysql-sys
    Before changing innodb_log_file_size and/or innodb_log_files_in_group read this: http://bit.ly/2wgkDvS
Variables to adjust:
  *** MySQL's maximum memory usage is dangerously high ***
  *** Add RAM before increasing MySQL buffer variables ***
    query_cache_size (=0)
    query_cache_type (=0)
    query_cache_limit (> 1M, or use smaller result sets)
    join_buffer_size (> 2.0M, or always use indexes with JOINs)
    table_open_cache (> 8000)
    innodb_buffer_pool_size (>= 69G) if possible.
    innodb_log_file_size should be (=1G) if possible, so InnoDB total log files size equals to 25% of buffer pool size.
    innodb_buffer_pool_instances(=10)

猜你喜欢

转载自blog.csdn.net/lichangzai/article/details/80800042
今日推荐