2 / 2
Jul 2024
command: > bash -c " sleep 30; echo 'Adding shards to config server...'; mongosh --port 27020 --eval 'sh.addShard(\"rs0/localhost:27018\")'; mongosh --port 27020 --eval 'sh.addShard(\"rs1/localhost:27019\")'; echo 'Creating zones...'; mongosh --port 27020 --eval 'sh.addShardToZone(\"rs0\", \"IndiaZone\")'; mongosh --port 27020 --eval 'sh.addShardToZone(\"rs1\", \"IndonesiaZone\")'; echo 'Enabling sharding for the database...'; mongosh --port 27020 --eval 'sh.enableSharding(\"TridentDB\")'; echo 'Creating timeseries collection and sharding...'; mongosh --port 27020 --eval ' db = db.getSiblingDB(\"TridentDB\"); db.createCollection(\"Vessel\", { timeseries: { timeField: \"timestamp\", metaField: \"metadata\", granularity: \"seconds\" } }); sh.shardCollection(\"TridentDB.Vessel\", { \"metadata.country\": 1 }); sh.updateZoneKeyRange(\"TridentDB.Vessel\", { \"metadata.country\": \"India\" }, { \"metadata.country\": \"India\uffff\" }, \"IndiaZone\"); sh.updateZoneKeyRange(\"TridentDB.Vessel\", { \"metadata.country\": \"Indonesia\" }, { \"metadata.country\": \"Indonesia\uffff\" }, \"IndonesiaZone\"); '; "

Data is not sharding