如何将我的 MongoDB 迁移到 RethinkDB? [英] How can I migrate my MongoDB to RethinkDB?

查看:40
本文介绍了如何将我的 MongoDB 迁移到 RethinkDB?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将我的 MongoDB 集合迁移到 RethinkDB 表?

How can I migrate my MongoDB collections to RethinkDB tables?

我不担心将旧的 Mongo _id 更改为 Rethink id,因为它们将在我的实现中被忽略,我并不担心关于他们弄乱我的数据.

I'm not concerned about changing my old Mongo _id's to Rethink id's because they will be ignored in my implementation, and I'm not concerned about them cluttering my data.

推荐答案

我写了一个快速的 BASH 脚本来解决这个问题.因为我只有 JavaScript RethinkDB 驱动程序,所以我必须先安装 python 驱动程序 这样我就可以使用 rethinkdb import.

I wrote a quick BASH script to solve this. Because I only had the JavaScript RethinkDB driver, I had to install the python driver first so I could use rethinkdb import.

对于这个例子,我正在迁移 mongo 集合:userspinboardsanalytics;根据需要将您的收藏添加到以下 BASH 命令:

For this example, I am migrating the mongo collections: users, pinboards, and analytics; add your collections as needed to the following BASH command:

for collection in users pinboards analytics; \
do \
  mongoexport \
    --host my.mongo.server \
    --db my_mongo_database \
    --collection $collection \
  > $collection.json; \
  rethinkdb import \
    --file $collection.json \
    --table my_rethink_database.$collection; \
  rm $collection.json; \
done

不要忘记更改您的集合、主机和数据库的名称.另外,调整 mongoexportrethinkdb import 根据需要.

Don't forget to change the names of your collections, host, and database. Also, adjust arguments to mongoexport and rethinkdb import as needed.

这又快又脏,但我希望它能让某人朝着正确的方向开始!

This is quick and dirty, but I hope it gets someone started in the right direction!

这篇关于如何将我的 MongoDB 迁移到 RethinkDB?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