[MySQL FAQ]系列 -- 64位系统下也报内存分配不能超过2G?

明明是64位系统下,有16G内存,启动mysqld时指定 innodb_buffer_pool_size 为12G,却报一下错误:

080829 14:15:14  mysqld started
InnoDB: HugeTLB: Warning: Failed to allocate 12884918272 bytes. errno 22
InnoDB HugeTLB: Warning: Using conventional memory pool
080829 14:15:14  InnoDB: Error: cannot allocate 12884918272 bytes of
InnoDB: memory with malloc! Total allocated memory
InnoDB: by InnoDB 44607312 bytes. Operating system errno: 12
InnoDB: Check if you should increase the swap file or
InnoDB: ulimits of your operating system.
InnoDB: On FreeBSD check you have compiled the OS with
InnoDB: a big enough maximum process size.
InnoDB: Note that in most 32-bit computers the process
InnoDB: memory space is limited to 2 GB or 4 GB.
InnoDB: We keep retrying the allocation for 60 seconds...
InnoDB: Fatal error: cannot allocate the memory for the buffer pool
Warning: Failed to allocate 29360128 bytes from HugeTLB memory. errno 12
Warning: Using conventional memory pool
080829 14:16:14 [Note] /usr/local/mysql/bin/mysqld: ready for connections.
Version: '5.0.45-log'  socket: '/home/mysql/mysql.sock'  port: 3306  MySQL Community Server (GPL)

是不是很奇怪呢?
根据错误提示的内容,google一下,发现是内核限制的缘故:

[root@yejr mysql]# cat /proc/sys/vm/nr_hugepages
6000

修改一下内核限制:

[root@yejr mysql]# echo 0 > /proc/sys/vm/nr_hugepages

然后重启mysql,一切正常了。
另外,还需要关注一下配置文件 /etc/security/limits.conf 里的内容。

技术相关:

评论

老大,在开启Large Page Support时,他会报这个错误,这样该怎么解决呢?

贴具体日志