File tree Expand file tree Collapse file tree 3 files changed +65
-1
lines changed Expand file tree Collapse file tree 3 files changed +65
-1
lines changed Original file line number Diff line number Diff line change 22
33Simple 3 node replica mongodb on offcial ` mongo ` docker image using ` docker-compose ` .
44
5+ For details description, steps and discussion go to:
6+
7+ 1 . https://warzycha.pl/mongo-db-sharding-docker-example/
8+ 2 . https://warzycha.pl/mongo-db-location-based-segments/
9+
510# Run
611
712```
8- > docker-compose -f docker-compose.1.yml -f docker-compose.2.yml -f docker-compose.cnf.yml -f docker-compose.shard.yml up
13+ docker-compose -f docker-compose.1.yml -f docker-compose.2.yml -f docker-compose.cnf.yml -f docker-compose.shard.yml up
914```
1015
1116# Tests
@@ -49,6 +54,12 @@ this should return something similar to:
4954
5055```
5156
57+ # Sharding configuration
58+
59+ Connect to 'mongos' router and run ` queries/shard-status.js ` for shard status.
60+
61+ To establish location based partitioning on it just run ` queries/init.js ` .
62+
5263# Issues and limitations
5364
5465It's sometimes stuck on 'mongo-router | 2017-01-16T21:29:48.573+0000 W NETWORK [ replSetDistLockPinger] No primary detected for
Original file line number Diff line number Diff line change 1+ sh . removeShardTag ( "rs1" , "US" ) ;
2+
3+ sh . removeShardTag ( "rs2" , "EU" ) ;
4+
5+ sh . addShardTag ( "rs1" , "US" ) ;
6+
7+ sh . addShardTag ( "rs2" , "EU" ) ;
8+
9+ sh . disableBalancing ( "test.sample" ) ;
10+
11+ db . sample . drop ( ) ;
12+
13+ db . createCollection ( "sample" ) ;
14+
15+ db . sample . createIndex ( { location : 1 , _id : 1 } )
16+
17+ sh . addTagRange (
18+ "test.sample" ,
19+ { "location" : "US" , "_id" : MinKey } ,
20+ { "location" : "US" , "_id" : MaxKey } ,
21+ "US"
22+ ) ;
23+
24+ sh . addTagRange (
25+ "test.sample" ,
26+ { "location" : "EU" , "_id" : MinKey } ,
27+ { "location" : "EU" , "_id" : MaxKey } ,
28+ "EU"
29+ )
30+
31+
32+ sh . enableSharding ( "test" ) ;
33+
34+ sh . shardCollection ( "test.sample" , { location : 1 , _id : 1 } ) ;
35+
36+ sh . enableBalancing ( "test.sample" ) ;
37+
38+ db . sample . insert ( {
39+ "_id" : ObjectId ( "5787936b94afebe02398521a" ) ,
40+ "location" : "US" ,
41+ "__v" : 0
42+ } ) ;
43+
44+ db . sample . insert ( {
45+ "_id" : ObjectId ( "5787a08c94afebe023985224" ) ,
46+ "location" : "EU" ,
47+ "__v" : 0
48+ } ) ;
49+
50+ sh . startBalancer ( ) ;
51+
52+ db . sample . find ( ) ;
Original file line number Diff line number Diff line change 1+ sh . status ( ) ;
You can’t perform that action at this time.
0 commit comments