Can't start server: can't create PID file: No space left on device错误详解

发布时间:2015-05-22编辑:脚本学堂
小编来介绍一下在使用mysql时遇到的Can't start server: can't create PID file: No space left on device的错误,下面小编举几个案例说明这个问题。
先看这句英文的意思 No space left on device 没有足够的磁盘空间。 清理/var/log的空间即可。

解决方案1:

小编自己的服务器上所有的网站都出现问题,有的打开没有数据,有的直接是空白。

小编第一反应就是数据库挂了。打开远程,进了系统,service mysqld stop 失败。service mysqld start等了好大一会,提示Timeout error occurred trying to start MySQL Daemon

一开始以为是mysql用户问题,查询系统用户完全没有问题。

打开log日志一看,问题出现了Can't start server: can't create PID file: No space left on device;

df -h看了一下磁盘,1000G的硬盘已经使用了百分之百,可用为0;

小编删光了var/log文件夹。没想到的是log日志已经积累达到85G。

删除后启动mysql一切正常。

 

解决方案2:

小编最近在维护linux服务器时发现,网站打不开了,经过检查发现是mysql数据库宕掉了,死活就是启动不起来。

然后看mysql日志文件

Can't start server: can't create PID file: No space left on device

 

出现Can't start server: can't create PID file: No space left on device

这个错误。

提示磁盘空间不足

后用df -h 命令查看

Can't start server: can't create PID file: No space left on device

竟然发现磁盘容量全部用完了,于是要查看是谁占用了
用命令:
find /tmp -size +100000000c
查找下磁盘中大于100M的文件
竟然出现:

Can't start server: can't create PID file: No space left on device

tomcat的日志文件占用了478G.

删掉此日志文件
rm -rf catalina.out
重新启动mysql即可。
最好重启linux os。

解决方案3:

mysql启动失败,日志显示如下:

 

120321 14:23:54 InnoDB: 1.1.8 started; log sequence number 1595695
120321 14:23:54 [ERROR] /usr/libexec/mysqld: Error writing file ‘/var/run/mysqld/mysqld.pid' (Errcode: 28)
120321 14:23:54 [ERROR] Can't start server: can't create PID file: No space left on device
120321 14:23:54 mysqld_safe Number of processes running now: 0
120321 14:23:54 mysqld_safe mysqld restarted
120321 14:23:54 [Note] Plugin ‘FEDERATED' is disabled.
120321 14:23:54 InnoDB: The InnoDB memory heap is disabled
120321 14:23:54 InnoDB: Mutexes and rw_locks use InnoDB's own implementation
120321 14:23:54 InnoDB: Compressed tables use zlib 1.2.3
120321 14:23:54 InnoDB: Using Linux native AIO
120321 14:23:54 InnoDB: Initializing buffer pool, size = 128.0M
120321 14:23:54 InnoDB: Completed initialization of buffer pool
120321 14:23:54 InnoDB: highest supported file format is Barracuda.
120321 14:23:55  InnoDB: Waiting for the background threads to start