Comments (4)
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.
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:
- https://docs.mongodb.com/manual/tutorial/sharding-tiered-hardware-for-varying-slas/
- https://docs.mongodb.com/manual/tutorial/sharding-segmenting-shards/
from mongo-cluster-docker.
@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.
@senssei Yes, you can close this.. thank you! :)
from mongo-cluster-docker.
Related Issues (16)
- Add sample sharding with index.
- Not working ping on docker container
- Update docs with latest and upcoming mongo
- Mongodb cluster Docker Unable to connect from other machine to Docker host machine (Centos 7) HOT 4
- Invalid `--rest` parameters on `mongo-cnf`
- Support for replication protocol version 0 was removed in MongoDB 4.0.
- MongoDB 4.0, you cannot specify --nojournal in replica set on wiredTiger engine
- Where The Data Path Setting? HOT 2
- replSetGetStatus is not supported through mongos HOT 1
- dont work in sworm HOT 1
- No primary detected for set cnf-serv HOT 8
- Missing support for proper healthchecks HOT 4
- Missing chmod +x
- scripts need the execute permission
- I have a bit of a problem. HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mongo-cluster-docker.