System version: 32-bit CENTOS5.5
Installing MongoDB
Install SCons, JS
Yum install-y boost Boost-devel pcre pcre-develwget http://sourceforge.net/projects/scons/files/scons/2.1.0. Alpha.20101125/scons-2.1.0.alpha.20101125.tar.gz/downloadtar XVF SCONS-2.1.0.ALPHA.20101125.TAR.GZCD Scons-2.1.0.alpha.20101125python setup.py INSTALLCD. wget http://ftp.mozilla.org/pub/mozilla.org/js/js-1.7.0.tar.gztar zxvf js-1.7.0.tar.gzcd js/src/export cflags= "-djs _c_strings_are_utf8 "Make-f makefile.refjs_dist=/usr gmake-f makefile.ref Exportcd. /..
Installing MongoDB
wget Http://fastdl.mongodb.org/linux/mongodb-linux-i686-2.0.4.tgztar XVF http://fastdl.mongodb.org/linux/ MONGODB-LINUX-I686-2.0.4.TGZMV mongodb-linux-i686-2.0.4/usr/local/mongodbmkdir-pv/usr/local/mongodb/data/usr/ Local/mongodb/etc/usr/local/mongodb/log
Configuration file
cat > /usr/local/mongodb/etc/mongod.conf << ' EOF ' # log file to send write to instead of stdout – has to be a file, Not directorylogpath=/usr/local/mongodb/log/mongod.log# append to logpath instead of over-writinglogappend=true# fork and run in backgroundfork = True# specify port numberport = 27017# comma separated list of ip addresses to listen on – all local ips by default# bind_ip = 192.168.51.119# directory for datafilesdbpath = /usr/local/ mongodb/data# full path to pidfile (if not set, no pidfile is created) pidfilepath = /usr/local/mongodb/log/mongod.pid# enables periodic logging of cpu Utilization and i/o wait#cpu = true# turn on/off security. off is currently the default#noauth = trueauth = true# Verbose Logging output. #verbose = true# Inspect all client data for validity on receipt (useful for# developing drivers) #objcheck = true# enable db quota managementquota = true# set oplogging level where n is# 0=off (default) # 1=w# 2=r# 3=both# 7=w+some reads#oplog = 0# diagnostic/debugging option#nocursors = true# ignore query hints#nohints = true# disable the http interface (Defaults to localhost:27018). #nohttpinterface = true# Turns off server-side scripting. this will result in greatly limited# functionality#noscripting = true# turns off table scans. any query that would do a table scan Fails. #notablescan = true# disable data file preallocation. #noprealloc = true# specify .ns file size for new databases.nssize = 16# accout token for mongo monitoring server. #mms-token = <token># server name for mongo monitoring server. #mms-name = <server-name ># ping interval for mongo monitoring server. #mms-interval = < Seconds># replication options# in replicated mongo databases, specify here whether this is a slave or master#slave = true#source = master.example.com# slave only: specify a single database to replicate#only = master.example.com# or#master = true#source = slave.example.comeof
Startup script
cat > /etc/rc.d/init.d/mongod << ' EOF ' #!/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/functionsprog= "Mongod" mongod= "/usr/local/mongodb/bin/ Mongod "options=" -f /usr/local/mongodb/etc/mongod.conf "Retval=0start () { echo -n $ "starting $prog: " $mongod $OPTIONS RETVAL=$? echo [ $RETVAL - eq 0 ] && touch /usr/local/mongodb/log/$prog return $RETVAl}stop () { echo -n $ "Stopping $prog: " killproc $prog RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f /usr/local/mongodb/log/$prog return $RETVAL}reload () { echo -n $ "reloading $prog: " killproc $prog -HUP RETVAL=$? echo return $RETVAL} case "$" in start) start ;; stop) stop ;; restart) stop start ;; condrestart) if [ -f / usr/local/mongodb/log/$prog ]; then stop start fi ;; reload) reload ;; status) status $mongod retval=$? ;; *) echo $ "Usage: $0 { Start|stop|restart|condrestart|reload|status} " retval=1esacexit $RETVALEOF # Execute permissions chmod a+x /etc/rc.d/init.d/mongod# add to boot entry Chkconfig --add mongodchkconfig mongod on
Installing the PHP MONGO extension
wget http://pecl.php.net/get/mongo-1.2.2.tgztar zxf mongo-1.2.2.tgzcd mongo-1.2.2phpize./configuremake && Make install
Add a line to the php.ini file after completion
[mongodb]extension=mongo.so
Successful words phpinfo () will see MONGO a
Welcome to visit the Mall!
Dressing up
City of words and things
This article from "Linux operation and Maintenance" blog, declined reprint!
KV Permanent Storage MongoDB