C:\Users\TUNA>mongosh --port 37017
Current Mongosh Log ID: 665c972d28bed6034ecdcdf5
Connecting to: mongodb://127.0.0.1:37017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.2.6
Using MongoDB: 8.0.0-rc6
Using Mongosh: 2.2.6
For mongosh info see: https://docs.mongodb.com/mongodb-shell/
Enterprise shard0 [direct: secondary] test> rs.status()
{
set: 'shard0',
date: ISODate('2024-06-02T16:00:47.637Z'),
myState: 2,
term: Long('17'),
syncSourceHost: '127.0.0.1:37019',
syncSourceId: 2,
heartbeatIntervalMillis: Long('2000'),
majorityVoteCount: 2,
writeMajorityCount: 2,
votingMembersCount: 3,
writableVotingMembersCount: 3,
optimes: {
lastCommittedOpTime: { ts: Timestamp({ t: 1717344044, i: 1 }), t: Long('17') },
lastCommittedWallTime: ISODate('2024-06-02T16:00:44.211Z'),
readConcernMajorityOpTime: { ts: Timestamp({ t: 1717344044, i: 1 }), t: Long('17') },
appliedOpTime: { ts: Timestamp({ t: 1717344044, i: 1 }), t: Long('17') },
durableOpTime: { ts: Timestamp({ t: 1717344044, i: 1 }), t: Long('17') },
writtenOpTime: { ts: Timestamp({ t: 1717344044, i: 1 }), t: Long('17') },
lastAppliedWallTime: ISODate('2024-06-02T16:00:44.211Z'),
lastDurableWallTime: ISODate('2024-06-02T16:00:44.211Z'),
lastWrittenWallTime: ISODate('2024-06-02T16:00:44.211Z')
},
lastStableRecoveryTimestamp: Timestamp({ t: 1717344024, i: 1 }),
electionParticipantMetrics: {
votedForCandidate: true,
electionTerm: Long('17'),
lastVoteDate: ISODate('2024-06-02T15:57:44.133Z'),
electionCandidateMemberId: 2,
voteReason: '',
lastWrittenOpTimeAtElection: { ts: Timestamp({ t: 1717343684, i: 2 }), t: Long('15') },
maxWrittenOpTimeInSet: { ts: Timestamp({ t: 1717343684, i: 2 }), t: Long('15') },
lastAppliedOpTimeAtElection: { ts: Timestamp({ t: 1717343684, i: 2 }), t: Long('15') },
maxAppliedOpTimeInSet: { ts: Timestamp({ t: 1717343684, i: 2 }), t: Long('15') },
priorityAtElection: 1,
newTermStartDate: ISODate('2024-06-02T15:57:44.142Z'),
newTermAppliedDate: ISODate('2024-06-02T15:57:44.161Z')
},
members: [
{
_id: 0,
name: '127.0.0.1:37017',
health: 1,
state: 2,
stateStr: 'SECONDARY',
uptime: 198,
optime: { ts: Timestamp({ t: 1717344044, i: 1 }), t: Long('17') },
optimeDate: ISODate('2024-06-02T16:00:44.000Z'),
optimeWritten: { ts: Timestamp({ t: 1717344044, i: 1 }), t: Long('17') },
optimeWrittenDate: ISODate('2024-06-02T16:00:44.000Z'),
lastAppliedWallTime: ISODate('2024-06-02T16:00:44.211Z'),
lastDurableWallTime: ISODate('2024-06-02T16:00:44.211Z'),
lastWrittenWallTime: ISODate('2024-06-02T16:00:44.211Z'),
syncSourceHost: '127.0.0.1:37019',
syncSourceId: 2,
infoMessage: '',
configVersion: 1,
configTerm: 17,
self: true,
lastHeartbeatMessage: ''
},
{
_id: 1,
name: '127.0.0.1:37018',
health: 1,
state: 2,
stateStr: 'SECONDARY',
uptime: 193,
optime: { ts: Timestamp({ t: 1717344044, i: 1 }), t: Long('17') },
optimeDurable: { ts: Timestamp({ t: 1717344044, i: 1 }), t: Long('17') },
optimeWritten: { ts: Timestamp({ t: 1717344044, i: 1 }), t: Long('17') },
optimeDate: ISODate('2024-06-02T16:00:44.000Z'),
optimeDurableDate: ISODate('2024-06-02T16:00:44.000Z'),
optimeWrittenDate: ISODate('2024-06-02T16:00:44.000Z'),
lastAppliedWallTime: ISODate('2024-06-02T16:00:44.211Z'),
lastDurableWallTime: ISODate('2024-06-02T16:00:44.211Z'),
lastWrittenWallTime: ISODate('2024-06-02T16:00:44.211Z'),
lastHeartbeat: ISODate('2024-06-02T16:00:47.085Z'),
lastHeartbeatRecv: ISODate('2024-06-02T16:00:47.052Z'),
pingMs: Long('0'),
lastHeartbeatMessage: '',
syncSourceHost: '127.0.0.1:37019',
syncSourceId: 2,
infoMessage: '',
configVersion: 1,
configTerm: 17
},
{
_id: 2,
name: '127.0.0.1:37019',
health: 1,
state: 1,
stateStr: 'PRIMARY',
uptime: 193,
optime: { ts: Timestamp({ t: 1717344044, i: 1 }), t: Long('17') },
optimeDurable: { ts: Timestamp({ t: 1717344044, i: 1 }), t: Long('17') },
optimeWritten: { ts: Timestamp({ t: 1717344044, i: 1 }), t: Long('17') },
optimeDate: ISODate('2024-06-02T16:00:44.000Z'),
optimeDurableDate: ISODate('2024-06-02T16:00:44.000Z'),
optimeWrittenDate: ISODate('2024-06-02T16:00:44.000Z'),
lastAppliedWallTime: ISODate('2024-06-02T16:00:44.211Z'),
lastDurableWallTime: ISODate('2024-06-02T16:00:44.211Z'),
lastWrittenWallTime: ISODate('2024-06-02T16:00:44.211Z'),
lastHeartbeat: ISODate('2024-06-02T16:00:47.084Z'),
lastHeartbeatRecv: ISODate('2024-06-02T16:00:46.552Z'),
pingMs: Long('0'),
lastHeartbeatMessage: '',
syncSourceHost: '',
syncSourceId: -1,
infoMessage: '',
electionTime: Timestamp({ t: 1717343864, i: 1 }),
electionDate: ISODate('2024-06-02T15:57:44.000Z'),
configVersion: 1,
configTerm: 17
}
],
ok: 1,
'$clusterTime': {
clusterTime: Timestamp({ t: 1717344044, i: 1 }),
signature: {
hash: Binary.createFromBase64('AAAAAAAAAAAAAAAAAAAAAAAAAAA=', 0),
keyId: Long('0')
}
},
operationTime: Timestamp({ t: 1717344044, i: 1 })
}
and I'm going to write that
Enterprise shard0 [direct: secondary] test> show dbs
admin 40.00 KiB
config 112.00 KiB
local 460.00 KiB
mydatabase 40.00 KiB
Enterprise shard0 [direct: secondary] test> use mydatabase
switched to db mydatabase
Enterprise shard0 [direct: secondary] mydatabase> sh.enableSharding("mydatabase")
MongoServerError[CommandNotFound]: no such command: 'enableSharding'. Are you connected to mongos?
Enterprise shard0 [direct: secondary] mydatabase>
that always say no such command why that happen?