Giter Club home page Giter Club logo

Comments (4)

senssei avatar senssei commented on July 17, 2024 1

Thanks for asking. Yes, that is true. In this docker-compose there is no shards defined, only configuration for single logical shard instance on 3 nodes.

To create sample shard on it please follow instructions from https://warzycha.pl/mongo-db-shards-by-location/.

Afterwards you should get something like this:

--- Sharding Status --- 
  sharding version: {
    "_id" : 1,
    "minCompatibleVersion" : 5,
    "currentVersion" : 6,
    "clusterId" : ObjectId("58a1bfb6b0ad6efb4f160875")
}
  shards:
    {  "_id" : "rs1",  "host" : "rs1/172.18.0.10:27017,172.18.0.4:27017,172.18.0.5:27017",  "state" : 1,  "tags" : [ "US" ] }
    {  "_id" : "rs2",  "host" : "rs2/172.18.0.3:27017,172.18.0.7:27017,172.18.0.8:27017",  "state" : 1,  "tags" : [ "EU" ] }
  active mongoses:
    "3.4.1" : 1
  balancer:
    Currently enabled:  yes
    Currently running:  yes
        Balancer lock taken at Mon Feb 13 2017 15:16:28 GMT+0100 (Central Europe Standard Time) by ConfigServer:Balancer
    Failed balancer rounds in last 5 attempts:  0
    Migration Results for the last 24 hours: 
        1 : Success
  databases:
    {  "_id" : "test",  "primary" : "rs1",  "partitioned" : true }
        test.sample
            shard key: { "location" : 1, "_id" : 1 }
            unique: false
            balancing: true
            chunks:
                rs1 4
                rs2 1
            { "location" : { "$minKey" : 1 }, "_id" : { "$minKey" : 1 } } -->> { "location" : "EU", "_id" : { "$minKey" : 1 } } on : rs1 Timestamp(2, 1) 
            { "location" : "EU", "_id" : { "$minKey" : 1 } } -->> { "location" : "EU", "_id" : { "$maxKey" : 1 } } on : rs2 Timestamp(2, 0) 
            { "location" : "EU", "_id" : { "$maxKey" : 1 } } -->> { "location" : "US", "_id" : { "$minKey" : 1 } } on : rs1 Timestamp(1, 3) 
            { "location" : "US", "_id" : { "$minKey" : 1 } } -->> { "location" : "US", "_id" : { "$maxKey" : 1 } } on : rs1 Timestamp(1, 4) 
            { "location" : "US", "_id" : { "$maxKey" : 1 } } -->> { "location" : { "$maxKey" : 1 }, "_id" : { "$maxKey" : 1 } } on : rs1 Timestamp(1, 5) 
             tag: EU  { "location" : "EU", "_id" : { "$minKey" : 1 } } -->> { "location" : "EU", "_id" : { "$maxKey" : 1 } }
             tag: US  { "location" : "US", "_id" : { "$minKey" : 1 } } -->> { "location" : "US", "_id" : { "$maxKey" : 1 } }

from mongo-cluster-docker.

senssei avatar senssei commented on July 17, 2024

Moreover, I think it could be done as additional shell commands in mongo-cluster-docker/scripts/init-shard.sh.

I did not put any shard configuration in it to provide generic environment for configuring any shard example - not only based on location as in my example.

You can read more here:

from mongo-cluster-docker.

senssei avatar senssei commented on July 17, 2024

@richmondwang If my answer is ok with you I will close this issue and create a separate one for the enhancement.

from mongo-cluster-docker.

richmondwang avatar richmondwang commented on July 17, 2024

@senssei Yes, you can close this.. thank you! :)

from mongo-cluster-docker.

Related Issues (16)

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.