我如何运行这个 perl 脚本来操作 MongoDB?

发布于 2024-12-12 21:18:48 字数 1504 浏览 0 评论 0原文

我见过一个用于预分割数据的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

静若繁花 2024-12-19 21:18:48

根据评论,看起来该脚本只是为了创建一组命令,您应该能够在 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! :-)

雄赳赳气昂昂 2024-12-19 21:18:48

该脚本有效地生成了 MongoDB 脚本。

That script effectively generates a script for MongoDB.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文