Hello,
I have 3 vm pinging each other in virtualbox.
They All have an almalinux9.5 os and mongodb v.6 installed.
I am attempting to create a replica set.
The 3 ips are 10.17.60.102, 10.17.60.103, 10.17.60.104 and the relevant hostname is dw4-mongo-test-01 dw4-mongo-test-02 dw4-mongo-test-03.
When I open mongosh with command:
mongosh --port 27017 --authenticationDatabase "admin" -u "admin" -p
and try to do
rs.initiate(
{
_id : "rs0",
members: [
{ _id : 0, host : "dw4-mongo-test-01:27017" },
{ _id : 1, host : "dw4-mongo-test-02:27017" },
{ _id : 2, host : "dw4-mongo-test-03:27017" }
]
}
)
on the tree machines, I get:
MongoServerError[AlreadyInitialized]: already initialized
and if I give on each node rs.conf that is the output:
node1)
rs0 [direct: primary] test> rs.conf()
{
_id: 'rs0',
version: 3,
term: 2,
members: [
{
_id: 0,
host: 'dw4-mongo-test-01:27017',
arbiterOnly: false,
buildIndexes: true,
hidden: false,
priority: 1,
tags: {},
secondaryDelaySecs: Long('0'),
votes: 1
},
{
_id: 1,
host: '10.17.60.103:27017',
arbiterOnly: false,
buildIndexes: true,
hidden: false,
priority: 1,
tags: {},
secondaryDelaySecs: Long('0'),
votes: 1
},
{
_id: 2,
host: '10.17.60.104:27017',
arbiterOnly: false,
buildIndexes: true,
hidden: false,
priority: 1,
tags: {},
secondaryDelaySecs: Long('0'),
votes: 1
}
],
protocolVersion: Long('1'),
writeConcernMajorityJournalDefault: true,
settings: {
chainingAllowed: true,
heartbeatIntervalMillis: 2000,
heartbeatTimeoutSecs: 10,
electionTimeoutMillis: 10000,
catchUpTimeoutMillis: -1,
catchUpTakeoverDelayMillis: 30000,
getLastErrorModes: {},
getLastErrorDefaults: { w: 1, wtimeout: 0 },
replicaSetId: ObjectId('678925cb7823cfd20d73907b')
}
}
node2
rs0 [direct: primary] test> rs.conf();
{
_id: 'rs0',
version: 2,
term: 2,
members: [
{
_id: 0,
host: 'dw4-mongo-test-02:27017',
arbiterOnly: false,
buildIndexes: true,
hidden: false,
priority: 1,
tags: {},
secondaryDelaySecs: Long('0'),
votes: 1
},
{
_id: 1,
host: '10.17.60.102:27017',
arbiterOnly: false,
buildIndexes: true,
hidden: false,
priority: 1,
tags: {},
secondaryDelaySecs: Long('0'),
votes: 1
}
],
protocolVersion: Long('1'),
writeConcernMajorityJournalDefault: true,
settings: {
chainingAllowed: true,
heartbeatIntervalMillis: 2000,
heartbeatTimeoutSecs: 10,
electionTimeoutMillis: 10000,
catchUpTimeoutMillis: -1,
catchUpTakeoverDelayMillis: 30000,
getLastErrorModes: {},
getLastErrorDefaults: { w: 1, wtimeout: 0 },
replicaSetId: ObjectId('678925cb1a6df32544b87ae4')
}
}
node3
rs0 [direct: primary] test> rs.conf();
{
_id: 'rs0',
version: 2,
term: 2,
members: [
{
_id: 0,
host: 'dw4-mongo-test-03:27017',
arbiterOnly: false,
buildIndexes: true,
hidden: false,
priority: 1,
tags: {},
secondaryDelaySecs: Long('0'),
votes: 1
},
{
_id: 1,
host: '10.17.60.102:27017',
arbiterOnly: false,
buildIndexes: true,
hidden: false,
priority: 1,
tags: {},
secondaryDelaySecs: Long('0'),
votes: 1
}
],
protocolVersion: Long('1'),
writeConcernMajorityJournalDefault: true,
settings: {
chainingAllowed: true,
heartbeatIntervalMillis: 2000,
heartbeatTimeoutSecs: 10,
electionTimeoutMillis: 10000,
catchUpTimeoutMillis: -1,
catchUpTakeoverDelayMillis: 30000,
getLastErrorModes: {},
getLastErrorDefaults: { w: 1, wtimeout: 0 },
replicaSetId: ObjectId('678925cbf60d4cde61d263e0')
}
}
how can I fix that and re initialize the cluster with my previous command? the tree hosts are pinging each other and ports are open.