为什么在Linux上错误mongod死了但子系统却被锁定,可用空间不足以存放日志文件?


68

我已经安装了mongo-10gen mongo-10gen-server在Linux CentOS服务器上 server。

我遵循链接中的步骤

我已经将/etc/mongod.conf配置为-

logpath=/var/log/mongo/mongod.log
port=27017
dbpath=/var/lib/mongo

我在iptables中为mongo设置了端口27017 。要启动mongo,我使用了命令-

service mongod start and
mongo

一切顺利,但是几天后我收到了错误消息-

Tue Jan 29 08:41:54 [initandlisten] ERROR: Insufficient free space for journal files
Tue Jan 29 08:41:54 [initandlisten] Please make at least 3379MB available in /var/lib/mongo/journal or use --smallfiles
Tue Jan 29 08:41:54 [initandlisten]
Tue Jan 29 08:41:54 [initandlisten] exception in initAndListen: 15926 Insufficient free space for journals, terminating
Tue Jan 29 08:41:54 dbexit:
Tue Jan 29 08:41:54 [initandlisten] shutdown: going to close listening sockets...
Tue Jan 29 08:41:54 [initandlisten] shutdown: going to flush diaglog...
Tue Jan 29 08:41:54 [initandlisten] shutdown: going to close sockets...
Tue Jan 29 08:41:54 [initandlisten] shutdown: waiting for fs preallocator...
Tue Jan 29 08:41:54 [initandlisten] shutdown: lock for final commit...
Tue Jan 29 08:41:54 [initandlisten] shutdown: final commit...
Tue Jan 29 08:41:54 [initandlisten] shutdown: closing all files...
Tue Jan 29 08:41:54 [initandlisten] closeAllFiles() finished
Tue Jan 29 08:41:54 [initandlisten] journalCleanup...
Tue Jan 29 08:41:54 [initandlisten] removeJournalFiles
Tue Jan 29 08:41:54 [initandlisten] shutdown: removing fs lock...
Tue Jan 29 08:41:54 dbexit: really exiting now

当我执行命令时-

service mongod status

它给出了错误-

mongod dead but subsys locked

请帮助我解决mongod死但子系统已锁定以及期刊可用空间不足的问题,从而终止


9
它告诉您,您没有足够的可用磁盘空间来创建/var/lib/mongo/journal需要的3.3GB文件,因此无法启动。
JohnnyHK 2013年

我有足够的空间,但仍然遇到问题。我在下面发布了对我有用的内容。
user3270763

Answers:


88

您可以将以下内容添加到运行时提供的配置文件中 mongod --config mongod.conf

对于MongoDB 3.x(最新版本)

storage:
   mmapv1:
      smallFiles: true

对于2.6+版本

storage:
   smallFiles: true

对于2.4及以下版本

smallfiles = true

然后只需执行mongod接受您的配置文件(此处假定配置位置为/etc/mongodb.conf):

mongod -f /etc/mongodb.conf

文档smallfiles参数:

Set to true to modify MongoDB to use a smaller default data file size. 
Specifically, smallfiles reduces the initial size for data files and
limits them to 512 megabytes. The smallfiles setting also reduces the
size of each journal files from 1 gigabyte to 128 megabytes.

@Andrei Karpushonak配置文件在哪里?进行设置samllfiles = true
Labanino

根据您的操作系统,在Linux上是/etc/mongodb.conf
Andrei Karpushonak 2014年

解析INI配置文件时出错:“存储:”中无法识别的行请尝试使用“ mongod --help”了解更多信息
Thoman 2015年

2
我正在运行3.0.2版本,并且上面的配置引发了错误,我必须做smallfiles=true才能使其正常工作。
Rakesh Sankar

确定没有足够的可用磁盘空间来创建=> 3.3GB <=的/ var / lib / mongo / journal文件
雷米Becheras


11

我在http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/上遵循官方指南。

使用后

$sudo service mongod start

我通过查看以下日志来验证MongoDB是否已成功启动:

/var/log/mongodb/mongod.log

这是我发现的问题:

