ミライハック
  • Home
  • Categories
  • About

>> Home / LInux

MySQLのパフォーマンスチューニングはmysqltuner.plが便利

∵ Takayoshi Saito ∴ 2017-08-11 ∞ 2'

MySQLのチューニング箇所を提案してくれるmysqltuner.pl

MySQLのパフォーマンスチューニングにはmysqltuner.plが便利です。現在のサーバーのMySQLの使用状況や/etc/my.cnfの設定を分析して、最適なチューニング法を提案してくれます。

まずMySQLTuner-perlをダウンロードしましょう。

$ git clone https://github.com/major/MySQLTuner-perl

次にmysqltuner.plを実行します。

$ cd MySQLTuner-perl
$ perl mysqltuner.pl

MySQLの管理権限ユーザーのユーザー名とパスワードを聞いてくるので入力します。その後、MySQLの設定に関する診断とレポートが行われて、最適なチューニング方法の提案が表示されます。

 >>  MySQLTuner 1.7.3 - Major Hayden 
 >>  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:  Currently running supported MySQL version 5.7.19
 Operating on 64-bit architecture

-------- Log file Recommendations ------------------------------------------------------------------
[--] Log file: /var/log/mysqld.log(191K)
 Log file /var/log/mysqld.log exists
[!!] Log file /var/log/mysqld.log isn't readable.

-------- Storage Engine Statistics -----------------------------------------------------------------
[--] Status: +ARCHIVE +BLACKHOLE +CSV -FEDERATED +InnoDB +MEMORY +MRG_MYISAM +MyISAM +PERFORMANCE_SCHEMA
[--] Data in MyISAM tables: 9M (Tables: 4)
[--] Data in InnoDB tables: 20M (Tables: 91)
 Total fragmented tables: 0

-------- Security Recommendations ------------------------------------------------------------------
 There are no anonymous accounts for any database users

-------- CVE Security Recommendations --------------------------------------------------------------
[--] Skipped due to --cvefile option undefined

-------- Performance Metrics -----------------------------------------------------------------------
[--] Up for: 16h 2m 52s (438K q [7.583 qps], 6K conn, TX: 5G, RX: 85M)
[--] Reads / Writes: 95% / 5%
[--] Binary logging is disabled
[--] Physical Memory     : 3.9G
[--] Max MySQL memory    : 1.6G
[--] Other process memory: 1.1G
[--] Total buffers: 1.1G global + 1.1M per thread (512 max threads)
[--] P_S Max memory usage: 72B
[--] Galera GCache Max memory usage: 0B
 Maximum reached memory usage: 1.1G (28.27% of installed RAM)
 Maximum possible memory usage: 1.6G (42.70% of installed RAM)
 Overall possible memory usage with other process is compatible with memory available
 Slow queries: 0% (0/438K)
 Highest usage of available connections: 0% (5/512)
 Aborted connections: 0.07%  (4/6127)
[!!] name resolution is active : a reverse name resolution is made for each new connection and can reduce performance
 Query cache is disabled by default due to mutex contention on multiprocessor machines.
 Sorts requiring temporary tables: 0% (1 temp sorts / 55K sorts)
 No joins without indexes
[!!] Temporary tables created on disk: 73% (13K on disk / 17K total)
 Thread cache hit rate: 99% (5 created / 6K connections)
 Table cache hit rate: 56% (1K open / 2K opened)
 Open file limit used: 2% (107/5K)
 Table locks acquired immediately: 100% (84K immediate / 84K locks)

-------- Performance schema ------------------------------------------------------------------------
[--] Memory used by P_S: 72B
[--] Sys schema is installed.

-------- ThreadPool Metrics ------------------------------------------------------------------------
[--] ThreadPool stat is disabled.

-------- MyISAM Metrics ----------------------------------------------------------------------------
[!!] Key buffer used: 25.5% (2M used / 8M cache)
 Key buffer size / total MyISAM indexes: 8.0M/3.6M
 Read Key buffer hit rate: 99.9% (553K cached / 588 reads)
[!!] Write Key buffer hit rate: 14.8% (3K cached / 463 writes)

-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is enabled.
[--] InnoDB Thread Concurrency: 0
 InnoDB File per table is activated
 InnoDB buffer pool / data size: 1.0G/20.1M
 Ratio InnoDB log file size / InnoDB Buffer pool size: 128.0M * 2/1.0G should be equal 25%
 InnoDB buffer pool instances: 1
[--] Number of InnoDB Buffer Pool Chunk : 8 for 1 Buffer Pool Instance(s)
 Innodb_buffer_pool_size aligned with Innodb_buffer_pool_chunk_size & Innodb_buffer_pool_instances
 InnoDB Read buffer efficiency: 99.99% (12806082 hits/ 12807199 total)
[!!] InnoDB Write Log efficiency: 88.34% (164903 hits/ 186664 total)
 InnoDB log waits: 0.00% (0 waits / 21761 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.
[--] This is a standalone server.

-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
    Set up a Password for user with the following SQL statement ( SET PASSWORD FOR 'user'@'SpecificDNSorIp' = PASSWORD('secure_password'); )
    MySQL started within last 24 hours - recommendations may be inaccurate
    Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1
    When making adjustments, make tmp_table_size/max_heap_table_size equal
    Reduce your SELECT DISTINCT queries which have no LIMIT clause
Variables to adjust:
    tmp_table_size (> 16M)
    max_heap_table_size (> 16M)

ここではパスワードの強化、tmp_table_sizeを16MB以上にすること、max_heap_table_sizeを16MB以上にすることが提案されました。

利用状況に依るので常に最適とは限らないですが、1つの提案として参考になることは間違いないかと思います。

実践ハイパフォーマンスMySQL 第3版posted with カエレバBaron Schwartz,Peter Zaitsev,Vadim Tkachenko オライリージャパン 2013-11-25

Search

Categories
  • LInux
  • インターネット
  • インフラ
  • エッセイ
  • ゲーム
  • システム開発
  • セキュリティ
  • データサイエンス
  • 国際関係
  • 政治
  • 歴史
  • 社会学
  • 自己紹介
  • 行ってきた

Pages
  • 齊藤貴義
  • 職務経歴
  • スクレイピング・ハッキング・ラボ サポートページ
  • 『爆速開発を支えるClaude Code上級者テクニック』サポートページ

2026 © Takayoshi Saito | Twitter GitHub | Built on Zola