replica-set - mongodb replica set 新增從節點出錯?
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-05-02 09:19:18
0
0
1695

我在三台虛擬機器上設定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"
求助各位有經驗的行家!

曾经蜡笔没有小新
曾经蜡笔没有小新

全部回覆(0)
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板