当我向我的MongoDB配置文件添加IP地址时,它将无法启动。当我只使用1个IP地址(127.0.0.1)时,没有问题。有人知道我做错了吗?
我的配置文件:
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1,192.168.2.1
#processManagement:
#security:
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
这是我的日志文件
2016-06-16T12:57:32.007+0200 I CONTROL [signalProcessingThread] got signal 15 (Terminated), will terminate after current cmd ends
2016-06-16T12:57:32.007+0200 I FTDC [signalProcessingThread] Shutting down full-time diagnostic data capture
2016-06-16T12:57:32.009+0200 I CONTROL [signalProcessingThread] now exiting
2016-06-16T12:57:32.009+0200 I NETWORK [signalProcessingThread] shutdown: going to close listening sockets...
2016-06-16T12:57:32.009+0200 I NETWORK [signalProcessingThread] closing listening socket: 6
2016-06-16T12:57:32.009+0200 I NETWORK [signalProcessingThread] closing listening socket: 7
2016-06-16T12:57:32.009+0200 I NETWORK [signalProcessingThread] removing socket file: /tmp/mongodb-27017.sock
2016-06-16T12:57:32.010+0200 I NETWORK [signalProcessingThread] shutdown: going to flush diaglog...
2016-06-16T12:57:32.010+0200 I NETWORK [signalProcessingThread] shutdown: going to close sockets...
2016-06-16T12:57:32.010+0200 I STORAGE [signalProcessingThread] WiredTigerKVEngine shutting down
2016-06-16T12:57:32.072+0200 I STORAGE [signalProcessingThread] shutdown: removing fs lock...
2016-06-16T12:57:32.072+0200 I CONTROL [signalProcessingThread] dbexit: rc: 0
2016-06-16T12:57:32.106+0200 I CONTROL [main] ***** SERVER RESTARTED *****
2016-06-16T12:57:32.110+0200 I CONTROL [initandlisten] MongoDB starting : pid=1689 port=27017 dbpath=/var/lib/mongodb 64-bit host=***-***-***-***
2016-06-16T12:57:32.110+0200 I CONTROL [initandlisten] db version v3.2.7
2016-06-16T12:57:32.110+0200 I CONTROL [initandlisten] git version: 4249c1d2b5999ebbf1fdf3bc0e0e3b3ff5c0aaf2
2016-06-16T12:57:32.110+0200 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g-fips 1 Mar 2016
2016-06-16T12:57:32.110+0200 I CONTROL [initandlisten] allocator: tcmalloc
2016-06-16T12:57:32.110+0200 I CONTROL [initandlisten] modules: none
2016-06-16T12:57:32.110+0200 I CONTROL [initandlisten] build environment:
2016-06-16T12:57:32.110+0200 I CONTROL [initandlisten] distmod: ubuntu1404
2016-06-16T12:57:32.110+0200 I CONTROL [initandlisten] distarch: x86_64
2016-06-16T12:57:32.110+0200 I CONTROL [initandlisten] target_arch: x86_64
2016-06-16T12:57:32.110+0200 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1,192.168.2.1", port: 27017 }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log", quiet: true } }
2016-06-16T12:57:32.133+0200 E NETWORK [initandlisten] listen(): bind() failed errno:99 Cannot assign requested address for socket: 192.168.2.1:27017
2016-06-16T12:57:32.133+0200 E STORAGE [initandlisten] Failed to set up sockets during startup.
2016-06-16T12:57:32.133+0200 I CONTROL [initandlisten] dbexit: rc: 48
如果需要更多信息,请告诉我。
谢谢!
- 编辑 -
我尝试将127.0.0.1,192.168.2.1
更改为[127.0.0.1,192.168.2.1]
(添加括号)。现在服务器确实启动了,但它可以从任何地方访问......
答案 0 :(得分:0)
使用bindIp
设置mongo将侦听的IP,例如 PRIVATE 网络中的192.168.2.1:27017
。使用0.0.0.0
,您只是告诉它在您的专用网络中打开,您无法使用bindIp
过滤外部传入连接,您可以使用防火墙