2、安装scons:
[root@localhost mongodb]# tar zxvf scons-2.1.0.alpha.20101125.tar.gz
[root@localhost mongodb]# cd scons-2.1.0.alpha.20101125
[root@localhost scons-2.1.0.alpha.20101125]# python setup.py install
[root@localhost mongodb]# cd scons-2.1.0.alpha.20101125
[root@localhost scons-2.1.0.alpha.20101125]# python setup.py install
3、安装pcre:
[root@localhost mongodb]# tar zxvf pcre-7.4.tar.gz
[root@localhost mongodb]# cd pcre-7.4
[root@localhost pcre-7.4]# ./configure
[root@localhost pcre-7.4]# make
[root@localhost pcre-7.4]# make install
[root@localhost mongodb]# cd pcre-7.4
[root@localhost pcre-7.4]# ./configure
[root@localhost pcre-7.4]# make
[root@localhost pcre-7.4]# make install
4、安装Spider Monkey:
[root@localhost mongodb]# tar zxvf js-1.7.0.tar.gz
[root@localhost mongodb]# cd js/src
[root@localhost src]# export CFLAGS="-DJS_C_STRINGS_ARE_UTF8"
[root@localhost src]# make -f Makefile.ref
[root@localhost src]# JS_DIST=/usr make -f Makefile.ref export
[root@localhost mongodb]# cd js/src
[root@localhost src]# export CFLAGS="-DJS_C_STRINGS_ARE_UTF8"
[root@localhost src]# make -f Makefile.ref
[root@localhost src]# JS_DIST=/usr make -f Makefile.ref export
5、安装boost,yum方式比较偷懒:
[root@localhost src]# yum -y install boost boost-devel
6、安装mongodb:
[root@localhost mongodb]# tar zxvf mongodb-src-r1.8.2-rc3.tar.gz
[root@localhost mongodb]# cd mongodb-src-r1.8.2-rc3
[root@localhost mongodb-src-r1.8.2-rc3]# scons all
[root@localhost mongodb-src-r1.8.2-rc3]# scons --prefix=/usr/local/mongodb --full install
[root@localhost mongodb]# cd mongodb-src-r1.8.2-rc3
[root@localhost mongodb-src-r1.8.2-rc3]# scons all
[root@localhost mongodb-src-r1.8.2-rc3]# scons --prefix=/usr/local/mongodb --full install
这样就安装完毕了,可以简单的启动mongod进程来验证一下:
[root@localhost bin]# ./mongod --dbpath /tmp
Wed Jun 8 11:57:38 [initandlisten] MongoDB starting : pid=29700 port=27017 dbpath=/tmp 64-bit
Wed Jun 8 11:57:38 [initandlisten] db version v1.8.2-rc3, pdfile version 4.5
Wed Jun 8 11:57:38 [initandlisten] git version: nogitversion
Wed Jun 8 11:57:38 [initandlisten] build sys info: Linux localhost.localdomain 2.6.18-128.el5 #1 SMP Wed Jan 21 10:41:14 EST 2009 x86_64 BOOST_LIB_VERSION=1_33_1
Wed Jun 8 11:57:38 [initandlisten] waiting for connections on port 27017
Wed Jun 8 11:57:38 [websvr] web admin interface listening on port 28017
Wed Jun 8 11:57:38 [initandlisten] MongoDB starting : pid=29700 port=27017 dbpath=/tmp 64-bit
Wed Jun 8 11:57:38 [initandlisten] db version v1.8.2-rc3, pdfile version 4.5
Wed Jun 8 11:57:38 [initandlisten] git version: nogitversion
Wed Jun 8 11:57:38 [initandlisten] build sys info: Linux localhost.localdomain 2.6.18-128.el5 #1 SMP Wed Jan 21 10:41:14 EST 2009 x86_64 BOOST_LIB_VERSION=1_33_1
Wed Jun 8 11:57:38 [initandlisten] waiting for connections on port 27017
Wed Jun 8 11:57:38 [websvr] web admin interface listening on port 28017
可见mongod默认在27017端口监听,而28017端口是web管理的端口,可通过http方式来访问。为了规范,我们用以下命令启动一个mongod进程:
[root@localhost data]# /usr/local/mongodb/bin/mongod --fork --dbpath /home/mongo/data/ --logpath /home/mongo/mongo.log --logappend --directoryperdb --journal --rest
这样一个mongod进程就启动了,它监听27017端口来提供服务,可以在应用程序中进行建立数据库等操作,它不像传统的Oracle等关系数据库那样,建库是个很慎重的工作。要了解更详细的使用MongoDB的信息,读者可以参看官方文档,这里就不提及了。