mongoDB错误
发布日期:2021-07-20 20:53:12 浏览次数:12 分类:技术文章

本文共 3282 字,大约阅读时间需要 10 分钟。

mongdb启动的时候会报如上标题的错误,查询了很多资料终于找到解决办法,现把解决方法记录下来,以免以后忘记。

 

原链接:

 
  1. [root@localhost bin]# ./mongo

  2. 但是出现如下错误:

  3. [root@localhost bin]# ./mongo

  4. MongoDB shell version: 2.6.1

  5. connecting to: test

  6. 2014-05-30T19:58:07.179+0800 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused

  7. 2014-05-30T19:58:07.181+0800 Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146

  8. exception: connect failed

 

 

1、若数据库出现如上不能连接的原因,可能是data目录下的mongod.lock文件问题,可以用如下命令修复:

 

[root@localhost mongodb]# ./bin/mongod --repair

 

 

或者直接删除mongod.lock

 

rm -f /usr/local/mongodb/data/db/mongod.lock


然后再启动mongodb。

 

 

2、如果第一步解决不了,那么就是路径设置有问题,通过重新对路径的设置解决此问题

 

[root@localhost mongodb]# ./bin/mongod --dbpath=/usr/local/mongodb/data/db/

 

 

然后界面会出现:

 
  1. 2015-03-19T15:32:27.923+0800 [initandlisten] MongoDB starting : pid=2079 port=27017 dbpath=/root/mongodb/data/db/ 64-bit host=localhost.localdomain

  2. 2015-03-19T15:32:27.923+0800 [initandlisten] db version v2.6.7

  3. 2015-03-19T15:32:27.923+0800 [initandlisten] git version: a7d57ad27c382de82e9cb93bf983a80fd9ac9899

  4. 2015-03-19T15:32:27.923+0800 [initandlisten] build info: Linux build7.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

  5. 2015-03-19T15:32:27.923+0800 [initandlisten] allocator: tcmalloc

  6. 2015-03-19T15:32:27.923+0800 [initandlisten] options: { storage: { dbPath: "/root/mongodb/data/db/" } }

  7. 2015-03-19T15:32:27.935+0800 [initandlisten] journal dir=/root/mongodb/data/db/journal

  8. 2015-03-19T15:32:27.935+0800 [initandlisten] recover begin

  9. 2015-03-19T15:32:27.936+0800 [initandlisten] info no lsn file in journal/ directory

  10. 2015-03-19T15:32:27.936+0800 [initandlisten] recover lsn: 0

  11. 2015-03-19T15:32:27.936+0800 [initandlisten] recover /root/mongodb/data/db/journal/j._0

  12. 2015-03-19T15:32:27.938+0800 [initandlisten] recover cleaning up

  13. 2015-03-19T15:32:27.938+0800 [initandlisten] removeJournalFiles

  14. 2015-03-19T15:32:27.938+0800 [initandlisten] recover done

  15. 2015-03-19T15:32:27.990+0800 [initandlisten] waiting for connections on port 27017

  16. 2015-03-19T15:33:06.907+0800 [initandlisten] connection accepted from 127.0.0.1:56793 #1 (1 connection now open)

  17. 2015-03-19T15:33:27.991+0800 [clientcursormon] mem (MB) res:37 virt:456

  18. 2015-03-19T15:33:27.991+0800 [clientcursormon] mapped (incl journal view):160

  19. 2015-03-19T15:33:27.991+0800 [clientcursormon] connections:1

  20. 2015-03-19T15:38:28.011+0800 [clientcursormon] mem (MB) res:37 virt:456

  21. 2015-03-19T15:38:28.011+0800 [clientcursormon] mapped (incl journal view):160

  22. 2015-03-19T15:38:28.011+0800 [clientcursormon] connections:1

  23. 2015-03-19T15:43:28.032+0800 [clientcursormon] mem (MB) res:37 virt:456

  24. 2015-03-19T15:43:28.032+0800 [clientcursormon] mapped (incl journal view):160

  25. 2015-03-19T15:43:28.032+0800 [clientcursormon] connections:1

  26. 2015-03-19T15:44:42.655+0800 [conn1] end connection 127.0.0.1:56793

 

 

表示设置成功,此时不要关闭这个界面,需要重新打开一个窗口来启动mongo

 
  1. [root@localhost]# cd /usr/local/mongodb

  2. [root@localhost mongodb]# ./bin/mongo

  3. MongoDB shell version: 2.6.7

  4. connecting to: test

  5. Welcome to the MongoDB shell.

  6. For interactive help, type "help".

  7. For more comprehensive documentation, see

  8. http://docs.mongodb.org/

  9. Questions? Try the support group

  10. http://groups.google.com/group/mongodb-user

 

 

当出现这个时候表示启动成功

转载地址:https://blog.csdn.net/liao0801_123/article/details/82392435 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:web前端之闭包
下一篇:Centos6.5 安装 RabbitMQ3.6.1

发表评论

最新留言

哈哈,博客排版真的漂亮呢~
[***.13.112.135]2022年12月07日 05时11分21秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

最新文章