标签:style blog http color java 使用 os strong
MongoDB是一个高性能,开源,无模式的文档型数据库,是当前NoSql数据库中比较热门的一种。它在许多场景下可用于替代传统的关系型数据库或键/值存储方式。Mongo使用C++开发。Mongo的官方网站地址是:http://www.mongodb.org/,读者可以在此获得更详细的信息。
特点:
高性能、易部署、易使用,存储数据非常方便。主要功能特性有:
功能:
适用场合:
下载安装包
MongoDB最新版本下载在官网的DownLoad菜单下:http://www.mongodb.org/downloads 找到合适的下载安装包
一、windows环境安装
本文采用的mongodb-win32-x86_64-2.4.9.zip安装包。
配置Mongo服务端:
打开CMD窗口,按照如下方式输入命令:
> d:
> cd D:\mongodb\bin
> mongod --dbpath D:\MongoDB\data
配置成功后会看到如下画面:
在浏览器输入:http://localhost:27017/,可以看到如下提示:
You are trying to access MongoDB on the native driver port. For http diagnostic access, add 1000 to the port number
如此,在windows环境下的MongoDB数据库服务已经成功启动了。
4.配置windows服务
D:\mongodb\bin>mongod --dbpath D:\MongoDB\data --logpath D:\MongoDB\log\MongoDB
.log --install --serviceName mongodb
配置成功显示的界面的如下:
如果需要删除服务,可以使用命令卸载服务:sc delete mongodb
二、linux环境下安装
本文采用的mongodb-linux-x86_64-2.4.9.tgz安装包。
二、linux环境下安装
本文采用的mongodb-linux-x86_64-2.4.9.tgz安装包。
1.解压文件: tar zxvf mongodb-linux-x86_64-2.4.9.tgz
[mysql@local data_dsk]$ tar zxvf mongodb-linux-x86_64-2.4.9.tgz ##解压文件
mongodb-linux-x86_64-2.4.9/README
mongodb-linux-x86_64-2.4.9/THIRD-PARTY-NOTICES
mongodb-linux-x86_64-2.4.9/GNU-AGPL-3.0
mongodb-linux-x86_64-2.4.9/bin/mongodump
mongodb-linux-x86_64-2.4.9/bin/mongorestore
mongodb-linux-x86_64-2.4.9/bin/mongoexport
mongodb-linux-x86_64-2.4.9/bin/mongoimport
mongodb-linux-x86_64-2.4.9/bin/mongostat
mongodb-linux-x86_64-2.4.9/bin/mongotop
mongodb-linux-x86_64-2.4.9/bin/mongooplog
mongodb-linux-x86_64-2.4.9/bin/mongofiles
mongodb-linux-x86_64-2.4.9/bin/bsondump
mongodb-linux-x86_64-2.4.9/bin/mongoperf
mongodb-linux-x86_64-2.4.9/bin/mongosniff
mongodb-linux-x86_64-2.4.9/bin/mongod
mongodb-linux-x86_64-2.4.9/bin/mongos
mongodb-linux-x86_64-2.4.9/bin/mongo
2.创建目录,在mongodb目录下创建data、log目录,并将解压文件的bin目录移到mongodb目录下
[mysql@local data_dsk]$ mkdir -p mongodb/log mongodb/data mongodb/bin
[mysql@local data_dsk]$ ll mongodb
total 24
drwxrwxr-x 2 mysql mysql 4096 Jul 31 17:10 bin
drwxrwxr-x 2 mysql mysql 4096 Jul 31 14:35 data
drwxrwxr-x 2 mysql mysql 4096 Jul 31 17:06 log
[mysql@local data_dsk]$ mv mongodb-linux-x86_64-2.4.9/bin/* ./mongodb/bin
[mysql@local data_dsk]$ ll ./mongodb/bin
total 237940
-rwxr-xr-x 1 mysql mysql 18294928 Jan 10 2014 bsondump
-rwxr-xr-x 1 mysql mysql 9535400 Jan 10 2014 mongo
-rwxr-xr-x 1 mysql mysql 18348264 Jan 10 2014 mongod
-rwxr-xr-x 1 mysql mysql 18352336 Jan 10 2014 mongodump
-rwxr-xr-x 1 mysql mysql 18307248 Jan 10 2014 mongoexport
-rwxr-xr-x 1 mysql mysql 18356384 Jan 10 2014 mongofiles
-rwxr-xr-x 1 mysql mysql 18319472 Jan 10 2014 mongoimport
-rwxr-xr-x 1 mysql mysql 18298992 Jan 10 2014 mongooplog
-rwxr-xr-x 1 mysql mysql 18298992 Jan 10 2014 mongoperf
-rwxr-xr-x 1 mysql mysql 18357712 Jan 10 2014 mongorestore
-rwxr-xr-x 1 mysql mysql 13862296 Jan 10 2014 mongos
-rwxr-xr-x 1 mysql mysql 18262728 Jan 10 2014 mongosniff
-rwxr-xr-x 1 mysql mysql 18344432 Jan 10 2014 mongostat
-rwxr-xr-x 1 mysql mysql 18298992 Jan 10 2014 mongotop
3.启动mongodb服务.
[mysql@local data_dsk]$ ./mongodb/bin/mongod --dbpath=/data_dsk/mongodb/data/ Thu Jul 31 17:12:51.834 [initandlisten] MongoDB starting : pid=6052 port=27017 dbpath=/data_dsk/mongodb/data/ 64-bit host=local.stage1 Thu Jul 31 17:12:51.836 [initandlisten] db version v2.4.9 Thu Jul 31 17:12:51.836 [initandlisten] git version: 52fe0d21959e32a5bdbecdc62057db386e4e029c Thu Jul 31 17:12:51.836 [initandlisten] build info: Linux ip-10-2-29-40 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_49 Thu Jul 31 17:12:51.836 [initandlisten] allocator: tcmalloc Thu Jul 31 17:12:51.836 [initandlisten] options: { dbpath: "/data_dsk/mongodb/data/" } Thu Jul 31 17:12:51.854 [initandlisten] journal dir=/data_dsk/mongodb/data/journal Thu Jul 31 17:12:51.854 [initandlisten] recover : no journal files present, no recovery needed Thu Jul 31 17:12:52.918 [initandlisten] preallocateIsFaster=true 10.12 Thu Jul 31 17:12:54.041 [initandlisten] preallocateIsFaster=true 12.32 Thu Jul 31 17:12:56.520 [initandlisten] preallocateIsFaster=true 19.36 Thu Jul 31 17:12:56.520 [initandlisten] preallocateIsFaster check took 4.665 secs Thu Jul 31 17:12:56.520 [initandlisten] preallocating a journal file /data_dsk/mongodb/data/journal/prealloc.0 Thu Jul 31 17:12:59.007 [initandlisten] File Preallocator Progress: 754974720/1073741824 70% Thu Jul 31 17:13:08.700 [initandlisten] preallocating a journal file /data_dsk/mongodb/data/journal/prealloc.1 Thu Jul 31 17:13:11.024 [initandlisten] File Preallocator Progress: 786432000/1073741824 73% Thu Jul 31 17:13:21.612 [initandlisten] preallocating a journal file /data_dsk/mongodb/data/journal/prealloc.2 Thu Jul 31 17:13:24.060 [initandlisten] File Preallocator Progress: 775946240/1073741824 72% Thu Jul 31 17:13:34.110 [FileAllocator] allocating new datafile /data_dsk/mongodb/data/local.ns, filling with zeroes... Thu Jul 31 17:13:34.110 [FileAllocator] creating directory /data_dsk/mongodb/data/_tmp Thu Jul 31 17:13:34.324 [FileAllocator] done allocating datafile /data_dsk/mongodb/data/local.ns, size: 16MB, took 0.205 secs Thu Jul 31 17:13:34.326 [FileAllocator] allocating new datafile /data_dsk/mongodb/data/local.0, filling with zeroes... Thu Jul 31 17:13:35.192 [FileAllocator] done allocating datafile /data_dsk/mongodb/data/local.0, size: 64MB, took 0.865 secs Thu Jul 31 17:13:35.197 [initandlisten] command local.$cmd command: { create: "startup_log", size: 10485760, capped: true } ntoreturn:1 keyUpdates:0 reslen:37 1121ms Thu Jul 31 17:13:35.219 [initandlisten] waiting for connections on port 27017 Thu Jul 31 17:13:35.230 [websvr] admin web console waiting for connections on port 28017 Thu Jul 31 17:14:22.269 [initandlisten] connection accepted from 127.0.0.1:58182 #1 (1 connection now open) Thu Jul 31 17:14:24.093 [conn1] recv(): message len -33557249 is too large. Max is 48000000 Thu Jul 31 17:14:24.093 [conn1] end connection 127.0.0.1:58182 (0 connections now open) Thu Jul 31 17:21:37.366 [initandlisten] connection accepted from 127.0.0.1:54038 #2 (1 connection now open)
4.开启另一个终端登录mongodb
[mysql@local bin]$ ./mongo MongoDB shell version: 2.4.9 connecting to: test Welcome to the MongoDB shell. For interactive help, type "help". For more comprehensive documentation, see http://docs.mongodb.org/ Questions? Try the support group http://groups.google.com/group/mongodb-user >
标签:style blog http color java 使用 os strong
原文地址:http://www.cnblogs.com/huminxxl/p/3880736.html