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.ymlwithMONGODB_ROOT_PASSWORDfield, you can change it mongo_mongodb-primary_1it's name docker container, you can change it with fieldcontainer_nameindocker-composefile
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 --buildrs.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-primaryif you change it indocker-compose.ymlwithMONGODB_ADVERTISED_HOSTNAMEfield, 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