{"id":15571434,"url":"https://github.com/hatamiarash7/mongodb_replica","last_synced_at":"2026-05-07T10:34:45.726Z","repository":{"id":73239743,"uuid":"237941438","full_name":"hatamiarash7/MongoDB_Replica","owner":"hatamiarash7","description":"MongoDB Replica Set on Docker ( Swarm Mode )","archived":false,"fork":false,"pushed_at":"2024-04-01T20:41:35.000Z","size":11,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-25T08:36:28.095Z","etag":null,"topics":["docker","docker-swarm","high-availability","mongo","mongodb","mongodb-database","replica","replica-set","replicaset","replicated","replication"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hatamiarash7.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-03T10:39:05.000Z","updated_at":"2020-10-22T02:53:02.000Z","dependencies_parsed_at":"2024-10-02T18:00:36.166Z","dependency_job_id":"e53607ae-08c8-400d-b005-b9978f439c2e","html_url":"https://github.com/hatamiarash7/MongoDB_Replica","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hatamiarash7/MongoDB_Replica","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hatamiarash7%2FMongoDB_Replica","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hatamiarash7%2FMongoDB_Replica/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hatamiarash7%2FMongoDB_Replica/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hatamiarash7%2FMongoDB_Replica/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hatamiarash7","download_url":"https://codeload.github.com/hatamiarash7/MongoDB_Replica/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hatamiarash7%2FMongoDB_Replica/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32733666,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-07T02:14:30.463Z","status":"ssl_error","status_checked_at":"2026-05-07T02:14:29.405Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-swarm","high-availability","mongo","mongodb","mongodb-database","replica","replica-set","replicaset","replicated","replication"],"created_at":"2024-10-02T18:00:25.278Z","updated_at":"2026-05-07T10:34:45.711Z","avatar_url":"https://github.com/hatamiarash7.png","language":"Shell","funding_links":["https://ko-fi.com/D1D1WGU9"],"categories":[],"sub_categories":[],"readme":"# MongoDB_Replica\n\nRunning Mongo DB Replica Set on three different server by Docker Swarm.\n\nThe oplog size sets to 3 MB, because of 5% of free disk space.\n\n### Initialize Manager Node\n\n    docker swarm init --listen-addr *manager-ip:2377* --advertise-addr *manager-ip*\n\n*Output*\n\n    $ docker swarm init --advertise-addr *manager-ip*\n    Swarm initialized: current node (wvkk65249ch286431df31) is now a manager.\n\n    To add a worker to this swarm, run the following command:\n\n        docker swarm join \\\n        --token *token* \\\n        *manager-ip*\n\n    To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.\n\n### Join Worker Nodes into network\n\n    docker swarm join --token *token* *manager-ip*\n\n### Setup Mongo DB on each node\n\nFirst, you should update label on each node :\n\n    ssh \u003c-- The manager node server --\u003e\n    docker node update --label-add replica=1 *manager-ip*\n    docker node update --label-add replica=2 *worker1-ip*\n    docker node update --label-add replica=3 *worker2-ip*\n\nSecond, deploy service on manager node :\n\n    ssh \u003c-- The manager node server --\u003e\n    docker stack deploy -c docker-stack.yml overlay\n\nAnd, you should login *Manager node* and run the under command :\n\n    ./initiate.sh\n\n    # // if publish port was set before, need to remove first and update it.\n    # docker service update --publish-rm 27017:27017 mongo_replica_mongo1\n\n    docker service update --publish-add 27017:27017 mongo_replica_mongo1\n\n## Persistent storage\n\nData is stored at `Docker Swarm Volume`, if you want to check the `Mountpoint` on physical machine. Running the following command:\n\n    docker volume inspect *service name*\n\nData will be persistent between service runs. To remove docker stack and all data. Run the following command:\n\n    docker stack rm overlay\n    docker volume rm $(docker volume ls -qf label=com.docker.stack.namespace=mongo_replica)\n\nLeave smarm mode\n\n    docker swarm leave\n\n## Run example project\n\nLet's run Koalab :\n\n    docker service create --env 'MONGO_URL=mongodb://mongo1:27017,mongo2:27017,mongo3:27017/koalab?replicaSet=rs1' --name koalab --network mongo --replicas 2 --publish 8080:8080 kalahari/koalab\n\n## Reference\n\n- [Docker Swarm Document](https://docs.docker.com/engine/reference/commandline/swarm_init)\n- [Learning note about Docker Swarm Mode](http://www.evanlin.com/til-2016-07-13/)\n- [Mongo Documentation - mongod](https://docs.mongodb.com/manual/reference/program/mongod/)\n- [Running a MongoDB Replica Set on Docker 1.12 Swarm Mode: Step by Step](https://medium.com/@kalahari/running-a-mongodb-replica-set-on-docker-1-12-swarm-mode-step-by-step-a5f3ba07d06e)\n\n---\n\n## Support\n\n[![ko-fi](https://www.ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/D1D1WGU9)\n\n\u003cdiv\u003e\u003ca href=\"https://payping.ir/@hatamiarash7\"\u003e\u003cimg src=\"https://cdn.payping.ir/statics/Payping-logo/Trust/blue.svg\" height=\"128\" width=\"128\"\u003e\u003c/a\u003e\u003c/div\u003e\n\n## Contributing\n\n1. Fork it !\n2. Create your feature branch : `git checkout -b my-new-feature`\n3. Commit your changes : `git commit -am 'Add some feature'`\n4. Push to the branch : `git push origin my-new-feature`\n5. Submit a pull request :D\n\n## Issues\n\nEach project may have many problems. Contributing to the better development of this project by reporting them.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhatamiarash7%2Fmongodb_replica","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhatamiarash7%2Fmongodb_replica","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhatamiarash7%2Fmongodb_replica/lists"}