search

Home  >  Q&A  >  body text

mongodb 外网IP启动失败

centos 部署mongodb 服务器。 启动命令

/usr/local/mongodb/bin/mongod --bind_ip 内网ip 或127.0.0.1 --port 27017 --maxConns 20000 --dbpath=/usr/local/mongodb/db --logpath=/usr/local/mongodb/log/mongo.log --logappend &
;;

可以启动成功。

/usr/local/mongodb/bin/mongod --bind_ip 外网ip --port 27017 --maxConns 20000 --dbpath=/usr/local/mongodb/db --logpath=/usr/local/mongodb/log/mongo.log --logappend &
;;

启动失败
[ 防火墙已关闭,27017端口也开启]
错误日志:
[initandlisten] listen(): bind() failed errno:99 Cannot assign requested address for socket: 外网ip:27017
[initandlisten] journal dir=/usr/local/mongodb/db/journal
Durability thread stopped

ringa_leeringa_lee2763 days ago871

reply all(4)I'll reply

  • 仅有的幸福

    仅有的幸福2017-04-26 09:04:01

    --bind_ip # Bind the service IP. If bound to 127.0.0.1, it can only be accessed locally. If not specified, all IPs can be accessed by default. If you want to allow the external network to access your database, just don't specify this parameter!

    reply
    0
  • 某草草

    某草草2017-04-26 09:04:01

    Judging from the error message, there are a few things to check:

    1. Is there any program occupying port 27017 of the external IP address: sudo netstat -pln | grep 27017
    2. Have you made a mistake in the external IP address: ifconfig | grep inet

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-04-26 09:04:01

    You should map the external IP port to the internal IP port, right?

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-04-26 09:04:01

    It should not be that the port is occupied. If it is, the error should be Already in use. I suspect that there are multiple network cards on your host, and the port of one of the network cards is still restricted by the firewall. I would like to verify it.

    reply
    0
  • Cancelreply