wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.0.2.tgz
tar zxvf mongodb-linux-x86_64-2.0.2.tgz
tar zxvf mongodb-linux-x86_64-2.0.2.tgz
cd /usr/mongodb-linux-x86_64-2.0.2/bin
但是在运行前,需要创建mongodb需要的存放数据和日志的目录:
sudo mkdir -p /data/db/journal
sudo chmod -R 777 /data/db/
启动mongodb server,-journal 代表要写日志,-maxConns=2400代表mongodb 可以接受2400个 tcp连接,-rest代表可以允许客户端通过rest API访问mongdb server.
./mongod -journal -maxConns=2400 -rest
服务程序启动后,终端会显示一些信息,比如:
Wed Aug 31 16:40:03 [initandlisten] MongoDB starting : pid=2410 port=27017 dbpath=/data/db/ 64-bit
Wed Aug 31 16:40:03 [initandlisten] db version v2.0.2, pdfile version 4.5
Wed Aug 31 16:40:03 [initandlisten] git version: c206d77e94bc3b65c76681df5a6b605f68a2de05
Wed Aug 31 16:40:03 [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
Wed Aug 31 16:40:03 [initandlisten] journal dir=/data/db/journal
Wed Aug 31 16:40:03 [initandlisten] recover : no journal files present, no recovery needed
Wed Aug 31 16:40:06 [initandlisten] preallocateIsFaster=true 33.84
Wed Aug 31 16:40:08 [initandlisten] preallocateIsFaster=true 36.84
Wed Aug 31 16:40:11 [initandlisten] preallocateIsFaster=true 37.48
Wed Aug 31 16:40:11 [initandlisten] preallocating a journal file /data/db/journal/prealloc.0
Wed Aug 31 16:41:03 [initandlisten] preallocating a journal file /data/db/journal/prealloc.1
Wed Aug 31 16:41:55 [initandlisten] preallocating a journal file /data/db/journal/prealloc.2
Wed Aug 31 16:42:48 [initandlisten] waiting for connections on port 27017
Wed Aug 31 16:42:48 [initandlisten] —maxConns too high, can only handle 819
Wed Aug 31 16:42:48 [websvr] web admin interface listening on port 28017
机器IP: 10.0.14.218
安装目录 : /usr/local/mongodb/bin
数据存储目录: /data/db
web console : http://10.0.14.218:28017/
web admin port : 28017
db.createCollection(“collName”, {size: 20, capped: 5, max: 100}); 创建一个聚集集合。
db.getCollection(‘dict‘); 得到指定名称的聚集集合。
MongoDB 学习笔记一 安装以及基础命令,布布扣,bubuko.com
原文地址:http://blog.csdn.net/jiangtao_st/article/details/25719731