Skip to content

Commit aa993c2

Browse files
committed
v4.0.1
2 parents 096c105 + bb2fc08 commit aa993c2

File tree

9 files changed

+107
-113
lines changed

9 files changed

+107
-113
lines changed

ENV.md

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,15 @@
11
# Test rig
22

3-
# Docker for Windows
4-
5-
| Key | Value |
6-
|----------------|-------------------|
7-
| Version | 1.13.0-rc4 |
8-
| API version | 1.25 |
9-
| Go version | go1.7.3 |
10-
| OS type | linux |
11-
| OS | Alpine Linux v3.4 |
12-
| Architecture | amd64 |
13-
| Kernel version | 4.8.15-moby |
3+
Using `mongo:latest` image, tested on "MONGO_VERSION=4.0.1".
144

15-
# Linux
5+
# Docker for Windows
166

17-
| Key | Value |
18-
|----------------|--------------------|
19-
| Version | 1.12.6 |
20-
| API version | 1.24 |
21-
| Go version | go1.6.4 |
22-
| OS type | linux |
23-
| OS | Ubuntu 16.04.1 LTS |
24-
| Architecture | amd64 |
25-
| Kernel version | 4.4.0-57-generic |
7+
| Key | Value |
8+
|----------------|------------------------------|
9+
| Version | 18.06.0-ce |
10+
| API version | 1.38 (minimum version 1.12) |
11+
| Go version | go1.10.3 |
12+
| Git commit | 0ffa825 |
13+
| Built | Wed Jul 18 19:13:46 2018 |
14+
| OS/Arch | windows/amd64 |
15+
| Experimental | false |

docker-compose.1.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
version: '2'
1+
version: '3'
22
services:
33
mongo-1-2:
44
container_name: "mongo-1-2"
5-
image: mongo
5+
image: mongo:4.0.1
66
ports:
77
- "30012:27017"
8-
command: mongod --replSet rs1 --shardsvr --port 27017 --nojournal --oplogSize 16 --noprealloc --smallfiles
8+
command: mongod --replSet rs1 --shardsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles
99
restart: always
1010

1111
mongo-1-3:
1212
container_name: "mongo-1-3"
13-
image: mongo
13+
image: mongo:4.0.1
1414
ports:
1515
- "30013:27017"
16-
command: mongod --replSet rs1 --shardsvr --port 27017 --nojournal --oplogSize 16 --noprealloc --smallfiles
16+
command: mongod --replSet rs1 --shardsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles
1717
restart: always
1818

1919
mongo-1-1:
2020
container_name: "mongo-1-1"
21-
image: mongo
21+
image: mongo:4.0.1
2222
ports:
2323
- "30011:27017"
24-
command: mongod --replSet rs1 --shardsvr --port 27017 --nojournal --oplogSize 16 --noprealloc --smallfiles
24+
command: mongod --replSet rs1 --shardsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles
2525
links:
2626
- mongo-1-2:mongo-1-2
2727
- mongo-1-3:mongo-1-3
2828
restart: always
2929

3030
mongo-rs1-setup:
3131
container_name: "mongo-rs1-setup"
32-
image: mongo
32+
image: mongo:4.0.1
3333
depends_on:
3434
- "mongo-1-1"
3535
- "mongo-1-2"

docker-compose.2.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
version: '2'
1+
version: '3'
22
services:
33
mongo-2-2:
44
container_name: "mongo-2-2"
5-
image: mongo
5+
image: mongo:4.0.1
66
ports:
7-
- "30042:27017"
8-
command: mongod --replSet rs2 --shardsvr --port 27017 --nojournal --oplogSize 16 --noprealloc --smallfiles
7+
- "30022:27017"
8+
command: mongod --replSet rs2 --shardsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles
99
restart: always
1010

1111
mongo-2-3:
1212
container_name: "mongo-2-3"
13-
image: mongo
13+
image: mongo:4.0.1
1414
ports:
15-
- "30043:27017"
16-
command: mongod --replSet rs2 --shardsvr --port 27017 --nojournal --oplogSize 16 --noprealloc --smallfiles
15+
- "30023:27017"
16+
command: mongod --replSet rs2 --shardsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles
1717
restart: always
1818

1919
mongo-2-1:
2020
container_name: "mongo-2-1"
21-
image: mongo
21+
image: mongo:4.0.1
2222
ports:
23-
- "30041:27017"
24-
command: mongod --replSet rs2 --shardsvr --port 27017 --nojournal --oplogSize 16 --noprealloc --smallfiles
23+
- "30021:27017"
24+
command: mongod --replSet rs2 --shardsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles
2525
links:
2626
- mongo-2-2:mongo-2-2
2727
- mongo-2-3:mongo-2-3
2828
restart: always
2929

3030
mongo-rs2-setup:
3131
container_name: "mongo-rs2-setup"
32-
image: mongo
32+
image: mongo:4.0.1
3333
depends_on:
3434
- "mongo-2-1"
3535
- "mongo-2-2"

