为什么在 Linux 上出现错误 mongod dead 但 subsys 被锁定并且日志文件的可用空间不足?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14584393/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why getting error mongod dead but subsys locked and Insufficient free space for journal files on Linux?
提问by Deepu
I have installed mongo-10gen mongo-10gen-serveron Linux CentOS server.
我已经在 Linux CentOS 服务器上安装了mongo-10gen mongo-10gen-server。
I followed the steps from Link.
我按照Link 中的步骤操作。
I have configured /etc/mongod.confas -
我已将/etc/mongod.conf配置为 -
logpath=/var/log/mongo/mongod.log
port=27017
dbpath=/var/lib/mongo
I have set port 27017 for mongo in iptables. To start mongo I used commands -
我已经在iptables 中为 mongo 设置了端口 27017 。要启动 mongo,我使用了命令 -
service mongod start and
mongo
It get started well, but after few days I am getting the error -
它开始很好,但几天后我收到错误 -
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
When I execute the command -
当我执行命令时 -
service mongod status
It gives Error -
它给出了错误 -
mongod dead but subsys locked
Please help me to solve the problem of mongod dead but subsys lockedand Insufficient free space for journals, terminating
请帮我解决mongod死但subsys被锁定和期刊可用空间不足的问题,终止
采纳答案by Andrei Karpushonak
You can add following to the config file provided when running mongod --config mongod.conf
您可以在运行时提供的配置文件中添加以下内容 mongod --config mongod.conf
For MongoDB 3.x(latest version)
对于 MongoDB 3.x(最新版本)
storage:
mmapv1:
smallFiles: true
For version 2.6+
对于2.6+版本
storage:
smallFiles: true
For version 2.4and less
对于2.4及以下版本
smallfiles = true
Then just execute mongod to accept your config file (here it assumes that location of the config is /etc/mongodb.conf):
然后只需执行 mongod 以接受您的配置文件(这里假设配置的位置是/etc/mongodb.conf):
mongod -f /etc/mongodb.conf
Documentationfor smallfilesparameter:
文档为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.
回答by Rajkumar Singh
Start mongod
instance using following command
mongod
使用以下命令启动实例
mongod --dbpath /data/db --smallfiles
回答by Jaime Montoya
I was following the official guide at http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/
我正在关注http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/ 上的官方指南
After using
使用后
$sudo service mongod start
I went to verify if MongoDB had started successfully by reviewing this log:
我通过查看此日志来验证 MongoDB 是否已成功启动:
/var/log/mongodb/mongod.log
This is the problem that I found:
这是我发现的问题:
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
Solution:
解决方案:
At the end of the file /etc/mongod.conf I added this line:
在文件 /etc/mongod.conf 的末尾我添加了这一行:
smallfiles = true
After that, I restarted the mongod service:
之后,我重新启动了 mongod 服务:
$sudo service mongod restart
Then when I went to review the log, I realized that everything was perfect, and the problem was fixed:
然后当我去查看日志时,发现一切都很完美,问题解决了:
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
回答by user3831127
first
第一的
cd /usr/local/src/mongo/bin/<br>
then
然后
./mongod --dbpath /usr/local/src/mongo/data/db/ --smallfiles
回答by user3270763
For anyone having this issue despite having enough space for the journal file to be created.
对于尽管有足够的空间来创建日志文件但遇到此问题的任何人。
My problem: I had more than enough space for the journal file to be created. Mongo gave me a connection failed issue. I used kill command to kill the mongod process which in turn gave me the subsys issue. Here is what worked for me:
我的问题:我有足够的空间来创建日志文件。Mongo 给了我一个连接失败的问题。我使用 kill 命令杀死了 mongod 进程,这反过来又给了我 subsys 问题。这是对我有用的:
Go to /var/lock/subsys
and delete file mongod
转到/var/lock/subsys
并删除文件mongod
now service mongod stop
and then service mongod start
现在service mongod stop
,然后service mongod start
Started mongo shell now and everything seems to be running fine.
现在启动 mongo shell,一切似乎都运行良好。
回答by Kunal Panchal
Just a note, which helped me. Though there were no technical issue related to mongo. It was just the system's space was insufficient. Clearing the system's cache worked out to me and mongo was back running smoothly.
只是一个笔记,这对我有帮助。虽然没有与 mongo 相关的技术问题。只是系统空间不够。清除系统的缓存对我来说很有效,mongo 又恢复了顺利运行。
yum clean all
回答by adeel
Problem Background: I upgraded DB server from t2.micro to the larger instance without stopping database services. which in return created this lock file and throwing this error, mongod dead but subsys lockedAfter this I was unable to use mongo shell.
问题背景:我在不停止数据库服务的情况下将数据库服务器从 t2.micro 升级到更大的实例。作为回报,它创建了这个锁定文件并抛出了这个错误, mongod 死了,但是 subsys 被锁定了在此之后我无法使用 mongo shell。
If you have enough disk space. Then follow these steps,
如果你有足够的磁盘空间。然后按照这些步骤,
1.sudo mongod(if you find below failed reason)
1. sudo mongod(如果你发现以下失败的原因)
Failed to unlink socket file /tmp/mongodb-27017.sock Operation not permitted)
Go to /tmp/directory
Remove mongodb-27017.sockfile
Restart mongod with sudo service mongod restart
进入/tmp/目录
删除mongodb-27017.sock文件
使用sudo service mongod restart 重新启动 mongod