I have seen a usage perl script used to pre-split data Link
Question> How do I run this script?
The reason why I am asking this question is that the perl script doesn’t include a typical statement as follows:
use MongoDB;
Also, I don’t see it uses the MongoDB Perl Driver.
/// Updated ///
Here is the output from the script:
use admin;
db.runCommand({split: "archive.postings", middle: { PostingID: 95326 } });
db.runCommand({moveChunk: "archive.postings", find: { PostingID: 95326 }, to: "archive001"});
db.runCommand({split: "archive.postings", middle: { PostingID: 190651 } });
db.runCommand({moveChunk: "archive.postings", find: { PostingID: 190651 }, to: "archive002"});
db.runCommand({split: "archive.postings", middle: { PostingID: 285976 } });
db.runCommand({moveChunk: "archive.postings", find: { PostingID: 285976 }, to: "archive003"});
db.runCommand({split: "archive.postings", middle: { PostingID: 381301 } });
db.runCommand({moveChunk: "archive.postings", find: { PostingID: 381301 }, to: "archive001"});
db.runCommand({split: "archive.postings", middle: { PostingID: 476626 } });
db.runCommand({moveChunk: "archive.postings", find: { PostingID: 476626 }, to: "archive002"});
db.runCommand({split: "archive.postings", middle: { PostingID: 571951 } });
db.runCommand({moveChunk: "archive.postings", find: { PostingID: 571951 }, to: "archive003"});
Question> First, I run the above script on MongoDB. Now if I insert a doc as follows:
db.postings.insert({PostingID : 95327, xx : xxxxxxxx})
Will MongoDB send the inserted data on archive001?
According to the comments, it looks like the script is just there to create a set of commands that you should be able to run in Mongo to pre-shard your database.
It then becomes pretty simple when you think about it… No need for Mongo if it’s not even going to run the commands! 🙂