关于安装在阿里云上的wordpress MySQL进程总是被kill掉

查询mariadb.log,mariadb崩掉时的日志如下

170217 23:19:26 mysqld_safe Number of processes running now: 0
170217 23:19:26 mysqld_safe mysqld restarted
170217 23:19:37 [Note] /usr/libexec/mysqld (mysqld 5.5.52-MariaDB) starting as process xxx ...
170217 23:19:40 InnoDB: The InnoDB memory heap is disabled
170217 23:19:40 InnoDB: Mutexes and rw_locks use GCC atomic builtins
170217 23:19:40 InnoDB: Compressed tables use zlib 1.2.7
170217 23:19:40 InnoDB: Using Linux native AIO
170217 23:19:40 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(xxx bytes) failed; errno 12
170217 23:19:40 InnoDB: Completed initialization of buffer pool
170217 23:19:40 InnoDB: Fatal error: cannot allocate memory for the buffer pool
170217 23:19:40 [ERROR] Plugin 'InnoDB' init function returned error.
170217 23:19:40 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
170217 23:19:41 [Note] Plugin 'FEEDBACK' is disabled.
170217 23:19:41 [ERROR] Unknown/unsupported storage engine: InnoDB
170217 23:19:41 [ERROR] Aborting

几经Google之后,找到两个解决方法:加内存和调低Innodb_buffer_pool_size

没钱加物理内存,就加swap吧:

1.创建要作为swap分区的文件:增加1GB大小的交换分区,则命令写法如下,其中的count等于想要的块的数量(bs*count=文件大小)。

dd if=/dev/zero of=/root/swapfile bs=1M count=1024

2.格式化为交换分区文件:

mkswap /root/swapfile #建立swap的文件系统

3.启用交换分区文件:

swapon /root/swapfile #启用swap文件

4.使系统开机时自启用,在文件/etc/fstab中添加一行:

/root/swapfile swap swap defaults 0 0

参考:

LINUX新建和增加SWAP分区:http://smilejay.com/2012/09/new-or-add-swap/

一些关于swap的指令:swapon、swapoff、free

调低Innodb_buffer_pool_size:

innodb_buffer_pool_size参数用来设置Innodb最主要的Buffer(Innodb_Buffer_Pool)的大小,也就是缓存用户表及索引数据的最主要缓存空间,对Innodb整体性能影响也最大。官方手册建议在整个系统 物理内存的50%~80%之间。

在cent os 7系统下,在/usr/share/mysql目录下可以查看到mariadb给出的一些my-xxx.cnf实例文件,按照自己的内存选择对应的文件,我选的是my-huge.cnf,在[mysqld]下查询到如下内容

# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 384M

将innodb_buffer_pool_size = 384M粘贴至/etc/my.cnf.d/server.cnf文件的对应位置即可,记得去掉#

参考:

MySQL Crash with Fatal error: cannot allocate memory for the buffer pool:http://www.webtrafficexchange.com/solved-mysql-crash-fatal-error-cannot-allocate-memory-buffer-pool

其他参考:

Mysql日志报The InnoDB memory heap is disabled解决办法:http://blog.sina.com.cn/s/blog_a55699a601019t5d.html

简单粗暴解决,过程仅供参考。

chromebook修改host文件

参考:

Chromebook修改hosts简易教程:http://jieyujing.blogspot.com/2013/05/chromebookhosts.html

【吧主教程】chromebook hosts 替换教程 ~:http://tieba.baidu.com/p/4196419557?see_lz=1

host文件下载:https://laod.cn/hosts