본문 바로가기

Technical/DBMS

Building mongodb r1.4.4

반응형

[Getting ready]

* Install spidermonkey(js.lib)
# curl -O ftp://ftp.mozilla.org/pub/mozilla.org/js/js-1.7.0.tar.gz
# tar zxvf js-1.7.0.tar.gz
# cd js/src
# export CFLAGS="-DJS_C_STRINGS_ARE_UTF8"
# make -f Makefile.ref
# JS_DIST=/usr make -f Makefile.ref export

* install scons, pcre-devel
# zypper in scons
# zypper in pcre-devel

* Packages needed for building  mongo
<Fedora 8, 10, ...Opensuse 11, ...>
git, tcsh, scons, gcc-c++, glibc-devel
boost-devel pcre-devel js-devel readline-devel
boost-devel-static, readline-static ncurses-static
<Ubuntu 9.x>
tcsh git-core scons g++
libpcre++-dev libboost-dev libreadline-dev xulrunner-1.9.1-dev
libboost-program-options-dev libboost-thread-dev libboost-filesystem-dev libboost-date-time-dev

[Building & installing]
* js와 mongodb-src-r1.x.x 가 동일한 directory에 위치하도록(mongo build시 ../js 를 참조함)

# scons all
# scons --prefix=/user/service/mongo install

* Enjoy huMONGOus document database

[Run mongo as an auto-start daemon]

* Make data & log directory for mongo
# mkdir /user/service/mongo/data
# mkdir /user/service/mongo/log

vi mongo
-----------------------------------------------------------------------------
#!/bin/bash
#
### BEGIN INIT INFO
# Provides:          mongoDB
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start and stop the mongo database server daemon
# Description:       Controls the main mongo database server daemon "mongod"
### END INIT INFO
#
# Copy this file to /etc/init.d & run commands below
#  1. Make symbolic link to /etc/rc[0-6].d/S??mongo
#  2. ln -s /etc/init.d/mongo /etc/rc[2345].d/S30mongo ==> start on boot(as to run level 2, 3, 4, 5
#  3. ln -s /etc/init.d/mongo /etc/rc[012].d/K30mongo ==> start on boot(as to run level 2, 3, 4, 5
#
export MONGO_HOME=/user/service/mongo
# Test if the file is executable, exits if not
test -x $MONGO_HOME/bin/mongod || exit 0
#
# main()
#
case "${1:-''}" in
  'start')
        # Start daemon
        $MONGO_HOME/bin/mongod --auth --port 28017 --dbpath $MONGO_HOME/data/ --fork --logpath $MONGO_HOME/log/mongodb.log
        ;;

  'stop')
        pid=`ps -o pid,command ax | grep mongod | awk '!/awk/ && !/grep/ {print $1}'`
        if [ "${pid}" != "" ]; then
            echo "About to kill mongod ...";
            echo "Pid: $pid";
            sudo kill -2 ${pid};
        fi
        ;;

  'restart'|'reload'|'force-reload')
        pid=`ps -o pid,command ax | grep mongod | awk '!/awk/ && !/grep/ {print $1}'`
        if [ "${pid}" != "" ]; then
            echo "About to kill '$1'...";
            echo $pid;
            sudo kill -2 ${pid};
        fi
        sleep 5
        $MONGO_HOME/bin/mongod --auth --port 28017 --dbpath $MONGO_HOME/data/ --fork --logpath $MONGO_HOME/log/mongodb.log
        ;;

  'status')
        $MONGO_HOME/bin/mongod --sysinfo
        ;;

  *)
        echo "Usage: $SELF start|stop|restart|reload|force-reload|status"
        exit 1
        ;;
esac
-----------------------------------------------------------------------------

# chmod +x mongo
# cp mongo /etc/init.d
# chkconfig --add mongo
# chkconfig mongo ON

* Start by "/etc/init.d/mongo start" & have fun.


반응형