我收到以下错误:
alex@alex-K43U:/$ mongo
MongoDB shell version: 2.2.0
connecting to: test
Thu Oct 11 11:46:53 Error: couldn't connect to server 127.0.0.1:27017 src/mongo/shell/mongo.js:91
exception: connect failed
alex@alex-K43U:/$
Run Code Online (Sandbox Code Playgroud)
当我尝试启动mongodb时会发生这种情况:
* Starting database mongodb [fail]
Run Code Online (Sandbox Code Playgroud)
我已经试过了 mongo --repair
我将chown和chmod设为var,lib和data/db以及log mongodb.
不知道还能做什么.有什么建议?
mongodb.log:
***** SERVER RESTARTED *****
Thu Oct 11 08:29:40
Thu Oct 11 08:29:40 warning: 32-bit servers don't have journaling enabled by default. Please use --journal if you want durability.
Thu Oct 11 08:29:40
Thu Oct 11 08:29:41 [initandlisten] MongoDB starting : pid=1052 port=27017 dbpath=/var/lib/mongodb 32-bit host=alex-K43U
Thu Oct 11 08:29:41 [initandlisten]
Thu Oct 11 08:29:41 [initandlisten] ** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data
Thu Oct 11 08:29:41 [initandlisten] ** see http://blog.mongodb.org/post/137788967/32-bit-limitations
Thu Oct 11 08:29:41 [initandlisten] ** with --journal, the limit is lower
Thu Oct 11 08:29:41 [initandlisten]
Thu Oct 11 08:29:41 [initandlisten] db version v2.2.0, pdfile version 4.5
Thu Oct 11 08:29:41 [initandlisten] git version: f5e83eae9cfbec7fb7a071321928f00d1b0c5207
Thu Oct 11 08:29:41 [initandlisten] build info: Linux domU-12-31-39-01-70-B4 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:39:36 EST 2008 i686 BOOST_LIB_VERSION=1_49
Thu Oct 11 08:29:41 [initandlisten] options: { config: "/etc/mongodb.conf", dbpath: "/var/lib/mongodb", logappend: "true", logpath: "/var/log/mongodb/mongodb.log" }
Thu Oct 11 08:29:41 [initandlisten] Unable to check for journal files due to: boost::filesystem::basic_directory_iterator constructor: No such file or directory: "/var/lib/mongodb/journal"
**************
Unclean shutdown detected.
Please visit http://dochub.mongodb.org/core/repair for recovery instructions.
*************
Thu Oct 11 08:29:41 [initandlisten] exception in initAndListen: 12596 old lock file, terminating
Thu Oct 11 08:29:41 dbexit:
Thu Oct 11 08:29:41 [initandlisten] shutdown: going to close listening sockets...
Thu Oct 11 08:29:41 [initandlisten] shutdown: going to flush diaglog...
Thu Oct 11 08:29:41 [initandlisten] shutdown: going to close sockets...
Thu Oct 11 08:29:41 [initandlisten] shutdown: waiting for fs preallocator...
Thu Oct 11 08:29:41 [initandlisten] shutdown: closing all files...
Thu Oct 11 08:29:41 [initandlisten] closeAllFiles() finished
Thu Oct 11 08:29:41 dbexit: really exiting now
Run Code Online (Sandbox Code Playgroud)
编辑:
我删除了锁然后做了mongod修复并得到了这个错误:
Thu Oct 11 12:05:37 [initandlisten] exception in initAndListen: 10309 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
Run Code Online (Sandbox Code Playgroud)
所以我用sudo做到了:
alex@alex-K43U:~$ sudo mongod --repair
Thu Oct 11 12:05:42
Thu Oct 11 12:05:42 warning: 32-bit servers don't have journaling enabled by default. Please use --journal if you want durability.
Thu Oct 11 12:05:42
Thu Oct 11 12:05:42 [initandlisten] MongoDB starting : pid=5129 port=27017 dbpath=/data/db/ 32-bit host=alex-K43U
Thu Oct 11 12:05:42 [initandlisten]
Thu Oct 11 12:05:42 [initandlisten] ** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data
Thu Oct 11 12:05:42 [initandlisten] ** see http://blog.mongodb.org/post/137788967/32-bit-limitations
Thu Oct 11 12:05:42 [initandlisten] ** with --journal, the limit is lower
Thu Oct 11 12:05:42 [initandlisten]
Thu Oct 11 12:05:42 [initandlisten] db version v2.2.0, pdfile version 4.5
Thu Oct 11 12:05:42 [initandlisten] git version: f5e83eae9cfbec7fb7a071321928f00d1b0c5207
Thu Oct 11 12:05:42 [initandlisten] build info: Linux domU-12-31-39-01-70-B4 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:39:36 EST 2008 i686 BOOST_LIB_VERSION=1_49
Thu Oct 11 12:05:42 [initandlisten] options: { repair: true }
Thu Oct 11 12:05:42 [initandlisten] Unable to check for journal files due to: boost::filesystem::basic_directory_iterator constructor: No such file or directory: "/data/db/journal"
Thu Oct 11 12:05:42 [initandlisten] finished checking dbs
Thu Oct 11 12:05:42 dbexit:
Thu Oct 11 12:05:42 [initandlisten] shutdown: going to close listening sockets...
Thu Oct 11 12:05:42 [initandlisten] shutdown: going to flush diaglog...
Thu Oct 11 12:05:42 [initandlisten] shutdown: going to close sockets...
Thu Oct 11 12:05:42 [initandlisten] shutdown: waiting for fs preallocator...
Thu Oct 11 12:05:42 [initandlisten] shutdown: closing all files...
Thu Oct 11 12:05:42 [initandlisten] closeAllFiles() finished
Thu Oct 11 12:05:42 [initandlisten] shutdown: removing fs lock...
Thu Oct 11 12:05:42 dbexit: really exiting now
Run Code Online (Sandbox Code Playgroud)
但仍然有同样的问题.
Nan*_*mar 140
Step 1: Remove lock file.
sudo rm /var/lib/mongodb/mongod.lock
Step 2: Repair mongodb.
sudo mongod --repair
Step 3: start mongodb.
sudo start mongodb
or
sudo service mongodb start
Step 4: Check status of mongodb.
sudo status mongodb
or
sudo service mongodb status
Step 5: Start mongo console.
mongo
Run Code Online (Sandbox Code Playgroud)
elo*_*one 81
你跑mongod前跑了mongo吗?
我从http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/上按照mongodb的安装说明操作,我遇到了与你mongo在实际运行mongo进程之前运行时相同的错误.mongod.我认为安装mongodb也会启动它,但你需要mongod在你做任何需要mongodb的事情之前手动启动它.
Jav*_*mez 42
这是因为mongod进程失效,你必须运行下面的命令才能启动mongod进程:
sudo service mongodb stop
sudo rm /var/lib/mongodb/mongod.lock
sudo mongod --repair --dbpath /var/lib/mongodb
sudo mongod --fork --logpath /var/lib/mongodb/mongodb.log --dbpath /var/lib/mongodb
sudo service mongodb start
Run Code Online (Sandbox Code Playgroud)
希望这对你有所帮助.
Tro*_*ott 28
日志表明mongodb正在终止,因为有一个旧的锁文件.
如果您不是并且没有运行日记功能,请删除锁定文件,运行修复,然后再次启动mongodb.
如果您已启用或正在运行日记功能,请参阅相关的Mongo DB文档.请注意,他们说"如果您使用日记功能运行,则不应进行修复以恢复到一致状态." 因此,如果你是日记,修复可能会使事情变得更糟.
小智 9
苹果系统
如果你有 mac 并使用 mongodb4.4,你可以运行:
brew services start mongodb-community@4.4
Run Code Online (Sandbox Code Playgroud)
检查您的文件系统可用空间,如果较少则增加它.这也可能导致mongo无法启动.检查/var/log/mongodb/mongodb.log文件.
ERROR: Insufficient free space for journal files
Please make at least 3379MB available in /var/lib/mongodb/journal or use --smallfiles
Run Code Online (Sandbox Code Playgroud)
小智 6
所以首先你必须通过下面的命令删除mongod.lock文件
sudo rm /var/lib/mongodb/mongod.lock
Run Code Online (Sandbox Code Playgroud)
然后通过发出以下命令重新启动mongo服务
sudo service mongod restart
Run Code Online (Sandbox Code Playgroud)
小智 6
在 Windows 中cmd以管理员身份运行:
1.创建目录:
mkdir c:\mongo\data\db
Run Code Online (Sandbox Code Playgroud)
2.安装服务:
mongod.exe --install --logpath c:\mongo\logs --logappend --bind_ip 127.0.0.1 --dbpath c:\mongo\data\db --directoryperdb
Run Code Online (Sandbox Code Playgroud)
3.启动MongoDB:
net start MongoDB
Run Code Online (Sandbox Code Playgroud)
4.启动Mongo shell:
c:\mongo\bin\mongo.exe
Run Code Online (Sandbox Code Playgroud)
这个解决方案对我有用。
| 归档时间: |
|
| 查看次数: |
378722 次 |
| 最近记录: |