Skip to content

Database Replication - MongoDB ReplicaSets #11

@shehabadel

Description

@shehabadel
  1. Create mongos directory with folders db1, db2, and db3
  2. Run mongod --replSet Dist --dbpath mongos/db1 --port 27018
  3. Run mongod --replSet Dist --dbpath mongos/db2 --port 27019
  4. Run mongod --replSet Dist --dbpath mongos/db3 --port 27020
  5. In case replicaSet error or it is not initiliazed
  • Run mongosh --port 27018
  • Write
rsconfig={_id:"Dist",
members:[
{_id:0, host:"localhost:27018"},
{_id:1, host:"localhost:27019"},
{_id:2, host:"localhost:27020"}
]}
  • Run rs.initiate(rsconfig)
  • It must be working now!
  1. Run rs.status() to make sure it is working well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions