From e5b2822c8d0057aabd3314c31d99321dcaf9c318 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Warzycha?= Date: Tue, 21 Aug 2018 10:00:09 +0200 Subject: [PATCH 1/4] #14 Invalid `--rest` parameters on `mongo-cnf` --- docker-compose.cnf.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-compose.cnf.yml b/docker-compose.cnf.yml index f2fbc37..23320e7 100644 --- a/docker-compose.cnf.yml +++ b/docker-compose.cnf.yml @@ -5,7 +5,7 @@ services: image: mongo ports: - "30002:27017" - command: mongod --replSet cnf-serv --rest --configsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles + command: mongod --replSet cnf-serv --configsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles restart: always mongo-cnf-3: @@ -13,7 +13,7 @@ services: image: mongo ports: - "30003:27017" - command: mongod --replSet cnf-serv --rest --configsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles + command: mongod --replSet cnf-serv --configsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles restart: always mongo-cnf-1: @@ -21,7 +21,7 @@ services: image: mongo ports: - "30001:27017" - command: mongod --replSet cnf-serv --rest --configsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles + 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 From 7f55bba30f42d7eface0ade3d921be74d86551bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Warzycha?= Date: Tue, 21 Aug 2018 10:29:44 +0200 Subject: [PATCH 2/4] #16 MongoDB 4.0 --nojournal You cannot specify --nojournal in replica set on wiredTiger engine Bumped docker compose version to 3.x --- docker-compose.1.yml | 8 ++++---- docker-compose.2.yml | 8 ++++---- docker-compose.cnf.yml | 2 +- docker-compose.shard.yml | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docker-compose.1.yml b/docker-compose.1.yml index fc57312..ac99e70 100644 --- a/docker-compose.1.yml +++ b/docker-compose.1.yml @@ -1,11 +1,11 @@ -version: '2' +version: '3' services: mongo-1-2: container_name: "mongo-1-2" image: mongo 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: @@ -13,7 +13,7 @@ services: image: mongo 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: @@ -21,7 +21,7 @@ services: image: mongo 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 diff --git a/docker-compose.2.yml b/docker-compose.2.yml index 3e11dd5..b7b46bd 100644 --- a/docker-compose.2.yml +++ b/docker-compose.2.yml @@ -1,11 +1,11 @@ -version: '2' +version: '3' services: mongo-2-2: container_name: "mongo-2-2" image: mongo ports: - "30042:27017" - command: mongod --replSet rs2 --shardsvr --port 27017 --nojournal --oplogSize 16 --noprealloc --smallfiles + command: mongod --replSet rs2 --shardsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles restart: always mongo-2-3: @@ -13,7 +13,7 @@ services: image: mongo ports: - "30043:27017" - command: mongod --replSet rs2 --shardsvr --port 27017 --nojournal --oplogSize 16 --noprealloc --smallfiles + command: mongod --replSet rs2 --shardsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles restart: always mongo-2-1: @@ -21,7 +21,7 @@ services: image: mongo ports: - "30041:27017" - command: mongod --replSet rs2 --shardsvr --port 27017 --nojournal --oplogSize 16 --noprealloc --smallfiles + command: mongod --replSet rs2 --shardsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles links: - mongo-2-2:mongo-2-2 - mongo-2-3:mongo-2-3 diff --git a/docker-compose.cnf.yml b/docker-compose.cnf.yml index f2fbc37..909128a 100644 --- a/docker-compose.cnf.yml +++ b/docker-compose.cnf.yml @@ -1,4 +1,4 @@ -version: '2' +version: '3' services: mongo-cnf-2: container_name: "mongo-cnf-2" diff --git a/docker-compose.shard.yml b/docker-compose.shard.yml index 0fd5bdf..9dfce89 100644 --- a/docker-compose.shard.yml +++ b/docker-compose.shard.yml @@ -1,4 +1,4 @@ -version: '2' +version: '3' services: mongo-router: container_name: "mongo-router" 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 3/4] #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} < Date: Wed, 22 Aug 2018 13:58:07 +0200 Subject: [PATCH 4/4] #15 Support for replication protocol version 0 was removed in Mongo 4.0. --- ENV.md | 14 ++------------ docker-compose.1.yml | 8 ++++---- docker-compose.2.yml | 8 ++++---- docker-compose.cnf.yml | 8 ++++---- docker-compose.shard.yml | 4 ++-- 5 files changed, 16 insertions(+), 26 deletions(-) diff --git a/ENV.md b/ENV.md index 7690aad..f60bfd0 100644 --- a/ENV.md +++ b/ENV.md @@ -1,5 +1,7 @@ # Test rig +Using `mongo:latest` image, tested on "MONGO_VERSION=4.0.1". + # Docker for Windows | Key | Value | @@ -11,15 +13,3 @@ | Built | Wed Jul 18 19:13:46 2018 | | OS/Arch | windows/amd64 | | Experimental | false | - -# Linux - -| 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 | \ No newline at end of file diff --git a/docker-compose.1.yml b/docker-compose.1.yml index ac99e70..d81cd5b 100644 --- a/docker-compose.1.yml +++ b/docker-compose.1.yml @@ -2,7 +2,7 @@ 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 --oplogSize 16 --noprealloc --smallfiles @@ -10,7 +10,7 @@ services: 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 --oplogSize 16 --noprealloc --smallfiles @@ -18,7 +18,7 @@ services: 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 --oplogSize 16 --noprealloc --smallfiles @@ -29,7 +29,7 @@ services: mongo-rs1-setup: container_name: "mongo-rs1-setup" - image: mongo + image: mongo:4.0.1 depends_on: - "mongo-1-1" - "mongo-1-2" diff --git a/docker-compose.2.yml b/docker-compose.2.yml index d490071..47f162e 100644 --- a/docker-compose.2.yml +++ b/docker-compose.2.yml @@ -2,7 +2,7 @@ version: '3' services: mongo-2-2: container_name: "mongo-2-2" - image: mongo + image: mongo:4.0.1 ports: - "30022:27017" command: mongod --replSet rs2 --shardsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles @@ -10,7 +10,7 @@ services: mongo-2-3: container_name: "mongo-2-3" - image: mongo + image: mongo:4.0.1 ports: - "30023:27017" command: mongod --replSet rs2 --shardsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles @@ -18,7 +18,7 @@ services: mongo-2-1: container_name: "mongo-2-1" - image: mongo + image: mongo:4.0.1 ports: - "30021:27017" command: mongod --replSet rs2 --shardsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles @@ -29,7 +29,7 @@ services: mongo-rs2-setup: container_name: "mongo-rs2-setup" - image: mongo + image: mongo:4.0.1 depends_on: - "mongo-2-1" - "mongo-2-2" diff --git a/docker-compose.cnf.yml b/docker-compose.cnf.yml index 87432e8..b4f57ee 100644 --- a/docker-compose.cnf.yml +++ b/docker-compose.cnf.yml @@ -2,7 +2,7 @@ version: '3' services: mongo-cnf-2: container_name: "mongo-cnf-2" - image: mongo + image: mongo:4.0.1 ports: - "30102:27017" command: mongod --replSet cnf-serv --configsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles @@ -10,7 +10,7 @@ services: mongo-cnf-3: container_name: "mongo-cnf-3" - image: mongo + image: mongo:4.0.1 ports: - "30103:27017" command: mongod --replSet cnf-serv --configsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles @@ -18,7 +18,7 @@ services: mongo-cnf-1: container_name: "mongo-cnf-1" - image: mongo + image: mongo:4.0.1 ports: - "30101:27017" command: mongod --replSet cnf-serv --configsvr --port 27017 --oplogSize 16 --noprealloc --smallfiles @@ -29,7 +29,7 @@ services: mongo-cnf-setup: container_name: "mongo-cnf-setup" - image: mongo + image: mongo:4.0.1 depends_on: - "mongo-cnf-1" - "mongo-cnf-2" diff --git a/docker-compose.shard.yml b/docker-compose.shard.yml index 0226b3a..fd5283f 100644 --- a/docker-compose.shard.yml +++ b/docker-compose.shard.yml @@ -2,7 +2,7 @@ version: '3' services: mongo-router: container_name: "mongo-router" - image: mongo + image: mongo:4.0.1 ports: - "30001:27017" depends_on: @@ -24,7 +24,7 @@ services: mongo-shard-setup: container_name: "mongo-shard-setup" - image: mongo + image: mongo:4.0.1 depends_on: - "mongo-router" links: