Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No shards? #12

Closed
richmondwang opened this issue Apr 6, 2018 · 4 comments
Closed

No shards? #12

richmondwang opened this issue Apr 6, 2018 · 4 comments

Comments

@richmondwang
Copy link

Just reading on the documentation, It seems that there are no shards added after completing the instructions.

--- 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:

Isn't the line shards: supposed to contain the added shards?
Is this setup include automatic adding of shards?

@senssei
Copy link
Owner

senssei commented Apr 6, 2018

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 } }

@senssei
Copy link
Owner

senssei commented Apr 6, 2018

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:

@senssei
Copy link
Owner

senssei commented Apr 9, 2018

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

@richmondwang
Copy link
Author

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

@senssei senssei closed this as completed Apr 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants