繁体   English   中英

连接到远程 MongoDB 服务器时出现问题

[英]Having problem in connecting to remote MongoDB Server

我尝试使用 Windows 上的 MongoDB Compass 连接运行在 Ubuntu 上的远程 MongoDB 服务器。但由于 Windows 机器的 IP 每天都在变化,所以我总是遇到连接问题。

我做了以下事情来连接到远程服务器 -

  1. 获得客户端机器的 IP,然后在端口 27017 上的服务器机器的防火墙上允许 IP。
sudo ufw allow from client_machine_ip to any port 27017

注意:ufw 状态看起来没问题。

  1. 拿到Server Machine的IP,然后在server上的MongoDB配置文件上,我修改了bindIp。
bindIp: 127.0.0.1,server_machine_ip

注:我重启了mongod也没有问题。

我第一次成功使用 MongoDB Compass 连接到远程 MongoDB 服务器。 然后我看到,客户端机器的IP每天都在变。 因此,每次客户端 IP 更改时,我都需要在端口 27017 上的服务器机器(其中我使用 MongoDB 服务器)的防火墙上允许 IP。你能帮忙解决这个问题吗? 提前致谢。

您可以更新端口 27017 的防火墙以允许来自任何地方,因为客户端计算机 IP 不是 static。

sudo ufw allow 27017 #(this will allow from any IP)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM