将数据从外部驱动器导入托管在 Google 计算引擎上的 Mongodb
Importing data from external drive to Mongodb hosted on Google compute engine
我在 google 云上部署了 MongoDB。我现在无法导入数据。我的硬盘上有一个json
格式的数据,想把它导入到数据库中。我尝试了多种方法均无效:
- 直接指定文件位置
- 将文件保存在 Google 存储桶中。
这些是我的命令 运行:
mongoimport -d test -c trialcollection - f /mongobucket/trial.json
mongoimport -d test -c trialcollection /mongobucket/trial.json
mongoimport -d test -c trialcollection - f C:/desktop/mongo/trial.json
如何将数据导入 Google 计算引擎上托管的 Mongo?
听起来您的本地计算机上有 json 文件,您需要将它们 mongoimport 到删除的 GCE MongoDB 实例中。最好的方法是将您需要的文件复制到您的 GCE 实例。
如果您还没有,您应该安装 Google Cloud SDK on your local system. After you've installed that, you should be able to use the gcloud compute copy-files 命令以将文件从您的本地系统复制到您的 GCE 实例。这个命令基本上像 scp.
从那里您可以使用 gcloud compute ssh 连接到您的实例,然后 运行 在您的 GCE 实例上本地使用 mongoimport 命令。
我在 google 云上部署了 MongoDB。我现在无法导入数据。我的硬盘上有一个json
格式的数据,想把它导入到数据库中。我尝试了多种方法均无效:
- 直接指定文件位置
- 将文件保存在 Google 存储桶中。
这些是我的命令 运行:
mongoimport -d test -c trialcollection - f /mongobucket/trial.json
mongoimport -d test -c trialcollection /mongobucket/trial.json
mongoimport -d test -c trialcollection - f C:/desktop/mongo/trial.json
如何将数据导入 Google 计算引擎上托管的 Mongo?
听起来您的本地计算机上有 json 文件,您需要将它们 mongoimport 到删除的 GCE MongoDB 实例中。最好的方法是将您需要的文件复制到您的 GCE 实例。
如果您还没有,您应该安装 Google Cloud SDK on your local system. After you've installed that, you should be able to use the gcloud compute copy-files 命令以将文件从您的本地系统复制到您的 GCE 实例。这个命令基本上像 scp.
从那里您可以使用 gcloud compute ssh 连接到您的实例,然后 运行 在您的 GCE 实例上本地使用 mongoimport 命令。