超级神器系统:【教程】野心勃勃的NoSQL新贵 MongoDB应用实战(3) — Windows版本服务器安装

来源:百度文库 编辑:九乡新闻网 时间:2024/04/27 13:25:07

Windows版本服务器安装

(1)、下载MongoDB

url地址: http://downloads.mongodb.org/win32/mongodb-win32-i386-1.8.1.zip

(2)、设置MongoDB目录

将其解压到 d:\,再重命名为mongodb,路径为d:\mongodb

(3)、设置数据文件路径

在d:盘建一个db文件夹,路径d:\db

(4)、启动MongoDB服务

进入 cmd 提示符控制台,D:\mongodb\bin\mongod.exe --dbpath=d:\data\db

  1. D:\mongodb\bin>D:\mongodb\bin\mongod --dbpath=d:\data\db  
  2. Sun Apr 10 22:34:09 [initandlisten] MongoDB starting : pid=5192 port=27017 dbpat  
  3. h=d:\data\db 32-bit  
  4. ** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data  
  5. **       see http://blog.mongodb.org/post/137788967/32-bit-limitations  
  6. **       with --dur, the limit is lower  
  7. Sun Apr 10 22:34:09 [initandlisten] db version v1.8.1, pdfile version 4.5  
  8. Sun Apr 10 22:34:09 [initandlisten] git version: a429cd4f535b2499cc4130b06ff7c26  
  9. f41c00f04  
  10. Sun Apr 10 22:34:09 [initandlisten] build sys info: windows (5, 1, 2600, 2, 'Ser  
  11. vice Pack 3') BOOST_LIB_VERSION=1_35 
  12. Sun Apr 10 22:34:09 [initandlisten] waiting for connections on port 27017  
  13. Sun Apr 10 22:34:09 [websvr] web admin interface listening on port 28017 

MongoDB服务端的默认连接端口是 27017

(5)、将MongoDB作为 Windows 服务随机启动

先创建D:\mongodb\logs\mongodb.log文件,用于存储MongoDB的日志文件, 再安装系统服务:

  1. D:\mongodb\bin\mongod --dbpath=d:\data\db --logpath=d:\mongodb\logs\mongodb.log --install  
  2. D:\mongodb\bin>D:\mongodb\bin\mongod --dbpath=d:\data\db --logpath=d:\mongodb\lo  
  3. gs\mongodb.log --install  
  4. all output going to: d:\mongodb\logs\mongodb.log  
  5. Creating service MongoDB.  
  6. Service creation successful.  
  7. Service can be started from the command line via 'net start "MongoDB"'.  
  8. D:\mongodb\bin>net start mongodb  
  9. Mongo DB 服务已经启动成功。  
  10. D:\mongodb\bin> 

(6)、客户端连接验证

新打开一个CMD输入:d:\mongodb\bin\mongo,如果出现下面提示,那么您就可以开始MongoDB之旅了:

  1. D:\mongodb\bin>d:\mongodb\bin\mongo  
  2. MongoDB shell version: 1.8.1  
  3. connecting to: test  

(7)、查看MongoDB日志

查看D:\mongodb\logs\mongodb.log文件,即可对MongoDB的运行情况进行查看或排错了:

 

这样就完成了Windows平台的MongoDB安装。