【已解决】MongoDB绑定多个ip启动报错

原创文章,转载请注明: 转载自勤奋的小青蛙
本文链接地址: 【已解决】MongoDB绑定多个ip启动报错

参考来源:

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.

如下启动错误:

QQ截图20170513221827

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.

这样子即可成功启动。

原创文章,转载请注明: 转载自勤奋的小青蛙
本文链接地址: 【已解决】MongoDB绑定多个ip启动报错

文章的脚注信息由WordPress的wp-posturl插件自动生成



|2|left
打赏

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: