2

云服务器不能通过公网 IP 连接本机

 2 years ago
source link: https://www.v2ex.com/t/814807
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  程序员

云服务器不能通过公网 IP 连接本机

  aqtata · 5 小时 35 分钟前 · 174 次点击

我在 mongo 建立集群时无法将本机公网 IP 写入 primary 的host,因为在服务器上,socket 无法通过公网 IP 连接本机,mongo 就不让创建集群。

只能填写内网 IP 或localhost,如果 secondary 节点和 primary 不在一个局域网内,就无法连接了,因为是 secondary 主动连接 primary 的,对于 secondary 来说它看到的 primary 地址是一个局域网地址。

于是我修改服务器的 host ,将xxx.com指向127.0.0.1,这样就将 mongo 欺骗过去了,集群中的主节点 host 成功变成xxx.com

我想问的是,这是标准答案吗?百度了一下没看到类似问题,难道大家的集群都在一个局域网?


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK