nciaer 发表于 2019-3-7 15:36:18

innodb_buffer_pool_size参数设置

innodb_buffer_pool_size参数,顾名思义,应该是负责innodb缓存池大小的吧。

自从买了这个900块3年的腾讯云之后(配置1核1G1M带宽),mysql(mariadb)经常挂,重启又好了。今天看了日志,内容如下:
190307 02:47:50 mysqld_safe Number of processes running now: 0
190307 02:47:50 mysqld_safe mysqld restarted
1903072:47:52 /usr/libexec/mysqld (mysqld 5.5.60-MariaDB) starting as process 25683 ...
1903072:47:52 InnoDB: The InnoDB memory heap is disabled
1903072:47:52 InnoDB: Mutexes and rw_locks use GCC atomic builtins
1903072:47:52 InnoDB: Compressed tables use zlib 1.2.7
1903072:47:52 InnoDB: Using Linux native AIO
1903072:47:52 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137756672 bytes) failed; errno 12
1903072:47:52 InnoDB: Completed initialization of buffer pool
1903072:47:52 InnoDB: Fatal error: cannot allocate memory for the buffer pool
1903072:47:52 Plugin 'InnoDB' init function returned error.
1903072:47:52 Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
1903072:47:52 Plugin 'FEEDBACK' is disabled.
1903072:47:52 Unknown/unsupported storage engine: InnoDB
1903072:47:52 Aborting

1903072:47:52 /usr/libexec/mysqld: Shutdown complete

190307 02:47:52 mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended


看不太懂,不过里面有个致命错误提示的是无法给缓存分配内存,是不是这里的问题呢?

百度吧,然后就是innodb_buffer_pool_size这个参数来控制内存的大小。通过show global variables like 'innodb_buffer_pool_size'来查看其值,是128M,是不是有点大啊,看了看系统内存就几十M,估计有可能是这里的问题,改成50M试试吧。
在my.cnf里设置如下:
innodb_buffer_pool_size = 50M
好像不设置默认就是128M。

重启就生效了。

my.cnf里有很多分组,我是写在了分组下,因为我mysql的版本是5.5。

刚搞完,具体是不是这个参数引起的mysql挂,观察几天看看吧。


页: [1]
查看完整版本: innodb_buffer_pool_size参数设置