最初我在两个不同的端口上的同一台主机上启动了两个节点(主要和次要),二级是正确复制主要的,但我的实际要求是在两个不同的机器上有两个差异IP地址,一个应该作为主要的另一个应该充当辅助,为此我在本地主机中删除辅助,并查看下面的状态,然后尝试在同一副本上添加远程IP,但显示下面描述的错误,请帮助。 < / p>
"members" : [
{
"_id" : 0,
"name" : "localhost:27017",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 5359,
"optime" : {
"ts" : Timestamp(1502370582, 1),
"t" : NumberLong(1)
},
"optimeDate" : ISODate("2017-08-10T13:09:42Z"),
"electionTime" : Timestamp(1502366671, 1),
"electionDate" : ISODate("2017-08-10T12:04:31Z"),
"configVersion" : 4,
"self" : true
}
],
"ok" : 1
}
myreplset:PRIMARY> config = {_id:"myreplset", members:[ {_id:0, host:"localhost:27017"}, {_id:1, host:"192.168.205.59:27017"} ] };
{
"_id" : "myreplset",
"members" : [
{
"_id" : 0,
"host" : "localhost:27017"
},
{
"_id" : 1,
"host" : "192.168.205.59:27017"
}
]
}
myreplset:PRIMARY> rs.initiate(config);
{
"info" : "try querying local.system.replset to see current configuration",
"ok" : 0,
"errmsg" : "already initialized",
"code" : 23,
"codeName" : "AlreadyInitialized"
}