首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >面向wordpress的MariaDB优化

面向wordpress的MariaDB优化
EN

Stack Overflow用户
提问于 2017-04-20 09:25:33
回答 1查看 5.5K关注 0票数 3

我有一个有两个CPU核心的服务器,1GB的RAM.The服务器只运行一个wordpress site.My服务器堆栈是LEMP.I。我在设置wordpress站点两周后运行了mysql调谐器。以下是结果

代码语言:javascript
复制
[!!] Maximum reached memory usage: 884.8M (89.15% of installed RAM)
[!!] Maximum possible memory usage: 1.4G (139.86% of installed RAM)
[!!] Overall possible memory usage with other process exceeded memory
[!!] Slow queries: 15% (629K/4M)
[OK] Highest usage of available connections: 9% (19/200)
[OK] Aborted connections: 0.75%  (4103/548857)
[!!] name resolution is active : a reverse name resolution is made for each new connection and can reduce performance

这是我的my.cnf配置

代码语言:javascript
复制
 [mysql]

# CLIENT #
port                           = 3306
socket                         = /var/lib/mysql/mysql.sock

[mysqld]

# GENERAL #
user                           = mysql
default-storage-engine         = InnoDB
socket                         = /var/lib/mysql/mysql.sock
pid-file                       = /var/lib/mysql/mysql.pid

# MyISAM #
key-buffer-size                = 32M
myisam-recover                 = FORCE,BACKUP

# SAFETY #
max-allowed-packet             = 16M
max-connect-errors             = 1000000

# DATA STORAGE #
datadir                        = /var/lib/mysql/

# BINARY LOGGING #
log-bin                        = /var/lib/mysql/mysql-bin
expire-logs-days               = 14
sync-binlog                    = 1

# CACHES AND LIMITS #
tmp-table-size                 = 32M
max-heap-table-size            = 32M
query-cache-type               = 0
query-cache-size               = 0
max-connections                = 200
thread-cache-size              = 20
open-files-limit               = 65535
table-definition-cache         = 1024
table-open-cache               = 2048

# INNODB #
innodb-flush-method            = O_DIRECT
innodb-log-files-in-group      = 2
innodb-log-file-size           = 64M
innodb-flush-log-at-trx-commit = 1
innodb-file-per-table          = 1
innodb-buffer-pool-size        = 624M

# LOGGING #
log-error                      = /var/lib/mysql/mysql-error.log
log-queries-not-using-indexes  = 1
slow-query-log                 = 1
slow-query-log-file            = /var/lib/mysql/mysql-slow.log

如何优化配置以解决这些问题?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-04-21 02:08:30

有一个非常糟糕的环境:

代码语言:javascript
复制
innodb-buffer-pool-size        = 624M

在一个很小的1GB服务器中,可能同时包含WP和MySQL?换到200米。注意交换。如果有任何交换,降低它更多。交换会导致大量的I/O,最好是缩小设置。以下是一个先行的开始:

代码语言:javascript
复制
tmp-table-size                 = 32M  -> 8M
max-heap-table-size            = 32M  -> 8M
query-cache-type               = 0    -- good
query-cache-size               = 0    -- good
max-connections                = 200  -> 50
thread-cache-size              = 20
open-files-limit               = 65535
table-definition-cache         = 1024 -> 200
table-open-cache               = 2048 -> 300

你打开了慢速原木?让我们看看最糟糕的查询,如mysqldumpslow -s tpt-query-digest所示。

这是另一个提示。这个重要的表目前有糟糕的索引;这些索引会有所帮助:

代码语言:javascript
复制
CREATE TABLE wp_postmeta (
    post_id …,
    meta_key …,
    meta_value …,
    PRIMARY KEY(post_id, meta_key),
    INDEX(meta_key)
) ENGINE=InnoDB;

在听吗?

原因如下:

  • AUTO_INCREMENT是浪费
  • 这是一个更好的PK
  • 必要时使用191 (5.6.3至5.7.6)
  • 用于集群PK的InnoDB

详细信息: postmeta

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

https://stackoverflow.com/questions/43515478

复制
相关文章

相似问题

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