【问题标题】:Configure MongoDB Replication at AWS在 AWS 上配置 MongoDB 复制
【发布时间】:2016-09-17 13:35:21
【问题描述】:

我正在尝试在 AWS 上使用 3 个实例配置 MongoDB 复制。 我现在有两个实例,我可以互相ping通。 Mongo 守护程序使用相同的复制名称正确运行。

但是在启动主节点后,我无法添加第二个实例并出现错误

yaodao:PRIMARY> rs.add("yaodao2:27017")
{
"ok" : 0,
"errmsg" : "Quorum check failed because not enough voting nodes responded; required 2 but only the following 1 voting nodes responded: yaodao1:27017; the following nodes did not respond affirmatively: yaodao2:27017 failed with Connection refused",
"code" : 74
}

有人说“coeection denied”是因为没有 mongod 守护进程在第二次运行,但我验证了这一点,一切正常。

/etc/hosts 用于主实例

127.0.0.1 yaodao1
54.173.155.9 yaodao2

/etc/hosts 用于第二个实例

127.0.0.1 yaodao2
54.175.238.78 yaodao1

rs.status() 用于主要

yaodao:PRIMARY> rs.status()
{
"set" : "yaodao",
"date" : ISODate("2016-09-17T13:34:01.032Z"),
"myState" : 1,
"term" : NumberLong(4),
"heartbeatIntervalMillis" : NumberLong(2000),
"members" : [
    {
        "_id" : 1,
        "name" : "yaodao1:27017",
        "health" : 1,
        "state" : 1,
        "stateStr" : "PRIMARY",
        "uptime" : 1132,
        "optime" : {
            "ts" : Timestamp(1474118471, 2),
            "t" : NumberLong(4)
        },
        "optimeDate" : ISODate("2016-09-17T13:21:11Z"),
        "electionTime" : Timestamp(1474118471, 1),
        "electionDate" : ISODate("2016-09-17T13:21:11Z"),
        "configVersion" : 59679,
        "self" : true
    }
],
"ok" : 1
}

【问题讨论】:

  • 您是否尝试过使用 mongo shell 检查所有 mongo 之间的连接性? mongo --host --port
  • @Astro 我试过了,它无法连接到另一个 mongod 守护进程。那么问题出在哪里?
  • @Astro 我设法通过设置 /etc/mongo.cfg bind_ip = 0.0.0.0 来实现目标,但我真的不明白为什么。继续寻找原因。
  • 默认情况下 mongodb 只绑定到本地接口。

标签: mongodb amazon-web-services replication


【解决方案1】:

请为所有节点配置使用私有IP地址。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-04-18
    • 1970-01-01
    • 2018-07-09
    • 2021-05-29
    • 1970-01-01
    • 1970-01-01
    • 2021-11-06
    • 2019-10-30
    相关资源
    最近更新 更多