Created
December 22, 2015 17:39
-
-
Save thonguyenvn/9fae7416f6334b1a77bf to your computer and use it in GitHub Desktop.
Install node and mongodb on Amazon EC2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
First step: Installing node.js and npm | |
To compile node we need gcc, make and git to import node source code: | |
sudo yum install gcc-c++ make | |
sudo yum install openssl-devel | |
sudo yum install git | |
Cloning node.js source code: | |
git clone git://github.com/nodejs/node.git | |
Compile and install node.js | |
cd node | |
./configure | |
make | |
sudo make install | |
Add user´s directory to BIN Paths (node binaries location) | |
sudo su | |
nano /etc/sudoers | |
inside the editor scroll to where you see the line: Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin | |
Append the value :/usr/local/bin | |
Installing npm (Node Package Manager) | |
git clone https://github.com/npm/npm.git | |
cd npm | |
sudo make install | |
Test if node is working: | |
node | |
this must show a > indicator | |
press Ctrl+C two times to close node interpreter | |
If you receive a "Command not found" message, close your SSH connection and reconnect. This loads the PATH information you added into /etc/sudoers earlier. | |
Second step: Install and configure MongoDB database | |
Based on http://docs.mongodb.org/ecosystem/tutorial/install-mongodb-on-amazon-ec2/ | |
First add an entry to the local yum repository for MondoDB | |
echo "[10gen] | |
name=10gen Repository | |
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64 | |
gpgcheck=0" | sudo tee -a /etc/yum.repos.d/10gen.repo | |
You must respect jump of lines in the previous code | |
Next, install MongoDB and the sysstat diagnostic tools: | |
sudo yum -y install mongo-10gen-server mongodb-org-shell | |
sudo yum -y install sysstat | |
We are using /var/lib/mongo folder to save database, log and journal data, you can another folder path. | |
sudo mkdir /var/lib/mongo/data | |
sudo mkdir /var/lib/mongo/log | |
sudo mkdir /var/lib/mongo/journal | |
Set the storage items (data, log, journal) to be owned by the user (mongod) and group (mongod) that MongoDB will be starting under: | |
sudo chown mongod:mongod /var/lib/mongo/data | |
sudo chown mongod:mongod /var/lib/mongo/log | |
sudo chown mongod:mongod /var/lib/mongo/journal | |
Starting and testing MongoDB | |
Set the MongoDB service to start at boot and activate it: | |
sudo chkconfig mongod on | |
sudo /etc/init.d/mongod start | |
When starting for the first time, it will take a couple of minutes for MongoDB to start, setup it’s storage and become available. Once it is, you should be able to connect to it from within your instance: | |
$ mongo | |
MongoDB shell version: 2.4.3 | |
connecting to: test | |
> | |
For more information about how to configure storage setting for MongoDB on Amazon EC2, checkout http://docs.mongodb.org/ecosystem/tutorial/install-mongodb-on-amazon-ec2/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment