首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >无法连接到服务器127.0.0.1:27017

无法连接到服务器127.0.0.1:27017
EN

Stack Overflow用户
提问于 2012-10-11 11:51:43
回答 36查看 489K关注 0票数 177

我得到以下错误:

代码语言:javascript
复制
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:/$ 

以下是我尝试启动mongodb时发生的情况:

代码语言:javascript
复制
* Starting database mongodb                                             [fail]

我已经试过mongo --repair

我将chown和chmod设置为var、lib、data/db和log mongodb。

不知道还能做什么。有什么建议吗?

mongodb.log:

代码语言:javascript
复制
***** 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

编辑:

我删除了锁,然后进行了mongod修复,得到了这个错误:

代码语言:javascript
复制
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

所以我用sudo做了:

代码语言:javascript
复制
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

但是仍然有同样的问题。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12831939

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档