mongodb 副本集失败

程序猿与代码 2018-01-14 07:57:24
两台电脑做测试
zhf-linux:192.168.0.11
zhf-maple:192.168.0.12
在192.168.0.12上启动
启动命令:mongod --dbpath /home/zhf/node0 --replSet rs0
在192.168.0.11上启动
启动命令:mongod --dbpath /home/zhf/node1 --replSet rs0

在192.168.0.12上进入数据库,执行如下命令
> use admin
switched to db admin
> conf={_id:"rs0",members:[{_id:0,host:"zhf-maple:27017"},{_id:1,host:"zhf-linux:27017"}]}
{
"_id" : "rs0",
"members" : [
{
"_id" : 0,
"host" : "zhf-maple:27017"
},
{
"_id" : 1,
"host" : "zhf-linux:27017"
}
]
}
> rs.initiate(conf)
{ "ok" : 1 }
rs0:SECONDARY> rs.conf()
{
"_id" : "rs0",
"version" : 1,
"protocolVersion" : NumberLong(1),
"members" : [
{
"_id" : 0,
"host" : "zhf-maple:27017",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {

},
"slaveDelay" : NumberLong(0),
"votes" : 1
},
{
"_id" : 1,
"host" : "zhf-linux:27017",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {

},
"slaveDelay" : NumberLong(0),
"votes" : 1
}
],
"settings" : {
"chainingAllowed" : true,
"heartbeatIntervalMillis" : 2000,
"heartbeatTimeoutSecs" : 10,
"electionTimeoutMillis" : 10000,
"catchUpTimeoutMillis" : 60000,
"getLastErrorModes" : {

},
"getLastErrorDefaults" : {
"w" : 1,
"wtimeout" : 0
},
"replicaSetId" : ObjectId("5a5b4512be0049ae009cd493")
}
}
但是一直无法同步:提示如下消息
2018-01-14T19:56:44.394+0800 I REPL [rsBackgroundSync] waiting for 2 pings from other members before syncing
2018-01-14T19:56:44.827+0800 I REPL [ReplicationExecutor] Not starting an election, since we are not electable due to: Not standing for election because I cannot see a majority (mask 0x1)
2018-01-14T19:56:45.415+0800 I REPL [ReplicationExecutor] Error in heartbeat request to zhf-linux:27017; Location13111: exception: field not found, expected type 16
2018-01-14T19:56:45.428+0800 I REPL [ReplicationExecutor] Error in heartbeat request to zhf-linux:27017; Location13111: exception: field not found, expected type 16
2018-01-14T19:56:45.438+0800 I REPL [ReplicationExecutor] Error in heartbeat request to zhf-linux:27017; Location13111: exception: field not found, expected type 16


...全文
1957 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
remzhang 2018-02-08
  • 打赏
  • 举报
回复
zhf-linux:192.168.0.11 zhf-maple:192.168.0.12 ------------------------------ 你的这两个机器名称本地做了解析没有?
程序猿与代码 2018-01-18
  • 打赏
  • 举报
回复
有谁知道原因的么,帮看下这个是什么失败呢
程序猿与代码 2018-01-16
  • 打赏
  • 举报
回复
增加了一台电脑:192.168.0.4 ubuntu 启动后有2台是正常的。但是192.168.0.12这台启动的时候报如下的错误。然后就自动退出了 2018-01-16T17:46:25.127+0800 E REPL [replication-0] Initial sync attempt failed -- attempts left: 1 cause: CommandNotFound: error while getting last oplog entry for begin timestamp: no such cmd: find 2018-01-16T17:46:26.127+0800 I REPL [replication-1] Starting initial sync (attempt 10 of 10) 2018-01-16T17:46:26.978+0800 I REPL [replication-1] sync source candidate: ubuntu:27017 2018-01-16T17:46:26.995+0800 I STORAGE [replication-1] dropAllDatabasesExceptLocal 1 2018-01-16T17:46:26.995+0800 I REPL [replication-1] ****** 2018-01-16T17:46:26.995+0800 I REPL [replication-1] creating replication oplog of size: 33904MB... 2018-01-16T17:46:27.079+0800 I STORAGE [replication-1] WiredTigerRecordStoreThread local.oplog.rs already started 2018-01-16T17:46:27.079+0800 I STORAGE [replication-1] The size storer reports that the oplog contains 0 records totaling to 0 bytes 2018-01-16T17:46:27.079+0800 I STORAGE [replication-1] Scanning the oplog to determine where to place markers for truncation 2018-01-16T17:46:27.247+0800 I REPL [replication-1] ****** 2018-01-16T17:46:27.261+0800 I REPL [replication-1] Initial sync attempt finishing up. 2018-01-16T17:46:27.261+0800 I REPL [replication-1] Initial Sync Attempt Statistics: { failedInitialSyncAttempts: 9, maxFailedInitialSyncAttempts: 10, initialSyncStart: new Date(1516095963274), initialSyncAttempts: [ { durationMillis: 0, status: "CommandNotFound: error while getting last oplog entry for begin timestamp: no such cmd: find", syncSource: "ubuntu:27017" }, { durationMillis: 0, status: "CommandNotFound: error while getting last oplog entry for begin timestamp: no such cmd: find", syncSource: "zhf-linux:27017" }, { durationMillis: 0, status: "CommandNotFound: error while getting last oplog entry for begin timestamp: no such cmd: find", syncSource: "zhf-linux:27017" }, { durationMillis: 0, status: "CommandNotFound: error while getting last oplog entry for begin timestamp: no such cmd: find", syncSource: "zhf-linux:27017" }, { durationMillis: 0, status: "CommandNotFound: error while getting last oplog entry for begin timestamp: no such cmd: find", syncSource: "zhf-linux:27017" }, { durationMillis: 0, status: "CommandNotFound: error while getting last oplog entry for begin timestamp: no such cmd: find", syncSource: "zhf-linux:27017" }, { durationMillis: 0, status: "CommandNotFound: error while getting last oplog entry for begin timestamp: no such cmd: find", syncSource: "zhf-linux:27017" }, { durationMillis: 0, status: "CommandNotFound: error while getting last oplog entry for begin timestamp: no such cmd: find", syncSource: "ubuntu:27017" }, { durationMillis: 0, status: "CommandNotFound: error while getting last oplog entry for begin timestamp: no such cmd: find", syncSource: "ubuntu:27017" } ] } 2018-01-16T17:46:27.261+0800 E REPL [replication-1] Initial sync attempt failed -- attempts left: 0 cause: CommandNotFound: error while getting last oplog entry for begin timestamp: no such cmd: find 2018-01-16T17:46:27.261+0800 F REPL [replication-1] The maximum number of retries have been exhausted for initial sync. 2018-01-16T17:46:27.292+0800 E REPL [replication-1] Initial sync failed, shutting down now. Restart the server to attempt a new initial sync. 2018-01-16T17:46:27.293+0800 I - [replication-1] Fatal assertion 40088 CommandNotFound: error while getting last oplog entry for begin timestamp: no such cmd: find at src/mongo/db/repl/replication_coordinator_impl.cpp 633 2018-01-16T17:46:27.293+0800 I - [replication-1] ***aborting after fassert() failure
rucypli 2018-01-15
  • 打赏
  • 举报
回复
because I cannot see a majority

副本集至少三台,或者三个进程



















程序猿与代码 2018-01-15
  • 打赏
  • 举报
回复
好的,我用三台机器试下














******************************************************************************

1,747

社区成员

发帖
与我相关
我的任务
社区描述
MongoDB相关内容讨论区
社区管理员
  • MongoDB社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