Ubuntu 10.04+ 上安装 MongoDB 数据库

jopen 13年前
     <p><span style="line-height:24px;font-family:arial,宋体,sans-serif;font-size:14px;">MongoDB是一个基于分布式文件存储的数据库,与Redis 同样,基于NoSql 技术, 由C++语言编写。旨在为WEB应用提供可扩展的高性能数据存储解决方案,</span></p>    <p><span style="font-family:arial,宋体,sans-serif;"><span style="line-height:24px;font-size:14px;">下面为在ubuntu 上安装及运行mongodb 过程。</span></span></p>    <p><span style="font-family:arial,宋体,sans-serif;"><span style="line-height:24px;font-size:14px;"><br /> </span></span></p>    <p>1. 依赖包安装,mongodb 用boost库,js引擎(spider monkey 或者V8), 正则表达式库pcre.</p>    <p></p>    <div style="border-bottom:#6699cc 1px dashed;border-left:#6699cc 1px dashed;padding-bottom:0px;overflow-x:auto;overflow-y:auto;background-color:#ffffff;margin:10px 20px;padding-left:0px;padding-right:0px;color:black;border-top:#6699cc 1px dashed;border-right:#6699cc 1px dashed;padding-top:0px;" class="code panel">     <div style="text-align:left;padding-bottom:0px;background-color:#ffffff;margin:0px;padding-left:12px;padding-right:12px;color:#000000;font-size:0.95em;padding-top:0px;" class="codeContent panelContent">      <pre style="text-align:left;padding-bottom:0px;line-height:1.3;overflow-x:auto;overflow-y:auto;margin:10px 0px;padding-left:0px;padding-right:0px;font-family:'Courier New',Courier,monospace;white-space:pre-wrap;padding-top:0px;" class="code-java" name="code">apt-get -y install tcsh git-core scons g++ apt-get -y install libpcre++-dev libboost-dev libreadline-dev xulrunner-1.9.2-dev apt-get -y install libboost-program-options-dev libboost-thread-dev libboost-filesystem-dev libboost-date-time-dev</pre>     </div>    </div>    <h2 style="border-bottom-color:#6699cc;padding-bottom:0px;line-height:normal;margin:24px 0px 1.1em;padding-left:0px;padding-right:0px;color:#003366;font-size:16pt;font-weight:bold;text-decoration:none !important;padding-top:0px;"><a style="margin:0px;color:#4c3a2c !important;text-decoration:none !important;" name="BuildingforLinux-Building"></a>2.编译</h2>    <div>        2.1 获取源码,可以获取主分支,也可以编译子分支    </div>    <ol style="position:relative;line-height:13pt;list-style-type:decimal;margin:0px 0px 1em 0.8em;padding-left:1.2em;color:#4c3a2c !important;font-size:10pt;text-decoration:none !important;">     <li style="padding-bottom:0px;line-height:13pt;list-style-type:decimal;margin:0px;padding-left:0px;padding-right:0px;font-size:10pt;padding-top:0px;">      <div style="border-bottom:#6699cc 1px dashed;border-left:#6699cc 1px dashed;padding-bottom:0px;overflow-x:auto;overflow-y:auto;background-color:#ffffff;margin:10px 20px;padding-left:0px;padding-right:0px;color:black;border-top:#6699cc 1px dashed;border-right:#6699cc 1px dashed;padding-top:0px;" class="code panel">       <div style="text-align:left;padding-bottom:0px;background-color:#ffffff;margin:0px;padding-left:12px;padding-right:12px;color:#000000;font-size:0.95em;padding-top:0px;" class="codeContent panelContent">        <pre style="text-align:left;padding-bottom:0px;line-height:1.3;overflow-x:auto;overflow-y:auto;margin:10px 0px;padding-left:0px;padding-right:0px;font-family:'Courier New',Courier,monospace;white-space:pre-wrap;padding-top:0px;" class="code-java" name="code">git clone git:<span style="margin:0px;color:#808080;" class="code-comment">//github.com/mongodb/mongo.git</span>cd mongo # pick a stable version unless doing <span style="margin:0px;color:#000091;" class="code-keyword">true</span> dev git tag -l # Switch to a stable branch (unless doing development) -- # an even second number indicates <span style="margin:0px;color:#009100;" class="code-quote">"stable"</span>. (Although with # sharding you will want the latest <span style="margin:0px;color:#000091;" class="code-keyword">if</span> the latest is less # than 1.6.0.) For example: git checkout r2.0.0</pre>       </div>      </div> </li>     <li style="padding-bottom:0px;line-height:13pt;list-style-type:decimal;margin:0px;padding-left:0px;padding-right:0px;font-size:10pt;padding-top:0px;">编译<br />      <div style="border-bottom:#6699cc 1px dashed;border-left:#6699cc 1px dashed;padding-bottom:0px;overflow-x:auto;overflow-y:auto;background-color:#ffffff;margin:10px 20px;padding-left:0px;padding-right:0px;color:black;border-top:#6699cc 1px dashed;border-right:#6699cc 1px dashed;padding-top:0px;" class="code panel">       <div style="text-align:left;padding-bottom:0px;background-color:#ffffff;margin:0px;padding-left:12px;padding-right:12px;color:#000000;font-size:0.95em;padding-top:0px;" class="codeContent panelContent">        <pre style="text-align:left;padding-bottom:0px;line-height:1.3;overflow-x:auto;overflow-y:auto;margin:10px 0px;padding-left:0px;padding-right:0px;font-family:'Courier New',Courier,monospace;white-space:pre-wrap;padding-top:0px;" class="code-java" name="code">scons all</pre>       </div>      </div> </li>     <li style="padding-bottom:0px;line-height:13pt;list-style-type:decimal;margin:0px;padding-left:0px;padding-right:0px;font-size:10pt;padding-top:0px;">安装</li>    </ol>    <div>     <span style="color:#4c3a2c;font-size:13px;"><span style="line-height:17px;">          --prefix 指定 mongodb 库存放位置</span></span>    </div>    <ol style="position:relative;line-height:13pt;list-style-type:decimal;margin:0px 0px 1em 0.8em;padding-left:1.2em;color:#4c3a2c !important;font-size:10pt;text-decoration:none !important;">     <li style="padding-bottom:0px;line-height:13pt;list-style-type:decimal;margin:0px;padding-left:0px;padding-right:0px;font-size:10pt;padding-top:0px;">      <div style="border-bottom:#6699cc 1px dashed;border-left:#6699cc 1px dashed;padding-bottom:0px;overflow-x:auto;overflow-y:auto;background-color:#ffffff;margin:10px 20px;padding-left:0px;padding-right:0px;color:black;border-top:#6699cc 1px dashed;border-right:#6699cc 1px dashed;padding-top:0px;" class="code panel">       <div style="text-align:left;padding-bottom:0px;background-color:#ffffff;margin:0px;padding-left:12px;padding-right:12px;color:#000000;font-size:0.95em;padding-top:0px;" class="codeContent panelContent">        <pre style="text-align:left;padding-bottom:0px;line-height:1.3;overflow-x:auto;overflow-y:auto;margin:10px 0px;padding-left:0px;padding-right:0px;font-family:'Courier New',Courier,monospace;white-space:pre-wrap;padding-top:0px;" class="code-java" name="code">scons --prefix=/opt/mongo install</pre>       </div>      </div> </li>    </ol> 4. 运行    <p>                # sudo mkdir -p /data/db</p>    <p>              # sudo ./mongod </p>