web-dev-qa-db-ja.com

私はMySQLTunerを実行して、誰かが私と一緒に結果、特にクエリキャッシュと一時テーブルを調査するのではないかと考えました

MySQLTunerの結果は次のとおりです。

[--] Skipped version check for MySQLTuner script
[OK] Logged in using credentials from debian maintenance account.
[OK] Currently running supported MySQL version 5.7.21-0ubuntu0.16.04.1
[OK] Operating on 64-bit architecture

-------- Log file Recommendations ------------------------------------------------------------------
[--] Log file: /var/log/mysql/error.log(15K)
[OK] Log file /var/log/mysql/error.log exists
[OK] Log file /var/log/mysql/error.log is readable.
[OK] Log file /var/log/mysql/error.log is not empty
[OK] Log file /var/log/mysql/error.log is smaller than 32 Mb
[!!] /var/log/mysql/error.log contains 11 warning(s).
[OK] /var/log/mysql/error.log doesn't contain any error.
[--] 0 start(s) detected in /var/log/mysql/error.log
[--] 0 shutdown(s) detected in /var/log/mysql/error.log

-------- Storage Engine Statistics -----------------------------------------------------------------
[--] Status: +ARCHIVE +BLACKHOLE +CSV -FEDERATED +InnoDB +MEMORY +MRG_MYISAM +MyISAM +PERFORMANCE_SCHEMA
[--] Data in InnoDB tables: 3M (Tables: 54)
[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 'admin_default@%' hasn't specific Host restriction.
[!!] User 'admin_rpgc@%' hasn't specific Host restriction.
[!!] There is no basic password file list!

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

-------- Performance Metrics -----------------------------------------------------------------------
[--] Up for: 34d 13h 45m 15s (485K q [0.163 qps], 165K conn, TX: 520M, RX: 83M)
[--] Reads / Writes: 94% / 6%
[--] Binary logging is disabled
[--] Physical Memory     : 2.0G
[--] Max MySQL memory    : 299.5M
[--] Other process memory: 157.2M
[--] Total buffers: 177.0M global + 1.8M per thread (70 max threads)
[--] P_S Max memory usage: 72B
[--] Galera GCache Max memory usage: 0B
[OK] Maximum reached memory usage: 192.8M (9.41% of installed RAM)
[OK] Maximum possible memory usage: 299.5M (14.62% of installed RAM)
[OK] Overall possible memory usage with other process is compatible with memory available
[OK] Slow queries: 0% (0/485K)
[OK] Highest usage of available connections: 12% (9/70)
[!!] Aborted connections: 51.53%  (85302/165532)
[!!] 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 / 157K selects)
[OK] Query cache prunes per day: 0
[OK] Sorts requiring temporary tables: 0% (196 temp sorts / 44K sorts)
[OK] No joins without indexes
[!!] Temporary tables created on disk: 46% (27K on disk / 59K total)
[OK] Thread cache hit rate: 99% (9 created / 165K connections)
[!!] Table cache hit rate: 0% (64 open / 269K opened)
[OK] Open file limit used: 0% (4/1K)
[OK] Table locks acquired immediately: 100% (10K immediate / 10K locks)

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

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

-------- MyISAM Metrics ----------------------------------------------------------------------------
[!!] Key buffer used: 18.2% (3M used / 16M cache)
[OK] Key buffer size / total MyISAM indexes: 16.0M/43.0K
[!!] Read Key buffer hit rate: 62.9% (272 cached / 101 reads)

