Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup Mongo Replica Set for gate and mold #11

Open
yentsun opened this issue Nov 9, 2020 · 6 comments
Open

Setup Mongo Replica Set for gate and mold #11

yentsun opened this issue Nov 9, 2020 · 6 comments
Assignees

Comments

@yentsun
Copy link
Owner

yentsun commented Nov 9, 2020

A replica set needs to be setup

@yentsun yentsun self-assigned this Nov 9, 2020
@yentsun
Copy link
Owner Author

yentsun commented Nov 10, 2020

How Mongo distiguish read/write members of replica set: https://docs.mongodb.com/manual/applications/replication/

We probably just need to define primary replica, which will have the write previledge.

@yentsun
Copy link
Owner Author

yentsun commented Nov 10, 2020

Write concern is set during doc insertion time (or in a global config).

  • w: 1 means doc will be inserted into primary replica (probably what we need)
  • w: "majority" means the doc insertion will wait for it to reach majority of replicas (not what we need)

@yentsun
Copy link
Owner Author

yentsun commented Nov 10, 2020

Read preference could be set to secondary to direct read operation to secondary replicas only https://docs.mongodb.com/manual/core/read-preference/

@yentsun
Copy link
Owner Author

yentsun commented Nov 10, 2020

Actual replicaset setup on local: https://docs.mongodb.com/manual/tutorial/deploy-replica-set-for-testing/

@yentsun
Copy link
Owner Author

yentsun commented Nov 10, 2020

Launching alpha (primary) replica:

C:\"Program Files"\MongoDB\Server\4.2\bin\mongod --replSet rs0 --port 27017 --bind_ip localhost --dbpath C:\mongoReplicas\alpha --oplogSize 128

bravo (secondary)

C:\"Program Files"\MongoDB\Server\4.2\bin\mongod --replSet rs0 --port 27018 --bind_ip localhost --dbpath C:\mongoReplicas\bravo --oplogSize 128

delta (secondary)

C:\"Program Files"\MongoDB\Server\4.2\bin\mongod --replSet rs0 --port 27019 --bind_ip localhost --dbpath C:\mongoReplicas\delta --oplogSize 128

ReplicaSet config:

rsconf = {
    _id: "rs0",
    members: [
        { _id: 0,
          tags: { name: "alpha" },
          priority: 10,
          host: "localhost:27017" },

        { _id: 1,
          tags: { name: "bravo" },
          priority: 0,
          host: "localhost:27018" },

        { _id: 2,
          tags: { name: "delta" },
          priority: 0,
          host: "localhost:27019" }
    ]
}

@yentsun
Copy link
Owner Author

yentsun commented Nov 10, 2020

TODO:

  • How to designate a primary replica

@yentsun yentsun changed the title Setup dual MongoDB for gate and mold Setup Mongo Replica Set for gate and mold Nov 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant