Skip to content
This repository has been archived by the owner on May 31, 2019. It is now read-only.

Latest commit

 

History

History
51 lines (34 loc) · 1.44 KB

README.md

File metadata and controls

51 lines (34 loc) · 1.44 KB

mongodb-sharding-docker-compose

🐳 docker-compose stack that allows you to turn on a full MongoDB sharded cluster with the following components :

  • configserver replicaset: 3x mongod with configsrv enabled
  • first replicaset shard: 3x mongod
  • second replicaset shard: 3x mongod
  • third replicaset shard: 3x mongod
  • mongo query router: 1x mongos
  • authentication enabled + global auth key certificate between nodes

⚠️ Of course this is for development purpose only

# Usage :
$ git clone [email protected]:jfollenfant/mongodb-sharding-docker-compose.git
$ mongodb-sharding-docker-compose
$ ./up.sh

You can also edit mongo-auth.init.js to change admin credentials before turning up the cluster

admin = db.getSiblingDB("admin")
admin.createUser(
  {
     user: "admin",
     pwd: "admin",
     roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] 
  }
)

🍹 Then you should be able to log into the cluster:

$ docker exec -it mongodbdocker_mongo-router-01_1 mongo admin  -u'admin' -p'admin'
MongoDB shell version v3.4.2
connecting to: mongodb://127.0.0.1:27017/admin
MongoDB server version: 3.4.2
mongos>

🍺 And turn it down with:

$ ./down.sh

TODO 🚧

  • Generate random data to populate shards through balancing
  • Update compose syntax to v3
  • Use swarm capabilities for production grade deployment