Software must install before reading
- Docker
- Docker-compse
- Run docker-compose.yml
docker-compose up --detach
- To check status replica
docker exec -it mongo_mongodb-primary_1 mongo -u root
- Password in
docker-compose.yml
withMONGODB_ROOT_PASSWORD
field, you can change it mongo_mongodb-primary_1
it's name docker container, you can change it with fieldcontainer_name
indocker-compose
file
After that, enter code at below to terminal docker
replicaset:PRIMARY> rs.status();
you will see all config of replica set of cluster
- That shut-down the replica set
docker-compose down
- Remove network if you remove images don't use
docker-compose down
docker network prune
- Restart or rebuild
docker-compose up --detach --build
rs.status()
: checks status of the Replica setrs.initiate()
: initiates set with default settingsrs.conf()
: get the current configuration objectrs.add(hostportstr)
: add a new member to the setrs.remove(hostportstr)
: remove a host from the replica setrs.printReplicationInfo()
: check oplog size and time rangers.printSecondaryReplicationInfo()
: check replica set members and replication lagdb.isMaster()
: check who is primarydb.hello()
: check who is primary
- Every change, you must remove or edit config mongodb
- You should change file
host
127.0.0.1 mongodb-primary
mongodb-primary
if you change it indocker-compose.yml
withMONGODB_ADVERTISED_HOSTNAME
field, then you must change it's
- mkdir: cannot create directory
'/bitnami/mongodb/data'
: Operation not permitted
sudo chown -R 1001 /data/mongo
- /data/mongo:
Read file link