I'm quite new to amazon web services and elastic beanstalk.
Although many people say it's simple and straightforward to use, I would say that is a very subjective statement. For someone like me who is new to cloud hosting and virtual private servers, I believe the learning curve isn't much different to someone who would have to learn to do it "the hard way".
I'm developing a nodejs website that uses expressjs as it's core framework and MongoDB as its database. My employer wants us to use AWS. Now that's where the problem begins.
I've been able to set up an environment on elastic beanstalk and even upload the application and the environment started, but nothing's working.
The first problem I have is that as much as I set up the environment successfully, I have little to no idea about what all the configurations mean and my head is spinning. The official AWS documentation doesn't help much there.
Secondly, I don't know how to get it to work with MongoDB, on the dashboard the only option I'm seeing is Amazon RDS and any explanations I've searched for are quite complicated for a newbie like me.
Does anyone have a link to somewhere I can get a simple explanation for all this or can someone simply explain to how to do this?
PS: The AWS environment I created is a 64bit Amazon Linux 2014.03 v1.0.6 running Node.js
EDIT: I'm getting the error 502 Bad Gateway. The app runs behind a front facing nginx proxy.
AWS is a bit more advanced in what you can do with configuring your servers and applications, so it's no wonder it can be confusing. Most of the time, the docs don't do much to help either. Amazon steers you to using their RDS / nosql (DynamoDB). You can add many different types of databases in the AMI marketplace, but I find these to be way too expensive and unnecessary.
For the following, ssh
into your EC2 instance ssh -i <your .pem key> ec2-user@ec2-xx-xx-xx-xx.us-west-2.compute.amazonaws.com
(should look similar to that)
For MongoDB on AWS:
echo "[MongoDB]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64
gpgcheck=0
enabled=1" | sudo tee -a /etc/yum.repos.d/mongodb.repo
sudo yum install -y mongodb-org-server mongodb-org-shell mongodb-org-tools
sudo mkdir /data /log /journal
//Mount partitions -- Find available ones for /data /log /journal
sudo mkfs.ext4 /dev/xvdf
sudo mkfs.ext4 /dev/xvdg
sudo mkfs.ext4 /dev/xvdh
echo '/dev/xvdf /data ext4 defaults,auto,noatime,noexec 0 0
/dev/xvdg /journal ext4 defaults,auto,noatime,noexec 0 0
/dev/xvdh /log ext4 defaults,auto,noatime,noexec 0 0' | sudo tee -a /etc/fstab
sudo mount /data
sudo mount /journal
sudo mount /log
sudo chown mongod:mongod /data /journal /log
sudo ln -s /journal /data/journal
nano /etc/mongod.conf
//Change to
dbpath = /data
logpath = /log/mongod.log
sudo nano /etc/security/limits.conf
* soft nofile 64000
* hard nofile 64000
* soft nproc 32000
* hard nproc 32000
sudo nano /etc/security/limits.d/90-nproc.conf
* soft nproc 32000
* hard nproc 32000
sudo blockdev --setra 32 /dev/xvdf
echo 'ACTION=="add", KERNEL=="xvdf", ATTR{bdi/read_ahead_kb}="16"' | sudo tee -a /etc/udev/rules.d/85-ebs.rules
//Run persistent
mongod --fork --logpath /var/log/mongodb/mongod.log
Reference: gist
You can run mongo
in your current ssh session to make sure it's properly running.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.