系统:CentOS5.6
下载mongo源码包,pcre,epel,js 1 #wget http://downloads.mongodb.org/src/mongodb-src-r1.8.1.tar.gz
#wget http://ftp.mozilla.org/pub/mozilla.org/js/js-1.7.0.tar.gz
#wget http://sourceforge.net/projects/pcre/files/pcre/8.12/pcre-8.12.tar.bz2 安装 python : #yum install -y python-devel 安装scons: 下载scons tar zxf scons-2.0.1.tar.gzcd scons-2.0.1
python setup.py install 安装spidermonkey库,下载支持c的js api库 点此下载js-1.7.0.tar.gzyum install -y boost boost-develtar zxvf js-1.7.0.tar.gz
cd js/src/
export CFLAGS="-DJS_C_STRINGS_ARE_UTF8"
make -f Makefile.ref
JS_DIST=/usr gmake -f Makefile.ref export
cd ../.. 安装pcretar zxf pcre-8.12.tar.gzcd pcre-8.12
./configure --enable-utf8 --enable-unicode-properties
make && make install
cd .. 安装MongoDBtar zxf mongodb-src-r1.8.1.tar.gz cd mongodb-src-r1.8.1
scons all // scons可能出现找不到pcre库的现象(修改/etc/ld.so.conf也无用,是scons自身的问题),这时需要打开mongodb-src-r1.8.0下的SConstruct,查找【 linux2"== os.sys.platform:】,在LIBPATH后面添加上pcrecpp库的安装路径,在LIBS后添加上pcrecpp库名,再重新scons all即可(操作:vim SConstruct;原来:env.Append( LIBPATH=["/usr/lib64" , "/lib64" ] ) ;修改后env.Append( LIBPATH=["/usr/lib64" , "/lib64" ,"/usr/local/pcre/lib"]); 接下来在env.Append( LIBS=["pthread"] )后面添加 env.Append( LIBS=["libpcrecpp"] ) )scons --prefix=/usr/local/mongo install如果需要安装lib和head,使用如下方式安装scons --prefix=/usr/local/mongo --full install 创建配置文件mkdir -p /usr/local/mongo/etc /usr/local/mongo/data /usr/local/mongo/log/ /usr/local/mongo/repair
vim /usr/local/mongo/etc/mongo.conf
在mongo.conf中添加下面的内容
dbpath = /usr/local/mongo/data
logpath = /usr/local/mongo/mongodb.log
repairpath = /usr/local/mongo/repair
pidfilepath = /usr/local/mongo/mongodb.pid
directoryperdb = truelogappend = truenoauth = trueport = 27017maxConns = 1024fork = truerest = truequota = truequotaFiles = 1024nssize = 16 启动mongodbln -s /usr/local/mongo/bin/mongod /usr/bin/mongodmongod -f /usr/local/mongo/etc/mongo.conf看看是不是启动起来了,但是使用这种方式管理mongodb服务器很不明智,我们完善一下:
mkdir -p /usr/local/mongo/srvvim /usr/local/mongo/srv/mongodb-start添加下面的内容
#!/bin/shmongod -f /usr/local/mongo/etc/mongo.conf
vim /usr/local/mongo/srv/mongodb-stop添加下面的内容
#!/bin/bashpid=`ps -o pid,command ax | grep mongod | awk "!/awk/ && !/grep/ {print $1}"`;if [ "${pid}" != "" ]; then kill -2 ${pid};fi添加执行权限
chmod a+x /usr/local/mongo/srv/mongodb-startchmod a+x /usr/local/mongo/srv/mongodb-stopvim /etc/rc.d/init.d/mongodb添加下面的内容
#! /bin/sh## mongodb – this script starts and stops the mongodb daemon## chkconfig: - 85 15# description: MongoDB is a non-relational database storage system.# processname: mongodb# config: /usr/local/mongo/etc/mongo.conf# pidfile: /usr/local/mongo/mongodb.pidPATH=/usr/local/mongo/bin:/sbin:/bin:/usr/sbin:/usr/binNAME=mongodbtest -x $DAEMON || exit 0set -ecase "$1" in start) echo -n "Starting MongoDB... " /usr/local/mongo/srv/mongodb-start ;; stop) echo -n "Stopping MongoDB... " /usr/local/mongo/srv/mongodb-stop ;; *) N=/etc/init.d/$NAME echo "Usage: $N {start|stop}" >&2 exit 1 ;; esac exit 0添加服务chmod a+x /etc/rc.d/init.d/mongodbchkconfig --add mongodbchkconfig --level 345 mongodb on/etc/rc.d/init.d/mongodb start
Configure xfs filesystem on RHEL6Linux虚拟文件系统(安装根文件系统)相关资讯 MongoDB CentOS教程
- MongoDB 3.3.0 发布下载 (01月14日)
- 使用MongoDB C#官方驱动操作 (12/31/2015 16:27:56)
- CentOS 6.6下安装MongoDB 3.0.1 (12/21/2015 19:29:02)
| - MongoDB 3.2版WiredTiger存储引擎 (01月02日)
- 进程监控工具Supervisor 启动 (12/26/2015 10:49:57)
- MongoDB 3.2.1 RC0 发布下载 (12/18/2015 11:32:29)
|
本文评论 查看全部评论 (0)