参考来源:
mongodb-conf-bind-ip-127-0-0-1-does-not-work-but-0-0-0-0-works
how-to-set-mongod-conf-bind-ip-with-multiple-ip-address
绑定ip如下配置:
net: port: 27017 bindIp: 127.0.0.1,115.159.159.129 # Listen to local interface only, comment to listen on all interfaces.
如下启动错误:
2017-05-13T22:17:20.848+0800 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1,115.159.159.129", port: 27017 }, pro cessManagement: { fork: true, pidFilePath: "/var/run/mongodb/mongod.pid" }, storage: { dbPath: "/var/lib/mongo", journal: { enabled: true } }, systemLog: { d estination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } } 2017-05-13T22:17:20.870+0800 E NETWORK [initandlisten] listen(): bind() failed errno:98 Address already in use for socket: 127.0.0.1:27017 2017-05-13T22:17:20.870+0800 E NETWORK [initandlisten] addr already in use 2017-05-13T22:17:20.870+0800 E STORAGE [initandlisten] Failed to set up sockets during startup. 2017-05-13T22:17:20.870+0800 I CONTROL [initandlisten] dbexit: rc: 48
解决方案:
把ip地址用[]括起来即可,
如下:
# network interfaces net: port: 27017 bindIp: [127.0.0.1,115.159.159.129] # Listen to local interface only, comment to listen on all interfaces.
这样子即可成功启动。
文章的脚注信息由WordPress的wp-posturl插件自动生成