Local setup MongoDB server with replication set using docker-compose
The MongoDB database connector uses transactions to support nested writes. We get errors if we try to actually write to a database that does not have replication.
- Use MongoDB Atlas. It is a free-service where we can create MongoDB cluster that supports replication.
- Setup a local MongoDB server with replication
- Docker (docker-compose)
- YAML
- Bash
Clone the project
$ git clone git@github.com:AlaeddineMessadi/Mongodb-Replica-Set-docker-compose.git mongodb-replset
Go to the project directory
$ cd mongodb-replset
Start the server
$ ./start.sh
If you didn't use ./start.sh
script, then you should run $ docker exec mongo1 /scripts/init.sh
after your run $ docker-compose up -d
to initialize replica set in your servers.
Stop the server
$ ./stop.sh
# or
$ docker-compose down
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.