Skip to content

Commit

Permalink
v4.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
senssei committed Aug 22, 2018
2 parents 096c105 + bb2fc08 commit aa993c2
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 113 deletions.
32 changes: 11 additions & 21 deletions ENV.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
# Test rig

# Docker for Windows

| Key | Value |
|----------------|-------------------|
| Version | 1.13.0-rc4 |
| API version | 1.25 |
| Go version | go1.7.3 |
| OS type | linux |
| OS | Alpine Linux v3.4 |
| Architecture | amd64 |
| Kernel version | 4.8.15-moby |
Using `mongo:latest` image, tested on "MONGO_VERSION=4.0.1".

# Linux
# Docker for Windows

| Key | Value |
|----------------|--------------------|
| Version | 1.12.6 |
| API version | 1.24 |
| Go version | go1.6.4 |
| OS type | linux |
| OS | Ubuntu 16.04.1 LTS |
| Architecture | amd64 |
| Kernel version | 4.4.0-57-generic |
| Key | Value |
|----------------|------------------------------|
| Version | 18.06.0-ce |
| API version | 1.38 (minimum version 1.12) |
| Go version | go1.10.3 |
| Git commit | 0ffa825 |
| Built | Wed Jul 18 19:13:46 2018 |
| OS/Arch | windows/amd64 |
| Experimental | false |
16 changes: 8 additions & 8 deletions docker-compose.1.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
version: '2'
version: '3'
services:
mongo-1-2:
container_name: "mongo-1-2"
image: mongo
image: mongo:4.0.1
ports:
- "30012:27017"
command: mongod --replSet rs1 --shardsvr --port 27017 --nojournal --oplogSize 16 --noprealloc --smallfiles
command: mongod --replSet rs1 --shardsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles
restart: always

mongo-1-3:
container_name: "mongo-1-3"
image: mongo
image: mongo:4.0.1
ports:
- "30013:27017"
command: mongod --replSet rs1 --shardsvr --port 27017 --nojournal --oplogSize 16 --noprealloc --smallfiles
command: mongod --replSet rs1 --shardsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles
restart: always

mongo-1-1:
container_name: "mongo-1-1"
image: mongo
image: mongo:4.0.1
ports:
- "30011:27017"
command: mongod --replSet rs1 --shardsvr --port 27017 --nojournal --oplogSize 16 --noprealloc --smallfiles
command: mongod --replSet rs1 --shardsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles
links:
- mongo-1-2:mongo-1-2
- mongo-1-3:mongo-1-3
restart: always

mongo-rs1-setup:
container_name: "mongo-rs1-setup"
image: mongo
image: mongo:4.0.1
depends_on:
- "mongo-1-1"
- "mongo-1-2"
Expand Down
22 changes: 11 additions & 11 deletions docker-compose.2.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
version: '2'
version: '3'
services:
mongo-2-2:
container_name: "mongo-2-2"
image: mongo
image: mongo:4.0.1
ports:
- "30042:27017"
command: mongod --replSet rs2 --shardsvr --port 27017 --nojournal --oplogSize 16 --noprealloc --smallfiles
- "30022:27017"
command: mongod --replSet rs2 --shardsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles
restart: always

mongo-2-3:
container_name: "mongo-2-3"
image: mongo
image: mongo:4.0.1
ports:
- "30043:27017"
command: mongod --replSet rs2 --shardsvr --port 27017 --nojournal --oplogSize 16 --noprealloc --smallfiles
- "30023:27017"
command: mongod --replSet rs2 --shardsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles
restart: always

mongo-2-1:
container_name: "mongo-2-1"
image: mongo
image: mongo:4.0.1
ports:
- "30041:27017"
command: mongod --replSet rs2 --shardsvr --port 27017 --nojournal --oplogSize 16 --noprealloc --smallfiles
- "30021:27017"
command: mongod --replSet rs2 --shardsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles
links:
- mongo-2-2:mongo-2-2
- mongo-2-3:mongo-2-3
restart: always

mongo-rs2-setup:
container_name: "mongo-rs2-setup"
image: mongo
image: mongo:4.0.1
depends_on:
- "mongo-2-1"
- "mongo-2-2"
Expand Down
22 changes: 11 additions & 11 deletions docker-compose.cnf.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
version: '2'
version: '3'
services:
mongo-cnf-2:
container_name: "mongo-cnf-2"
image: mongo
image: mongo:4.0.1
ports:
- "30002:27017"
command: mongod --replSet cnf-serv --rest --configsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles
- "30102:27017"
command: mongod --replSet cnf-serv --configsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles
restart: always

mongo-cnf-3:
container_name: "mongo-cnf-3"
image: mongo
image: mongo:4.0.1
ports:
- "30003:27017"
command: mongod --replSet cnf-serv --rest --configsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles
- "30103:27017"
command: mongod --replSet cnf-serv --configsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles
restart: always

