ยง2023-07-30

initialize the replcationSet just use rs.initiate() without any arguments

[alexlai@n2Mnjaro ~]$ mongosh mongodb://localhost:27995
Current Mongosh Log ID: 64c61bddad43ef93ee2c092c
Connecting to:          mongodb://localhost:27995/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.10.1
Using MongoDB:          7.0.0-rc8
Using Mongosh:          1.10.1

For mongosh info see: https://docs.mongodb.com/mongodb-shell/

------
   The server generated these startup warnings when booting
   2023-07-30T15:50:54.674+08:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
   2023-07-30T15:50:54.675+08:00: vm.max_map_count is too low
------

test> rs.initiate()
{
  info2: 'no configuration specified. Using a default configuration for the set',
  me: 'n2Mnjaro:27995',
  ok: 1
}
MuneTakaShard [direct: other] test> exit
[alexlai@n2Mnjaro ~]$ mongosh mongodb://localhost:27995
Current Mongosh Log ID: 64c61c768af3995a7f18bd5a
Connecting to:          mongodb://localhost:27995/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.10.1
Using MongoDB:          7.0.0-rc8
Using Mongosh:          1.10.1

For mongosh info see: https://docs.mongodb.com/mongodb-shell/

------
   The server generated these startup warnings when booting
   2023-07-30T15:50:54.674+08:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
   2023-07-30T15:50:54.675+08:00: vm.max_map_count is too low
------

MuneTakaShard [direct: primary] test> use admin
switched to db admin
MuneTakaShard [direct: primary] admin> rs.status()
{
  set: 'MuneTakaShard',
  date: ISODate("2023-07-30T08:17:08.975Z"),
  myState: 1,
  term: Long("1"),
  syncSourceHost: '',
  syncSourceId: -1,
  heartbeatIntervalMillis: Long("2000"),
  majorityVoteCount: 1,
  writeMajorityCount: 1,
  votingMembersCount: 1,
  writableVotingMembersCount: 1,
  optimes: {
    lastCommittedOpTime: { ts: Timestamp({ t: 1690705028, i: 1 }), t: Long("1") },
    lastCommittedWallTime: ISODate("2023-07-30T08:17:08.475Z"),
    readConcernMajorityOpTime: { ts: Timestamp({ t: 1690705028, i: 1 }), t: Long("1") },
    appliedOpTime: { ts: Timestamp({ t: 1690705028, i: 1 }), t: Long("1") },
    durableOpTime: { ts: Timestamp({ t: 1690705028, i: 1 }), t: Long("1") },
    lastAppliedWallTime: ISODate("2023-07-30T08:17:08.475Z"),
    lastDurableWallTime: ISODate("2023-07-30T08:17:08.475Z")
  },
  lastStableRecoveryTimestamp: Timestamp({ t: 1690704988, i: 1 }),
  electionCandidateMetrics: {
    lastElectionReason: 'electionTimeout',
    lastElectionDate: ISODate("2023-07-30T08:14:37.182Z"),
    electionTerm: Long("1"),
    lastCommittedOpTimeAtElection: { ts: Timestamp({ t: 1690704876, i: 1 }), t: Long("-1") },
    lastSeenOpTimeAtElection: { ts: Timestamp({ t: 1690704876, i: 1 }), t: Long("-1") },
    numVotesNeeded: 1,
    priorityAtElection: 1,
    electionTimeoutMillis: Long("10000"),
    newTermStartDate: ISODate("2023-07-30T08:14:37.903Z"),
    wMajorityWriteAvailabilityDate: ISODate("2023-07-30T08:14:38.550Z")
  },
  members: [
    {
      _id: 0,
      name: 'n2Mnjaro:27995',
      health: 1,
      state: 1,
      stateStr: 'PRIMARY',
      uptime: 1575,
      optime: { ts: Timestamp({ t: 1690705028, i: 1 }), t: Long("1") },
      optimeDate: ISODate("2023-07-30T08:17:08.000Z"),
      lastAppliedWallTime: ISODate("2023-07-30T08:17:08.475Z"),
      lastDurableWallTime: ISODate("2023-07-30T08:17:08.475Z"),
      syncSourceHost: '',
      syncSourceId: -1,
      infoMessage: '',
      electionTime: Timestamp({ t: 1690704877, i: 1 }),
      electionDate: ISODate("2023-07-30T08:14:37.000Z"),
      configVersion: 1,
      configTerm: 1,
      self: true,
      lastHeartbeatMessage: ''
    }
  ],
  ok: 1,
  '$clusterTime': {
    clusterTime: Timestamp({ t: 1690705028, i: 1 }),
    signature: {
      hash: Binary(Buffer.from("0000000000000000000000000000000000000000", "hex"), 0),
      keyId: Long("0")
    }
  },
  operationTime: Timestamp({ t: 1690705028, i: 1 })
}
MuneTakaShard [direct: primary] admin> 
alexlai@hc4Jammy:~$ mongosh mongodb://localhost:27995
Current Mongosh Log ID: 64c61cbd5fea4feab23b8cce
Connecting to:          mongodb://localhost:27995/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.10.1
Using MongoDB:          7.0.0-rc8
Using Mongosh:          1.10.1

For mongosh info see: https://docs.mongodb.com/mongodb-shell/

------
   The server generated these startup warnings when booting
   2023-07-30T16:03:12.761+08:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
------

Hello
test> use admin
switched to db admin
admin> rs.initiate()
{
  info2: 'no configuration specified. Using a default configuration for the set',
  me: 'hc4Jammy:27995',
  ok: 1
}
MunetakaShard [direct: other] admin> rs.status
[Function: status] AsyncFunction {
  apiVersions: [ 0, 0 ],
  returnsPromise: true,
  serverVersions: [ '0.0.0', '999.999.999' ],
  topologies: [ 'ReplSet', 'Sharded', 'LoadBalanced', 'Standalone' ],
  returnType: { type: 'unknown', attributes: {} },
  deprecated: false,
  platforms: [ 'Compass', 'Browser', 'CLI' ],
  isDirectShellCommand: false,
  acceptsRawInput: false,
  shellCommandCompleter: undefined,
  help: [Function (anonymous)] Help
}
MunetakaShard [direct: primary] admin>