我和mongo斗争了一段时间,我认为现在是呼救的时候了。我使用的是纯主机的网络192.168.56.0/24。我有四个盒子。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。
发布于 2015-08-24 22:21:50
这个bind_ip指令是指指定MongoDB侦听连接的同一系统上的IP地址,而不是它接收连接的IP地址。
将此选项设置为配置要绑定到该地址上的应用程序并侦听来自该地址的应用程序的mongod或mongos进程。您可以在任何接口上附加一个或多个mongos实例;但是,如果将该过程附加到一个可公开访问的接口,则可以实现适当的身份验证或防火墙限制,以保护数据库的完整性。
因此,它应该不存在(建议),或者包含127.0.0.1以只接受本地连接,或者本地网络接口的IP地址。
如果您想限制哪些IP地址可以连接到MongoDB,则需要使用防火墙。
https://serverfault.com/questions/716451
复制相似问题