You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.
# How to create replicaset for mongodb in docker container
# Before doing step below, please configure your username or password by edit file named 'docker-compose.yml' and './setup/setup.sh'
1.) Compose first with `docker-compose build` or you can use `docker-compose up` for build & run.
2.) When compose done, connect to your primary container by using this `docker-compose exec mongo-rs0-1 mongo -u "root" -p "root"`.
3.) And when mongo shell popup, you need to check is it primary or secondary by `db.isMaster()`.
a.) You got some returned value, check the object value called by `"ismaster" : true` or `"primary" : "mongo-rs0-1:27017"`.
b.) When it's in primary cluster, continue to step 4. When it's not, continue to 3b.
c.) To make your current cluster become primary, execute command below (one by one)
`cfg = rs.conf();`
`cfg.members[0].priority = 2;`
`rs.reconfig(cfg);`
d.) Now check the cluster state again, is it primary or not?
4.) Create or Add user to your admin database by using this `db.createUser({user: "admin",pwd: "admin",roles: [ { role: "userAdminAnyDatabase", db: "admin" }, { "role" : "clusterAdmin", "db" : "admin" } ]});`
5.) Now you're done :D
NB: All command you have/want to execute without the tick (`)