在Mongod版本3.6.5的bindIp配置选项中使用多个IP地址时,无法运行MongoDB服务器

在Mongod版本3.6.5的bindIp配置选项中使用多个IP地址时,无法运行MongoDB服务器,mongodb,Mongodb,我试图在bindIp配置选项中使用多个IP地址,保存配置更改后,mongodb服务器将不会启动。MongoDB版本3.4中也有同样的功能 以下是配置设置: # network interfaces net: port: 36784 bindIp: 127.0.0.1,10.0.0.226 这里10.0.0.226是EC2实例的私有IP地址 同样类型的配置在早期版本的MongoDB中工作,更具体地说是在v3.4中 如果我使用bindIp到0.0.0.0,那么当然它允许远程连接到所

我试图在bindIp配置选项中使用多个IP地址,保存配置更改后,mongodb服务器将不会启动。MongoDB版本3.4中也有同样的功能

以下是配置设置:

    # network interfaces
net:
  port: 36784
  bindIp: 127.0.0.1,10.0.0.226
这里10.0.0.226是EC2实例的私有IP地址

同样类型的配置在早期版本的MongoDB中工作,更具体地说是在v3.4中

如果我使用bindIp到0.0.0.0,那么当然它允许远程连接到所有IP地址

重新启动服务器后,出现以下错误:

    mongod.service - High-performance, schema-free document-oriented database
   Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Mon 2018-06-25 05:36:45 UTC; 15s ago
     Docs: https://docs.mongodb.org/manual
  Process: 1570 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=48)
 Main PID: 1570 (code=exited, status=48)

Jun 25 05:36:45 ip-10-0-1-69 systemd[1]: Stopped High-performance, schema-free document-oriented database.
Jun 25 05:36:45 ip-10-0-1-69 systemd[1]: Started High-performance, schema-free document-oriented database.
Jun 25 05:36:45 ip-10-0-1-69 systemd[1]: mongod.service: Main process exited, code=exited, status=48/n/a
Jun 25 05:36:45 ip-10-0-1-69 systemd[1]: mongod.service: Unit entered failed state.
Jun 25 05:36:45 ip-10-0-1-69 systemd[1]: mongod.service: Failed with result 'exit-code'.
以下是日志文件内容:

    2018-06-25T05:07:38.842+0000 I CONTROL  [initandlisten] now exiting
2018-06-25T05:07:38.842+0000 I CONTROL  [initandlisten] shutting down with code:48
2018-06-25T05:13:43.192+0000 I CONTROL  [main] ***** SERVER RESTARTED *****
2018-06-25T05:13:43.201+0000 I CONTROL  [initandlisten] MongoDB starting : pid=1390 port=36784 dbpath=/var/lib/mongodb 64-bit host=ip-10-0-1-69
2018-06-25T05:13:43.201+0000 I CONTROL  [initandlisten] db version v3.6.5
2018-06-25T05:13:43.201+0000 I CONTROL  [initandlisten] git version: a20ecd3e3a174162052ff99913bc2ca9a839d618
2018-06-25T05:13:43.201+0000 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.2g  1 Mar 2016
2018-06-25T05:13:43.201+0000 I CONTROL  [initandlisten] allocator: tcmalloc
2018-06-25T05:13:43.201+0000 I CONTROL  [initandlisten] modules: none
2018-06-25T05:13:43.201+0000 I CONTROL  [initandlisten] build environment:
2018-06-25T05:13:43.201+0000 I CONTROL  [initandlisten]     distmod: ubuntu1604
2018-06-25T05:13:43.201+0000 I CONTROL  [initandlisten]     distarch: x86_64
2018-06-25T05:13:43.201+0000 I CONTROL  [initandlisten]     target_arch: x86_64
2018-06-25T05:13:43.201+0000 I CONTROL  [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1,10.0.0.226", port: 36784 }, processManagement: { timeZoneInfo: "/usr/share/zoneinfo" }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2018-06-25T05:13:43.201+0000 E STORAGE  [initandlisten] Failed to set up listener: SocketException: Cannot assign requested address
2018-06-25T05:13:43.201+0000 I CONTROL  [initandlisten] now exiting
2018-06-25T05:13:43.201+0000 I CONTROL  [initandlisten] shutting down with code:48
我查阅了官方文件,没有发现任何弃用通知

可能是什么问题


当我正确理解日志中的这一行时,谢谢你

2018-06-25T05:13:43.201+0000 I CONTROL  [initandlisten] MongoDB starting : pid=1390 port=36784 dbpath=/var/lib/mongodb 64-bit host=ip-10-0-1-69

主机的ip是
10.0.1.69
,而不是
10.0.0.226
。这可以解释错误。

请不要使用图像嵌入输出和日志。直接粘贴文本,缩进4个空格。并且只粘贴相关部分。是的,图像已替换为文本内容。我在bindIp配置选项中使用远程ip地址时出错。这就是它抛出错误的原因。是的,这是公共子网中EC2实例的私有IP地址。因此,api服务器将位于需要与私有子网中的MongoDB服务器交互的公共服务器中。因此,我不希望在bindIp配置选项中使用0.0.0.0,而是希望使用localhost和api服务器EC2实例的IP地址来允许MongoDB服务器使用。我不确定我是否理解正确。那你能不能不用它?