一、mongodb安装(版本:mongodb-win32-x86_64-2008plus-2.4.14.zip):
具体步骤可参考(http://jingyan.baidu.com/article/d5c4b52bef7268da560dc5f8.html)
1、下载地址:
https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-2.4.14.zip?_ga=1.167203774.1858851621.1438174880
下载完成后解压到D盘,目录结构为: D:/mongodb/bin
2、输入如下的命令启动mongodb服务:
D:/mongodb/bin>mongod --dbpath D:\mongodb\data\db
3、在浏览器输入:http://localhost:27017/,将会提示下面的信息:
You are trying to access MongoDB on the native driver port. For http diagnostic access, add 1000 to the port number”
4、我们把端口号加上1000后,再访问下,会打开下面的页面:
mongod ZHANGHJ-PC
List all commands | Replica set status
Commands : buildInfo cursorInfo features hostInfo isMaster listDatabases replSetGetStatus serverStatus topdb version v2.4.14 git hash: 05bebf9ab15511a71bfbded684bb226014c0a553 sys info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1') BOOST_LIB_VERSION=1_49 uptime: 17 seconds
overview (only reported if can acquire read lock quickly)
time to get readlock: 0ms # databases: 1 # Cursors: 0 replication: master: 0 slave: 0
clients
Client | OpId | Locking | Waiting | SecsRunning | Op | Namespace | Query | client | msg | progress |
---|---|---|---|---|---|---|---|---|---|---|
clientcursormon | 4 | { waitingForLock: false } | 0 | :27017 | ||||||
TTLMonitor | 5 | { waitingForLock: false } | 0 | :27017 | ||||||
snapshotthread | 3 | { waitingForLock: false } | 0 | :27017 | ||||||
journal | 2 | { waitingForLock: false } | 0 | :27017 | ||||||
DataFileSync | 0 | { waitingForLock: false } | 0 | :27017 | ||||||
initandlisten | 7 | { waitingForLock: false } | 2002 | local.startup_log | 0.0.0.0:0 | |||||
websvr | 8 | { waitingForLock: false } | 0 | :27017 |
dbtop (occurrences|percent of elapsed)
NS | total | Reads | Writes | Queries | GetMores | Inserts | Updates | Removes | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
TOTAL | 0 | 0% | 0 | 0% | 0 | 0% | 0 | 0% | 0 | 0% | 0 | 0% | 0 | 0% | 0 | 0% |
write lock % time in write lock, by 4 sec periods
Log
Sun Aug 02 16:27:10.133 [initandlisten] MongoDB starting : pid=9308 port=27017 dbpath=D:\mongodb\data\db 64-bit host=ZHANGHJ-PC 16:27:10.135 [initandlisten] db version v2.4.14 16:27:10.136 [initandlisten] git version: 05bebf9ab15511a71bfbded684bb226014c0a553 16:27:10.136 [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1') BOOST_LIB_VERSION=1_49 16:27:10.137 [initandlisten] allocator: system 16:27:10.137 [initandlisten] options: { dbpath: "D:\mongodb\data\db" } 16:27:10.383 [initandlisten] journal dir=D:\mongodb\data\db\journal 16:27:10.384 [initandlisten] recover : no journal files present, no recovery needed 16:27:10.488 [initandlisten] waiting for connections on port 27017 16:27:10.587 [websvr] admin web console waiting for connections on port 28017 16:27:17.706 [initandlisten] connection accepted from 127.0.0.1:52308 #1 (1 connection now open) 16:27:17.709 [initandlisten] connection accepted from 127.0.0.1:52309 #2 (2 connections now open) 16:27:17.712 [conn1] end connection 127.0.0.1:52308 (1 connection now open) 16:27:17.951 [conn2] end connection 127.0.0.1:52309 (0 connections now open) 16:27:17.961 [initandlisten] connection accepted from 127.0.0.1:52310 #3 (1 connection now open) 16:27:17.965 [conn3] end connection 127.0.0.1:52310 (0 connections now open)
5、测试连接
- C:\Documents and Settings\chenzhou>D:
- D:\>cd Mongodb\bin
- D:\Mongodb\bin>mongo 127.0.0.1:27017
- MongoDB shell version: 2.0.2-rc2
- connecting to: 127.0.0.1:27017/test
- >
C:\Documents and Settings\chenzhou>D: D:\>cd Mongodb\bin D:\Mongodb\bin>mongo 127.0.0.1:27017 MongoDB shell version: 2.0.2-rc2 connecting to: 127.0.0.1:27017/test >代表访问成功,连接到test库
- C:\Documents and Settings\chenzhou>D:
- D:\>cd Mongodb\bin
- D:\Mongodb\bin>mongo
- MongoDB shell version: 2.0.2-rc2
- connecting to: test
- >
C:\Documents and Settings\chenzhou>D: D:\>cd Mongodb\bin D:\Mongodb\bin>mongo MongoDB shell version: 2.0.2-rc2 connecting to: test >同样地,访问成功,连接到test库