尝试设置Mongo复制,但最终有两个辅助成员,没有主要成员

时间:2012-01-13 23:52:58

标签: mongodb replication

我一直在尝试设置一个简单的复制系统。 1个主要的蒙戈, 1个备份,1个仲裁。

不幸的是,解雇它导致主要被选为SECONDARY,并且 备份被选为PRIMARY(好工作仲裁者)。

Main的优先级为100,备份优先级为0,并且a 奴隶延迟。

我试图通过以下方式告诉备份:

PRIMARY>   db.runCommand({replSetReconfig: conf})
{
        "assertion" : "initiation and reconfiguration of a replica set must
be sent to a node that can become primary",
        "assertionCode" : 13420,
        "errmsg" : "db assertion failure",
        "ok" : 0
}
PRIMARY> .adminCommand({replSetStepDown:1000000, force:1})
Fri Jan 13 17:27:29 SyntaxError: syntax error (shell):1
PRIMARY> db.adminCommand({replSetStepDown:1000000, force:1})
Fri Jan 13 17:27:36 DBClientCursor::init call() failed
Fri Jan 13 17:27:36 query failed : admin.$cmd { replSetStepDown:
1000000.0, force: 1.0 } to: 127.0.0.1
Fri Jan 13 17:27:36 Error: error doing query: failed shell/
collection.js:151
Fri Jan 13 17:27:36 trying reconnect to 127.0.0.1
Fri Jan 13 17:27:36 reconnect 127.0.0.1 ok
SECONDARY>
SECONDARY>
SECONDARY> db.adminCommand({replSetStepDown:1000000, force:1})
{ "errmsg" : "not primary so can't step down", "ok" : 0 }

哪个有效,但主要还是次要的。

有什么想法吗?谢谢!

配置文件

conf = {
  version: 90002,
  _id : "example",
  members: [
    {
      _id : 1,
      host : "main.example.com:27017",
      priority: 100
    },
    {
      _id : 2,
      host : "backup.example.com:27017",
      priority: 0,
      slaveDelay : 3600
    },
    {
      _id : 3,
      host : "arbiter.example.com:27017",
      priority: 0,
      arbiterOnly: true
    }
  ]
};

主要()

上的rs.status
{
  "set" : "example",
  "date" : ISODate("2012-01-13T23:29:09Z"),
  "myState" : 2,
  "members" : [
    {
      "_id" : 1,
      "name" : "main.example.com:27017",
      "health" : 1,
      "state" : 2,
      "stateStr" : "SECONDARY",
      "optime" : {
        "t" : 1326496827000,
        "i" : 1
      },
      "optimeDate" : ISODate("2012-01-13T23:20:27Z"),
      "self" : true
    },
    {
      "_id" : 2,
      "name" : "backup.example.com:27017",
      "health" : 1,
      "state" : 2,
      "stateStr" : "SECONDARY",
      "uptime" : 324,
      "optime" : {
        "t" : 1326492641000,
        "i" : 1
      },
      "optimeDate" : ISODate("2012-01-13T22:10:41Z"),
      "lastHeartbeat" : ISODate("2012-01-13T23:29:09Z"),
      "pingMs" : 0
    },
    {
      "_id" : 3,
      "name" : "arbiter.example.com:27017",
      "health" : 1,
      "state" : 7,
      "stateStr" : "ARBITER",
      "uptime" : 324,
      "optime" : {
        "t" : 0,
        "i" : 0
      },
      "optimeDate" : ISODate("1970-01-01T00:00:00Z"),
      "lastHeartbeat" : ISODate("2012-01-13T23:29:09Z"),
      "pingMs" : 0
    }
  ],
  "ok" : 1

}
备份

上的rs.status()
{
  "set" : "example",
  "date" : ISODate("2012-01-13T23:31:06Z"),
  "myState" : 2,
  "members" : [
    {
      "_id" : 0,
      "name" : "BACKUPVMW02:27017",
      "health" : 1,
      "state" : 2,
      "stateStr" : "SECONDARY",
      "optime" : {
        "t" : 1326492641000,
        "i" : 1
      },
      "optimeDate" : ISODate("2012-01-13T22:10:41Z"),
      "self" : true
    }
  ],
  "ok" : 1

2 个答案:

答案 0 :(得分:1)

事实证明,它有一个3节点设置,1个主节点,1个从节点,1个仲裁器不能正常工作。删除了从属延迟,并且优先考虑了优先级(从头开始重新安装所有节点并删除数据目录)

答案 1 :(得分:1)

您可能正在使用旧版本的mongodb - 他们用于投票的字段被称为"投票"那么,我认为,不是优先事项。当他们切换到" priority"字段,你应该调用rs.reconfig(configfile),我想。