广州做网站如何,如何制作一个网页,微信企业推广,泰安新闻视频在线阿里云服务器 MySQL 经常自动停止、挂掉、重启。打开 MySQL 的 error.log 错误信息#xff0c;在阿里云 CentOS 的路径为 /alidata/log/mysql/error.log,如下#xff1a;2016-03-13 00:16:37 0[Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use--e…阿里云服务器 MySQL 经常自动停止、挂掉、重启。打开 MySQL 的 error.log 错误信息在阿里云 CentOS 的路径为 /alidata/log/mysql/error.log,如下2016-03-13 00:16:37 0[Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use--explicit_defaults_for_timestampserver option(see documentationformore details).
2016-03-13 00:16:37 30576[Note] PluginFEDERATEDis disabled.
2016-03-13 00:16:37 30576[Note] InnoDB: Using atomics to ref count buffer pool pages
2016-03-13 00:16:37 30576[Note] InnoDB: The InnoDB memory heap is disabled
2016-03-13 00:16:37 30576[Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-03-13 00:16:37 30576[Note] InnoDB: Memory barrier is not used
2016-03-13 00:16:37 30576[Note] InnoDB: Compressed tables use zlib 1.2.3
2016-03-13 00:16:37 30576[Note] InnoDB: Using Linux native AIO
2016-03-13 00:16:37 30576[Note] InnoDB: Using CPU crc32 instructions
2016-03-13 00:16:37 30576[Note] InnoDB: Initializing buffer pool, size64.0M
2016-03-13 00:16:37 30576[Note] InnoDB: Completed initialization of buffer pool
2016-03-13 00:16:37 30576[Note] InnoDB: Highest supported file format is Barracuda.
2016-03-13 00:16:37 30576[Note] InnoDB: The log sequence numbers 52296883 and 52296883inibdata filesdonot match the log sequence number 93636989inthe ib_logfiles!
2016-03-13 00:16:37 30576[Note] InnoDB: Database was not shutdown normally!
2016-03-13 00:16:37 30576[Note] InnoDB: Starting crash recovery.
2016-03-13 00:16:37 30576[Note] InnoDB: Reading tablespace information from the .ibd files...
2016-03-13 00:16:37 30576[Note] InnoDB: Restoring possible half-written data pages
2016-03-13 00:16:37 30576[Note] InnoDB: from the doublewrite buffer...InnoDB: Last MySQL binlog file position 0 9828, file name mysql-bin.000335
2016-03-13 00:16:37 30576[Note] InnoDB: 128 rollback segment(s)are active.
2016-03-13 00:16:37 30576[Note] InnoDB: Waitingforpurge to start
2016-03-13 00:16:37 30576[Note] InnoDB: 5.6.21 started;log sequence number 93636989
2016-03-13 00:16:38 30576[Note] Recovering after a crash using mysql-bin
2016-03-13 00:16:38 30576[Note] Starting crash recovery...
2016-03-13 00:16:38 30576[Note] Crash recovery finished.
2016-03-13 00:16:40 30576[Note] Server hostname(bind-address):*;port: 3306
2016-03-13 00:16:40 30576[Note] IPv6 is not available.
2016-03-13 00:16:40 30576[Note] -0.0.0.0resolves to0.0.0.0;
2016-03-13 00:16:40 30576[Note] Server socket created on IP:0.0.0.0.
2016-03-13 00:16:41 30576[Note] Event Scheduler: Loaded 0 events
2016-03-13 00:16:41 30576[Note] /alidata/server/mysql/bin/mysqld: readyforconnections.Version:5.6.21-logsocket:/tmp/mysql.sockport: 3306 MySQL Community Server(GPL)160313 00:16:41 mysqld_safe Number of processes running now: 0160313 00:16:41 mysqld_safe mysqld restartedMySQL 的 error.log 中我们很难找出出是哪里出了问题。去 Google 了一下给出的答案基本是修改”/alidata/server/mysql/my.cnf”:innodb_buffer_pool_size64M# 默认为128M修改成64M、32M或者8M但实际上重启 MySQL 之后以为能运行实际上过了一会 MySQL 还是会出现不知原因地自动关闭。注意去看其中的2016-03-13 00:16:37 30576[Note] InnoDB: Database was not shutdown normally!说明了 MySQL 非正常关闭MySQL 也不知道自己为什么被关闭掉了。。。于是 MySQL 觉得真奇怪自己又重启了自己的进程开始 Crash Recoverying如下接着大家又猜想这条2016-03-13 00:16:37 30576[Note] InnoDB: The log sequence numbers 52296883 and 52296883inibdata filesdonot match the log sequence number 93636989inthe ib_logfiles!Google发现原来就是这里捣鬼才出现了 MySQL 再重启之后又继续自动关闭再重启。于是尝试按照 StackOverflow 上面的 suggestions 去做重启又可以了。。。没一会嚓MySQL 又宕了这次不仅宕而且 error.log 又多了因 * innodb_force_recovery 6 * 而引起的错误。怎么办现在我们回到下面这条日志2016-03-13 00:16:37 30576[Note] InnoDB: Database was not shutdown normally!现在我们要看看为什么 MySQL 会不正常关闭呢现在我们打开top看看。下面使用htop进行查看一看 mysql 进程占用的 VIRT 怎么这么多这时你要是多刷新几下你服务器上搭建的 WordPress 网站的主页的话会出现 mysql 内存占用率超过 50% 的情况这时候 mysql 进程就会被 linux 内核杀死。也就出现了我们在 MySQL 的 error.log 中看到的“[Note] InnoDB: Database was not shutdown normally!” 日志了。为了确定这个猜测是否真实我们去看看 kernel 日志。接着你会看到看到最后的两条好了终于找出原因了内存不够杀死了 mysqld 进程。下面是我的优化方案1.创建 SWAP 分区检查系统Swap文件信息sudo swapon -s
free -m检查硬盘可用空间df -h创建Swap文件sudo /bin/dd if/dev/zero of/var/swap.1 bs1M count1024激活Swapsudo /sbin/mkswap /var/swap.1
sudo /sbin/swapon /var/swap.1使Swap在主机重启后依然生效sudo nano /etc/fstab加入以下内容/var/swap.1 swap swap defaults 0 0
All done!2.降低数据库 InnoDB 引擎的缓冲区大小以及限制 MySQL 的最大连接数(max_connections)降低 InnoDB 缓冲区大小为 64M 或者 32M到mysql配置文件中修改innodb_buffer_pool_size64M限制最大连接数为100在服务器配置很低时可以继续降低max_connections100修改完重启 MySQLservice mysqld restart注释max_connections 的默认值是 151可以动态更改这个值。参见max_connections如有必要可以重启服务器: reboot