简体   繁体   English

如何获得我的 mongodb 数据库的确切 IP 地址?

[英]How do I get the exact IP address of my mongodb database?

I am trying to deploy my node app to my Cpanel however the page times out with an error我正在尝试将我的节点应用程序部署到我的 Cpanel 但是页面超时并出现错误

503 Service unavailable

The website works on Heroku, ngrok and localhost however on my hosting service, it doesn't.该网站可在 Heroku、ngrok 和 localhost 上运行,但在我的托管服务上却不行。
I found out that the issue was due to port 27017 not being open.我发现问题是由于端口 27017 未打开。
On discussing with my hosting providers, they said在与我的托管服务提供商讨论时,他们说
"We can open the ports for you but our policy is to open non-standard ports to specific IP's for better security of the server. Is it possible to get the exact IP addresses of the database server you are trying to connect to." “我们可以为您打开端口,但我们的政策是向特定 IP 开放非标准端口,以提高服务器的安全性。是否可以获得您尝试连接的数据库服务器的确切 IP 地址。”

So I'm not familiar with mongodb database having a specific IP address.所以我不熟悉具有特定 IP 地址的 mongodb 数据库。 What could they mean?他们是什么意思?

To connect to your db, your node app needs a URL something like this.要连接到您的数据库,您的节点应用程序需要一个类似这样的 URL 。

const url = 'mongodb://hostnameOfMongo.example.com:27017'

Your database's hostname is the stuff after mongodb:// and before :27017 .您的数据库的主机名是mongodb://:27017之前的内容。

Open up a shell (a command window) and type打开 shell(命令窗口)并输入

  ping -n 1 hostnameOfMongo.example.com

or maybe或者可能

  ping -c 1 hostnameOfMongo.example.com

It should show you the IP address associated with your mongo server.它应该向您显示与您的 mongo 服务器关联的 IP 地址。 (Obvs, put your actual db hostname into the command, not my example.) (Obvs,将您的实际数据库主机名放入命令中,而不是我的示例。)

It's a little strange that your hosting provider didn't ask for the hostname when you didn't know the IP address.当您不知道 IP 地址时,您的托管服务提供商没有询问主机名,这有点奇怪。 If they were my hosting provider, my confidence in the competence of their support would go down a notch because of that.如果他们是我的托管服务提供商,我对他们支持能力的信心会因此而下降一个档次。

And please be aware that running a db in one data center and a node app (or indeed any app that uses the db) in another data center is a formula for poor performance and unreliability.请注意,在一个数据中心运行一个数据库,而在另一个数据中心运行一个节点应用程序(或实际上任何使用数据库的应用程序)是性能差和不可靠性的一个公式。 The app and the db work best with a short and private network connecting them.该应用程序和数据库最适合连接它们的短专用网络。 With respect, it doesn't seem likely you have the network engineering chops to make that sort of thing stable and reliable.恕我直言,您似乎不太可能拥有使这种东西稳定可靠的网络工程能力。

Not to mention the security problems with exposing mongodb to the public network.更不用说将 mongodb 暴露于公共网络的安全问题。 Your hosting service is reluctant to open a port for a very good reason.您的托管服务不愿意打开端口是有充分理由的。 Read this . 读这个 Because cybercreeps因为网络蠕虫

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

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