惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Threatpost
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
S
Security Affairs
N
News and Events Feed by Topic
T
Tenable Blog
P
Proofpoint News Feed
W
WeLiveSecurity
Simon Willison's Weblog
Simon Willison's Weblog
Google DeepMind News
Google DeepMind News
C
CERT Recently Published Vulnerability Notes
Help Net Security
Help Net Security
I
Intezer
T
Threat Research - Cisco Blogs
S
Secure Thoughts
C
Cyber Attacks, Cyber Crime and Cyber Security
L
Lohrmann on Cybersecurity
AWS News Blog
AWS News Blog
Google Online Security Blog
Google Online Security Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Know Your Adversary
Know Your Adversary
Project Zero
Project Zero
The Hacker News
The Hacker News
Security Archives - TechRepublic
Security Archives - TechRepublic
T
Tor Project blog
N
News | PayPal Newsroom
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Hacker News - Newest:
Hacker News - Newest: "LLM"
A
Arctic Wolf
Forbes - Security
Forbes - Security
O
OpenAI News
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Security Latest
Security Latest
P
Palo Alto Networks Blog
S
Schneier on Security
S
Securelist
C
Cybersecurity and Infrastructure Security Agency CISA
H
Heimdal Security Blog
V
Vulnerabilities – Threatpost
www.infosecurity-magazine.com
www.infosecurity-magazine.com
博客园_首页
T
Troy Hunt's Blog
Latest news
Latest news
Recent Announcements
Recent Announcements
MyScale Blog
MyScale Blog
人人都是产品经理
人人都是产品经理
L
LINUX DO - 热门话题
M
MIT News - Artificial intelligence
N
Netflix TechBlog - Medium
V
Visual Studio Blog
H
Hacker News: Front Page

博客园 - LixingTie

Git添加排除文件规则 [RabbitMQ+Python入门经典] 兔子和兔子窝 Win7强制删除文件 vim配置 Ubuntu部署HBase Ubuntu部署Zookeeper Ubuntu 12.04 Hadoop自动安装脚本 Ubuntu 12.04下安装Extmail 白话MongoDB(三) 白话MongoDB(一) 关于HBase的一些零碎事 Paxos在大型系统中常见的应用场景 某分布式应用实践一致性哈希的一些问题 多IDC的数据分布设计(二) 多IDC的数据分布设计(一) Redis新的存储模式diskstore Redis容量及使用规划 Redis几个认识误区 一致性哈希(Consistent Hashing)
白话MongoDB(二)
LixingTie · 2011-07-27 · via 博客园 - LixingTie

前面扯了一堆,要了解一个东西,最好的办法,还是让他跑起来,然后结合文档和测试,来验证其实现,并且了解其不足和优点。

MongoDB提供了部分系统的编译版本,但从研究学习以及线上不同依赖包的稳定性的目标,个人还是比较推荐从源代码编译安装的方式。MongoDB的源代码依赖了一些基础组件,如js引擎Spider Monkey,正则表达式引擎PCRE,安装构建工具Scons,以及C++的boost库等,因此编译还是有些麻烦的,realzyy的这篇文章已经比较详细的说明了编译的步骤,主要基于Redhat系统。在ubuntu上安装,还有几个注意点:

1. PCRE最好在编译的时候显式指明对UTF-8的支持

$ configure --enable-unicode-properties
$ sudo make -j 2 && make install

PCRE如果不支持UTF-8,则MongoDB无法启动

Thu Mar 31 17:27:16 Assertion: 10342:pcre not compiled with utf8 support
0x8169528 0x81e704e 0x8450212 0xb73b6ce7 0x80f5b11
 ./mongod(_ZN5mongo11msgassertedEiPKc+0x208) [0x8169528]
 ./mongod(_ZN5mongo6RXTest3runEv+0x3fe) [0x81e704e]
 ./mongod(main+0x3832) [0x8450212]
 /lib/libc.so.6(__libc_start_main+0xe7) [0xb73b6ce7]
 ./mongod() [0x80f5b11]

2. Ubuntu自身带了一个Spider Monkey,但版本有些老,有些MongoDB需要的特性不支持,需要先卸载

$dpkg -l | grep xulrunner
$sudo apt-get remove xulrunner-1.9.2-dev xulrunner-1.9.2

$export CFLAGS=”-DJS_C_STRINGS_ARE_UTF8″
$sudo make -f Makefile.ref
$sudo JS_DIST=/usr make -f Makefile.ref export

3. 需要安装boost等库的支持

$sudo apt-get -y install tcsh git-core scons g++
$sudo apt-get -y install libpcre++-dev libboost-dev libreadline-dev xulrunner-dev
$sudo apt-get -y install libboost-program-options-dev \
libboost-thread-dev libboost-filesystem-dev libboost-date-time-dev

4. 源代码建议从github上下载,根据需要编译相应的版本

$git clone git://github.com/mongodb/mongo.git
$cd mongo
$git tag -l
$git checkout r1.8.0

5.最后,编译安装MongoDB的时候,建议连带头文件和库文件一起

$scons -j 2 all
$scons --prefix=/opt/mongo --full install

另外,MongoDB也可以使用Google V8来作为js引擎,从性能方面来说,V8可能是更好的选择,从jira来看,MongoDB在未来或许会改用v8作为默认引擎。

首先编译V8,然后编译MongoDB的时候使用userv8参数:

$svn checkout http://v8.googlecode.com/svn/trunk/ v8
$cd v8
$scons
$sudo cp libv8.a /usr/lib
$sudo cp libv8preparser.a /usr/lib
$sudo cp -r include/* /usr/include/

$cd mongodb-src
$scons all --usev8
$scons --prefix=/opt/mongo --full install

MongoDB在32位环境下有诸多限制,只能用于学习研究的目的,线上环境一定要使用64位系统。

Thu Mar 31 17:24:58 --oplogSize of 1024MB is too big for 32 bit version. Use 64 bit build instead.

参考:
http://www.mongodb.org/display/DOCS/Building+Spider+Monkey
http://www.mongodb.org/display/DOCS/Building+for+Linux
http://www.howsthe.com/blog/2010/feb/22/mongodb-and-v8/
http://jira.mongodb.org/browse/SERVER-446