我如何运行这个 perl 脚本来操作 MongoDB?
我见过一个用于预分割数据的 perl 脚本链接
问题>;我如何运行这个脚本?
我问这个问题的原因是perl脚本不包含如下典型语句:
use MongoDB;
另外,我没有看到它使用MongoDB Perl驱动程序。
/// 已更新 /// 以下是脚本的输出:
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>首先,我在 MongoDB 上运行上述脚本。现在,如果我插入一个文档,如下所示:
db.postings.insert({PostingID : 95327, xx : xxxxxxxx})
MongoDB 将在 archive001 上发送插入的数据吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据评论,看起来该脚本只是为了创建一组命令,您应该能够在 Mongo 中运行这些命令来对数据库进行预分片。
当你思考它时,它就会变得非常简单......如果它甚至不打算运行命令,就不需要 Mongo! :-)
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! :-)
该脚本有效地生成了 MongoDB 脚本。
That script effectively generates a script for MongoDB.