MongoDB opensource Installation on RHEL6 64 bit from binaries

6:36 PM

1. Create a directory

[hostname_mongodb ~]# mkdir -p /usr/mongodb

2. Download the binaries files of MongoDB from https://www.mongodb.org/downloads and extract the files

[hostname_mongodb ~]# curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.0.3.tgz
[hostname_mongodb ~]# tar -zxvf mongodb-linux-x86_64-rhel62-3.0.3.tgz
[hostname_mongodb ~]# cp -R -n mongodb-linux-x86_64-3.0.3/* /usr/mongodb

3. Create a data directory

[hostname_mongodb ~]# mkdir -p /data/db

4. Add start/stop/restart control script

[hostname_mongodb ~]# vi /etc/init.d/mongod
#!/bin/bash
#
# mongodb     Startup script for the mongodb server
#
# chkconfig: - 64 36
# description: MongoDB Database Server
#
# processname: mongodb
#

# Source function library
. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/mongodb ]; then
	. /etc/sysconfig/mongodb
fi

prog="mongod"
mongod="/usr/mongodb/bin/mongod"
RETVAL=0

start() {
	echo -n $"Starting $prog: "
	daemon $mongod "--fork --logpath /var/log/mongodb.log --logappend 2>&1 >>/var/log/mongodb.log"
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
	return $RETVAL
}

stop() {
	echo -n $"Stopping $prog: "
	killproc $prog
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
	return $RETVAL
}

reload() {
	echo -n $"Reloading $prog: "
	killproc $prog -HUP
	RETVAL=$?
	echo
	return $RETVAL
}

case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	restart)
		stop
		start
		;;
	condrestart)
		if [ -f /var/lock/subsys/$prog ]; then
			stop
			start
		fi
		;;
	reload)
		reload
		;;
	status)
		status $mongod
		RETVAL=$?
		;;
	*)
		echo $"Usage: $0 {start|stop|restart|condrestart|reload|status}"
		RETVAL=1
esac

exit $RETVAL

5. Change the permission and add it to startup

[hostname_mongodb ~]#chmod 755 /etc/init.d/mongod
[hostname_mongodb ~]#chkconfig --add mongod && chkconfig mongod on

6. Start mongoDB service

[hostname_mongodb ~]# /etc/init.d/mongod start
[hostname_mongodb ~]# netstat -an | grep -i mongodb
unix  2      [ ACC ]     STREAM     LISTENING     135857003 /tmp/mongodb-27017.sock

7. How to access mongo shell client locally

[hostname_mongodb ~]# mongo
MongoDB shell version: 3.0.3
connecting to: test
2015-05-20T23:29:51.812-0400 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:36571 #1 (1 connection now open)
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
        http://docs.mongodb.org/
Questions? Try the support group
        http://groups.google.com/group/mongodb-user
Server has startup warnings:
2015-05-20T23:21:29.021-0400 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2015-05-20T23:21:29.021-0400 I CONTROL  [initandlisten]
2015-05-20T23:21:29.021-0400 I CONTROL  [initandlisten]
2015-05-20T23:21:29.021-0400 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2015-05-20T23:21:29.021-0400 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2015-05-20T23:21:29.021-0400 I CONTROL  [initandlisten]
2015-05-20T23:21:29.021-0400 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2015-05-20T23:21:29.021-0400 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2015-05-20T23:21:29.021-0400 I CONTROL  [initandlisten]
>

You Might Also Like

0 comments

Contact Form

Name

Email *

Message *

Translate

Wikipedia

Search results