Coder Social home page Coder Social logo

mongo-cluster-docker's Introduction

mongo-cluster-docker

This is a simple 3 node replica mongodb setup based on official mongo docker image using docker-compose described in my blogpost at https://warzycha.pl/mongo-db-sharding-docker-example/.

For details description, steps and discussion go to:

  1. https://warzycha.pl/mongo-db-sharding-docker-example/
  2. https://warzycha.pl/mongo-db-shards-by-location/

Run

docker-compose -f docker-compose.1.yml -f docker-compose.2.yml  -f docker-compose.cnf.yml -f docker-compose.shard.yml up

Tests

Manually for the time being

  1. Core tests

Basic replica test on rs1 replica set (data nodes), mongo-1-1

rs.status();

this should return in members 3 nodes.

Basic sharding test on router (mongos), mongo-router

sh.status();

this should return something similar to:

--- Sharding Status --- 
  sharding version: {
	"_id" : 1,
	"minCompatibleVersion" : 5,
	"currentVersion" : 6,
	"clusterId" : ObjectId("587d306454828b89adaca524")
}
  shards:
  active mongoses:
	"3.4.1" : 1
  balancer:
	Currently enabled:  yes
	Currently running:  yes
		Balancer lock taken at Mon Jan 16 2017 22:18:53 GMT+0100 by ConfigServer:Balancer
	Failed balancer rounds in last 5 attempts:  0
	Migration Results for the last 24 hours: 
		No recent migrations
  databases:

Sharding configuration

Connect to 'mongos' router and run queries/shard-status.js for shard status.

To establish location based partitioning on it just run queries/init.js.

Issues and limitations

It's sometimes stuck on 'mongo-router | 2017-01-16T21:29:48.573+0000 W NETWORK [replSetDistLockPinger] No primary detected for set cnf-serv'. It's because quite random order in docker-compose.

My workaround was just to kill all containers related.

docker-compose -f docker-compose.1.yml -f docker-compose.2.yml  -f docker-compose.cnf.yml -f docker-compose.shard.yml rm -f

Please pull request. :)

Basically mongosetup service is now splitted to multiple yml files. :)

Reference

See more @ ENV.md

MIT @ LICENSE

mongo-cluster-docker's People

Contributors

senssei avatar

Watchers

Thiago Magalhães avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.