AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / dba / 问题 / 81344
Accepted
Ben The Novice
Ben The Novice
Asked: 2014-10-03 12:30:43 +0800 CST2014-10-03 12:30:43 +0800 CST 2014-10-03 12:30:43 +0800 CST

使用 SSD 上的 mySQL 升级到新的 cPanel 服务器——我应该在 my.cnf 中更改什么?

  • 772

我正在使用 whm/cpanel 升级到更快的服务器,mysql 数据库将位于 SSD 上。我读过一些关于不需要任何查询缓存和类似内容的文章,但作为新手,我了解到修改 my.cnf 可能是灾难性的。

这是我基于“硬盘”的网络服务器的当前 my.cnf。

[mysqld]
query_cache_limit=32M
query_cache_size=128M
query_cache_type=1
query_cache_min_res_unit=4096
open_files_limit=16000

table_open_cache=25000
table_definition_cache=2000
key_buffer_size=128M
innodb_buffer_pool_size=2000M
innodb_buffer_pool_instances=2
join_buffer_size=4M
sort_buffer_size=4M
read_rnd_buffer_size=4M
tmp_table_size=3048M
max_heap_table_size=3048M
thread_cache_size=256

max_connections=250
table_cache=60000

如果 mysql 在 SSD 上,您会对其进行哪些更改?

以下是来自 tuner.sh 的一些信息:

Avg. qps = 447

WORKER THREADS
Current thread_cache_size = 256
Current threads_cached = 96
Current threads_per_sec = 0
Historic threads_per_sec = 0
Your thread_cache_size is fine

MAX CONNECTIONS
Current max_connections = 250
Current threads_connected = 20
Historic max_used_connections = 116
The number of used connections is 46% of the configured maximum.
Your max_connections variable seems to be fine.

INNODB STATUS
Current InnoDB index space = 794 M
Current InnoDB data space = 1.10 G
Current InnoDB buffer pool free = 14 %
Current innodb_buffer_pool_size = 1.95 G
Depending on how much space your innodb indexes take up it may be safe
to increase this value to up to 2 / 3 of total system memory

MEMORY USAGE
Max Memory Ever Allocated : 3.62 G
Configured Max Per-thread Buffers : 3.02 G
Configured Max Global Buffers : 2.21 G
Configured Max Memory Limit : 5.23 G
Physical Memory : 15.56 G
Max memory limit seem to be within acceptable norms

KEY BUFFER
Current MyISAM index space = 222 M
Current key_buffer_size = 128 M
Key cache miss rate is 1 : 1115
Key buffer free ratio = 72 %
Your key_buffer_size seems to be fine

QUERY CACHE
Query cache is enabled
Current query_cache_size = 128 M
Current query_cache_used = 28 M
Current query_cache_limit = 32 M
Current Query cache Memory fill ratio = 22.42 %
Current query_cache_min_res_unit = 4 K
Your query_cache_size seems to be too high.
Perhaps you can use these resources elsewhere
MySQL won't cache query results that are larger than query_cache_limit in size

SORT OPERATIONS
Current sort_buffer_size = 4 M
Current read_rnd_buffer_size = 4 M
Sort buffer seems to be fine

JOINS
Current join_buffer_size = 4.00 M
You have had 166 queries where a join could not use an index properly
join_buffer_size >= 4 M
This is not advised
You should enable "log-queries-not-using-indexes"
Then look for non indexed joins in the slow query log.

OPEN FILES LIMIT
Current open_files_limit = 120260 files
The open_files_limit should typically be set to at least 2x-3x
that of table_cache if you have heavy MyISAM usage.
Your open_files_limit value seems to be fine

TABLE CACHE
Current table_open_cache = 60000 tables
Current table_definition_cache = 2000 tables
You have a total of 733 tables
You have 851 open tables.
The table_cache value seems to be fine

TEMP TABLES
Current max_heap_table_size = 2.97 G
Current tmp_table_size = 2.97 G
Of 262494 temp tables, 33% were created on disk
Perhaps you should increase your tmp_table_size and/or max_heap_table_size
to reduce the number of disk-based temporary tables
Note! BLOB and TEXT columns are not allow in memory tables.
If you are using these columns raising these values might not impact your 
ratio of on disk temp tables.

TABLE SCANS
Current read_buffer_size = 128 K
Current table scan ratio = 1005 : 1
read_buffer_size seems to be fine

TABLE LOCKING
Current Lock Wait ratio = 1 : 101097
Your table locking seems to be fine

OLD 网络服务器是一个 8 核单 Xeon @ 16GB 内存。新的网络服务器是一个 24 核双至强@64GB 内存。新服务器上的 SSD 将仅包含操作系统和数据库,所有站点均基于 WordPress,因此每天的总浏览量约为 250,000 次。

非常感谢您的帮助或建议!

问候,

本

mysql ssd
  • 1 1 个回答
  • 988 Views