docker-compose.cnf.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
version: '2'
1+
version: '3'
22
services:
33
mongo-cnf-2:
44
container_name: "mongo-cnf-2"
5-
image: mongo
5+
image: mongo:4.0.1
66
ports:
7-
- "30002:27017"
8-
command: mongod --replSet cnf-serv --rest --configsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles
7+
- "30102:27017"
8+
command: mongod --replSet cnf-serv --configsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles
99
restart: always
1010

1111
mongo-cnf-3:
1212
container_name: "mongo-cnf-3"
13-
image: mongo
13+
image: mongo:4.0.1
1414
ports:
15-
- "30003:27017"
16-
command: mongod --replSet cnf-serv --rest --configsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles
15+
- "30103:27017"
16+
command: mongod --replSet cnf-serv --configsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles
1717
restart: always
1818

1919
mongo-cnf-1:
2020
container_name: "mongo-cnf-1"
21-
image: mongo
21+
image: mongo:4.0.1
2222
ports:
23-
- "30001:27017"
24-
command: mongod --replSet cnf-serv --rest --configsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles
23+
- "30101:27017"
24+
command: mongod --replSet cnf-serv --configsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles
2525
links:
2626
- mongo-cnf-2:mongo-cnf-2
2727
- mongo-cnf-3:mongo-cnf-3
2828
restart: always
2929

3030
mongo-cnf-setup:
3131
container_name: "mongo-cnf-setup"
32-
image: mongo
32+
image: mongo:4.0.1
3333
depends_on:
3434
- "mongo-cnf-1"
3535
- "mongo-cnf-2"

docker-compose.shard.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
version: '2'
1+
version: '3'
22
services:
33
mongo-router:
44
container_name: "mongo-router"
5-
image: mongo
5+
image: mongo:4.0.1
66
ports:
7-
- "30031:27017"
7+
- "30001:27017"
88
depends_on:
99
- "mongo-rs1-setup"
1010
- "mongo-rs2-setup"
1111
- "mongo-cnf-setup"
12-
links:
12+
external_links:
1313
- mongo-cnf-1:mongo-cnf-1
1414
- mongo-cnf-2:mongo-cnf-2
1515
- mongo-cnf-3:mongo-cnf-3
@@ -19,12 +19,12 @@ services:
1919
- mongo-2-1:mongo-2-1
2020
- mongo-2-2:mongo-2-2
2121
- mongo-2-3:mongo-2-3
22-
command: mongos --configdb cnf-serv/mongo-cnf-1:27017,mongo-cnf-2:27017,mongo-cnf-3:27017
22+
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
2323
restart: always
2424

2525
mongo-shard-setup:
2626
container_name: "mongo-shard-setup"
27-
image: mongo
27+
image: mongo:4.0.1
2828
depends_on:
2929
- "mongo-router"
3030
links:

queries/init.js

Lines changed: 53 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,54 @@
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-
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( { factoryId: 1 } );
16+
17+
sh.enableSharding("test");
18+
19+
sh.shardCollection("test.sample",{ location: 1, factoryId: 1});
20+
21+
sh.addTagRange(
22+
"test.sample",
23+
{ "location" : "US", "factoryId" : MinKey },
24+
{ "location" : "US", "factoryId" : MaxKey },
25+
"US"
26+
);
27+
28+
sh.addTagRange(
29+
"test.sample",
30+
{ "location" : "EU", "factoryId" : MinKey },
31+
{ "location" : "EU", "factoryId" : MaxKey },
32+
"EU"
33+
);
34+
35+
36+
37+
38+
sh.enableBalancing("test.sample");
39+
40+
for(var i=0; i<100; i++){
41+
db.sample.insert({
42+
"location": "US",
43+
"factoryId": NumberInt(i)
44+
});
45+
46+
db.sample.insert({
47+
"location": "EU",
48+
"factoryId": NumberInt(100+i)
49+
});
50+
}
51+
52+
sh.startBalancer();
53+
5254
db.sample.find();

queries/shard-status.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sh.status();
1+
sh.status(true);

scripts/setup-cnf.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,19 @@ echo setup-cnf.sh time now: `date +"%T" `
1818
mongo --host ${mongodb1}:${port} <<EOF
1919
var cfg = {
2020
"_id": "${RS}",
21-
configsvr: true,
21+
"configsvr": true,
22+
"protocolVersion": 1,
2223
"members": [
2324
{
24-
"_id": 0,
25+
"_id": 100,
2526
"host": "${mongodb1}:${port}"
2627
},
2728
{
28-
"_id": 1,
29+
"_id": 101,
2930
"host": "${mongodb2}:${port}"
3031
},
3132
{
32-
"_id": 2,
33+
"_id": 102,
3334
"host": "${mongodb3}:${port}"
3435
}
3536
]

scripts/setup.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ echo setup.sh time now: `date +"%T" `
1818
mongo --host ${mongodb1}:${port} <<EOF
1919
var cfg = {
2020
"_id": "${RS}",
21+
"protocolVersion": 1,
2122
"members": [
2223
{
2324
"_id": 0,

0 commit comments

Comments
 (0)