2014-11-11T12:54:05.808-0500 [initandlisten] ERROR: Insufficient free space for journal files
2014-11-11T12:54:05.808-0500 [initandlisten] Please make at least 3379MB available in /var/lib/mongodb/journal or use --smallfiles
2014-11-11T12:54:05.808-0500 [initandlisten]
2014-11-11T12:54:05.808-0500 [initandlisten] exception in initAndListen: 15926 Insufficient free space for journals, terminating
2014-11-11T12:54:05.808-0500 [initandlisten] dbexit:
2014-11-11T12:54:05.808-0500 [initandlisten] shutdown: going to close listening sockets...
2014-11-11T12:54:05.808-0500 [initandlisten] shutdown: going to flush diaglog...
2014-11-11T12:54:05.808-0500 [initandlisten] shutdown: going to close sockets...
2014-11-11T12:54:05.808-0500 [initandlisten] shutdown: waiting for fs preallocator...
2014-11-11T12:54:05.808-0500 [initandlisten] shutdown: lock for final commit...
2014-11-11T12:54:05.808-0500 [initandlisten] shutdown: final commit...
2014-11-11T12:54:05.808-0500 [initandlisten] shutdown: closing all files...
2014-11-11T12:54:05.808-0500 [initandlisten] closeAllFiles() finished
2014-11-11T12:54:05.808-0500 [initandlisten] journalCleanup...
2014-11-11T12:54:05.808-0500 [initandlisten] removeJournalFiles
2014-11-11T12:54:05.814-0500 [initandlisten] shutdown: removing fs lock...
2014-11-11T12:54:05.814-0500 [initandlisten] dbexit: really exiting now

解:

在文件/etc/mongod.conf的末尾,我添加了以下行:

smallfiles = true

之后,我重新启动了mongod服务:

$sudo service mongod restart

然后,当我去查看日志时,我意识到一切都很好,并且问题已解决:

2014-11-11T22:32:20.544-0500 ***** SERVER RESTARTED *****
2014-11-11T22:32:20.552-0500 [initandlisten] MongoDB starting : pid=5200 port=27017 dbpath=/var/lib/mongodb 64-bit host=jaimemontoya-VirtualBox
2014-11-11T22:32:20.552-0500 [initandlisten] db version v2.6.5
2014-11-11T22:32:20.552-0500 [initandlisten] git version: e99d4fcb4279c0279796f237aa92fe3b64560bf6
2014-11-11T22:32:20.552-0500 [initandlisten] build info: Linux build8.nj1.10gen.cc 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
2014-11-11T22:32:20.552-0500 [initandlisten] allocator: tcmalloc
2014-11-11T22:32:20.552-0500 [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1" }, storage: { dbPath: "/var/lib/mongodb", smallFiles: true }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2014-11-11T22:32:20.564-0500 [initandlisten] journal dir=/var/lib/mongodb/journal
2014-11-11T22:32:20.564-0500 [initandlisten] recover : no journal files present, no recovery needed
2014-11-11T22:32:20.738-0500 [initandlisten] waiting for connections on port 27017
2014-11-11T22:33:20.748-0500 [clientcursormon] mem (MB) res:36 virt:245
2014-11-11T22:33:20.748-0500 [clientcursormon]  mapped (incl journal view):64
2014-11-11T22:33:20.748-0500 [clientcursormon]  connections:0

1
确定没有足够的可用磁盘空间来创建的=> 3.3GB <=所需的/ var / lib中/蒙戈/日志文件
雷米Becheras

在我的系统上,要编辑的文件/etc/mongodb.conf不是/etc/mongod.conf
jtlindsey '18

1

对于尽管有足够的空间来创建日记文件但仍然存在此问题的任何人。

我的问题:我有足够的空间来创建日记文件。Mongo给了我一个连接失败的问题。我使用kill命令杀死mongod进程,这反过来又给了我subsys问题。这是对我有用的东西:

转到/var/lock/subsys并删除文件mongod

现在service mongod stop,然后service mongod start

现在启动mongo shell,一切似乎运行良好。


0

第一

cd /usr/local/src/mongo/bin/<br>

然后

./mongod --dbpath /usr/local/src/mongo/data/db/ --smallfiles

3
这可能会解决问题,但是如果您在回答中添加一些解释,那就更好了。这将增加您的答案的价值。
阿米特(Amit)2015年

0

只是一张纸条,对我有帮助。尽管没有与mongo相关的技术问题。只是系统空间不足。清除系统的缓存对我很有效,而mongo又恢复了正常运行。

yum clean all

0

问题背景:我将数据库服务器从t2.micro升级到了更大的实例,而没有停止数据库服务。作为回报,该文件创建了此锁定文件并抛出此错误, mongod已死,但子系统已锁定 此后,我无法使用mongo shell。

如果您有足够的磁盘空间。然后按照以下步骤操作,

1. sudo mongod (如果您发现以下失败原因)

Failed to unlink socket file /tmp/mongodb-27017.sock Operation not permitted)
  1. 转到/ tmp /目录

  2. 删除mongodb-27017.sock文件

  3. 使用sudo服务重启mongod

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.