【问题标题】:Unable to start mongo shell in ubuntu无法在 ubuntu 中启动 mongo shell
【发布时间】:2017-11-12 10:24:06
【问题描述】:

我是 Mongo 的新手。我已经在我的 ubuntu 桌面上安装了 mongo DB 并使用以下命令启动了 mongod 服务 -

sudo service mongod start
root@monti-ThinkPad-L440:/home/monti# sudo service mongod start
root@monti-ThinkPad-L440:/home/monti# sudo service mongod status
● mongod.service - High-performance, schema-free document-oriented database
   Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
   Active: active (running) since Sat 2017-06-10 19:19:04 IST; 19s ago
     Docs: https://docs.mongodb.org/manual
 Main PID: 4407 (mongod)
   CGroup: /system.slice/mongod.service
           └─4407 /usr/bin/mongod --quiet --config /etc/mongod.conf

Jun 10 19:19:04 monti-ThinkPad-L440 systemd[1]: Started High-performance, schema-free document-oriented database.

但是当我启动 mongo shell 时,我得到以下错误:

root@monti-ThinkPad-L440:/home/monti# mongo
MongoDB shell version: 3.2.13
connecting to: test
2017-06-10T19:20:44.363+0530 W NETWORK  [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: errno:111 Connection refused
2017-06-10T19:20:44.363+0530 E QUERY    [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:229:14
@(connect):1:6

exception: connect failed

非常感谢任何帮助!!!!谢谢!!!

【问题讨论】:

    标签: linux mongodb shell ubuntu


    【解决方案1】:

    这里有很多关于这个问题的好答案:
    Connection refused to MongoDB errno 111

    其中一个肯定会解决您的问题。
    通常由于 /etc/mongod.conf 中的一些错误配置或 /var/lib/mongodb/mongod.lock 中的锁定而发生

    希望这会有所帮助!

    【讨论】:

      【解决方案2】:

      您可能需要在 /etc/mongod.conf 上将您的 bind_ip 更改为 0.0.0.0 绑定 127.0.0.1 后无法访问自己的机器。

      127.0.0.1 只会绑定到环回接口(因此您只能在本地访问它),而 0.0.0.0 会将其绑定到所有可访问的网络接口。

      这就是为什么当您将 mongodb 绑定到 0.0.0.0 而不是通过 127.0.0.1 时可以访问它的原因。

      为本地服务器绑定到 0.0.0.0 可能会使它们在所有网络接口上可用。

      在你的防火墙中,你应该确保你只打开 27017 有权访问您的 MongoDB 服务器的人:如果您想 更严格,通过 IP 的授权范围更改 0.0.0.0。

      Example: 
      
      bindIp = [56.126.233.72, 172.29.19.240, 172.29.5.20/16]
      

      【讨论】:

        猜你喜欢
        • 2016-06-09
        • 2017-02-17
        • 2022-10-13
        • 1970-01-01
        • 2020-08-02
        • 2017-08-02
        • 2019-01-02
        • 2016-11-12
        • 1970-01-01
        相关资源
        最近更新 更多