mongo-cnf-1:
container_name: "mongo-cnf-1"
image: mongo
image: mongo:4.0.1
ports:
- "30001:27017"
command: mongod --replSet cnf-serv --rest --configsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles
- "30101:27017"
command: mongod --replSet cnf-serv --configsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles
links:
- mongo-cnf-2:mongo-cnf-2
- mongo-cnf-3:mongo-cnf-3
restart: always

mongo-cnf-setup:
container_name: "mongo-cnf-setup"
image: mongo
image: mongo:4.0.1
depends_on:
- "mongo-cnf-1"
- "mongo-cnf-2"
Expand Down
12 changes: 6 additions & 6 deletions docker-compose.shard.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
version: '2'
version: '3'
services:
mongo-router:
container_name: "mongo-router"
image: mongo
image: mongo:4.0.1
ports:
- "30031:27017"
- "30001:27017"
depends_on:
- "mongo-rs1-setup"
- "mongo-rs2-setup"
- "mongo-cnf-setup"
links:
external_links:
- mongo-cnf-1:mongo-cnf-1
- mongo-cnf-2:mongo-cnf-2
- mongo-cnf-3:mongo-cnf-3
Expand All @@ -19,12 +19,12 @@ services:
- mongo-2-1:mongo-2-1
- mongo-2-2:mongo-2-2
- mongo-2-3:mongo-2-3
command: mongos --configdb cnf-serv/mongo-cnf-1:27017,mongo-cnf-2:27017,mongo-cnf-3:27017
command: mongos --configdb cnf-serv/mongo-cnf-1:27017,mongo-cnf-2:27017,mongo-cnf-3:27017 --port 27017 --bind_ip 0.0.0.0
restart: always

mongo-shard-setup:
container_name: "mongo-shard-setup"
image: mongo
image: mongo:4.0.1
depends_on:
- "mongo-router"
links:
Expand Down
104 changes: 53 additions & 51 deletions queries/init.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,54 @@
sh.removeShardTag("rs1", "US");

sh.removeShardTag("rs2", "EU");

sh.addShardTag("rs1", "US");

sh.addShardTag("rs2", "EU");

sh.disableBalancing("test.sample");

db.sample.drop();

db.createCollection("sample");

db.sample.createIndex( { location: 1, _id: 1 } )

sh.addTagRange(
"test.sample",
{ "location" : "US", "_id" : MinKey },
{ "location" : "US", "_id" : MaxKey },
"US"
);

sh.addTagRange(
"test.sample",
{ "location" : "EU", "_id" : MinKey },
{ "location" : "EU", "_id" : MaxKey },
"EU"
)


sh.enableSharding("test");

sh.shardCollection("test.sample",{ location: 1, _id: 1 });

sh.enableBalancing("test.sample");

db.sample.insert({
"_id" : ObjectId("5787936b94afebe02398521a"),
"location": "US",
"__v" : 0
});

db.sample.insert({
"_id" : ObjectId("5787a08c94afebe023985224"),
"location": "EU",
"__v" : 0
});

sh.startBalancer();

sh.removeShardTag("rs1", "US");

sh.removeShardTag("rs2", "EU");

sh.addShardTag("rs1", "US");

sh.addShardTag("rs2", "EU");

sh.disableBalancing("test.sample");

db.sample.drop();

db.createCollection("sample");

db.sample.createIndex( { factoryId: 1 } );

sh.enableSharding("test");

sh.shardCollection("test.sample",{ location: 1, factoryId: 1});

sh.addTagRange(
"test.sample",
{ "location" : "US", "factoryId" : MinKey },
{ "location" : "US", "factoryId" : MaxKey },
"US"
);

sh.addTagRange(
"test.sample",
{ "location" : "EU", "factoryId" : MinKey },
{ "location" : "EU", "factoryId" : MaxKey },
"EU"
);




sh.enableBalancing("test.sample");

for(var i=0; i<100; i++){
db.sample.insert({
"location": "US",
"factoryId": NumberInt(i)
});

db.sample.insert({
"location": "EU",
"factoryId": NumberInt(100+i)
});
}

sh.startBalancer();

db.sample.find();
Expand Down
2 changes: 1 addition & 1 deletion queries/shard-status.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sh.status();
sh.status(true);
9 changes: 5 additions & 4 deletions scripts/setup-cnf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,19 @@ echo setup-cnf.sh time now: `date +"%T" `
mongo --host ${mongodb1}:${port} <<EOF
var cfg = {
"_id": "${RS}",
configsvr: true,
"configsvr": true,
"protocolVersion": 1,
"members": [
{
"_id": 0,
"_id": 100,
"host": "${mongodb1}:${port}"
},
{
"_id": 1,
"_id": 101,
"host": "${mongodb2}:${port}"
},
{
"_id": 2,
"_id": 102,
"host": "${mongodb3}:${port}"
}
]
Expand Down
1 change: 1 addition & 0 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ echo setup.sh time now: `date +"%T" `
mongo --host ${mongodb1}:${port} <<EOF
var cfg = {
"_id": "${RS}",
"protocolVersion": 1,
"members": [
{
"_id": 0,
Expand Down

0 comments on commit aa993c2

Please sign in to comment.