§2023-07-29

Now, we got the following up and running, we will intialize the replicationSet MuneTakaHome

Machine IP OS mongod Version Replication Set momgosh Avialbale Saharding
orgpi5Arch.yushei.net 192.168.48.241 Orange Pi 5 Plus, 16G mem, PCIeSSD 256G Archlinux 7.0.0-rc8 MuneTakaHome:27999 1.10.1 no ssl No
orgpi5Jammy.yushei.net 192.168.48.247 Orange Pi 5 Plus, 8G mem, PCIeSSD 256G Ubuntu Jammy 7.0.0-rc8 MuneTakaHome:27999 1.10.1 no ssl No

¶Step 1

From orgpi5Arch.yushei.net

[alexlai@orpi5Arch ~]$ mongosh
Current Mongosh Log ID: 64c4cc376be54269d3dd4d36
Connecting to:          mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.10.1
MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017
[alexlai@orpi5Arch ~]$ mongosh mongodb://orgpi5Arch.yushei.net:27999
Current Mongosh Log ID: 64c4cc52825284e6c3427698
Connecting to:          mongodb://orgpi5Arch.yushei.net:27999/?directConnection=true&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/

Hi! from orgpi5Arch.yushei.net:27999
admin> db.createUser( {
user: "siteRootAdmin",
pwd: "b2nnnnnnn",    <-- ⚠️
roles: [ { role: "root", db: "admin" } ]
});
{ ok: 1 }
admin> exit

db.updateUser("", { pwd: "<new_password>" })

again,

$ mongosh mongodb://orgpi5Arch.yushei.net:27999
Current Mongosh Log ID: 64c4ce5731a24f6c883031a0
Connecting to:          mongodb://orgpi5Arch.yushei.net:27999/?directConnection=true&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/

Hi! from orgpi5Arch.yushei.net:27999
admin> db.auth("siteRootAdmin", "b23258585")
{ ok: 1 }

// initialize a repliactionSet

admin> rs.initiate({
  _id: "MuneTakaHome",
  members: [
    { _id: 0, host: "orgpi5Arch.yushei.net:27999" },
    { _id: 1, host: "orgpi5Jammy.yushei.net:27999" },
    // Add other replica set members here
  ]
});

{ ok: 1 }

MuneTakaHome [direct: other] admin> rs.conf()
{
  _id: 'MuneTakaHome',
  version: 1,
  term: 1,
  members: [
    {
      _id: 0,
      host: 'orgpi5Arch.yushei.net:27999',
      arbiterOnly: false,
      buildIndexes: true,
      hidden: false,
      priority: 1,
      tags: {},
      secondaryDelaySecs: Long("0"),
      votes: 1
    },
    {
      _id: 1,
      host: 'orgpi5Jammy.yushei.net:27999',
      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("64c4d3e6e644cb13b7ff1910")
  }
}