MongoDB启动时出现errno:111 Connection refused错误的解决

问题描述:

MongoDB启动时报下列错误

[root@MongoDB ~]# mongo
MongoDB shell version: 2.6.1
connecting to: test
2014-05-25T18:47:24.021+0800 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2014-05-25T18:47:24.022+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
exception: connect failed


解决方案:

1.查看保存数据库的目录是否存在

ls -ld /data/db

执行结果如下:

cuigaochongdeMacBook-Pro:~ root# ls -ld /data/db

drwxr-xr-x  7 root  wheel  238 Sep 24 16:21 /data/db


2.启动MongoDB的同时指定数据库保存在什么地方

mongod --dbpath /data/db

执行结果如下:

cuigaochongdeMacBook-Pro:~ root# mongod --dbpath /data/db

2016-09-24T16:37:28.410+0800 I JOURNAL  [initandlisten] journal dir=/data/db/journal

2016-09-24T16:37:28.410+0800 I JOURNAL  [initandlisten] recover : no journal files present, no recovery needed

2016-09-24T16:37:28.422+0800 I JOURNAL  [durability] Durability thread started

2016-09-24T16:37:28.422+0800 I CONTROL  [initandlisten] MongoDB starting : pid=624 port=27017 dbpath=/data/db 64-bit host=cuigaochongdeMacBook-Pro.local

2016-09-24T16:37:28.422+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.

2016-09-24T16:37:28.422+0800 I JOURNAL  [journal writer] Journal writer thread started

2016-09-24T16:37:28.422+0800 I CONTROL  [initandlisten] 

2016-09-24T16:37:28.422+0800 I CONTROL  [initandlisten] 

2016-09-24T16:37:28.422+0800 I CONTROL  [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000

2016-09-24T16:37:28.422+0800 I CONTROL  [initandlisten] db version v3.0.7

2016-09-24T16:37:28.422+0800 I CONTROL  [initandlisten] git version: nogitversion

2016-09-24T16:37:28.422+0800 I CONTROL  [initandlisten] build info: Darwin yosemitevm.local 14.5.0 Darwin Kernel Version 14.5.0: Wed Jul 29 02:26:53 PDT 2015; root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49

2016-09-24T16:37:28.422+0800 I CONTROL  [initandlisten] allocator: system

2016-09-24T16:37:28.422+0800 I CONTROL  [initandlisten] options: { storage: { dbPath: "/data/db" } }

2016-09-24T16:37:28.431+0800 I NETWORK  [initandlisten] waiting for connections on port 27017

3.再次执行mongo

cuigaochongdeMacBook-Pro:~ cuigaochong$ mongo

MongoDB shell version: 3.0.7

connecting to: test

Server has startup warnings: 

2016-09-24T16:31:54.576+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.

2016-09-24T16:31:54.576+0800 I CONTROL  [initandlisten] 

2016-09-24T16:31:54.576+0800 I CONTROL  [initandlisten] 

2016-09-24T16:31:54.576+0800 I CONTROL  [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000


成功


本文出自 “云人生” 博客,请务必保留此出处http://ovcer.blog.51cto.com/1145188/1416906

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值