前几天数据库挂了,ssh 登陆服务器后service mysqld restart 重启数据库后正常了就没当回事,今天又挂了,然后重启mysql启动不了了。vi /var/log/mysql.log 查看mysql日志发现下面的内容:
2018-01-17T08:51:26.840981Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2018-01-17T08:51:26.845840Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.20) starting as process 6990 ... 2018-01-17T08:51:26.852860Z 0 [Note] InnoDB: PUNCH HOLE support available 2018-01-17T08:51:26.852949Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2018-01-17T08:51:26.852963Z 0 [Note] InnoDB: Uses event mutexes 2018-01-17T08:51:26.852983Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier 2018-01-17T08:51:26.852997Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3 2018-01-17T08:51:26.853134Z 0 [Note] InnoDB: Using Linux native AIO 2018-01-17T08:51:26.854126Z 0 [Note] InnoDB: Number of pools: 1 2018-01-17T08:51:26.854481Z 0 [Note] InnoDB: Using CPU crc32 instructions 2018-01-17T08:51:26.858480Z 0 [Note] InnoDB: Initializing buffer pool, total size = 512M, instances = 1, chunk size = 128M 2018-01-17T08:51:26.932921Z 0 [Note] InnoDB: Completed initialization of buffer pool 2018-01-17T08:51:26.950994Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority(). 2018-01-17T08:51:26.964684Z 0 [Note] InnoDB: Highest supported file format is Barracuda. 2018-01-17T08:51:26.980214Z 0 [Note] InnoDB: Log scan progressed past the checkpoint lsn 637921504 2018-01-17T08:51:26.980289Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 637921513 2018-01-17T08:51:26.980305Z 0 [Note] InnoDB: Database was not shutdown normally! 2018-01-17T08:51:26.980319Z 0 [Note] InnoDB: Starting crash recovery. 2018-01-17T08:51:27.110752Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables 2018-01-17T08:51:27.110915Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ... 2018-01-17T08:51:27.136323Z 0 [Warning] InnoDB: 1048576 bytes should have been written. Only 929792 bytes written. Retrying for the remaining bytes. 2018-01-17T08:51:27.136391Z 0 [Warning] InnoDB: Retry attempts for writing partial data failed. 2018-01-17T08:51:27.136427Z 0 [ERROR] InnoDB: Write to file ./ibtmp1failed at offset 10485760, 1048576 bytes should have been written, only 929792 were written. Operating system error number 28. Check that your OS and file system support files of this size. Check also that the disk is not full or a disk quota exceeded. 2018-01-17T08:51:27.136479Z 0 [ERROR] InnoDB: Error number 28 means 'No space left on device' 2018-01-17T08:51:27.136495Z 0 [Note] InnoDB: Some operating system error numbers are described at http://dev.mysql.com/doc/refman/5.7/en/operating-system-error-codes.html 2018-01-17T08:51:27.136513Z 0 [ERROR] InnoDB: Could not set the file size of './ibtmp1'. Probably out of disk space 2018-01-17T08:51:27.136528Z 0 [ERROR] InnoDB: Unable to create the shared innodb_temporary 2018-01-17T08:51:27.136544Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error 2018-01-17T08:51:27.643027Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1" 2018-01-17T08:51:27.643089Z 0 [ERROR] Plugin 'InnoDB' init function returned error. 2018-01-17T08:51:27.643111Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 2018-01-17T08:51:27.643140Z 0 [ERROR] Failed to initialize plugins. 2018-01-17T08:51:27.643160Z 0 [ERROR] Aborting 2018-01-17T08:51:27.643246Z 0 [Note] Binlog end 2018-01-17T08:51:27.644628Z 0 [Note] Shutting down plugin 'CSV' 2018-01-17T08:51:27.646083Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
敲黑板,划重点:
[ERROR] InnoDB: Error number 28 means 'No space left on device'
于是,来一记df -h ,卧槽,硬盘容量差不多就是被用光了,15G只剩下10M了,什么东西占了这么多硬盘?——一般不是日志就是备份文件。然后把我的博客备份文件都删掉后再一记df -h :
文件系统 容量 已用 可用 已用% 挂载点 /dev/xvda1 15G 4.0G 10G 29% / devtmpfs 952M 0 952M 0% /dev tmpfs 974M 0 974M 0% /dev/shm tmpfs 974M 113M 861M 12% /run tmpfs 974M 0 974M 0% /sys/fs/cgroup tmpfs 195M 0 195M 0% /run/user/0
非常棒,这样就还有10G可用了。最后运行本文开头的那个命令(service mysqld restart ),重启mysql服务,问题暂时解决。