简体   繁体   English

在Google Cloud Platform上部署mongodb?

[英]deploying mongodb on google cloud platform?

Hello all actually for my startup i am using google cloud platform, now i am using app engine with node.js this part is working fine but now for database, as i am mongoDB i saw this for mongoDB https://console.cloud.google.com/launcher/details/click-to-deploy-images/mongodb?q=mongo now when i launched it on my server now it created three instances in my compute engine but now i don't know which is primary instance and which is secondary, also one more thing as i read that primary instance should be used for writing data and secondary for reading, now when i will query my database should i provide secondary instance url and for updating/inserting data in my mongodb database should i provide primary instance url otherwise which url should i use for CRUD operations on my mongodb database ?? 大家好,对于我的创业公司来说,我正在使用Google Cloud Platform,现在我正在将App Engine与node.js一起使用,这部分工作正常,但是现在对于数据库,因为我是mongoDB,我在mongoDB https://console.cloud上看到了这一点。 google.com/launcher/details/click-to-deploy-images/mongodb?q=mongo现在,当我在服务器上启动它时,它在我的计算引擎中创建了三个实例,但是现在我不知道哪个是主实例,这是第二个,也是另外一件事,因为我读到应该使用主实例写入数据,而使用第二个实例进行读取,现在当我查询数据库时,我应该提供第二个实例url并在我的mongodb数据库中更新/插入数据提供主实例url,否则我应该在mongodb数据库上对CRUD操作使用哪个url? also after launcing this do i have to make any changes in any conf file or in any file manually or they already done that for me ?? 还在发布此消息后,我是否必须对任何conf文件或任何文件进行任何更改,否则他们已经为我做了更改? Also do i have to make instance groups of all three instances or not ?? 我是否也必须对所有三个实例进行实例分组?

Please if any one of you think i have not done any research on this or its not a valid stackoverflow question then i am so sorry google cloud platform is very much new that's why there is not much documentation on it also this is my first time here in deploying my code on servers that's why i am completely noob in this field Thanks Anyways please help me ut of here guys. 请如果任何人认为我没有对此进行任何研究或它不是有效的stackoverflow问题,那么我很抱歉google cloud平台非常新,这就是为什么没有太多文档的原因,这也是我第一次来在服务器上部署我的代码,这就是为什么我在这个领域完全不了解的原因不管怎么说,请帮助我。

but now i don't know which is primary instance and which is secondary, 但现在我不知道哪个是主要实例,哪个是次要实例,

Generally the Cloud Launcher will name the primary with suffix -1 (dash one). 通常, Cloud Launcher将使用后缀-1 (破折号1)来命名主数据库。 For example by default it would create mongodb-1-server-1 instance as the primary. 例如,默认情况下,它将创建mongodb-1-server-1实例作为主要实例。

Although you can also discover which one is the primary by running rs.status() on any of the instances via the mongo shell . 尽管您也可以通过mongo shell在任何实例上运行rs.status()来发现哪个是主要的。 As an example: 举个例子:

mongo --host <External instance IP> --port <Port Number>

You can get the list of external IPs of the instances using gcloud . 您可以使用gcloud获取实例的外部IP列表。 For example: 例如:

gcloud compute instances list

By default you won't be able to connect straight away, you need to create a firewall rule for the compute engines to open port(s). 默认情况下,您将无法立即连接,您需要为计算引擎创建防火墙规则以打开端口。 For example : 例如

gcloud compute firewall-rules create default-allow-mongo --allow tcp:<PORT NUMBER> --source-ranges 0.0.0.0/0 --target-tags mongodb --description "Allow mongodb access to all IPs"

Insert a sensible port number, please avoid using the default value. 插入一个明智的端口号,请避免使用默认值。 You may also want to limit the source IP ranges. 您可能还希望限制源IP范围。 ie your office IP. 即您的办公室IP。 See also Cloud Platform: Networking 另请参阅云平台:网络

i read that primary instance should be used for writing data and secondary for reading, 我读到主要实例应用于写入数据,次要实例用于读取,

Generally replication is to provide redundancy and high availability. 通常,复制是为了提供冗余和高可用性。 Where the primary instance is being used to read and write, and secondaries act as replicas to provide a level of fault tolerance. 主实例用于读取和写入,而辅助实例用作副本以提供一定程度的容错能力。 ie the loss of primary server. 即丢失主服务器。

See also: 也可以看看:

now when i will query my database should i provide secondary instance url and for updating/inserting data in my mongodb database should i provide primary instance url otherwise which url should i use for CRUD operations on my mongodb database 现在,当我查询数据库时,我应该提供辅助实例url,还是要在mongodb数据库中更新/插入数据,我应该提供主实例url,否则我应该在mongodb数据库上使用哪个URL进行CRUD操作

You can provide both in MongoDB URI and the driver will figure out where to read/write. 您可以同时在MongoDB URI中提供,驱动程序将确定在哪里进行读取/写入。 For example in your Node.js you could have: 例如,在您的Node.js中,您可以拥有:

mongodb://<instance 1>:<port 1>,<instance 2>:<port 2>/<database name>?replicaSet=<replica set name>

The default replica set name set by Cloud Launcher is rs0 . Cloud Launcher设置的默认副本集名称为rs0 Also see: 另请参阅:

also after launcing this do i have to make any changes in any conf file or in any file manually or they already done that for me ?? 还在发布此消息后,我是否必须对任何conf文件或任何文件进行任何更改,否则他们已经为我做了更改? Also do i have to make instance groups of all three instances or not ?? 我是否也必须对所有三个实例进行实例分组?

This depends on your application use case, but if you are launching through click and deploy the MongoDB config should all be taken care of. 这取决于您的应用程序用例,但是如果您通过单击启动并部署MongoDB配置,则应该全部处理。

For a complete guide please follow tutorial : Deploy MongoDB with Node.js . 有关完整的指南,请遵循以下教程: 使用Node.js部署MongoDB I would also recommend to check out MongoDB security checklist . 我还建议您查看MongoDB安全清单

Hope that helps. 希望能有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 选择在Cloud Platform上部署MongoDB的最佳方法? - selecting best way for deploying MongoDB on Cloud Platform? MongoDB 到 Google Cloud Platform VPC 不工作 - MongoDB to Google Cloud Platform VPC not working 将MongoDB部署到Google Cloud Platform的最佳方法? - Best way to deploy MongoDB to Google Cloud Platform? Google云端平台 - 无法连接到mongodb - Google Cloud Platform - Can't connect to mongodb 将外部硬盘上的 MongoDB 转储转移到谷歌云平台 - Transfer MongoDB dump on external hard drive to google cloud platform 如何将 MongoDB Atlas 连接到 GCP(谷歌云平台)? - how to connect MongoDB Atlas to GCP(Google Cloud Platform)? 如何在Google Cloud Platform中将Node.js应用程序与MongoDB连接 - How do i connect nodejs app with mongodb in google cloud platform 如何创建在谷歌云平台创建的MongoDB的用户? - How to create a user of MongoDB created in Google Cloud Platform? 如何使用有效的 MongoDB 在 Google Cloud Platform 上部署 Flask 网站 - How Can I Deploy a Flask Website on Google Cloud Platform with a working MongoDB 我正在尝试将 Node.js 应用程序部署到 Google Cloud Platform,但在使用 MongoDB 时遇到错误 - I'm trying to deploy Node.js app to Google Cloud Platform but catching error with MongoDB
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM