快乐描述一下
最近多手升级了一下mysql,结果出现了一下错误,要不是出错了都不会有这篇文章
解决过程
2024-05-12 15:02:43+08:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.44-1.el7 started.
2024-05-12 15:02:43+08:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2024-05-12 15:02:43+08:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.44-1.el7 started.
'/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
2024-05-12T07:02:44.639921Z 0 [Note] mysqld (mysqld 5.7.44) starting as process 1 ...
2024-05-12T07:02:44.809605Z 0 [Note] InnoDB: PUNCH HOLE support available
2024-05-12T07:02:44.809708Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2024-05-12T07:02:44.809721Z 0 [Note] InnoDB: Uses event mutexes
2024-05-12T07:02:44.809725Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2024-05-12T07:02:44.809728Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.13
2024-05-12T07:02:44.809731Z 0 [Note] InnoDB: Using Linux native AIO
2024-05-12T07:02:44.810330Z 0 [Note] InnoDB: Number of pools: 1
2024-05-12T07:02:44.810588Z 0 [Note] InnoDB: Using CPU crc32 instructions
2024-05-12T07:02:44.813686Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2024-05-12T07:02:44.814594Z 0 [ERROR] InnoDB: mmap(137428992 bytes) failed; errno 12
2024-05-12T07:02:44.814618Z 0 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2024-05-12T07:02:44.814629Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2024-05-12T07:02:44.814638Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2024-05-12T07:02:44.814643Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2024-05-12T07:02:44.814648Z 0 [ERROR] Failed to initialize builtin plugins.
2024-05-12T07:02:44.814651Z 0 [ERROR] Aborting
2024-05-12T07:02:44.814667Z 0 [Note] Binlog end
2024-05-12T07:02:44.815119Z 0 [Note] Shutting down plugin 'CSV'
2024-05-12T07:02:44.816517Z 0 [Note] mysqld: Shutdown complete
2024-05-12 15:06:12+08:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.44-1.el7 started.
2024-05-12 15:06:12+08:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2024-05-12 15:06:12+08:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.44-1.el7 started.
'/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
2024-05-12T07:06:13.479933Z 0 [Note] mysqld (mysqld 5.7.44) starting as process 1 ...
2024-05-12T07:06:13.514431Z 0 [Note] InnoDB: PUNCH HOLE support available
2024-05-12T07:06:13.514483Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2024-05-12T07:06:13.514488Z 0 [Note] InnoDB: Uses event mutexes
2024-05-12T07:06:13.514494Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2024-05-12T07:06:13.514497Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.13
2024-05-12T07:06:13.514500Z 0 [Note] InnoDB: Using Linux native AIO
2024-05-12T07:06:13.514924Z 0 [Note] InnoDB: Number of pools: 1
2024-05-12T07:06:13.515214Z 0 [Note] InnoDB: Using CPU crc32 instructions
2024-05-12T07:06:13.528685Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2024-05-12T07:06:13.528788Z 0 [ERROR] InnoDB: mmap(137428992 bytes) failed; errno 12
2024-05-12T07:06:13.528801Z 0 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2024-05-12T07:06:13.528808Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2024-05-12T07:06:13.528822Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2024-05-12T07:06:13.528827Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2024-05-12T07:06:13.531984Z 0 [ERROR] Failed to initialize builtin plugins.
2024-05-12T07:06:13.532007Z 0 [ERROR] Aborting
2024-05-12T07:06:13.532026Z 0 [Note] Binlog end
2024-05-12T07:06:13.535622Z 0 [Note] Shutting down plugin 'CSV'
2024-05-12T07:06:13.537283Z 0 [Note] mysqld: Shutdown complete
根据这些错误信息在网上,大多都是要你修改my.cnf配置文件,我都不知道修改了多少遍了!!!!如修改innodb_buffer_pool_size的大小之类的,但是都没有作用。后面复制整段错误信息查找,找到了正确的解决方法。free指令查看内存:

如果没有设置swap的话,则会显示
[root@VM_0_7_centos /]# free
total used free shared buff/cache available
Mem: 1016516 722544 70124 108428 223848 37380
Swap: 0 0 0
服务器没有配置Swap分区,关于Swap分区可以参见百度百科 (Swap分区) ,知道了当前问题的源头就给机器配置一个Swap分区大小1G,关于设置Swap分区大小可以参考 linux SWAP大小与内存的关系
[root@RainYun-rXQaeJGL ~]# sudo dd if=/dev/zero of=/swapfile bs=1M count=1024
记录了1024+0 的读入
记录了1024+0 的写出
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 1.72224 s, 623 MB/s
[root@RainYun-rXQaeJGL ~]# sudo mkswap /swapfile
mkswap: /swapfile:不安全的权限 0644,建议使用 0600。
正在设置交换空间版本 1,大小 = 1024 MiB (1073737728 个字节)
无标签,UUID=cdf83bfb-810d-4f54-ba58-553096424346
[root@RainYun-rXQaeJGL ~]# sudo swapon /swapfile
swapon: /swapfile:不安全的权限 0644,建议使用 0600。
解决方法
详细报错如下
InnoDB: mmap(137363456 bytes) failed; errno 12
2019-03-13 09:06:25 79498 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2019-03-13 09:06:25 79498 [ERROR] Plugin 'InnoDB' init function returned error.
2019-03-13 09:06:25 79498 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2019-03-13 09:06:25 79498 [ERROR] Unknown/unsupported storage engine: InnoDB
2019-03-13 09:06:25 79498 [ERROR] Aborting
解决方法如下:
查看内存
$ free
total used free shared buffers cached
Mem: 608476 565044 43432 0 1284 53996
-/+ buffers/cache: 509764 98712
Swap: 0 0 0
明显的swap问题。适当增加swap
$ sudo dd if=/dev/zero of=/swapfile bs=1M count=1024 #增加1G的SWAP进去
$ sudo mkswap /swapfile
$ sudo swapon /swapfile
$ free
total used free shared buffers cached
Mem: 608476 601432 7044 0 824 88752
-/+ buffers/cache: 511856 96620
Swap: 1048572 0 1048572
然后启动完美解决
## 感谢一下信息来源
https://blog.csdn.net/phpBin/article/details/95166610
感谢这篇文章:https://www.cnblogs.com/olinux/p/5144205.html
及原创文章:https://www.cnblogs.com/olinux/p/5144205.html
评论区(暂无评论)