RHEL5下编译MongoDB

很多人都说自己编译的稳定好用,我也来试试:

1. 参考官方文档,手工编译Spider Monkey
# 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

2. 安装scons,用官网的rpm包就行。

3. 重新编译pcre。自带的编译时没带--enable-unicode-properties参数,mongdb启动时会提示:warning: some regex utf8 things will not work. pcre build doesn't have --enable-unicode-properties. RPMS包是在这里找到的。

# rpm -ivh pcre-6.6-2.el5_1.7.src.rpm
# vi /usr/src/redhat/SPECS/pcre.spec
%configure --enable-utf8
修改成
%configure --enable-utf8 --enable-unicode-properties
# rpmbuild -ba /usr/src/redhat/SPECS/pcre.spec
# rpm -Uvh /usr/src/redhat/RPMS/x86_64/pcre*.rpm

4. 安装1.41版本的boost库。这里可以找到编译好的boost库的RPM包。因为后面要编译成静态库,还需要安装boost141-static-1.41.0-2.el5.i386.rpm

5. 开始编译MongoDB

# cd mongodb-src-r1.8.1
# scons --libpath=/usr/lib64/boost141/ \
--cpppath=/usr/include/boost141/ \
--release --64 --static all

如果你没有--release和--static选项,可能会看见下面这样的消息
*** notice: no readline library, mongo shell will not have nice interactive line editing ***
解决方法是加上--extralib=ncurses。

6. 安装

# cd mongodb-src-r1.8.1
# scons --libpath=/usr/lib64/boost141/ \
--cpppath=/usr/include/boost141/ \
--release --64 --static --prefix=/opt/mongo-1.8.1 install

参考:
1. http://www.mongodb.org/display/DOCS/Building+for+Linux
2. http://hi.baidu.com/farmerluo/blog/item/37364623f35ba55e9922ed2f.html

Using Postgresql

1. create tablespace
$ mkdir -p /home/postgresql/data
$ sudo chown -R postres:postres /home/postgresql/data
$ sudo chmod -R og-rx /home/postgresql/data
$ sudo su - postgres
$ psql
postgres=# create tablespace newspace location '/home/postgresql/data';

2. move a database to this new tablespace
use a php script from here to generate sql
$ sudo yum install php-pgsql
$ ./generate-mv-db.php
$ sudo su - postgres
$ psql -d mydb -f migrate_localhost_mydb_newspace.sql

3. install postgis
a. install proj4.7
$ sudo yum install proj
b. install geos 3.2.2
$ tar xvjf geos-3.2.2.tar.bz2
$ cd geos-3.2.2
$ ./configure --prefix=/usr
$ make && sudo make install
$ sudo ldconfig

must do this, otherwise postgis will fail to locate libgeos_c.so.1

c. install postgis-1.5.1.tar.gz
$ tar xvzf postgis-1.5.1.tar.gz
$ cd postgis-1.5.1
$ ./configure
$ make && sudo make install
d. create a spatially-enabled database
$ sudo su - postgres
$ createdb postgis_template -U postgres;
$ cd /usr/share/pgsql/contrib/postgis-1.5
$ createlang plpgsql postgis_template
$ psql -d postgis_template -f postgis.sql
$ psql -d postgis_template -f spatial_ref_sys.sql

给虚拟机的虚拟硬盘增加容量(vmdk file)

我使用虚拟机主要是为了使用Windows XP系统来访问网银、进行在线支付。当初安装时是用VMWare Player的,后来换成了VirtualBox 3。Windows XP越来越臃肿,虚拟机硬盘空间不够了。在网上搜索后找到了增加虚拟硬盘容量的方法:使用QEMNGParted,不用安装“庞大”的VMWare软件。特别说明一下最初创建虚拟硬盘时也是使用的QEMU工具。

具体步骤如下:
1. VMDK格式转成RAW格式

$ qemu-img convert -f vmdk winxp.vmdk -O raw winxp.raw

2. 新建一个RAW格式的文件,后面会用到

$ qemu-img create -f raw temp.img 512M

3. 用cat命令把temp.img多次追加到winxp.raw文件后,达到扩容的目的。

$ cat winxp.raw temp.img temp.img temp.img temp.img temp.img temp.img temp.img temp.img > winxp.img

4. 再转成原来的VMDK格式

$ qemu-img convert -f raw winxp.img -O vmdk winxp.vmdk

5. 用下载Gparted Live CD 的iso文件作为光盘启动虚拟机,可以看到硬盘物理空间已经变成了8G。修改硬盘上面的分区大小就行了,也可以创建新的分区。

参考:
http://www.cyberciti.biz/tips/howto-resize-vmware-virtual-harddisk-size.html#comments
http://qemu-forum.ipi.fi/viewtopic.php?t=846&highlight=