Mongodb安裝配置,啟動關閉
1. 下載mongodb的安裝檔案,我安裝的windows 32位的,下載地址如下:
http://www.mongodb.org/dr//fastdl.mongodb.org/win32/mongodb-win32-i386-2.6.4.zip/download
2. 建立一個mongodb檔案夾在E盤(隨便放)
E:\mongodb
3. 將下載的檔案安裝檔案解壓,把解壓的檔案移動到E盤mongodb下
4. 建立mongodb資料存放目錄E:\mongodb\data
5. 啟動mongodb(簡單啟動不佈建服務)
E:\mongodb\bin\mongod.exe --dbpath E:\mongodb\data
E:\mongodb\bin>mongod.exe --dbpath E:\mongodb\data
2014-09-13T22:18:50.640+0800
2014-09-13T22:18:50.640+0800 warning: 32-bit servers don't have journaling enabled by default. Please use --journal if you want durability.
2014-09-13T22:18:50.640+0800
2014-09-13T22:18:50.765+0800 [initandlisten] MongoDB starting : pid=9204 port=27
017 dbpath=E:\mongodb\data 32-bit host=20120621-1418
2014-09-13T22:18:50.765+0800 [initandlisten]
2014-09-13T22:18:50.765+0800 [initandlisten] ** NOTE: This is a 32 bit MongoDB binary.
2014-09-13T22:18:50.765+0800 [initandlisten] ** 32 bit builds are limitedto less than 2GB of data (or less with --journal).
2014-09-13T22:18:50.765+0800 [initandlisten] ** Note that journaling defaults to off for 32 bit and is currently off.
2014-09-13T22:18:50.765+0800 [initandlisten] ** See http://dochub.mongodb.org/core/32bit
2014-09-13T22:18:50.765+0800 [initandlisten]
2014-09-13T22:18:50.765+0800 [initandlisten] ** NOTE: your operating system version does not support the method that MongoDB
2014-09-13T22:18:50.765+0800 [initandlisten] ** uses to detect impending page faults.
2014-09-13T22:18:50.765+0800 [initandlisten] ** This may result in slowerperformance for certain use cases
2014-09-13T22:18:50.765+0800 [initandlisten]
2014-09-13T22:18:50.765+0800 [initandlisten] targetMinOS: Windows XP SP3
2014-09-13T22:18:50.765+0800 [initandlisten] db version v2.6.4
2014-09-13T22:18:50.765+0800 [initandlisten] git version: 3a830be0eb92d772aa855ebb711ac91d658ee910
2014-09-13T22:18:50.765+0800 [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1'BOOST_LIB_VERSION=1_49
2014-09-13T22:18:50.765+0800 [initandlisten] allocator: system
2014-09-13T22:18:50.765+0800 [initandlisten] options: { storage: { dbPath: "E:\mongodb\data" } }
在瀏覽器中輸入http://localhost:27017/,會出現表面mongdb已經啟動好了
It looks like you are trying to access MongoDB over HTTP on the native driver port.
6. 啟動好後串連到mongodb
E:\mongodb\bin\mongo.ext
E:\mongodb\bin>mongo
MongoDB shell version: 2.6.4
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
Server has startup warnings:
2014-09-13T22:18:50.765+0800 [initandlisten]
2014-09-13T22:18:50.765+0800 [initandlisten] ** NOTE: This is a 32 bit MongoDB binary.
2014-09-13T22:18:50.765+0800 [initandlisten] ** 32 bit builds are limitedto less than 2GB of data (or less with --journal).
2014-09-13T22:18:50.765+0800 [initandlisten] ** Note that journaling defaults to off for 32 bit and is currently off.
2014-09-13T22:18:50.765+0800 [initandlisten] ** See http://dochub.mongodb.org/core/32bit
2014-09-13T22:18:50.765+0800 [initandlisten]
2014-09-13T22:18:50.765+0800 [initandlisten] ** NOTE: your operating system version does not support the method that MongoDB
2014-09-13T22:18:50.765+0800 [initandlisten] ** uses to detect impending page faults.
2014-09-13T22:18:50.765+0800 [initandlisten] ** This may result in slowerperformance for certain use cases
2014-09-13T22:18:50.765+0800 [initandlisten]
>
Mongodb的關閉:
前台運行:
如果沒有使用--fork,直接可以前台退出終端關閉。通過這種方式,Mongodb將會自己做清理退出,把沒有寫好的資料寫完成,並最終關閉資料檔案。要注意的是這個過程會持續到所有操作都完成。
後台運行:
如果使用--fork在後台運行mongdb服務,那麼就要通過向伺服器發送shutdownServer()訊息來關閉。
1、普通命令:
$ ./mongod
> use admin
> db.shutdownServer()
> db.shutdownServer()
2014-09-13T22:25:07.843+0800 DBClientCursor::init call() failed
server should be down...
2014-09-13T22:25:07.890+0800 trying reconnect to 127.0.0.1:27017 (127.0.0.1) failed
2014-09-13T22:25:08.890+0800 warning: Failed to connect to 127.0.0.1:27017, reas
on: errno:10061由於目標機器積極拒絕,無法串連。
2014-09-13T22:25:08.890+0800 reconnect 127.0.0.1:27017 (127.0.0.1) failed failed
couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed
>
控制台顯示如下:
2014-09-13T22:25:07.625+0800 [conn1] terminating, shutdown command received
2014-09-13T22:25:07.625+0800 [conn1] dbexit: shutdown called
2014-09-13T22:25:07.625+0800 [conn1] shutdown: going to close listening sockets.
..
2014-09-13T22:25:07.625+0800 [conn1] closing listening socket: 1632
2014-09-13T22:25:07.625+0800 [conn1] shutdown: going to flush diaglog...
2014-09-13T22:25:07.625+0800 [conn1] shutdown: going to close sockets...
2014-09-13T22:25:07.625+0800 [conn1] shutdown: waiting for fs preallocator...
2014-09-13T22:25:07.625+0800 [conn1] shutdown: closing all files...
2014-09-13T22:25:07.625+0800 [conn1] closeAllFiles() finished
2014-09-13T22:25:07.625+0800 [conn1] shutdown: removing fs lock...
2014-09-13T22:25:07.625+0800 [conn1] dbexit: really exiting now
E:\mongodb\bin>
關閉成功
Mongodb啟動協助
E:\mongodb\bin>mongod --help
Options:
General options:
-h [ --help ] show this usage information
--version show version information
-f [ --config ] arg configuration file specifying additional options
-v [ --verbose ] [=arg(=v)] be more verbose (include multiple times for more
verbosity e.g. -vvvvv)
--quiet quieter output
--port arg specify port number - 27017 by default
--bind_ip arg comma separated list of ip addresses to listen on
- all local ips by default
--maxConns arg max number of simultaneous connections - 1000000
by default
--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
--timeStampFormat arg Desired format for timestamps in log messages.
One of ctime, iso8601-utc or iso8601-local
--pidfilepath arg full path to pidfile (if not set, no pidfile is
created)
--keyFile arg private key for cluster authentication
--setParameter arg Set a configurable parameter
--httpinterface enable http interface
--clusterAuthMode arg Authentication mode used for cluster
authentication. Alternatives are
(keyFile|sendKeyFile|sendX509|x509)
--auth run with security
--noauth run without security
--ipv6 enable IPv6 support (disabled by default)
--jsonp allow JSONP access via http (has security
implications)