MongoDB HA deployment with docker
MongoDB HA deployment with docker
· Docker (version 17.09.0-ce used).
· Linux OS (Ubuntu 16.04 Distribution used).
To pull the images from the repo:
# ./pull_containers.sh
To build images from local project:
# ./build_containers.sh
To deploy our mongodb cluster with the default configuration:
# ./run_all.sh
To check that all is working ok:
# mongo --host 172.18.0.10 Requirement --eval 'db.Requirements.insertOne({"Granada": "Alhambra"})'
# mongo --host 172.18.0.10 Requirement --eval 'db.Requirements.find()'
If it goes well, now you have to bring down the primary mongodb:
# docker stop mongodb_1
After that, you have to request again for the content of the Requirements collection:
# mongo --host 172.18.0.10 Requirement --eval 'db.Requirements.find()'
If it does not respond in the first request, try again (the cluster has to reconfigure).
The respond must be the same ({“Granada”: “Alhambra”}).
To remove the containers:
# ./remove_containers.sh