Mongodb学习笔记1 安装及启动
官网:http://www.mongodb.org/
下载:http://www.mongodb.org/downloads
文档:http://www.mongodb.org/display/DOCS/Home

安装运行环境:windows2003
1)下载文件并解压目录(D:\Prog-mongodb\ )结构如下:
1.1)根目录

1.2)bin文件夹

2)更改数据库默认目录:
在根目中新建数据库文件目录 database 名字任意,原始默认目录为c:\data\db\ 。
在dos中 ,切换到 D:\Prog-mongodb 目录,执行如下命令
$ bin\mongod.exe --dbpath --D:\Prog-mongodb\database
显示如下
D:\Prog-mongodb\bin>mongod.exe --dbpath D:\Prog-mongodb\database
Fri Oct 14 11:21:48
Fri Oct 14 11:21:48 warning: 32-bit servers don't have journaling enabled by def
ault. Please use --journal if you want durability.
Fri Oct 14 11:21:48
Fri Oct 14 11:21:48 [initandlisten] MongoDB starting : pid=4108 port=27017 dbpat
h=D:\Prog-mongodb\database 32-bit host=ijobs
Fri Oct 14 11:21:48 [initandlisten]
Fri Oct 14 11:21:48 [initandlisten] ** NOTE: when using MongoDB 32 bit, you are
limited to about 2 gigabytes of data
Fri Oct 14 11:21:48 [initandlisten] ** see http://blog.mongodb.org/post/13
7788967/32-bit-limitations
Fri Oct 14 11:21:48 [initandlisten] ** with --journal, the limit is lower
Fri Oct 14 11:21:48 [initandlisten]
Fri Oct 14 11:21:48 [initandlisten] db version v2.0.0, pdfile version 4.5
Fri Oct 14 11:21:48 [initandlisten] git version: 695c67dff0ffc361b8568a13366f027
caa406222
Fri Oct 14 11:21:48 [initandlisten] build info: windows (5, 1, 2600, 2, 'Service
Pack 3') BOOST_LIB_VERSION=1_42
Fri Oct 14 11:21:48 [initandlisten] options: { dbpath: "D:\Prog-mongodb\database
" }
Fri Oct 14 11:21:48 [websvr] admin web console waiting for connections on port 2 8017 Fri Oct 14 11:21:48 [initandlisten] waiting for connections on port 27017
Fri Oct 14 11:22:48 [clientcursormon] mem (MB) res:15 virt:45 mapped:0
Fri Oct 14 11:27:49 [clientcursormon] mem (MB) res:15 virt:45 mapped:0
Fri Oct 14 11:32:49 [clientcursormon] mem (MB) res:0 virt:45 mapped:0
Fri Oct 14 11:21:48 [websvr] admin web console waiting for connections on port 28017
为web管理端口,可通过http://localhost/28017 浏览
页面信息如下:
---------------------------------------------------------------------
mongod.exe ijobs
List all commands | Replica set status
Commands: buildInfo cursorInfo features isMaster listDatabases replSetGetStatus serverStatus top
db version v2.0.0, pdfile version 4.5 git hash: 695c67dff0ffc361b8568a13366f027caa406222 sys info: windows (5, 1, 2600, 2, 'Service Pack 3') BOOST_LIB_VERSION=1_42 uptime: 584 seconds
low level requires read lock
time to get readlock: 0ms # databases: 1 replication: master: 0 slave: 0
clients
| Client | OpId | Active | LockType | Waiting | SecsRunning | Op | Namespace | Query | client | msg | progress |
|---|---|---|---|---|---|---|---|---|---|---|---|
| initandlisten | 0 | W | 2004 | local.system.namespaces | { name: /^local.temp./ } | 0.0.0.0:0 | |||||
| websvr | 0 | 0 | 0 | ||||||||
| snapshotthread | 0 | 0 | 0 | ||||||||
| clientcursormon | 0 | R | 0 |
dbtop (occurences|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
write locked now: false
Log
Fri Oct 14 11:21:48 [initandlisten] MongoDB starting : pid=4108 port=27017 dbpath=D:\Prog-mongodb\database 32-bit host=ijobs 11:21:48 [initand
-----------------------------------------------
mongod 说明
-----------------------------------------------
D:\Prog-mongodb\bin>mongod.exe --help
Fri Oct 14 11:17:54
Fri Oct 14 11:17:54 ** NOTE: when using MongoDB 32 bit, you are limited to about
2 gigabytes of data
Fri Oct 14 11:17:54 ** see http://blog.mongodb.org/post/137788967/32-bit-l
imitations
Fri Oct 14 11:17:54 ** with --journal, the limit is lower
Fri Oct 14 11:17:54
Allowed options:
General options:
-h [ --help ] show this usage information
--version show version information
-f [ --config ] arg configuration file specifying additional options
-v [ --verbose ] be more verbose (include multiple times for more
verbosity e.g. -vvvvv)
--quiet quieter output
--port arg specify port number
--bind_ip arg comma separated list of ip addresses to listen on
- all local ips by default
--maxConns arg max number of simultaneous connections
--objcheck inspect client data for validity on receipt
--logpath arg log file to send write to instead of stdout - has
to be a file, not directory
--logappend append to logpath instead of over-writing
--pidfilepath arg full path to pidfile (if not set, no pidfile is
created)
--keyFile arg private key for cluster authentication (only for
replica sets)
--auth run with security
--cpu periodically show cpu and iowait utilization
--dbpath arg directory for datafiles
--diaglog arg 0=off 1=W 2=R 3=both 7=W+some reads
--directoryperdb each database will be stored in a separate
directory
--journal enable journaling
--journalOptions arg journal diagnostic options
--journalCommitInterval arg how often to group/batch commit (ms)
--ipv6 enable IPv6 support (disabled by default)
--jsonp allow JSONP access via http (has security
implications)
--noauth run without security
--nohttpinterface disable http interface
--nojournal disable journaling (journaling is on by default
for 64 bit)
--noprealloc disable data file preallocation - will often hurt
performance
--noscripting disable scripting engine
--notablescan do not allow table scans
--nssize arg (=16) .ns file size (in MB) for new databases
--profile arg 0=off 1=slow, 2=all
--quota limits each database to a certain number of files
(8 default)
--quotaFiles arg number of files allower per db, requires --quota
--rest turn on simple rest api
--repair run repair on all dbs
--repairpath arg root directory for repair files - defaults to
dbpath
--slowms arg (=100) value of slow for profile and console log
--smallfiles use a smaller default file size
--syncdelay arg (=60) seconds between disk syncs (0=never, but not
recommended)
--sysinfo print some diagnostic system information
--upgrade upgrade db if needed
Windows Service Control Manager options:
--install install mongodb service
--remove remove mongodb service
--reinstall reinstall mongodb service (equivilant of mongod
--remove followed by mongod --install)
--serviceName arg windows service name
--serviceDisplayName arg windows service display name
--serviceDescription arg windows service description
--serviceUser arg user name service executes as
--servicePassword arg password used to authenticate serviceUser
Replication options:
--fastsync indicate that this instance is starting from a dbpath
snapshot of the repl peer
--oplogSize arg size limit (in MB) for op log
Master/slave options:
--master master mode
--slave slave mode
--source arg when slave: specify master as <server:port>
--only arg when slave: specify a single database to replicate
--slavedelay arg specify delay (in seconds) to be used when applying
master ops to slave
--autoresync automatically resync if slave data is stale
Replica set options:
--replSet arg arg is <setname>[/<optionalseedhostlist>]
Sharding options:
--configsvr declare this is a config db of a cluster; default port
27019; default dir /data/configdb
--shardsvr declare this is a shard db of a cluster; default port
27018
--noMoveParanoia turn off paranoid saving of data for moveChunk. this
is on by default for now, but default will switch
3)以服务方法运行 mongodb

D:\mongodb\bin>mongod --install --logpath d:\mongodb\logs\MongoDB.log --dbpath d
:\mongodb\db --directoryperdb --bind_ip 127.0.0.1
all output going to: d:\mongodb\logs\MongoDB.log
D:\mongodb\bin>net start MongoDB
Mongo DB 服务已经启动成功。
停止:net stop MongoDB (注意大小写)
posted on 2011-10-14 11:11 Moutnainer 阅读(2042) 评论(0) 收藏 举报
浙公网安备 33010602011771号