记录一下源码安装MongoDB的过程

mongodb目前最新的版本是.8.2-rc3,其源码安装用了很多第三方的东西,比如JS引擎(目前官方推荐的是mozilla的Spider Monkey,以后可能改成google的V8,和node.js一样,呵呵)、正则表达式引擎(pcre)、安装构建工具scons(这东西还要用python来安装)、boost C++库等等。下面是安装实录:

1,下载需要的源文件和相关软件包:

        [root@localhost mongodb]# wget http://downloads.mongodb.org/src/mongodb-src-r1.8.2-rc3.tar.gz

        [root@localhost mongodb]# wget http://sourceforge.net/projects/scons/files/scons/2.1.0.alpha.20101125/scons-2.1.0.alpha.20101125.tar.gz/download

        [root@localhost mongodb]# wget http://ftp.mozilla.org/pub/mozilla.org/js/js-1.7.0.tar.gz

        [root@localhost mongodb]# wget http://sourceforge.net/projects/pcre/files/pcre/7.4/pcre-7.4.tar.gz/download

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


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


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


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


7,启动mongodb来测试:

[root@localhost bin]# ./mongod --dbpath /tmp
./mongod: error while loading shared libraries: libpcrecpp.so.0: cannot open shared object file: No such file or directory
    [root@localhost bin]# ./mongod --dbpath /tmp

    ./mongod: error while loading shared libraries: libpcrecpp.so.0: cannot open shared object file: No such file or directory

    [root@localhost bin]# LD_DEBUG=libs ./mongod -v

    ......

    29656:       trying file=/lib64/tls/x86_64/libpcrecpp.so.0

    29656:       trying file=/lib64/tls/libpcrecpp.so.0

    29656:       trying file=/lib64/x86_64/libpcrecpp.so.0

    29656:       trying file=/lib64/libpcrecpp.so.0

    29656:       trying file=/usr/lib64/tls/x86_64/libpcrecpp.so.0

    29656:       trying file=/usr/lib64/tls/libpcrecpp.so.0

    29656:       trying file=/usr/lib64/x86_64/libpcrecpp.so.0

    29656:       trying file=/usr/lib64/libpcrecpp.so.0

    29656:

    ./mongod: error while loading shared libraries: libpcrecpp.so.0: cannot open shared object file: No such file or directory

    [root@localhost bin]# ln -s /usr/local/lib/libpcrecpp.so.0 /usr/lib64/libpcrecpp.so.0

    [root@localhost bin]# ll /usr/lib64/libpcrecpp.so.0

    lrwxrwxrwx 1 root root 30 Jun  8 11:57 /usr/lib64/libpcrecpp.so.0 -> /usr/local/lib/libpcrecpp.so.0

    [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








在debian下安装mongoDB

1. apt-get install scons
2. apt-get install libpcrecpp0 ( Perl 5 Compatible Regular Expression Library - C++ runtime files )
3. apt-get install libpcre3-dev - Perl 5 Compatible Regular Expression Library - development files
4. apt-get install libboost1.35-dev (boost 库, 官网最新为1.4)
5. apt-get install libpcap-dev
6. apt-get install libmozjs-dev
7. apt-get install xulrunner-dev (gecko库)
8.  wget http://fastdl.mongodb.org/src/mongodb-src-r1.4.4.tar.gz
9. tar zxvf mongodb-src-r1.4.4.tar.gz
10.cd 源代码解压目录
11. scons --sharedclient=SHAREDCLIENT all --prefix=/home/liubao/mongodb/mongodb
12. scons --prefix=/usr/local/enginc/mongodb  install 

mongoDB是用C++写的,在编译的过程中用到gecko的库。内部应该用了很多js的操作。而且看到了类似json.cpp文件。不知道数据是不是以json格式压缩存储的。明天看看这个东东怎么用。

还注意到一个问题。mongoDB是自己写的driver;而canssandra一类的则是用Thrift的协议进行跨语言通信;不知道这是出于性能的考虑还是其它的原因





apt-get install scons

E: Sub-process /usr/bin/dpkg returned an error code (1)问题解决办法:

此时可以这样解决:
cd /var/lib/dpkg
sudo mv info info.bak
sudo mkdir info



你可能感兴趣的:(mongodb,object,File,library,mozilla,js引擎)