replSetInitiate quorum check failed because not all proposed set members are responsively

replSetInitiate quorum check failed because not all proposed set members responded affirmatively

我是 运行 3 mongodb pods 并为每个 pod 单独声明服务和持久卷。我想在 3 pods 之间进行 Mongodb 复制。登录到第一个 pod 并给出 mongo 命令,然后我将每个 pod 的主机配置为 podname.servicename.namespace.svc.cluster.local:27017

rs.initiate(
  {
    "_id": "rs0",
    "members": [
      {
        "_id": 0,
        "host": "mongo-.mongo.default.svc.cluster.local:27017",
        "priority": 10
      },
      {
        "_id": 1,
        "host": "mongo-1.mongo.default.svc.cluster.local:27017",
        "priority": 9
      },
      {
        "_id": 2,
        "host": "mongo-2.mongo.default.svc.cluster.local:27017",
        "arbiterOnly": true
      }
    ]
  }
)

我收到这样的错误

replSetInitiate quorum check failed because not all proposed set members responded affirmatively: mongo-1.mongo.default.svc.cluster.local:27017 failed with Error connecting to mongo-1.mongo.default.svc.cluster.local:27017 (10.36.0.1:27017) :: caused by :: Connection refused, mongo-2.mongo.default.svc.cluster.local:27017 failed with Error connecting to mongo-2.mongo.default.svc.cluster.local:27017 (10.44.0.3:27017) :: caused by :: Connection refused

在这里,我想知道在 kubernetes 集群中进行 MongoDB 复制时,它作为主机使用的是集群 IP 还是节点 IP。

有人可以建议我在 kubernates 中进行 mongodb 复制时如何配置主机名吗?

根据 the fine manual

,自 mongo 3.6 起,您必须明确地将 mongod 绑定到非环回接口

您可以通过执行到 mongo-1.mongo.default 并尝试手动连接到 mongo-2.mongo.default 来自己测试该理论,我大约 90% 肯定这对您来说会失败,就像它失败的方式一样mongod.