1 个回答

  • Voted
  1. Best Answer
    Bill Karwin
    2014-10-03T14:01:47+08:002014-10-03T14:01:47+08:00

    open_files_limit=16000

    将其设置为低于 table_open_cache 没有什么意义。请参阅https://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html#sysvar_open_files_limit中描述的默认值

    table_open_cache=25000 table_cache=60000

    考虑到您只有 < 900 个打开的表,您可能不需要将它设置得这么高。

    请注意,table_cache 是 table_open_cache 的过时同义词。my.cnf 文件中的最后一个优先。因此,您已将 table_open_cache 设置为 60000,覆盖了之前的设置。我建议决定你想要的值并使用一行来设置它,以避免混淆。

    table_definition_cache=2000

    这可以。

    key_buffer_size=128M

    密钥缓冲区仅适用于 MyISAM。如果你没有 MyISAM 表,默认的 8M 就可以了。

    如果你有很多 MyISAM 表,你应该将它们转换成 InnoDB。;-)

    innodb_buffer_pool_size=2000M

    由于您升级到 64G,这似乎很低。另一方面,您只有大约 2G 的 InnoDB 数据和索引,这对于一个简单的 Wordpress 站点来说并不罕见。将缓冲池增加得更高没有任何好处。

    innodb_buffer_pool_instances=2

    从 MySQL 5.6.6 开始,BP 实例的默认数量为 8。由于您有 24 个核心,您可能希望将 BP 至少拆分为 8 个实例。

    join_buffer_size=4M

    16x 默认的 256K 似乎太高了。理想情况下,您不需要依赖连接缓冲区,因为连接应该由索引处理。

    在 MySQL 5.6 中,join buffer 也用于 Batched Key Access 优化,但这并不经常出现。

    sort_buffer_size=4M

    也是默认值 256K 的 16 倍。当您对大型表进行文件排序时,对于避免排序合并传递很有用。监控SHOW GLOBAL STATUS LIKE 'Sort_merge_passes',但我敢打赌你可以减少它。

    read_rnd_buffer_size=4M

    也是默认值 256K 的 16 倍。用于 MyISAM 表,或用于任何存储引擎的多范围读取优化。很少需要这个。

    tmp_table_size=3048M max_heap_table_size=3048M

    这些恐怕都过分了。我从小开始,如果我看到SHOW GLOBAL STATUS LIKE 'Created_tmp_disk_table'.

    thread_cache_size=256

    可能根本不需要在您的系统上有线程缓存。默认值为 33。在现代版本的 Linux 上,无论如何创建一个新线程都很快,因此对线程缓存的需求并不像在 Solaris、FreeBSD 等上那么重要。

    max_connections=250 表缓存=60000

    请注意,table_cache 是 table_open_cache 的过时同义词。my.cnf 文件中的最后一个优先。因此,您已将 table_open_cache 设置为 60000,覆盖了之前的设置。我建议决定你想要的值并使用一行来设置它,以避免混淆。

    • 1

相关问题

  • 是否有任何 MySQL 基准测试工具?[关闭]

  • 我在哪里可以找到mysql慢日志?

  • 如何优化大型数据库的 mysqldump?

  • 什么时候是使用 MariaDB 而不是 MySQL 的合适时机,为什么?

  • 组如何跟踪数据库架构更改?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目

    • 12 个回答
  • Marko Smith

    如何让sqlplus的输出出现在一行中?

    • 3 个回答
  • Marko Smith

    选择具有最大日期或最晚日期的日期

    • 3 个回答
  • Marko Smith

    如何列出 PostgreSQL 中的所有模式?

    • 4 个回答
  • Marko Smith

    列出指定表的所有列

    • 5 个回答
  • Marko Smith

    如何在不修改我自己的 tnsnames.ora 的情况下使用 sqlplus 连接到位于另一台主机上的 Oracle 数据库

    • 4 个回答
  • Marko Smith

    你如何mysqldump特定的表?

    • 4 个回答
  • Marko Smith

    使用 psql 列出数据库权限

    • 10 个回答
  • Marko Smith

    如何从 PostgreSQL 中的选择查询中将值插入表中?

    • 4 个回答
  • Marko Smith

    如何使用 psql 列出所有数据库和表?

    • 7 个回答
  • Martin Hope
    Jin 连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目 2014-12-02 02:54:58 +0800 CST
  • Martin Hope
    Stéphane 如何列出 PostgreSQL 中的所有模式? 2013-04-16 11:19:16 +0800 CST
  • Martin Hope
    Mike Walsh 为什么事务日志不断增长或空间不足? 2012-12-05 18:11:22 +0800 CST
  • Martin Hope
    Stephane Rolland 列出指定表的所有列 2012-08-14 04:44:44 +0800 CST
  • Martin Hope
    haxney MySQL 能否合理地对数十亿行执行查询? 2012-07-03 11:36:13 +0800 CST
  • Martin Hope
    qazwsx 如何监控大型 .sql 文件的导入进度? 2012-05-03 08:54:41 +0800 CST
  • Martin Hope
    markdorison 你如何mysqldump特定的表? 2011-12-17 12:39:37 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 对 SQL 查询进行计时? 2011-06-04 02:22:54 +0800 CST
  • Martin Hope
    Jonas 如何从 PostgreSQL 中的选择查询中将值插入表中? 2011-05-28 00:33:05 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 列出所有数据库和表? 2011-02-18 00:45:49 +0800 CST

热门标签

sql-server mysql postgresql sql-server-2014 sql-server-2016 oracle sql-server-2008 database-design query-performance sql-server-2017

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve