Назад | Перейти на главную страницу

Mysql 100% CPU без активных процессов

Я настраиваю CentOS7 VPS с 4 виртуальными ядрами и 24 ГБ ОЗУ, я использую его для размещения 2 сайтов Wordpress. Есть 2 маленьких dbs, всего около 400MB.

На производственные сайты будет приходиться около 10 тысяч посещений в месяц, сейчас посещения низкие.

Mysqld использует высокий процессор, около 80-120%, без процессов на SQL. Что я должен делать?

У вас есть совет по поводу my.cnf? Я мог бы хранить всю базу данных в оперативной памяти, это плохо?

Запустил mysqltuner, вот результат, попробовал отредактировать my.cnf и перезапустить, но ситуация такая же.

[--] Skipped version check for MySQLTuner script
[OK] Logged in using credentials passed on the command line
[OK] Currently running supported MySQL version 5.7.26
[OK] Operating on 64-bit architecture

-------- Log file Recommendations ------------------------------------------------------------------
[--] Log file: /var/log/mysqld.log(570K)
[OK] Log file /var/log/mysqld.log exists
[OK] Log file /var/log/mysqld.log is readable.
[OK] Log file /var/log/mysqld.log is not empty
[OK] Log file /var/log/mysqld.log is smaller than 32 Mb
[!!] /var/log/mysqld.log contains 107 warning(s).
[!!] /var/log/mysqld.log contains 2702 error(s).
[--] 24 start(s) detected in /var/log/mysqld.log
[--] 1) 2019-07-12T08:42:40.196023Z 0 [Note] /usr/sbin/mysqld: ready for connections.
[--] 2) 2019-07-12T08:35:53.475244Z 0 [Note] /usr/sbin/mysqld: ready for connections.
[--] 3) 2019-07-12T08:33:59.155403Z 0 [Note] /usr/sbin/mysqld: ready for connections.
[--] 4) 2019-07-12T08:33:55.083171Z 0 [Note] /usr/sbin/mysqld: ready for connections.
[--] 5) 2019-07-10T08:55:22.967123Z 0 [Note] /usr/sbin/mysqld: ready for connections.
[--] 6) 2019-07-10T08:50:29.777561Z 0 [Note] /usr/sbin/mysqld: ready for connections.
[--] 7) 2019-07-10T08:47:25.039566Z 0 [Note] /usr/sbin/mysqld: ready for connections.
[--] 8) 2019-07-10T08:45:06.438441Z 0 [Note] /usr/sbin/mysqld: ready for connections.
[--] 9) 2019-07-10T08:16:36.170767Z 0 [Note] /usr/sbin/mysqld: ready for connections.
[--] 10) 2019-07-05T08:06:45.717190Z 0 [Note] /usr/sbin/mysqld: ready for connections.
[--] 44 shutdown(s) detected in /var/log/mysqld.log
[--] 1) 2019-07-12T08:41:52.967851Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
[--] 2) 2019-07-12T08:35:48.919495Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
[--] 3) 2019-07-12T08:33:57.050194Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
[--] 4) 2019-07-12T08:33:50.686294Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
[--] 5) 2019-07-12T08:33:46.827841Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
[--] 6) 2019-07-12T08:33:40.833353Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
[--] 7) 2019-07-12T08:33:37.082075Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
[--] 8) 2019-07-12T08:33:33.540923Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
[--] 9) 2019-07-12T08:33:30.271090Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
[--] 10) 2019-07-12T08:33:27.018529Z 0 [Note] /usr/sbin/mysqld: Shutdown complete

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

-------- Analysis Performance Metrics --------------------------------------------------------------
[--] innodb_stats_on_metadata: OFF
[OK] No stat updates during querying INFORMATION_SCHEMA.

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

-------- CVE Security Recommendations --------------------------------------------------------------
[OK] NO SECURITY CVE FOUND FOR YOUR VERSION

-------- Performance Metrics -----------------------------------------------------------------------
[--] Up for: 2d 22h 2m 8s (114M q [455.795 qps], 69K conn, TX: 1059G, RX: 75G)
[--] Reads / Writes: 99% / 1%
[--] Binary logging is disabled
[--] Physical Memory     : 22.8G
[--] Max MySQL memory    : 338.9M
[--] Other process memory: 0B
[--] Total buffers: 169.0M global + 1.1M per thread (151 max threads)
[--] P_S Max memory usage: 0B
[--] Galera GCache Max memory usage: 0B
[OK] Maximum reached memory usage: 178.0M (0.76% of installed RAM)
[OK] Maximum possible memory usage: 338.9M (1.45% of installed RAM)
[OK] Overall possible memory usage with other process is compatible with memory available
[OK] Slow queries: 0% (0/114M)
[OK] Highest usage of available connections: 5% (8/151)
[OK] Aborted connections: 1.03%  (712/69411)
[!!] 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 / 113M selects)
[OK] Query cache prunes per day: 0
[!!] Sorts requiring temporary tables: 17% (406K temp sorts / 2M sorts)
[!!] Joins performed without indexes: 3603
[!!] Temporary tables created on disk: 81% (1M on disk / 1M total)
[OK] Thread cache hit rate: 99% (8 created / 69K connections)
[OK] Table cache hit rate: 20% (1K open / 9K opened)
[OK] Open file limit used: 0% (79/10K)
[OK] Table locks acquired immediately: 100% (888 immediate / 888 locks)

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

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

-------- MyISAM Metrics ----------------------------------------------------------------------------
[!!] Key buffer used: 18.4% (1M used / 8M cache)
[OK] Key buffer size / total MyISAM indexes: 8.0M/43.0K
[OK] Read Key buffer hit rate: 99.2% (2K cached / 17 reads)

-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is enabled.
[--] InnoDB Thread Concurrency: 0
[OK] InnoDB File per table is activated
[!!] InnoDB buffer pool / data size: 128.0M/318.0M
[!!] Ratio InnoDB log file size / InnoDB Buffer pool size (75 %): 48.0M * 2/128.0M should be equal to 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% (33049906110 hits/ 33050550153 total)
[!!] InnoDB Write Log efficiency: 18.15% (110271 hits/ 607553 total)
[OK] InnoDB log waits: 0.00% (0 waits / 497282 writes)

-------- AriaDB Metrics ----------------------------------------------------------------------------
[--] AriaDB is disabled.

-------- TokuDB Metrics ----------------------------------------------------------------------------
[--] TokuDB is disabled.

-------- XtraDB Metrics ----------------------------------------------------------------------------
[--] XtraDB 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/mysqld.log file
    Control error line(s) into /var/log/mysqld.log file
    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
    When making adjustments, make tmp_table_size/max_heap_table_size equal
    Reduce your SELECT DISTINCT queries which have no LIMIT clause
    Performance schema should be activated for better diagnostics
    Before changing innodb_log_file_size and/or innodb_log_files_in_group read this:
Variables to adjust:
    query_cache_size (=0)
    query_cache_type (=0)
    query_cache_limit (> 1M, or use smaller result sets)
    sort_buffer_size (> 256K)
    read_rnd_buffer_size (> 256K)
    join_buffer_size (> 256.0K, or always use indexes with JOINs)
    tmp_table_size (> 16M)
    max_heap_table_size (> 16M)
    performance_schema = ON enable PFS
    innodb_buffer_pool_size (>= 318.0M) if possible.
    innodb_log_file_size should be (=16M) if possible, so InnoDB total log files size equals to 25% of buffer pool size.

Спасибо.