我正在尝试使用mongodb设置Elastic Beanstalk。我从这个link得到了一个解决方案。 但这对我不起作用。我正在使用" 64位Amazon Linux 2014.03 v1.0.4。"。当我尝试使用链接解决方案安装mongodb时,它会因以下错误而停止实例。
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)
我按照说明将内容放在aws.config文件中。请帮忙。
答案 0 :(得分:2)
我必须这么做才能创建一个gist所以我可以快速再做一次。
首先,ssh进入您的AWS EC2实例(ssh -i ec2-user @)
从现在开始,它几乎可以复制/粘贴:
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