【问题标题】:Error :couldn't connect to server 127.0.0.1:27017 MongoDB错误:无法连接到服务器 127.0.0.1:27017 MongoDB
【发布时间】:2016-09-03 04:09:09
【问题描述】:

服务器启动mongodb时出现问题

user@-VirtualBox:~$ mongo MongoDB 外壳版本:2.4.9 连接到:测试 Sun May 8 22:10:13.641 错误:无法连接到 服务器 127.0.0.1:27017 在 src/mongo/shell/mongo.js:145 异常: 连接失败

这个问题是怎么解决的?

【问题讨论】:

  • 你启动了mongodb服务了吗?如果没有,请使用 service mongod start 启动它
  • user@-VirtualBox:~$ sudo start mongod mongod start/running, process 9129 user@-VirtualBox:~$ sudo status mongod mongod stop/waiting 不明白为什么关闭了??
  • 执行 sudo ps -ef | grep mongod 并杀死那里列出的所有进程,然后重新开始
  • 这就是我的用户@-VirtualBox:~$ sudo ps -ef | grep mongod user 9160 8986 0 22:24 pts/1 00:00:00 grep --color=auto mongod after another server start the same result of last command
  • 这里是 mongodb.con 文件的内容 # mongod.conf # 所有选项的文档,请参阅: # Where and how to store data。 storage: dbPath: /var/lib/mongodb journal: enabled: true #engine: # mmapv1: #wiredTiger: # 写入日志数据的位置。 systemLog: 目的地: 文件 logAppend: true path: /var/log/mongodb/mongod.log # network interfaces net: port: 27017 bindIp: 127.0.0.1

标签: mongodb ubuntu-14.04


【解决方案1】:

您的端口似乎已被使用,请尝试更改 27017 以外的端口号。 然后首先使用“mongod”命令开始,该命令在运行“mongo”之后继续在后台运行。 这个在我的 Mac 上为我工作

找到“usr/local/etc”目录 在“etc”文件夹中找到“mongod.conf” 在文件中我必须将 bindIp 配置项设置为 0.0.0.0,我将端口更改为 27020

# network interfaces
net:
  port: 27020
  bindIp: 0.0.0.0

运行以下:

mongod --config /usr/local/etc/mongod.conf

然后通过在终端中打开新标签运行以下操作:

> mongo --port 27020

希望这对你有用。

【讨论】:

    【解决方案2】:

    我遇到了同样的问题。查看位于 /var/log/mongodb/mongodb.log 的 MongoDB 日志文件,解释了原因 - 在我的情况下是:

    ERROR: Insufficient free space for journal files
    Please make at least 3379MB available in /var/lib/mongodb/journal or use --smallfiles
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-21
      • 2012-10-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多