【mongodb】mongodb的安装

获取mongodb安装包解压
[root@localhost ~]# wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-1.8.3-rc0.tgz
[monogdb@localhost ~]$ tar xzf mongodb-linux-x86_64-1.8.3-rc0.tgz  
创建monogdb的数据存放位置并赋予monogdb相应的权限。
[root@localhost ~]# cd /opt
[root@localhost opt]# mkdir monogdata
[root@localhost opt]# ls
monogdata  oracle  software
[root@localhost opt]# chown monogdb:monogdb /opt/monogdata/
[root@localhost opt]# su - monogdb
[monogdb@localhost ~]$ mv mongodb-linux-x86_64-1.8.3-rc0  monogdb
[monogdb@localhost ~]$ cd monogdb/
[monogdb@localhost monogdb]$ cd bin/

[monogdb@localhost bin]$ ./mongod  -dbpath /opt/monogdata/data/ --指定monogdb数据存放的位置。并开启monogdb的服务。
Mon Aug  8 20:45:15 [initandlisten] MongoDB starting : pid=10340 port=27017 dbpath=/opt/monogdata/data/ 64-bit 
Mon Aug  8 20:45:15 [initandlisten] db version v1.8.3-rc0, pdfile version 4.5
Mon Aug  8 20:45:15 [initandlisten] git version: 81147c1ca4cc10d9a81a0a2afdf364ab1ca8867d
Mon Aug  8 20:45:15 [initandlisten] build sys info: Linux bs-linux64.10gen.cc 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_41
Mon Aug  8 20:45:15 [initandlisten] waiting for connections on port 27017
Mon Aug  8 20:45:15 [websvr] web admin interface listening on port 28017
Mon Aug  8 20:47:15 [initandlisten] connection accepted from 127.0.0.1:21108 #1
Mon Aug  8 21:16:25 [conn1] end connection 127.0.0.1:21108
在另一个窗口即客户端
/home/monogdb/monogdb/bin目录下,执行./mongo 启动客户端和服务端连接,并做一些简单的测试。
[monogdb@localhost bin]$ ./mongo 
MongoDB shell version: 1.8.3-rc0
connecting to: test
> db                                                                                                                                
test
> use test;
switched to db test
> help
        db.help()                    help on db methods
        db.mycoll.help()             help on collection methods
        rs.help()                    help on replica set methods
        help connect                 connecting to a db help
        help admin                   administrative help
        help misc                    misc things to know
        help mr                      mapreduce help

        show dbs                     show database names
        show collections             show collections in current database
        show users                   show users in current database
        show profile                 show most recent system.profile entries with time >= 1ms
        use                set current database
        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
        DBQuery.shellBatchSize = x   set default number of items to display on shell
        exit                         quit the mongo shell

> show dbs
admin   (empty)
local   (empty)
> show users
> show profile
db.system.profile is empty
Use db.setProfilingLevel(2) will enable profiling
Use db.system.profile.find() to show raw profile entries
> exit
bye
上一篇:glassfish v3 安装报无domain 问题


下一篇:Django中的模板