【问题标题】:Optimal setting for mysql (mariadb optimization 10.5) in my.cnf (Centos 8)my.cnf (Centos 8) 中 mysql (mariadb optimization 10.5) 的最佳设置
【发布时间】:2020-05-10 19:16:09
【问题描述】:

这是我的 mysqltuner 结果:

 [--] Skipped version check for MySQLTuner script
    [!!] Successfully authenticated with no password - SECURITY RISK!
    [!!] Your MySQL version 10.5.0-MariaDB is EOL software!  Upgrade soon!
    [OK] Operating on 64-bit architecture

    -------- Log file Recommendations ------------------------------------------------------------------
    [!!] Log file  doesn't exist

    -------- Storage Engine Statistics -----------------------------------------------------------------
    [--] Status: +Aria +CSV +InnoDB +MEMORY +MRG_MyISAM +MyISAM +PERFORMANCE_SCHEMA +SEQUENCE
    [--] Data in InnoDB tables: 4.4G (Tables: 227)
    [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 is no basic password file list!

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

    -------- Performance Metrics -----------------------------------------------------------------------
    [--] Up for: 50m 57s (911K q [298.114 qps], 2K conn, TX: 3G, RX: 104M)
    [--] Reads / Writes: 99% / 1%
    [--] Binary logging is disabled
    [--] Physical Memory     : 31.2G
    [--] Max MySQL memory    : 3.2G
    [--] Other process memory: 0B
    [--] Total buffers: 417.0M global + 18.9M per thread (151 max threads)
    [--] P_S Max memory usage: 0B
    [--] Galera GCache Max memory usage: 0B
    [OK] Maximum reached memory usage: 568.3M (1.78% of installed RAM)
    [OK] Maximum possible memory usage: 3.2G (10.24% of installed RAM)
    [OK] Overall possible memory usage with other process is compatible with memory available
    [OK] Slow queries: 0% (0/911K)
    [OK] Highest usage of available connections: 5% (8/151)
    [OK] Aborted connections: 0.00%  (0/2906)
    [!!] 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 / 888K selects)
    [OK] Query cache prunes per day: 0
    [OK] Sorts requiring temporary tables: 0% (286 temp sorts / 50K sorts)
    [!!] Joins performed without indexes: 18
    [!!] Temporary tables created on disk: 81% (15K on disk / 18K total)
    [OK] Thread cache hit rate: 99% (8 created / 2K connections)
    [OK] Table cache hit rate: 93% (93 open / 99 opened)
    [OK] table_definition_cache(400) is upper than number of tables(391)
    [OK] Open file limit used: 0% (28/4K)
    [OK] Table locks acquired immediately: 100% (143 immediate / 143 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: 32 thread(s).
    [--] Using default value is good enough for your version (10.5.0-MariaDB)

    -------- MyISAM Metrics ----------------------------------------------------------------------------
    [!!] Key buffer used: 18.2% (24M used / 134M cache)
    [!!] Cannot calculate MyISAM index size - re-run script as root user

    -------- InnoDB Metrics ----------------------------------------------------------------------------
    [--] InnoDB is enabled.
    [--] InnoDB Thread Concurrency: 0
    [OK] InnoDB File per table is activated
    [!!] InnoDB buffer pool / data size: 128.0M/4.4G
    [!!] Ratio InnoDB log file size / InnoDB Buffer pool size (75 %): 96.0M * 1/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: 95.00% (920105182 hits/ 968548737 total)
    [!!] InnoDB Write Log efficiency: 33.6% (1776 hits/ 5285 total)
    [OK] InnoDB log waits: 0.00% (0 waits / 7061 writes)

    -------- AriaDB Metrics ----------------------------------------------------------------------------
    [--] AriaDB is enabled.
    [OK] Aria pagecache size / total Aria indexes: 128.0M/320.0K
    [OK] Aria pagecache hit rate: 98.6% (936K cached / 13K 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: MIXED
    [--] XA support enabled: ON
    [--] Semi synchronous replication Master: OFF
    [--] Semi synchronous replication Slave: OFF
    [--] This is a standalone server

-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
    MySQL was started within the last 24 hours - recommendations may be inaccurate
    Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1
    We will suggest raising the 'join_buffer_size' until JOINs not using indexes are found.
             See https://dev.mysql.com/doc/internals/en/join-buffer-size.html
             (specially the conclusions at the bottom of the page).
    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
    Consider installing Sys schema from https://github.com/mysql/mysql-sys for MySQL
    Consider installing Sys schema from https://github.com/FromDual/mariadb-sys for MariaDB
    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)
    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 (>= 4.4G) if possible.
    innodb_log_file_size should be (=32M) if possible, so InnoDB total log files size equals to 25% of buffer pool size.

谁能优化这个我该怎么办?让事情变得更快?

我想优化 CPU 使用率。

服务器规格: 16核32线程 32 GB 内存

需要我的 mysql 设置的最佳配置

【问题讨论】:

  • 你注意到这条线Your MySQL version 10.5.0-MariaDB is EOL software! Upgrade soon!
  • 是的,但我坚持使用 10.5,也许他们很快就会发布决赛,然后我会更新
  • 我不明白您为什么要更改设置。知道当前配置有什么问题会更有趣。瓶颈在哪里?整体性能是不是太慢了?
  • 如果您珍惜时间,您将不会使用明确标记为 2019 年 12 月 19 日发布的 Alpha 版本的 10.5.0 - 除非您有足够的时间来查找和报告错误。从这个 url,mariadb.com/kb/en/release-notes-mariadb-104-series 选择至少 6 个月前标记为稳定的版本,以保护您的时间投资。我会选择 10.4.7 来节省我的时间。
  • @wilson hauck: 10.5.alpha 意味着 10.5 中的所有新功能都处于 alpha 状态。在 10.4 中工作的所有内容也将在 10.5 中工作。即使它是阿尔法。为此,我们有一个庞大的测试套件在每个受支持的平台上频繁运行。

标签: mysql mariadb centos8 mysqltuner


【解决方案1】:

对您的 my.cnf 或 my.ini [mysqld] 部分的建议

innodb_buffer_pool_size=6G
thread_handling=pool-of-threads

在正常运行 24 小时后,我们会发布一份新的 MySQLTuner 完整报告,以便我们可以看到您的进度,即使这个 Alpha 版本不用于生产。

【讨论】:

  • 的[mysqld] innodb_log_file_size = 2048M innodb_buffer_pool_size = 10240M innodb_buffer_pool_instances = 10 query_cache_size变量= 0 query_cache_type的= 0 query_cache_limit = 1M tmp_table_size的= 256M max_heap_table_size = 256M performance_schema = ON join_buffer_size = 1M的max_connections = 10000 MAX_USER_CONNECTIONS = 6000 thread_handling =池线程数
  • @Wed 仅供参考,8 个 innodb_buffer_pool_instances 的开销小于任何更大数量的实例。对于 8 个实例,innodb_lru_scan_depth 应为 100,以节省用于该函数的 90% 的 CPU 周期。当你有时间时,innodb_page_cleaners 和 innodb_purge_threads 中的实例数应该匹配。期待您周一工作日后的“新日期”MySQLTuner 报告。
  • 一般建议:MySQL 是在过去 24 小时内启动的 - 建议可能不准确 减少您的整体 MySQL 内存占用以确保系统稳定性 将此服务器专用于您的数据库以获得最高性能。临时表大小已经很大 - 减少结果集大小 减少没有 LIMIT 子句的 SELECT DISTINCT 查询 考虑从github.com/mysql/mysql-sys 为 MySQL 安装 Sys 架构 考虑从 github.com/FromDual/mariadb-sys 为 Maria 安装 Sys 架构->尚未添加 innodb_lru、ipc 和 ipt还
  • @Wed MariaDB 10.3.10 有 innodb_lru_scan_depth 可用。避免在不到 6 个月前发布任何内容的另一个原因 - 将来。我希望你能继续你的 10.5.0 之旅——因为没有方便的返回方式。至少在至少 6 个月大的稳定标记版本可供下载之前,安装 Sys 架构将是我的事。
【解决方案2】:

innodb_buffer_pool_size 设置为可用 RAM 的大约 70%。 mysqltuner 建议的 4.4G 将处理您当前的所有数据。如果你期望它成长,那就给它更多。此设置可能有助于 I/O(而不是 CPU)。

(实际上“InnoDB 读取缓冲区效率:95.00%(920105182 次点击/总共 968548737)”表示 paultry 128M buffer_pool 似乎可以充分处理“工作集”。)

您无法调整“优化以提高 CPU 使用率”。您可以找到慢查询并处理索引(尤其是“复合”索引)和查询公式。 那些将有助于 CPU。

http://mysql.rjweb.org/doc.php/mysql_analysis

【讨论】:

    猜你喜欢
    • 2019-05-29
    • 2016-08-23
    • 1970-01-01
    • 2013-07-22
    • 2020-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-21
    相关资源
    最近更新 更多