Heim > Fragen und Antworten > Hauptteil
我在三台虚拟机上配置mongodb replica set副本集,使用conf文件启动mongodb
启动命令:
/appdev/mongodb/bin/mongod --config /data/mongodb0/conf/mongodb0.conf -quiet
conf文件内容:
port=29001
bind_ip=192.168.1.205
dbpath=/data/mongodb0
replSet=rs0
logpath=/data/mongodb0/mongodb0.log
logappend=true
journal=true
另外两台机器的启动命令和conf配置文件内容都是一样的,只有文件名和ip不同
将205server设置为primary节点
rs0:PRIMARY> rs.status()
{
"set" : "rs0",
"date" : ISODate("2016-06-02T08:03:50.304Z"),
"myState" : 1,
"term" : NumberLong(1),
"heartbeatIntervalMillis" : NumberLong(2000),
"members" : [
{
"_id" : 0,
"name" : "192.168.1.205:29001",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 6111,
"optime" : {
"ts" : Timestamp(1464849936, 1),
"t" : NumberLong(1)
},
"optimeDate" : ISODate("2016-06-02T06:45:36Z"),
"electionTime" : Timestamp(1464849935, 2),
"electionDate" : ISODate("2016-06-02T06:45:35Z"),
"configVersion" : 1,
"self" : true
}
],
"ok" : 1
}
rs0:PRIMARY>
rs0:PRIMARY> rs.conf()
{
"_id" : "rs0",
"version" : 1,
"protocolVersion" : NumberLong(1),
"members" : [
{
"_id" : 0,
"host" : "192.168.1.205:29001",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {
},
"slaveDelay" : NumberLong(0),
"votes" : 1
}
],
"settings" : {
"chainingAllowed" : true,
"heartbeatIntervalMillis" : 2000,
"heartbeatTimeoutSecs" : 10,
"electionTimeoutMillis" : 10000,
"getLastErrorModes" : {
},
"getLastErrorDefaults" : {
"w" : 1,
"wtimeout" : 0
},
"replicaSetId" : ObjectId("574fd60f2e5b59fe492a9c28")
}
}
rs0:PRIMARY>
然后开始添加从节点:
rs0:PRIMARY> rs.add("192.168.1.206:29001")
{
"ok" : 0,
"errmsg" : "Our set name did not match that of 192.168.1.206:29001",
"code" : 103
}
rs0:PRIMARY>
然后就是报错信息了:"errmsg" : "Our set name did not match that of 192.168.1.206:29001"
求助各位有经验的行家!