mysql 无法启动 ,查看日志:
17-10-01T15:37:27.401599Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2017-10-01T15:37:27.403209Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.19) starting as process 5504 ... 2017-10-01T15:37:27.406004Z 0 [Note] InnoDB: PUNCH HOLE support available 2017-10-01T15:37:27.406028Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2017-10-01T15:37:27.406032Z 0 [Note] InnoDB: Uses event mutexes 2017-10-01T15:37:27.406035Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier 2017-10-01T15:37:27.406038Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3 2017-10-01T15:37:27.406041Z 0 [Note] InnoDB: Using Linux native AIO 2017-10-01T15:37:27.406290Z 0 [Note] InnoDB: Number of pools: 1 2017-10-01T15:37:27.406379Z 0 [Note] InnoDB: Using CPU crc32 instructions 2017-10-01T15:37:27.407775Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M 2017-10-01T15:37:27.407813Z 0 [ERROR] InnoDB: mmap(137428992 bytes) failed; errno 12 2017-10-01T15:37:27.407819Z 0 [ERROR] InnoDB: Cannot allocate memory for the buffer pool 2017-10-01T15:37:27.407824Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error 2017-10-01T15:37:27.407829Z 0 [ERROR] Plugin 'InnoDB' init function returned error. 2017-10-01T15:37:27.407832Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 2017-10-01T15:37:27.407834Z 0 [ERROR] Failed to initialize plugins. 2017-10-01T15:37:27.407836Z 0 [ERROR] Aborting 2017-10-01T15:37:27.407852Z 0 [Note] Binlog end 2017-10-01T15:37:27.407890Z 0 [Note] Shutting down plugin 'CSV' 2017-10-01T15:37:27.408059Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
定位到最后几行,果然有一个FATAL ERROR:Cannot allocate memory for the buffer pool,看来应该是mariadb没有配置好,php程序访问量稍微大一些,分配给mariadb的内存就满了,然后就锁死了,mysql –u root –p竟然也打不开,看来确实是mariadb daemon挂掉了…
Innodb 存储引擎的缓存机制和 MyISAM 的最大区别就在于 Innodb 不仅仅缓存索引,同时还会缓存实际的数据。所以,完全相同的数据库,使用 Innodb 存储引擎可以使用更多的内存来缓存数据库相关的信息,当然前提是要有足够的物理内存。innodb_buffer_pool_size 参数用来设置 Innodb 最主要的 Buffer(Innodb_Buffer_Pool)的大小,也 就是缓存用户表及索引数据的最主要缓存空间,对 Innodb 整体性能影响也最大。这个参数设置成内存的50%-80%,当然具体要结合实际情况而定,考虑别的存储引擎占用的内存,考虑服务器是不是还提供其他服务等等…看来,我的机器之所以宕掉的原因是,系统默认的内存:
default innodb_buffer_pool_size
innodb_buffer_pool_size=50M
再次启动
sudo systemctl start mysqld
恢复正常
关闭suse:
查看SELinux状态:
1、/usr/sbin/sestatus -v ##如果SELinux status参数为enabled即为开启状态
SELinux status: enabled
2、getenforce ##也可以用这个命令检查
关闭SELinux:
1、临时关闭(不用重启机器):
setenforce 0 ##设置SELinux 成为permissive模式
##setenforce 1 设置SELinux 成为enforcing模式
2、修改配置文件需要重启机器:
修改/etc/selinux/config 文件
将SELINUX=enforcing改为SELINUX=disabled
重启机器即可
参考:https://blog.feehi.com/linux/132.html
mysql安装:
https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-centos-7