Skip to content

Commit 2842c22

Browse files
committed
#15 Support for replication protocol version 0 was removed in MongoDB 4
1 parent 8606789 commit 2842c22

File tree

8 files changed

+78
-74
lines changed

8 files changed

+78
-74
lines changed

ENV.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
# Docker for Windows
44

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 |
5+
| Key | Value |
6+
|----------------|------------------------------|
7+
| Version | 18.06.0-ce |
8+
| API version | 1.38 (minimum version 1.12) |
9+
| Go version | go1.10.3 |
10+
| Git commit | 0ffa825 |
11+
| Built | Wed Jul 18 19:13:46 2018 |
12+
| OS/Arch | windows/amd64 |
13+
| Experimental | false |
1414

1515
# Linux
1616

docker-compose.2.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ services:
44
container_name: "mongo-2-2"
55
image: mongo
66
ports:
7-
- "30042:27017"
7+
- "30022:27017"
88
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"
1313
image: mongo
1414
ports:
15-
- "30043:27017"
15+
- "30023:27017"
1616
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"
2121
image: mongo
2222
ports:
23-
- "30041:27017"
23+
- "30021:27017"
2424
command: mongod --replSet rs2 --shardsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles
2525
links:
2626
- mongo-2-2:mongo-2-2

docker-compose.cnf.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ services:
44
container_name: "mongo-cnf-2"
55
image: mongo
66
ports:
7-
- "30002:27017"
7+
- "30102:27017"
88
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"
1313
image: mongo
1414
ports:
15-
- "30003:27017"
15+
- "30103:27017"
1616
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"
2121
image: mongo
2222
ports:
23-
- "30001:27017"
23+
- "30101:27017"
2424
command: mongod --replSet cnf-serv --configsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles
2525
links:
2626
- mongo-cnf-2:mongo-cnf-2

docker-compose.shard.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ services:
44
container_name: "mongo-router"
55
image: mongo
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,7 +19,7 @@ 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:

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)