Monday, February 27, 2012

Install & setup MongoDB 2.0.2 on Ubuntu 11.10

Steps to install latest MongoDB(2.0.2) on ubuntu 11.10.

1. Download latest MongoDB(MongoDB 2.0.2) from here
$ cd tmp $ wget http://fastdl.mongodb.org/linux/mongodb-linux-i686-2.0.2.tgz

2. Extract downloaded file into /user/local
$ chmod +x mongodb-linux-i686-2.0.2.tgz $ sudo tar -zxvf mongodb-linux-i686-2.0.2.tgz -C /usr/local/ $ sudo mv mongodb-linux-i686-2.0.2 /usr/local/mongodb

3. Create a mongoDB data folder and log file for MongoDB service
mkdir -p /opt/data/mongodb mkdir -p /var/log/mongodb touch /var/log/mongodb/mongodb.log

4. Setup start and stop mongoDB service scripts
cd /usr/local/bin/ wget -O mongodb-start https://github.com/veera/MongoDB-scripts/blob/master/mongodb-start.sh wget -O mongodb-stop https://github.com/veera/MongoDB-scripts/blob/master/mongodb-stop.sh chmod +x *

5. MongoDB configuration
mkdir /usr/local/config touch /usr/local/config/mongodb Add these configuration on /usr/local/config/mongodb for mongoDB service # START bind_ip = 127.0.0.1 port = 27017 fork = true auth = true dbpath = /opt/data/mongodb logpath = /var/log/mongodb/mongodb.log logappend = true # END

6. Setup init script, basically needed for start and stop MongoDB server easily
$ cd tmp $ wget -O mongodb-service.sh https://github.com/veera/MongoDB-scripts/blob/master/mongodb-service.sh $ sudo mv mongodb-service.sh /etc/init.d/mongodb $ sudo chmod +x /etc/init.d/mongodb $ sudo /usr/sbin/update-rc.d -f mongodb defaults

6. Add mongodb user
$ adduser --system --disabled-login --disabled-password --group mongodb

7. Give permission to MongoDB data folder
$ sudo chown mongodb:mongodb -R /opt/data/mongodb

Start/Stop MongoDB service
$ sudo /etc/init.d/mongodb start $ sudo /etc/init.d/mongodb stop

I hope you've installed MongoDB without any issues.

No comments:

Post a Comment