在弹性beantalk上安装mongodb的推荐方法 [英] recommended way to install mongodb on elastic beanstalk

查看:85
本文介绍了在弹性beantalk上安装mongodb的推荐方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看过如何在Elastic Beanstalk中安装mongodb? (日期为2014年),该版本不再有效.以及 https://docs. mongodb.org/ecosystem/platforms/amazon-ec2/#manually-deploy-mongodb-on-ec2

I have already taken a look at How to install mongodb in Elastic Beanstalk? dated 2014, which no longer works. as well as https://docs.mongodb.org/ecosystem/platforms/amazon-ec2/#manually-deploy-mongodb-on-ec2

我已经建立了一个在node.js上运行的新的Elastic beantalk环境,其中包含1个ec2微型实例运行Node.js的64位Amazon Linux 2016.03 v2.1.0"

I have set up a new elastic beanstalk environment running on node.js with 1 ec2 micro instance '64bit Amazon Linux 2016.03 v2.1.0 running Node.js'

我已经尝试使用ssh连接到我的实例并使用yum命令安装mongodb软件包:

I have already tried using ssh to connect into my instance and install the mongodb packages using yum command:

$ sudo yum install -y mongodb-org-server mongodb-org-shell mongodb-org-tools

并收到此回叫:

Loaded plugins: priorities, update-motd, upgrade-helper
No package mongodb-org-server available.
No package mongodb-org-shell available.
No package mongodb-org-tools available.
Error: Nothing to do

当我第一次ssh进入实例时,我收到以下错误警告:

When I first ssh 'd into my instance, I received this error warning:

This EC2 instance is managed by AWS Elastic Beanstalk. Changes made via SSH 
WILL BE LOST if the instance is replaced by auto-scaling. For more information 
on customizing your Elastic Beanstalk environment, see our documentation here: 
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html

当前,我的环境设置为单实例环境,以节省成本.但是,将来我将升级到自动缩放环境.

Currently my environment is set up as a single instance environment, to save on costs. However, in the future I will upgrade to an auto-scaling environment.

因此,我想建议在ec2中通过ssh进行任何更改,还是只使用EB CLI?

Because of this, I am asking is it recommendable to make any changes via ssh in ec2, or should I only be using EB CLI?

我在本地安装了EC2和EB CLI,但是我以前从未使用过EB CLI.如果我应该使用EB,是否有人建议安装mongodb?

I have both EC2 and EB CLI installed locally, however I have never used EB CLI before. If I should be using EB, does anyone have a recommended way to install mongodb?

推荐答案

万一有人在寻找答案,以下是我从aws业务支持那里收到的建议.

In case anyone is looking for an answer, here is the advice I received from aws business support.

部署到Elastic Beanstalk的所有代码都必须是无状态的" IE.切勿使用SSH或FTP ...直接对正在运行的beantalk实例进行更改...,因为这将导致不一致和/或数据丢失! -Elastic Beanstalk不是为非无状态的应用程序设计的. 该环境旨在在您的网络/CPU负载上按比例扩展和缩小,并通过基本AMI构建新实例.如果实例出现问题或底层硬件,Elastic Beanstalk将终止这些正在运行的实例并替换为新实例.因此,为什么不必须对现有实例直接"应用或不进行任何代码修改,因为新实例将不会意识到这些直接更改.需要将所有更改/代码上载到Elastic Beanstalk控制台或CLI工具,然后将其推送到所有正在运行的实例. 有关Elastic Beanstalk设计概念的更多信息,请参见以下链接 http://docs.aws.amazon.com/elasticbeanstalk /latest/dg/concepts.concepts.design.html

All code deployed to Elastic Beanstalk needs to be "stateless" I.E. Never make changes directly to a running beanstalk instance using SSH or FTP.... As this will cause inconsistencies and or data lose! - Elastic Beanstalk is not designed for application that are not stateless. The environment is designed to scale up and down pending on your Network / CPU load and build new instances from a base AMI. If an instance has issues or the underlying hardware, Elastic Beanstalk will terminate these running instances and replace with new instances. Hence, why no code modification must be applied or done "directly" to an existing instance as new instances will not be aware of these direct changes. ALL changes / code needs to be either uploaded to Elastic Beanstalk console or the CLI tools and the pushed to all the running instances. More information on Elastic Beanstalk design concepts can be read at the following link http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/concepts.concepts.design.html

建议的解决方案: 考虑到以上几点,如果使用MongoDB存储应用程序数据,我们的建议是将MongoDB环境与Node.js应用程序进行DE耦合. I.E在Elastic Beanstalk外部创建MongoDB服务器,例如直接在EC2实例上启动MongoDB,并使用应用程序中的连接设置将Elastic Beanstalk Node.js应用程序连接到MongoDB Server.

Suggested Solution: With the above in mind, if using MongoDB to store application data our recommendation would be to DE-couple the MongoDB environment from your Node.js application. I.E Create a MongoDB Server outside of Elastic Beanstalk, example launching MongoDB directly on a EC2 instance and have your Elastic Beanstalk Node.js application connect to MongoDB Server using connection settings in your app.

-创建MongoDB 以下是一些示例链接,这些链接可能适用于您创建MongoDB服务器的方案. 在EC2上部署MongoDB, https://docs.mongodb.org/ecosystem/platforms/amazon-ec2/ MongoDB节点客户端 https://docs.mongodb.org/getting-started/node/client/ AWS Cloud上的MongoDB快速入门指南 http://docs.aws.amazon.com/quickstart/latest/mongodb /architecture.html

-Creating MongoDB Below is some example links that may be of use for your scenario for creating a MongoDB Server. Deploy MongoDB on EC2, https://docs.mongodb.org/ecosystem/platforms/amazon-ec2/ MongoDB node client https://docs.mongodb.org/getting-started/node/client/ MongoDB on the AWS Cloud quick start guide http://docs.aws.amazon.com/quickstart/latest/mongodb/architecture.html

-将环境变量添加到Elastic Beanstalk以引用您的MongoDB服务器 创建MongoDB服务器后,您可以使用环境变量将所需的连接设置传递到Elastic Beanstalk环境. 使用.ebextensions .config的示例,您可以添加Mongo URL/端口/用户等.

-Adding environment variables to Elastic Beanstalk to reference your MongoDB server Once you have created your MongoDB Server you can pass the needed connection settings to your Elastic Beanstalk environment using environment variables. Example using .ebextensions .config which you can add Mongo URL / ports / users etc..

option_settings: -option_name:MONGO_DB_URL 值:您的MongoDB EC2内部IP地址"

option_settings: - option_name: MONGO_DB_URL value: "Your MongoDB EC2 internal IP address"

有关如何使用环境属性以及如何从应用程序中读取它们的信息可以在下面看到. http://docs.aws.amazon.com /elasticbeanstalk/latest/dg/create_deploy_nodejs.container.html#create_deploy_nodejs_custom_container-envprop 在以下链接中可以找到使用.ebextensions .config的信息 http://docs.aws.amazon.com/elasticbeanstalk/latest/dg /ebextensions.html

Information on how to use environment properties and read them from within your application can be seen below. http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_nodejs.container.html#create_deploy_nodejs_custom_container-envprop And information using .ebextensions .config can be found at the following link http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/ebextensions.html

或者,您也可以使用cli或通过AWS控制台设置环境变量 可以通过以下链接读取eb cli set环境变量. http://docs.aws.amazon.com/elasticbeanstalk/latest /dg/eb3-setenv.html 使用AWS控制台 设置系统属性(AWS管理控制台) 打开Elastic Beanstalk控制台. 导航到您环境的管理控制台. 选择配置. 在软件配置"部分中,选择编辑". 在环境属性"下,创建您的名称/值...

Alternatively you can also set environment variable using the cli or via the AWS Console eb cli set environment variables can be read per the below link. http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb3-setenv.html Using AWS Console To set system properties (AWS Management Console) Open the Elastic Beanstalk console. Navigate to the management console for your environment. Choose Configuration. In the Software Configuration section, choose Edit. Under Environment Properties, create your name / values ...

访问环境配置设置 在AWS Elastic Beanstalk中运行的Node.js环境中,您可以使用process.env.ENV_VARIABLE来访问环境变量,类似于以下示例. process.env.MONGO_DB_URL process.env.PARAM2

Accessing Environment Configuration Settings Inside the Node.js environment running in AWS Elastic Beanstalk, you can access the environment variables using process.env.ENV_VARIABLE similar to the following example. process.env.MONGO_DB_URL process.env.PARAM2

http://docs.aws. amazon.com/elasticbeanstalk/latest/dg/create_deploy_nodejs.container.html#create_deploy_nodejs_custom_container-envprop

摘要: 总而言之,我建议按照以下步骤将MongoDB与Elastic Beanstalk环境集成. 步骤1)在Elastic Beanstalk之外创建MongoDB服务器 第2步)在Elastic Beanstalk中创建连​​接到MongoDB服务器的Node.js应用程序

Summary: In summary I would recommend the following steps to integrate MongoDB with Elastic Beanstalk environments. Step 1) Create a MongoDB Server outside of Elastic Beanstalk Step 2) Create your Node.js application in Elastic Beanstalk that connect to your MongoDB server

这篇关于在弹性beantalk上安装mongodb的推荐方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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