`
nanjingjiangbiao_T
  • 浏览: 2593416 次
  • 来自: 深圳
文章分类
社区版块
存档分类
最新评论

开源云计算技术系列三(10gen)安装配置

 
阅读更多

10gen 是一套云计算平台,可以为web应用提供可以扩展的高性能的数据存储解决方案。10gen的开源项目是mongoDB,主要功能是解决website的操作性数据存储,session对象的存储,数据缓存,高效率的实时计数(比如统计pv,uv),并支持ruby,python,java,c++,php等众多的页面语言。

MongoDB主要特征是存储数据非常方便,不在是传统的object-relational mapping的模式,高性能,可以存储大对象数据,比如视频等,可以自动复制和failover。

技术需要实践,让我们一起来从实践中体会mongoDB的众多优越的特性。

首先建立一台虚拟机rhel 5.2.

下载符合版本的软件,

http://www.mongodb.org/display/DOCS/Downloads

curl -O http://downloads.mongodb.org/linux/mongodb-linux-i686-latest.tgz

安装非常简单,解压好就可以使用,非常方便。

tar xvzf mongodb-linux-i686-latest.tgz

解压后的目录结构如下:

|-- bin  |   |-- mongo                              (the database shell)  |   |-- mongod                             (the database)  |   |-- mongodump                          (dump/export utility)  |   `-- mongorestore                       (restore/imp<wbr>ort utility)  |-- include                                (c++ driver include files)  |   `-- mongo  |       |-- client  |       |-- db  |       |-- grid  |       `-- util  |-- lib  |-- lib64</wbr>

在启动之前,先建立数据库存放的目录 。

mkdir –p /da<wbr>ta/db</wbr>

接着后台启动mongoDB

bin/mongod run &

[1] 5673

[root@rac01 mongodb-linux-i686-2009-06-14]# Mon Jun 15 20:27:32 Mongo DB : starting : pid = 5673 port = 27017 dbpath = /da<wbr>ta/db/ master = 0 slave = 0</wbr>

Mon Jun 15 20:27:32 db version v0.9.4+, pdfile version 4.4

Mon Jun 15 20:27:32 git version: 004cd26deee50b7fdf060c06605bbce37bc09794

Mon Jun 15 20:27:32 sys info: Linux domU-12-31-39-01-70-B4 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:39:36 EST 2008 i686

Mon Jun 15 20:27:32 waiting for connections on port 27017

Mon Jun 15 20:27:32 web admin interface listening on port 28017

ok,启动完毕,我们用mongoDB自带的客户端连接上。

bin/mongo
url: test

connecting to: test

type “help” for help

Mon Jun 15 20:28:09 connection accepted from 127.0.0.1:19943

> help

HELP

show dbs show database names

show collections show collections in current database

show users show users in current database

show pro<wbr>file show most recent system.pro<wbr>file entries with time &gt;= 1ms</wbr></wbr>

use <db name> set curent database to <db name>

db.help() help on DB methods

db.foo.help() help on collection methods

db.foo.find() list objects in collection foo

db.foo.find( { a : 1 } ) list objects in foo where a == 1

it result of the last line evaluated; use to further iterate

> show dbs

admin

local

test

帮助的层次非常清楚。

我们来检查一下mongoDB是否运行正常。

bin/mongo

url: test

connecting to: test

type “help” for help

Mon Jun 15 20:28:56 connection accepted from 127.0.0.1:31975

> db.foo.save( { a : 1 } )

> db.foo.findOne()

{”_id” : “4a3631b14ae1a7d3e24cab82″ , “a” : 1}

到这一步,这个强大的mongoDB就安装配置好了,下一篇我们来进一步体验一下这个开源mongoDB的强大功能要点。

转自:http://rdc.taobao.com/blog/dw/archives/410

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics