From 2842c22fd0ca4b7c40e2089907ae40c7c582f65a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Warzycha?= Date: Wed, 22 Aug 2018 11:49:08 +0200 Subject: [PATCH] #15 Support for replication protocol version 0 was removed in MongoDB 4 --- ENV.md | 18 +++---- docker-compose.2.yml | 6 +-- docker-compose.cnf.yml | 6 +-- docker-compose.shard.yml | 6 +-- queries/init.js | 104 ++++++++++++++++++++------------------- queries/shard-status.js | 2 +- scripts/setup-cnf.sh | 9 ++-- scripts/setup.sh | 1 + 8 files changed, 78 insertions(+), 74 deletions(-) diff --git a/ENV.md b/ENV.md index 3a4da2c..7690aad 100644 --- a/ENV.md +++ b/ENV.md @@ -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 diff --git a/docker-compose.2.yml b/docker-compose.2.yml index b7b46bd..d490071 100644 --- a/docker-compose.2.yml +++ b/docker-compose.2.yml @@ -4,7 +4,7 @@ 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 @@ -12,7 +12,7 @@ services: 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 @@ -20,7 +20,7 @@ services: 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 diff --git a/docker-compose.cnf.yml b/docker-compose.cnf.yml index 22b5a34..87432e8 100644 --- a/docker-compose.cnf.yml +++ b/docker-compose.cnf.yml @@ -4,7 +4,7 @@ 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 @@ -12,7 +12,7 @@ services: 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 @@ -20,7 +20,7 @@ services: 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 diff --git a/docker-compose.shard.yml b/docker-compose.shard.yml index 9dfce89..0226b3a 100644 --- a/docker-compose.shard.yml +++ b/docker-compose.shard.yml @@ -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 @@ -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: diff --git a/queries/init.js b/queries/init.js index 8316339..46cbcdb 100644 --- a/queries/init.js +++ b/queries/init.js @@ -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(); \ No newline at end of file diff --git a/queries/shard-status.js b/queries/shard-status.js index d55e16d..3a2a4af 100644 --- a/queries/shard-status.js +++ b/queries/shard-status.js @@ -1 +1 @@ -sh.status(); \ No newline at end of file +sh.status(true); \ No newline at end of file diff --git a/scripts/setup-cnf.sh b/scripts/setup-cnf.sh index c3dcc73..517c7f6 100755 --- a/scripts/setup-cnf.sh +++ b/scripts/setup-cnf.sh @@ -18,18 +18,19 @@ echo setup-cnf.sh time now: `date +"%T" ` mongo --host ${mongodb1}:${port} <