[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 里的内容。

回复

此内容将保密,不会被其他人看见。
  • 允许的 HTML 标签: <a> <b> <address> <blockquote> <br> <caption> <center> <code> <dd> <del> <div> <dl> <dt> <em> <font> <h2> <h3> <h4> <h5> <h6> <hr> <i> <img> <li> <ol> <p> <pre> <span> <strong> <sub> <sup> <table> <tbody> <td> <tfoot> <th> <thead> <tr> <u> <ul> <tr>
  • 行和段被自动切分。
  • 网页地址和电子邮件地址将会被自动转换为链接。

更多格式化选项信息

随机验证
本功能用于防止垃圾信息