我正在尝试设置主从副本。这是为了在接下来的几天内从第一个节点到第二个节点进行无停机迁移。
主节点已设置完毕,配置已更新,我添加了密钥文件。对辅助节点执行了相同操作。
我还初始化了复制,并将辅助节点添加到复制中。我可以看到 ping 和正常运行时间,但辅助节点卡在“启动”状态。
但是,辅助节点上没有副本配置。此外,它一遍又一遍地在错误日志中重复此操作。
辅助节点(日志):
{"t":{"$date":"2024-11-14T11:35:14.018+00:00"},"s":"I", "c":"CONNPOOL", "id":22576, "ctx":"ReplNetwork","msg":"Connecting","attr":{"hostAndPort":"Ubuntu-2204-jammy-amd64-base:27017"}}
{"t":{"$date":"2024-11-14T11:35:14.818+00:00"},"s":"W", "c":"SHARDING", "id":7012500, "ctx":"QueryAnalysisConfigurationsRefresher","msg":"Failed to refresh query analysis configurations, will try again at the next interval","attr":{"error":"PrimarySteppedDown: No primary exists currently"}}
{"t":{"$date":"2024-11-14T11:35:15.000+00:00"},"s":"W", "c":"QUERY", "id":23799, "ctx":"ftdc","msg":"Aggregate command executor error","attr":{"error":{"code":26,"codeName":"NamespaceNotFound","errmsg":"Unable to retrieve storageStats in $collStats stage :: caused by :: Collection [local.oplog.rs] not found."},"stats":{},"cmd":{"aggregate":"oplog.rs","cursor":{},"pipeline":[{"$collStats":{"storageStats":{"waitForLock":false,"numericOnly":true}}}],"$db":"local"}}}
{"t":{"$date":"2024-11-14T11:35:15.000+00:00"},"s":"W", "c":"QUERY", "id":23799, "ctx":"ftdc","msg":"Aggregate command executor error","attr":{"error":{"code":26,"codeName":"NamespaceNotFound","errmsg":"Unable to retrieve storageStats in $collStats stage :: caused by :: Collection [config.transactions] not found."},"stats":{},"cmd":{"aggregate":"transactions","cursor":{},"pipeline":[{"$collStats":{"storageStats":{"waitForLock":false,"numericOnly":true}}}],"$db":"config"}}}
{"t":{"$date":"2024-11-14T11:35:15.001+00:00"},"s":"W", "c":"QUERY", "id":23799, "ctx":"ftdc","msg":"Aggregate command executor error","attr":{"error":{"code":26,"codeName":"NamespaceNotFound","errmsg":"Unable to retrieve storageStats in $collStats stage :: caused by :: Collection [config.image_collection] not found."},"stats":{},"cmd":{"aggregate":"image_collection","cursor":{},"pipeline":[{"$collStats":{"storageStats":{"waitForLock":false,"numericOnly":true}}}],"$db":"config"}}}
{"t":{"$date":"2024-11-14T11:35:15.018+00:00"},"s":"I", "c":"CONNPOOL", "id":22576, "ctx":"ReplNetwork","msg":"Connecting","attr":{"hostAndPort":"Ubuntu-2204-jammy-amd64-base:27017"}}
{"t":{"$date":"2024-11-14T11:35:16.000+00:00"},"s":"W", "c":"QUERY", "id":23799, "ctx":"ftdc","msg":"Aggregate command executor error","attr":{"error":{"code":26,"codeName":"NamespaceNotFound","errmsg":"Unable to retrieve storageStats in $collStats stage :: caused by :: Collection [local.oplog.rs] not found."},"stats":{},"cmd":{"aggregate":"oplog.rs","cursor":{},"pipeline":[{"$collStats":{"storageStats":{"waitForLock":false,"numericOnly":true}}}],"$db":"local"}}}
{"t":{"$date":"2024-11-14T11:35:16.000+00:00"},"s":"W", "c":"QUERY", "id":23799, "ctx":"ftdc","msg":"Aggregate command executor error","attr":{"error":{"code":26,"codeName":"NamespaceNotFound","errmsg":"Unable to retrieve storageStats in $collStats stage :: caused by :: Collection [config.transactions] not found."},"stats":{},"cmd":{"aggregate":"transactions","cursor":{},"pipeline":[{"$collStats":{"storageStats":{"waitForLock":false,"numericOnly":true}}}],"$db":"config"}}}
{"t":{"$date":"2024-11-14T11:35:16.001+00:00"},"s":"W", "c":"QUERY", "id":23799, "ctx":"ftdc","msg":"Aggregate command executor error","attr":{"error":{"code":26,"codeName":"NamespaceNotFound","errmsg":"Unable to retrieve storageStats in $collStats stage :: caused by :: Collection [config.image_collection] not found."},"stats":{},"cmd":{"aggregate":"image_collection","cursor":{},"pipeline":[{"$collStats":{"storageStats":{"waitForLock":false,"numericOnly":true}}}],"$db":"config"}}}
{"t":{"$date":"2024-11-14T11:35:16.018+00:00"},"s":"I", "c":"CONNPOOL", "id":22576, "ctx":"ReplNetwork","msg":"Connecting","attr":{"hostAndPort":"Ubuntu-2204-jammy-amd64-base:27017"}}
主服务器上的 rs.config()
{
set: 'rs0',
date: ISODate('2024-11-14T11:36:01.498Z'),
myState: 1,
term: Long('3'),
syncSourceHost: '',
syncSourceId: -1,
heartbeatIntervalMillis: Long('2000'),
majorityVoteCount: 1,
writeMajorityCount: 1,
votingMembersCount: 1,
writableVotingMembersCount: 1,
optimes: {
lastCommittedOpTime: { ts: Timestamp({ t: 1731584161, i: 5 }), t: Long('3') },
lastCommittedWallTime: ISODate('2024-11-14T11:36:01.474Z'),
readConcernMajorityOpTime: { ts: Timestamp({ t: 1731584161, i: 5 }), t: Long('3') },
appliedOpTime: { ts: Timestamp({ t: 1731584161, i: 5 }), t: Long('3') },
durableOpTime: { ts: Timestamp({ t: 1731584161, i: 5 }), t: Long('3') },
writtenOpTime: { ts: Timestamp({ t: 1731584161, i: 5 }), t: Long('3') },
lastAppliedWallTime: ISODate('2024-11-14T11:36:01.474Z'),
lastDurableWallTime: ISODate('2024-11-14T11:36:01.474Z'),
lastWrittenWallTime: ISODate('2024-11-14T11:36:01.474Z')
},
lastStableRecoveryTimestamp: Timestamp({ t: 1731584157, i: 2 }),
electionCandidateMetrics: {
lastElectionReason: 'electionTimeout',
lastElectionDate: ISODate('2024-11-14T09:11:55.719Z'),
electionTerm: Long('3'),
lastCommittedOpTimeAtElection: { ts: Timestamp({ t: 0, i: 0 }), t: Long('-1') },
lastSeenWrittenOpTimeAtElection: { ts: Timestamp({ t: 1731575489, i: 10 }), t: Long('2') },
lastSeenOpTimeAtElection: { ts: Timestamp({ t: 1731575489, i: 10 }), t: Long('2') },
numVotesNeeded: 1,
priorityAtElection: 1,
electionTimeoutMillis: Long('10000'),
numCatchUpOps: Long('0'),
newTermStartDate: ISODate('2024-11-14T09:11:55.790Z'),
wMajorityWriteAvailabilityDate: ISODate('2024-11-14T09:11:55.803Z')
},
members: [
{
_id: 0,
name: 'Ubuntu-2204-jammy-amd64-base:27017',
health: 1,
state: 1,
stateStr: 'PRIMARY',
uptime: 8656,
optime: { ts: Timestamp({ t: 1731584161, i: 5 }), t: Long('3') },
optimeDate: ISODate('2024-11-14T11:36:01.000Z'),
optimeWritten: { ts: Timestamp({ t: 1731584161, i: 5 }), t: Long('3') },
optimeWrittenDate: ISODate('2024-11-14T11:36:01.000Z'),
lastAppliedWallTime: ISODate('2024-11-14T11:36:01.474Z'),
lastDurableWallTime: ISODate('2024-11-14T11:36:01.474Z'),
lastWrittenWallTime: ISODate('2024-11-14T11:36:01.474Z'),
syncSourceHost: '',
syncSourceId: -1,
infoMessage: '',
electionTime: Timestamp({ t: 1731575515, i: 1 }),
electionDate: ISODate('2024-11-14T09:11:55.000Z'),
configVersion: 10,
configTerm: 3,
self: true,
lastHeartbeatMessage: ''
},
{
_id: 1,
name: 'XXXXXXXXXXXXXXX:27017',
health: 1,
state: 0,
stateStr: 'STARTUP',
uptime: 1925,
optime: { ts: Timestamp({ t: 0, i: 0 }), t: Long('-1') },
optimeDurable: { ts: Timestamp({ t: 0, i: 0 }), t: Long('-1') },
optimeWritten: { ts: Timestamp({ t: 0, i: 0 }), t: Long('-1') },
optimeDate: ISODate('1970-01-01T00:00:00.000Z'),
optimeDurableDate: ISODate('1970-01-01T00:00:00.000Z'),
optimeWrittenDate: ISODate('1970-01-01T00:00:00.000Z'),
lastAppliedWallTime: ISODate('1970-01-01T00:00:00.000Z'),
lastDurableWallTime: ISODate('1970-01-01T00:00:00.000Z'),
lastWrittenWallTime: ISODate('1970-01-01T00:00:00.000Z'),
lastHeartbeat: ISODate('2024-11-14T11:36:00.038Z'),
lastHeartbeatRecv: ISODate('1970-01-01T00:00:00.000Z'),
pingMs: Long('9'),
lastHeartbeatMessage: '',
syncSourceHost: '',
syncSourceId: -1,
infoMessage: '',
configVersion: -2,
configTerm: -1
}
],
ok: 1,
'$clusterTime': {
clusterTime: Timestamp({ t: 1731584161, i: 5 }),
signature: {
hash: Binary.createFromBase64('XXXXXXXXXX', 0),
keyId: Long('XXXXXXXXXXXX')
}
},
operationTime: Timestamp({ t: 1731584161, i: 5 })
}
辅助服务器上的 rs.config()
MongoServerError[NotYetInitialized]: no replset config has been received