-1

I'm trying to setup an Elastic Beanstalk with mongodb. I got a solution from this link. But it is not working for me. I'm using " 64-bit Amazon Linux 2014.03 v1.0.4.". When I'm trying to install mongodb using the solution of the link, it stops the instance with the following error.

Error: failed to connect to [localhost:27017]
at null.<anonymous> (/var/app/current/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:546:74)
at EventEmitter.emit (events.js:106:17)
at null.<anonymous> (/var/app/current/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:150:15)
at EventEmitter.emit (events.js:98:17)
at Socket.<anonymous> (/var/app/current/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:533:10)
at Socket.EventEmitter.emit (events.js:95:17)
at net.js:440:14
at process._tickCallback (node.js:415:13)

I followed the instruction and put the content in aws.config file as told. Please help.

Community
  • 1
  • 1
Kaushick Gope
  • 154
  • 1
  • 11
  • 2
    I have the same issue. This is not working as well in my side. – Kundu Jul 09 '14 at 12:26
  • Per the provided link, what do the logs say? The error you're getting indicates that the mongo server isn't running or that if it is, it's not accessible through its default port (27017:tcp) – Rob Raisch Jul 09 '14 at 16:24
  • 2
    Do not link to another answer and say "I used this." First of all, you didn't link to an answer, you linked to a question. The question might get more answers in the future, in which case we won't know which answer you're talking about. Second, the answer, or it's question, may change or even be deleted in the future, in which case, again, we won't know what ***you*** tried specifically. So copy whatever code you tried to use into your own question (but still link to where you originally got the code from). –  Jul 10 '14 at 21:08
  • Why do you not ask under the corresponding answer? You have all the required reputation for that. – László Papp Jul 10 '14 at 21:15
  • 1
    @FinalContest Please look at my question, I mentioned the link and for the solution given there I'm getting the error. – Kaushick Gope Jul 11 '14 at 07:13
  • Need logs to see exactly what is going on. To get the logs you can go into elastic beanstalk console and click on the link that says "Request Logs" – Jeff T Sep 24 '14 at 21:25

1 Answers1

2

I've had to do this enough times to create a gist so I can quickly do it again.

First, ssh into your AWS EC2 instance (ssh -i ec2-user@)

From here on, it's pretty much copy/paste:

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

Now fill in the contents of the file to:

* soft nofile 64000
* hard nofile 64000
* soft nproc 32000
* hard nproc 32000

Now change this file:

sudo nano /etc/security/limits.d/90-nproc.conf

with contents:

* 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

And don't forget to start the daemon process:

//Run persistent
mongod --fork --logpath /var/log/mongodb/mongod.log
jordan
  • 9,570
  • 9
  • 43
  • 78