`
Hooopo
  • 浏览: 329901 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

MongoDB【hello word 系列】

阅读更多
下载:
[root@jakarta hooopo]# wget http://downloads.mongodb.org/linux/mongodb-linux-x86_64-static-1.3.0.tgz

安装:
直接解压就ok。。
[root@jakarta hooopo]# tar zxvf mongodb-linux-x86_64-static-1.3.0.tgz

创建目录:
[root@jakarta mongodb-linux-x86_64-static-1.3.0]# mkdir -p /data/db

启动mongodb  server:
[root@jakarta mongodb-linux-x86_64-static-1.3.0]# ./bin/mongod &
[1] 8507
[root@jakarta mongodb-linux-x86_64-static-1.3.0]# ./bin/mongod --help for help and startup options
Sat Mar  6 20:18:02 Mongo DB : starting : pid = 8507 port = 27017 dbpath = /data/db/ master = 0 slave = 0  64-bit 

warning: built with boost version <= 1.34, limited concurrency
Sat Mar  6 20:18:02 db version v1.3.0, pdfile version 4.5
Sat Mar  6 20:18:02 git version: 6fb87032031c0d9f88490c14b953b5dd934a5849
Sat Mar  6 20:18:02 sys info: Linux ofc-n1.10gen.com 2.6.23.17-88.fc7 #1 SMP Thu May 15 00:02:29 EDT 2008 x86_64 BOOST_LIB_VERSION=1_33_1
Sat Mar  6 20:18:02 waiting for connections on port 27017


启动客户端连接mongodb:
[root@jakarta mongodb-linux-x86_64-static-1.3.0]# ./bin/mongo
MongoDB shell version: 1.3.0
url: test
connecting to: test
Sat Mar  6 20:19:34 connection accepted from 127.0.0.1:39857 #1
type "help" for help
> db.foo.save({a:1})
Sat Mar  6 20:19:56 allocating new datafile /data/db/test.ns, filling with zeroes...
Sat Mar  6 20:19:56 done allocating datafile /data/db/test.ns, size: 16MB, took 0.046 secs
Sat Mar  6 20:19:56 allocating new datafile /data/db/test.0, filling with zeroes...
Sat Mar  6 20:19:56 done allocating datafile /data/db/test.0, size: 64MB, took 0.104 secs
Sat Mar  6 20:19:56 building new index on { _id: ObjId(000000000000000000000000) } for test.foo...
Sat Mar  6 20:19:56 Buildindex test.foo idxNo:0 { name: "_id_", ns: "test.foo", key: { _id: ObjId(000000000000000000000000) } }
Sat Mar  6 20:19:56 done for 0 records 0secs
Sat Mar  6 20:19:56 insert test.foo32152ms
> db.foo.findOne()
{ "_id" : ObjectId("4b92486c67fe79f9ebd399a5"), "a" : 1 }


指定data存放目录:
./mongod --dbpath /var/lib/mongodb/


指定端口:
./mongod --port 12345

以精灵进程方式运行:
./mongod --fork --logpath /var/log/mongodb.log --logappend



结束server:
kill -2 PID

or
> db.shutdownServer()



mongodb官方网站:http://www.mongodb.org/
还有国人翻译的文档:http://www.mongodb.org/display/DOCSCN/Home
1
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics