你的位置:首页 > 数据库

[数据库]Insufficient free space for journal files


   前两天请假了,公司的很多app突然挂掉了,说是mongodb莫名的挂掉了,赶紧进去看了看日志:

2015-08-31T14:06:20.070+0800 [initandlisten] ERROR: Insufficient free space for journal files2015-08-31T14:06:20.070+0800 [initandlisten] Please make at least 3379MB available in /data/mongodb/data/journal or use --smallfiles2015-08-31T14:06:20.070+0800 [initandlisten] 2015-08-31T14:06:20.070+0800 [initandlisten] exception in initAndListen: 15926 Insufficient free space for journals, terminating2015-08-31T14:06:20.070+0800 [initandlisten] dbexit: 2015-08-31T14:06:20.071+0800 [initandlisten] shutdown: going to close listening sockets...2015-08-31T14:06:20.071+0800 [initandlisten] shutdown: going to flush diaglog...2015-08-31T14:06:20.071+0800 [initandlisten] shutdown: going to close sockets...2015-08-31T14:06:20.071+0800 [initandlisten] shutdown: waiting for fs preallocator...2015-08-31T14:06:20.071+0800 [initandlisten] shutdown: lock for final commit...2015-08-31T14:06:20.071+0800 [initandlisten] shutdown: final commit...2015-08-31T14:06:20.071+0800 [initandlisten] shutdown: closing all files...2015-08-31T14:06:20.071+0800 [initandlisten] closeAllFiles() finished2015-08-31T14:06:20.071+0800 [initandlisten] journalCleanup...2015-08-31T14:06:20.071+0800 [initandlisten] removeJournalFiles2015-08-31T14:06:20.075+0800 [initandlisten] shutdown: removing fs lock...2015-08-31T14:06:20.075+0800 [initandlisten] dbexit: really exiting now

查了查,原来是因为mongodb对硬盘的增长是以倍数增长的,每次增加2G,查了查服务器的硬盘空间,我去,剩下1.8G了

看到错误日志中解决的办法是使用 --smallfiles参数,然后我就试了试

./mongod --dbpath /data/mongodb/data --logpath /data/mongodb/mongodb.log --smallfiles

好是好了,可是一直在输出log,只要一终止,mongodb就又挂了,然后看了看mongodb的参数。找到了一个 --fork ,创建一个子进程参数。好的

./mongod --dbpath /data/mongodb/data --logpath /data/mongodb/mongodb.log --smallfiles --fork

搞定~~