首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >MariaDB将cpu固定在100%,需要帮助

MariaDB将cpu固定在100%,需要帮助
EN

Database Administration用户
提问于 2019-11-19 14:53:21
回答 1查看 342关注 0票数 0

我的服务器出了问题,已经有一段时间了,但我终于开始试着修复它了。

当我跑到最上面的时候,我看到其中一个核心接近100%,而且通常不会下降到95%以下。

代码语言:javascript
运行
复制
%Cpu(s):  0.3 us,  0.2 sy,  0.0 ni, 99.5 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st

我有64 ram内存:

代码语言:javascript
运行
复制
KiB Mem : 65748964 total,   494008 free,   985284 used, 64269672 buff/cache
KiB Swap: 33521660 total, 33400828 free,   120832 used. 63915376 avail Mem 

这是我的my.cnf (修剪以删除任何#)

代码语言:javascript
运行
复制
[server]
[mysqld]
max_connections = 50
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
skip-name-resolve
sort_buffer_size        = 128M
tmp_table_size          = 256MM
key_buffer_size         = 128M
max_allowed_packet      = 256M
thread_stack            = 192K
thread_cache_size       = 16
myisam_recover_options  = BACKUP
query_cache_limit       = 128M
query_cache_size        = 0
query_cache_type        = 0
performance_schema = OFF
log_error = /var/log/mysql/error.log
expire_logs_days        = 10
max_binlog_size   = 100M
character-set-server  = utf8mb4
collation-server      = utf8mb4_general_ci
[embedded]
[mariadb]
[mariadb-10.1]

我确实运行了mysql调谐器,下面是输出:

代码语言:javascript
运行
复制
[--] Skipped version check for MySQLTuner script
[OK] Logged in using credentials passed on the command line
[OK] Currently running supported MySQL version 10.1.34-MariaDB-0ubuntu0.18.04.1
[OK] Operating on 64-bit architecture
-------- Log file Recommendations ------------------------------------------------------------------
[--] Log file: /var/log/mysql/error.log(0B)
[OK] Log file /var/log/mysql/error.log exists
[OK] Log file /var/log/mysql/error.log is readable.
[!!] Log file /var/log/mysql/error.log is empty
[OK] Log file /var/log/mysql/error.log is smaller than 32 Mb
[OK] /var/log/mysql/error.log doesn't contain any warning.
[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: +Aria +CSV +InnoDB +MEMORY +MRG_MyISAM +MyISAM +PERFORMANCE_SCHEMA +SEQUENCE
[--] Data in InnoDB tables: 2.1M (Tables: 49)
[--] Data in MyISAM tables: 31.4G (Tables: 339)
[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
[OK] All database users have passwords assigned
[--] There are 618 basic passwords in the list.
-------- CVE Security Recommendations --------------------------------------------------------------
[OK] NO SECURITY CVE FOUND FOR YOUR VERSION
-------- Performance Metrics -----------------------------------------------------------------------
[--] Up for: 131d 22h 10m 38s (7B q [644.089 qps], 2M conn, TX: 1414G, RX: 556G)
[--] Reads / Writes: 96% / 4%
[--] Binary logging is disabled
[--] Physical Memory     : 62.7G
[--] Max MySQL memory    : 6.7G
[--] Other process memory: 989.5M
[--] Total buffers: 424.0M global + 128.8M per thread (50 max threads)
[--] P_S Max memory usage: 0B
[--] Galera GCache Max memory usage: 0B
[OK] Maximum reached memory usage: 3.6G (5.68% of installed RAM)
[OK] Maximum possible memory usage: 6.7G (10.69% of installed RAM)
[OK] Overall possible memory usage with other process is compatible with memory available
[OK] Slow queries: 0% (216/7B)
[OK] Highest usage of available connections: 50% (25/50)
[OK] Aborted connections: 2.03%  (52376/2580658)
[OK] Query cache is disabled by default due to mutex contention on multiprocessor machines.
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 3M sorts)
[OK] No joins without indexes
[!!] Temporary tables created on disk: 27% (83K on disk / 304K total)
[OK] Thread cache hit rate: 99% (667 created / 2M connections)
[!!] Table cache hit rate: 3% (606 open / 15K opened)
[OK] Open file limit used: 5% (874/16K)
[OK] Table locks acquired immediately: 99% (7B immediate / 7B locks)
-------- Performance schema ------------------------------------------------------------------------
[--] Performance schema is disabled.
[--] Memory used by P_S: 0B
[--] Sys schema isn't installed.
-------- ThreadPool Metrics ------------------------------------------------------------------------
[--] ThreadPool stat is enabled.
[--] Thread Pool Size: 8 thread(s).
[--] Using default value is good enough for your version (10.1.34-MariaDB-0ubuntu0.18.04.1)
-------- MyISAM Metrics ----------------------------------------------------------------------------
[OK] Key buffer used: 100.0% (134M used / 134M cache)
[OK] Key buffer size / total MyISAM indexes: 128.0M/9.2G
[OK] Read Key buffer hit rate: 99.9% (53B cached / 33M reads)
[!!] Write Key buffer hit rate: 50.0% (515M cached / 257M writes)
-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is enabled.
[--] InnoDB Thread Concurrency: 0
[OK] InnoDB File per table is activated
[OK] InnoDB buffer pool / data size: 128.0M/2.1M
[!!] Ratio InnoDB log file size / InnoDB Buffer pool size (75 %): 48.0M * 2/128.0M should be equal 25%
[!!] InnoDB buffer pool <= 1G and Innodb_buffer_pool_instances(!=1).
[--] InnoDB Buffer Pool Chunk Size not used or defined in your version
[OK] InnoDB Read buffer efficiency: 99.27% (76133 hits/ 76689 total)
[!!] InnoDB Write Log efficiency: 14.75% (63 hits/ 427 total)
[OK] InnoDB log waits: 0.00% (0 waits / 364 writes)
-------- AriaDB Metrics ----------------------------------------------------------------------------
[--] AriaDB is enabled.
[OK] Aria pagecache size / total Aria indexes: 128.0M/1B
[OK] Aria pagecache hit rate: 99.9% (87M cached / 83K reads)
-------- 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: STATEMENT
[--] XA support enabled: ON
[--] Semi synchronous replication Master: Not Activated
[--] Semi synchronous replication Slave: Not Activated
[--] This is a standalone server
-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
    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
    Read this before increasing for MariaDB https://mariadb.com/kb/en/library/optimizing-table_open_cache/
    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 (16364) variable
    should be greater than table_open_cache (2000)
    Performance schema should be activated for better diagnostics
    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:
    tmp_table_size (> 256M)
    max_heap_table_size (> 16M)
    table_open_cache (> 2000)
    performance_schema = ON enable PFS
    innodb_log_file_size should be (=16M) if possible, so InnoDB total log files size equals to 25% of buffer pool size.
    innodb_buffer_pool_instances (=1)

如果你能做到这一点,谢谢你,如果你能帮我的话,非常感谢。我唯一的其他选择是一个新的框,但是如果是配置,我最终只会看到相同的结果。

EN

回答 1

Database Administration用户

回答已采纳

发布于 2019-11-19 16:25:41

给你一个简短的任务清单。

请查看mariadb,以获得纠正上述错误报告的更新,遵循上述准则,以提高table_open_cache。

考虑一下切换到InnoDB (在我自己的经验中,MyISAM通常没有InnoDB做不到的事情),除了数据库级别上的外键引用、外键引用上的自动索引、用于各种操作的更智能的表锁等优点之外。

大多数由oracle完成的数据库代码优化都完全进入了InnoDB。

票数 -1
EN
页面原文内容由Database Administration提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://dba.stackexchange.com/questions/253630

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档