在mongodb mon Virtualbox上使用bind_ip问题

我一直在努力与mongo绑定IP一段时间,我认为这是大声呼救的时候。 我正在使用hostonlynetworking192.168.56.0/24 。 我有4盒。 mongo的3个盒子192.168.56.111,192.168.56.112,192.168.56.113 。 和一个框为应用程序192.168.56.114

所以对于mongo绑定参数是: bind_ip =127.0.0.1,192.168.56.114,192.168.56.113,192.168.56.112,192.168.56.111,10.0.2.1

 2015-08-22T12:35:44.547+0000 E NETWORK [initandlisten] listen(): bind() failed errno:99 Cannot assign requested address for socket: 192.168.56.114:27017 2015-08-22T12:35:44.553+0000 I JOURNAL [initandlisten] journal dir=/var/lib/mongodb/journal 2015-08-22T12:35:44.554+0000 I JOURNAL [initandlisten] recover : no journal files present, no recovery needed 2015-08-22T12:35:44.623+0000 I JOURNAL [durability] Durability thread started 2015-08-22T12:35:44.624+0000 I JOURNAL [journal writer] Journal writer thread started 2015-08-22T12:35:44.624+0000 I CONTROL [initandlisten] MongoDB starting : pid=3519 port=27017 dbpath=/var/lib/mongodb 64-bit host=vagrant-ubuntu-trusty-64 2015-08-22T12:35:44.625+0000 I CONTROL [initandlisten] db version v3.0.5 2015-08-22T12:35:44.625+0000 I CONTROL [initandlisten] git version: 8bc4ae20708dbb493cb09338d9e7be6698e4a3a3 2015-08-22T12:35:44.625+0000 I CONTROL [initandlisten] build info: Linux ip-10-183-35-50 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49 2015-08-22T12:35:44.625+0000 I CONTROL [initandlisten] allocator: tcmalloc 2015-08-22T12:35:44.626+0000 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1,192.168.56.114,192.168.56.113,192.168.56.112,192.168.56.111,10.0.2.15", port: 27017 }, storage: { dbPath: "/var/lib/mongodb" }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } } 2015-08-22T12:35:44.631+0000 I CONTROL [initandlisten] now exiting 2015-08-22T12:35:44.631+0000 I NETWORK [initandlisten] shutdown: going to close listening sockets... 2015-08-22T12:35:44.632+0000 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock 2015-08-22T12:35:44.632+0000 I NETWORK [initandlisten] shutdown: going to flush diaglog... 2015-08-22T12:35:44.632+0000 I NETWORK [initandlisten] shutdown: going to close sockets... 2015-08-22T12:35:44.632+0000 I STORAGE [initandlisten] shutdown: waiting for fs preallocator... 2015-08-22T12:35:44.632+0000 I STORAGE [initandlisten] shutdown: final commit... 2015-08-22T12:35:44.635+0000 I JOURNAL [initandlisten] journalCleanup... 2015-08-22T12:35:44.635+0000 I JOURNAL [initandlisten] removeJournalFiles 2015-08-22T12:35:44.636+0000 I JOURNAL [initandlisten] Terminating durability thread ... 2015-08-22T12:35:44.735+0000 I JOURNAL [journal writer] Journal writer thread stopped 2015-08-22T12:35:44.736+0000 I JOURNAL [durability] Durability thread stopped 2015-08-22T12:35:44.736+0000 I STORAGE [initandlisten] shutdown: closing all files... 2015-08-22T12:35:44.736+0000 I STORAGE [initandlisten] closeAllFiles() finished 2015-08-22T12:35:44.737+0000 I STORAGE [initandlisten] shutdown: removing fs lock... 2015-08-22T12:35:44.737+0000 I CONTROL [initandlisten] dbexit: rc: 48 

我真的不知道任何其他IP有什么问题。 除了环回,自己的IP和0.0.0.0/0每隔一个IP无法启动mongodb。

bind_ip指令用于指定MongoDB侦听连接的同一系统上的IP地址,而不是指定从其接收连接的IP地址。

设置这个选项来configurationmongod进程或者mongos进程来绑定和监听这个地址上的应用程序的连接。 您可以将mongod或mongos实例附加到任何接口; 但是,如果将进程附加到可公开访问的接口,请执行适当的身份validation或防火墙限制,以保护数据库的完整性。

所以它应该不存在(推荐),或者包含127.0.0.1只接受本地连接,或者本地networking接口的IP地址。

如果你想限制什么IP地址可以连接到MongoDB,你需要使用防火墙。