【问题标题】:Google Cloud Mongo DB: External IP not connectingGoogle Cloud Mongo DB:外部 IP 未连接
【发布时间】:2015-05-22 00:46:41
【问题描述】:

我使用默认参数在 Google Cloud 上创建了一个准备就绪的 MongoDB 服务器。他们之间一切正常(有通信,我可以添加数据库和集合)。但是,我无法在任何外部机器上连接到 MongoDB。 我在 GCP 中创建了防火墙规则,允许端口 27017 上的所有连接(“0.0.0.0./0”)。

我正在运行命令:

giuseppe@ubuntu:~$ mongo --host rs0/104.154.xx.xxx,173.255.xxx.xxx,104.197.xxx.xxx 



giuseppe@ubuntu:~$ mongo --host rs0/104.154.xxx.xxx:27017,173.255.xxx.xxx:27017,104.197.xxx.xxx:27017

我在他们两个上都遇到了同样的错误。我不知道如何解决这个问题。

connecting to: rs0/104.154.41.xxx,173.255.xxx.xxx,104.197.22.xxx:27017/test
2015-03-18T19:47:33.770-0500 starting new replica set monitor for replica set rs0 with seeds 104.154.41.xxx:27017,104.197.22.1xx:27017,xx.255.114.xxx:27017
2015-03-18T19:47:33.770-0500 [ReplicaSetMonitorWatcher] starting
2015-03-18T19:47:34.119-0500 changing hosts to rs0/mongo-db-jff3:27017,mongo-db-vnc4:27017 from rs0/104.154.41.246:27017,1xx.197.22.xxx:27017,173.255.1xx.xx:27017
2015-03-18T19:47:34.493-0500 getaddrinfo("mongo-db-vnc4") failed: Name or service not known
2015-03-18T19:47:34.511-0500 getaddrinfo("mongo-db-jff3") failed: Name or service not known
2015-03-18T19:47:34.512-0500 Error: connect failed to replica set rs0/104.154.xxx.xxx:27017,173.2xx.xxx.68:27017,104.197.22.xxx:27017 at src/mongo/shell/mongo.js:148

编辑:

这是我的防火墙设置。

【问题讨论】:

  • 这与 google-app-engine 有什么关系(如果有)? 为什么人们会以这种方式标记这么多 Q,这显然是 不是 GAE 问题,但与 GCP 中的许多产品中的其他产品有关,例如(我怀疑这里)google -计算引擎?当您错误地标记这样的问题时,您是否意识到您让我们为您提供免费支持变得多么困难?!
  • 我对 GCP 也有同样的问题,我使用端口 27017 设置了一个新的防火墙规则,IP 范围为 0.0.0.0/0,然后我在我的 vm 实例中添加了目标标签。我可以使用 SSH 连接和查看 instace 内的其他 mongo 实例(成员),一切正常,但在外部我无法连接“mongodb://user:pass@ip-1:27017,ip-2:27017,ip -3:27017/admin?replicaSet=rs-0" 只有我删除副本集时才能连接,"mongodb://user:pass@ip-1:27017,ip-2:27017,ip-3:27017/管理员”,我不知道为什么...
  • community.bitnami.com/t/…中描述的错误相同

标签: mongodb google-compute-engine google-cloud-platform


【解决方案1】:

你有没有

  • 在谷歌云控制台配置防火墙规则
  • 在您的防火墙规则中提供标签
  • 使用与防火墙规则相同的标签标记您的实例

?

我详细解释了如何对外开放端口over here。替换为您自己的端口号。

【讨论】:

  • 是的,我已经上传了我的设置图片
  • 或者你确定进程正在监听给定的端口?你可以尝试做netstat -an | grep -i listen | grep tcp 来验证吗?
  • 适合我的防火墙规则
【解决方案2】:

我相信这里的问题是 ReplicaSetMonitorWatcher 正在将主机更改为 rs0/mongo-db-jff3:27017,其中 mongo-db-jff3 无法从您的网络访问。您需要将副本集中的主机配置为您可以访问的内容(静态 IP 或 URL)。

https://docs.mongodb.com/manual/tutorial/change-hostnames-in-a-replica-set/

快速示例,将 mongo 放入您的 PRIMARY(如果您不想停机,则为 SECONDARY):

cfg = rs.conf()
cfg.members[0].host = "mongodb0.example.net:27017"
cfg.members[1].host = "mongodb1.example.net:27017"
rs.reconfig(cfg)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-10-04
    • 2021-09-14
    • 2018-05-01
    • 2022-12-21
    • 1970-01-01
    • 2021-10-21
    • 2018-04-01
    • 1970-01-01
    相关资源
    最近更新 更多