本地问题 运行 meteor 与从 Atlas 快照恢复的 mongodb
Problem running meteor locally with a mongodb restored from Atlas snapshot
我想 运行 一个 localhost meteor 在本地使用来自生产数据库的数据进行调试。
我从 Mongo Atlas 下载了每日快照,将其解压缩到桌面,将其解压缩到名为“snap”的文件夹中
那我运行:
mongod --dbpath snap -port 3001
我现在可以在 127.0.0.1:3001 看到 mongodb 运行ning。
我去本地开始我的流星项目:
meteor --settings settings.json
希望它能以某种方式神奇地在 3001 端口获取 运行ning 数据库,但它没有。
它抱怨:
=> Started proxy.
Unexpected mongo exit code 48. Restarting.
=> Meteor 2.1 is available. Update this project with 'meteor update'.
Unexpected mongo exit code 48. Restarting.
Unexpected mongo exit code 48. Restarting.
Can't start Mongo server.
MongoDB exited because its port was closed, or was already
taken by a previous instance of MongoDB
Check for other processes listening on port 3001
or other Meteor instances running in the same project.
我应该怎么做才能让 Meteor 使用恢复的数据库启动项目?
假设您的数据库是 运行ning,您可以使用环境变量 MONGO_URL
在本地 运行 使用您自己的数据库
$ MONGO_URL=mongodb://localhost:<port>/<dbname> meteor run --settings settings.json
请注意,您需要为数据库设置一个明确的名称,如果您的 Meteor 数据库已经包含数据,那么您需要将其导入此数据库才能访问两者。
此外,我个人会避免设置端口 3001
,以免将其与 Meteor 捆绑的数据库混淆。 Mongo 的默认 27017
端口应该没问题。
参考文献:
https://docs.meteor.com/environment-variables.html#MONGO-URL
我想 运行 一个 localhost meteor 在本地使用来自生产数据库的数据进行调试。
我从 Mongo Atlas 下载了每日快照,将其解压缩到桌面,将其解压缩到名为“snap”的文件夹中
那我运行:
mongod --dbpath snap -port 3001
我现在可以在 127.0.0.1:3001 看到 mongodb 运行ning。
我去本地开始我的流星项目:
meteor --settings settings.json
希望它能以某种方式神奇地在 3001 端口获取 运行ning 数据库,但它没有。
它抱怨:
=> Started proxy.
Unexpected mongo exit code 48. Restarting.
=> Meteor 2.1 is available. Update this project with 'meteor update'.
Unexpected mongo exit code 48. Restarting.
Unexpected mongo exit code 48. Restarting.
Can't start Mongo server.
MongoDB exited because its port was closed, or was already
taken by a previous instance of MongoDB
Check for other processes listening on port 3001
or other Meteor instances running in the same project.
我应该怎么做才能让 Meteor 使用恢复的数据库启动项目?
假设您的数据库是 运行ning,您可以使用环境变量 MONGO_URL
$ MONGO_URL=mongodb://localhost:<port>/<dbname> meteor run --settings settings.json
请注意,您需要为数据库设置一个明确的名称,如果您的 Meteor 数据库已经包含数据,那么您需要将其导入此数据库才能访问两者。
此外,我个人会避免设置端口 3001
,以免将其与 Meteor 捆绑的数据库混淆。 Mongo 的默认 27017
端口应该没问题。
参考文献:
https://docs.meteor.com/environment-variables.html#MONGO-URL