-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is enabled.
[--] InnoDB Thread Concurrency: 0
[OK] InnoDB File per table is activated
[OK] InnoDB buffer pool / data size: 128.0M/3.6M
[!!] Ratio InnoDB log file size / InnoDB Buffer pool size (75 %): 48.0M * 2/128.0M should be equal 25%
[OK] InnoDB buffer pool instances: 1
[--] Number of InnoDB Buffer Pool Chunk : 1 for 1 Buffer Pool Instance(s)
[OK] Innodb_buffer_pool_size aligned with Innodb_buffer_pool_chunk_size & Innodb_buffer_pool_instances
[OK] InnoDB Read buffer efficiency: 100.00% (4276367247 hits/ 4276367871 total)
[!!] InnoDB Write Log efficiency: 278.6% (19527 hits/ 7009 total)
[OK] InnoDB log waits: 0.00% (0 waits / 26536 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: ROW
[--] XA support enabled: ON
[--] Semi synchronous replication Master: Not Activated
[--] Semi synchronous replication Slave: Not Activated
[--] This is a standalone server

-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
    Control warning line(s) into /var/log/mysql/error.log file
    Restrict Host for user@% to user@SpecificDNSorIp
    Reduce or eliminate unclosed connections and network issues
    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
    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 (1024) variable
    should be greater than table_open_cache (64)
    Read this before changing innodb_log_file_size and/or innodb_log_files_in_group: http://bit . ly/2wgkDvS
Variables to adjust:
    query_cache_size (=0)
    query_cache_type (=0)
    query_cache_limit (> 1M, or use smaller result sets)
    tmp_table_size (> 16M)
    max_heap_table_size (> 16M)
    table_open_cache (> 64)
    innodb_log_file_size should be (=16M) if possible, so InnoDB total log files size equals to 25% of buffer pool size.

Query_cacheを有効にする必要がありますか?

そして、非常に多くの一時テーブルの作成を減らす方法はありますか?

セクションを調整する変数の下で、それらは良い選択のように聞こえますか? 2GBのサーバーがありますRAM=それをすべて使用しない場合、最大使用量を増やすことはまったく役立ちますか?

編集:

my.cnf

mysql/error.log

グローバルステータスを表示;

グローバル変数を表示;

SHOW ENGINE INNODB STATUS;

トップ

ulimit -a

core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 289215
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 289215
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

df -h

Filesystem      Size  Used Avail Use% Mounted on
/dev/simfs       60G  3.8G   57G   7% /
devtmpfs        1.0G     0  1.0G   0% /dev
tmpfs           1.0G     0  1.0G   0% /dev/shm
tmpfs           1.0G  104M  921M  11% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           1.0G     0  1.0G   0% /sys/fs/cgroup
none            1.0G     0  1.0G   0% /run/shm

無料-m

              total        used        free      shared  buff/cache   available
Mem:           2048        1109         187         263         750         827
Swap:          2048         246        1801
1
SvEnjoyPro

いいえ、クエリキャッシュを有効にしないでください。 Q 8.0を含むV 8.0の発表は利用できなくなり、削除されます。さらに、QCは低品質の開発のみを奨励します。

My.cnf-ini [mysqld]セクションの提案

tmp_table_size=40M  # from 16M to reduce TT creations
max_heap_table_size=40M  # from 16M - should ALWAYS be same size as tmp_table_size
max_connections=36  # from 70 because in 30+ days, you had 9 max_used_connections
key_buffer_size=8M  # from 16M - because only 3M used
log_warnings=2  # for addl error.log info on connection errors
0
Wilson Hauck

考慮すべき追加の提案。

ulimit -n 5000
Ubuntoで、1Kの現在のOS制限からより多くのファイルハンドル容量を有効にします。

My.cnf-ini [mysqld]セクションで、2018年4月13日の早いAMに関するその他の提案

max_connect_errors=10  # why allow hacker/cracker 100 opportunities to guess PW?
thread_cache_size=32  # from 8 to improve thread concurrency
lock_wait_timeout=300  # from 1year (3153600 seconds) for reasonable timeout
expire_logs_days=30  # from 0 for limited historical logs
innodb_print_all_deadlocks=ON  # from OFF - you will WANT the information for corrective action
innodb_read_ahead_threshold=8  # from 56 to read next EXTENT earlier
innodb_stats_sample_pages=32  # from 8 for more accurate NDX cardinality
max_join_size=1000000000  # from a HUGE number for 1Billion row limit
max_seeks_for_key=32  # from a HUGE number, after nn NDX tries, scan table
max_write_lock_count=32  # from a HUGE number, give RD a chance after nn locks
table_open_cache=1024  # from 64 to reduce table_open_cache_misses
open_files_limit=3K  # from 1024 to support volume of tables, definitions, files used
query_cache_size=0  # from 1M - QC not being used today
query_cache_limit=1K  # to conserve RAM for other purposes, QC not used
query_cache_min_res_unit=512  # for more RESULTS in QC, if ever used
slow_query_log=ON  # from OFF  to be aware of ATTENTION needed to improve

2018年5月2日のオフィスでの次の日になります。頑張ってください

0
Wilson Hauck

小さなサーバー(またはVM)に小さなデータセットがあります。 SlowLogは、一部のクエリが適切に記述されていないことを示します。それらを修正します。あなたは「パフォーマンスの問題からあなたの方法を調整することはできません」。

QCをオンにしないでください。

(私はもっと言いたいことがあるかもしれませんが、変数とグローバルステータスはPastebinで期限切れになりました。)

0
Rick James