largepages没有与mariadb合作

时间:2015-04-05 13:25:00

标签: mysql centos6 galera huge-pages

我们尝试为使用galera集群运行的mariabdb设置hugepage。我们已经分配了足够高的大页面来容纳innodb缓冲区。

server.conf中

[mysqld]
large-pages
innodb_buffer_pool_size =4G

/etc/sysctl.conf中

# hugepages information
vm.nr_hugepages = 3072

# Controls the maximum shared segment size, in bytes
kernel.shmmax = 68719476736

# Controls the maximum number of shared memory segments, in pages
kernel.shmall = 4294967296

/etc/security/limits.conf文件

@mysql      soft    memlock     unlimited
@mysql      hard    memlock     unlimited

free -m

             total       used       free     shared    buffers     cached
Mem:         11908      11635        272          0         68       5502
-/+ buffers/cache:       6064       5843
Swap:         2559          0       2559

mysqld.log中的错误

150403  4:46:12 [Note] InnoDB: Initializing buffer pool, size = 4.0G
InnoDB: HugeTLB: Warning: Failed to allocate 687865856 bytes. errno 1
InnoDB HugeTLB: Warning: Using conventional memory pool
InnoDB: HugeTLB: Warning: Failed to allocate 687865856 bytes. errno 1
InnoDB HugeTLB: Warning: Using conventional memory pool
InnoDB: HugeTLB: Warning: Failed to allocate 687865856 bytes. errno 1
InnoDB HugeTLB: Warning: Using conventional memory pool
InnoDB: HugeTLB: Warning: Failed to allocate 687865856 bytes. errno 1
InnoDB HugeTLB: Warning: Using conventional memory pool
InnoDB: HugeTLB: Warning: Failed to allocate 687865856 bytes. errno 1
InnoDB HugeTLB: Warning: Using conventional memory pool
InnoDB: HugeTLB: Warning: Failed to allocate 687865856 bytes. errno 1
InnoDB HugeTLB: Warning: Using conventional memory pool
InnoDB: HugeTLB: Warning: Failed to allocate 687865856 bytes. errno 1
InnoDB HugeTLB: Warning: Using conventional memory pool
InnoDB: HugeTLB: Warning: Failed to allocate 687865856 bytes. errno 1
InnoDB HugeTLB: Warning: Using conventional memory pool
150403  4:46:13 [Note] InnoDB: Completed initialization of buffer pool

cat / proc / meminfo | grep -i huge

AnonHugePages:         0 kB
HugePages_Total:       3072
HugePages_Free:        3072
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB

1 个答案:

答案 0 :(得分:0)

我的配置中缺少一个步骤:您需要设置可以访问HugeTLB内存的组号(mysql)。

检查当前指定的值:

$ sysctl vm.hugetlb_shm_group

这可能只返回0,所以" root"组。您应该创建一个hugetlb组并将mysql添加到该组或使用mysql所属的组之一。无论哪个组使用其GID(分别使用grep '^hugetlb:' /etc/group | cut -d: -f3id -g mysql)并执行:

# sysctl -w vm.hugetlb_shm_group=<gid>

(替换为您小组的GID)

测试它是否有效,它确实添加到/etc/sysctl.conf(或在/etc/sysctl.d/下的新文件中)以下行:

vm.hugetlb_shm_group = <gid>