Skip to content

Commit

Permalink
#15 Support for replication protocol version 0 was removed in MongoDB 4
Browse files Browse the repository at this point in the history
  • Loading branch information
senssei committed Aug 22, 2018
1 parent 8606789 commit 2842c22
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 74 deletions.
18 changes: 9 additions & 9 deletions ENV.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

# 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 |
| 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 |

# Linux

Expand Down
6 changes: 3 additions & 3 deletions docker-compose.2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ services:
container_name: "mongo-2-2"
image: mongo
ports:
- "30042:27017"
- "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
ports:
- "30043:27017"
- "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
ports:
- "30041:27017"
- "30021:27017"
command: mongod --replSet rs2 --shardsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles
links:
- mongo-2-2:mongo-2-2
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.cnf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ services:
container_name: "mongo-cnf-2"
image: mongo
ports:
- "30002:27017"
- "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
ports:
- "30003:27017"
- "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
ports:
- "30001:27017"
- "30101:27017"
command: mongod --replSet cnf-serv --configsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles
links:
- mongo-cnf-2:mongo-cnf-2
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ services:
container_name: "mongo-router"
image: mongo
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,7 +19,7 @@ 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:
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 2842c22

Please sign in to comment.