我在AWS上运行一个开发服务器,工作完美无缺。 最近,周期性的mysql服务器开始不工作。 然后我input
service mysqld restart
这会产生一个错误信息
MySQL Daemon failed to start.
现在,如果我停止实例,然后启动它,然后从命令行重新启动服务器,一切工作正常(这迫使我重新编辑我的区域文件由于更改的IP地址,但我已经读了重启将不会摆脱IP地址)。 但是有没有线索,为什么这不起作用?
这里是几行var / log / mysqld.log,我无法做正面或反面。
130613 23:12:21 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 130613 23:12:21 [Note] Plugin 'FEDERATED' is disabled. 130613 23:12:21 InnoDB: The InnoDB memory heap is disabled 130613 23:12:21 InnoDB: Mutexes and rw_locks use GCC atomic builtins 130613 23:12:21 InnoDB: Compressed tables use zlib 1.2.5 130613 23:12:21 InnoDB: Using Linux native AIO 130613 23:12:21 InnoDB: Initializing buffer pool, size = 128.0M 130613 23:12:21 InnoDB: Completed initialization of buffer pool InnoDB: The first specified data file ./ibdata1 did not exist: InnoDB: a new database to be created! 130613 23:12:21 InnoDB: Setting file ./ibdata1 size to 10 MB InnoDB: Database physically writes the file full: wait... 130613 23:12:22 InnoDB: Log file ./ib_logfile0 did not exist: new to be created InnoDB: Setting log file ./ib_logfile0 size to 5 MB InnoDB: Database physically writes the file full: wait... 130613 23:12:23 InnoDB: Log file ./ib_logfile1 did not exist: new to be created InnoDB: Setting log file ./ib_logfile1 size to 5 MB InnoDB: Database physically writes the file full: wait... InnoDB: Doublewrite buffer not found: creating new InnoDB: Doublewrite buffer created InnoDB: 127 rollback segment(s) active. InnoDB: Creating foreign key constraint system tables InnoDB: Foreign key constraint system tables created 130613 23:12:24 InnoDB: Waiting for the background threads to start 130613 23:12:25 InnoDB: 5.5.31 started; log sequence number 0 130613 23:12:25 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306 130613 23:12:25 [Note] - '0.0.0.0' resolves to '0.0.0.0'; 130613 23:12:25 [Note] Server socket created on IP: '0.0.0.0'. 130613 23:12:25 [Note] Event Scheduler: Loaded 0 events 130613 23:12:25 [Note] /usr/libexec/mysqld: ready for connections. Version: '5.5.31' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server (GPL) 130614 6:08:52 [Note] /usr/libexec/mysqld: Normal shutdown 130614 6:08:53 [Note] Event Scheduler: Purging the queue. 0 events
我在stackexchange的其他post上读到,有时这可能是由于磁盘大小的限制。 df – h说
Filesystem Size Used Avail Use% Mounted on /dev/xvda1 7.9G 1.7G 6.2G 22% / tmpfs 298M 0 298M 0% /dev/shm
任何人有任何想法我应该寻找什么?
首先,你必须备份你的数据库:
cp -r /var/lib/mysql /tmp/mysql_backup
然后,从/var/lib/mysql
删除该文件。
rm -rf ibdata1
现在重新启动mysql服务器。
/etc/init.d/mysqld start
如果你使用的是微型或小型实例,mysql数据库运行的网站可能会给虚拟机内存带来相当大的负载,最终会导致你的mysql服务器崩溃。
考虑使用RDS ,可能会更昂贵,或者至less可以省钱,运行良好。
对于IP,您必须分配实例弹性 IP,该实例将保留在您的实例中,直到您摆脱它为止,只要您使用IP,就不必为IP付费。
如果你正在使用只有1GB内存的t2.micro实例,那么mysql实例会被终止。 如果你做ps -ef | grep apache,你可以看到运行的apache实例的数量。 大量的apache实例会强制服务器在内存不足的情况下终止mysql。
安装监视器来监视Apache。 当负载上升时,Monit正常地重启Apache,并且一切都继续工作。