-1

私はMySQLTuner.plを使用してサイト/サーバーを最適化しています....これらの問題のいくつかを解決する方法が完全にはわからず、誰かが私を助けてくれるかどうか疑問に思っています.

私は 4GB RAM の VPS を持っています。これは my.cnf 設定です:

[mysqld]    
expire_logs_days=14
sync_binlog=1

query_cache_limit=32M
query_cache_size=128M

slow_query_log=1
log_queries_not_using_indexes=0

thread_cache_size=50

max_allowed_packet=16M
max_connect_errors=1000000
max_connections=250
key_buffer_size=8M

open_files_limit=65535
tmp_table_size=256M
max_heap_table_size=256M
table_definition_cache=2048
table_open_cache=2048
default_storage_engine=InnoDB

innodb_flush_method=O_DIRECT
innodb_file_per_table=1
innodb_log_files_in_group=2
innodb_additional_mem_pool_size=40M
innodb_max_dirty_pages_pct=90
innodb_flush_log_at_trx_commit=1
innodb_log_buffer_size=64M
innodb_log_file_size=256M
innodb_buffer_pool_size=1152M

mysqltuner の出力は次のとおりです。

-------- Performance Metrics -------------------------------------------------
[--] Up for: 2d 8h 36m 40s (7M q [34.897 qps], 504K conn, TX: 41B, RX: 735M)
[--] Reads / Writes: 68% / 32%
[--] Total buffers: 2.0G global + 2.8M per thread (200 max threads)
[OK] Maximum possible memory usage: 2.5G (63% of installed RAM)
[OK] Slow queries: 0% (30K/7M)
[OK] Highest usage of available connections: 20% (40/200)
[OK] Key buffer size / total MyISAM indexes: 8.0M/7.8M
[OK] Key buffer hit rate: 99.9% (1M cached / 1K reads)
[OK] Query cache efficiency: 29.3% (1M cached / 4M selects)
[!!] Query cache prunes per day: 11573
[OK] Sorts requiring temporary tables: 0% (3K temp sorts / 999K sorts)
[!!] Temporary tables created on disk: 48% (54K on disk / 112K total)
[OK] Thread cache hit rate: 99% (40 created / 504K connections)
[OK] Table cache hit rate: 33% (499 open / 1K opened)
[OK] Open file limit used: 0% (380/65K)
[OK] Table locks acquired immediately: 99% (4M immediate / 4M locks)
[OK] InnoDB buffer pool / data size: 1.1G/1001.0M
[OK] InnoDB log waits: 0
-------- Recommendations -----------------------------------------------------
General recommendations:
    Run OPTIMIZE TABLE to defragment tables for better performance
    Increasing the query_cache size over 128M may reduce performance
    Temporary table size is already large - reduce result set size
    Reduce your SELECT DISTINCT queries without LIMIT clauses
Variables to adjust:
    query_cache_size (> 512M) [see warning above]
  1. パフォーマンスを向上させるために改善できることはありますか?

  2. これを修正する方法:

ディスク上に作成された一時テーブル: 48%

1 日あたりのクエリ キャッシュ プルーニング: 11573

クエリ キャッシュ効率: 29.3%

アップデート:

my.cnf の設定について意見をいただければ幸いです (私は専門家ではなく、設定はインターネット上の他のシステムで見たものであるため、一部間違っている可能性があります)。

ありがとうございました

4

1 に答える 1

4

最適化に関しては、「壊れていない場合は修正しないでください」と信じています。つまり、ディスク上の一時テーブルに関する優れた投稿がここにあります

https://dba.stackexchange.com/questions/17677/why-is-mysql-is-creating-so-many-temporary-tables-on-disk

これらの設定をどうすればよいかわからない場合は、「触らないでください」という大きなサインです。質問を少し変更する必要があるかもしれません。DB を最適化する理由をみんなに伝えてください。何かが非常に遅く実行されたためですか?DB がサーバーのリソースを占有しすぎているためでしょうか? 特定の目標のない最適化は非常に危険です。最適化とは、使用方法に最適な方法でシステムを微調整することを意味します。これは、多くの場合、必要のない他の領域でパフォーマンスを交換していることを意味します。あなたの場合、私たちはあなたが必要としないものを知りません。

于 2014-06-11T07:43:23.173 に答える