MongoDB General Installation
1. First to the official website (http://www.mongodb.org/downloads) Download the appropriate installation package, the current version is 2.6
Installation package has zip and MSI format, it is recommended to download the ZIP format, the MSI is actually the next decompression, and the installation does not allow the selection of installation path, the default installation to the C:\Program FILES\MONGODB 2.6 standard directory, Choose 32-bit or 64-bit according to your system.
I am the computer is WIN8 system 64-bit, download 64-bit zip package, download completed after extracting to D:\MongoDB directory
To create the database directory D:\MongoDB\data, then open the Command Line window and switch to the D:\MongoDB\bin directory to execute the following command:
Where--dbpath is the specified database storage directory, there are two "-" to be aware of
Mongod--dbpath D:\MongoDB\data
View Code
This is a command-line window that prints some startup information, and the last line displays the following information to indicate that the boot was successful.
2014-04-23t10:38:48.391+0800 [Initandlisten] waiting for connections on port 27017
This is the browser input http://localhost:27017/can see the display information for
It looks like you is trying to access MongoDB over HTTP on the native driver port.
Specific as follows:
To this MongoDB is installed, than imagined simple too Doha
MongoDB is installed as a Windows service
Installing MongoDB as a Windows service is simple, just add--install after the command line that you executed above
Mongod--dbpath D:\MongoDB\data--install
According to the normal plot, the service should be installed successfully, but unfortunately, the following prompt appears
--install have to is used with--logpath
As prompted, we need to specify the log directory, so we create the log directory D:\MongoDB\logs and then re-execute the command
Mongod--dbpath D:\MongoDB\data--logpath=d:\mongodb\logs\mongodb.log--logappend
However, the hint still does not specify the log path, after several toss found that this is a 2.6 version of a bug, will be repaired in the next version, then we have two options, one option is to use the previous version of 2.4.9, the other option is to first use 2.4.9 version of the installation successful service, and then upgrade to 2.6 (swollen upgrade? Replace the corresponding 2.4.9 file directly with version 2.6, and we have other options, of course, yes, the answer is yes, using the SC command to create the service, start the service with net start
SC create MongoDB binpath= "D:\MongoDB\bin\mongod.exe--service--dbpath D:\MongoDB\data--logpath=d:\mongodb\logs\ Mongodb.log --logappend "
net start MongoDB
MongoDB configuration file
Unfortunately, the official download of the installation package does not have a default configuration file, if you want to use the configuration file can only build one, and the other person also recommended to use the configuration file to manage MongoDB configuration, using configuration file configuration database files, log files and some other configuration is at a glance
Unpack the installation package to D:\MongoDB
Set up the database directory D:\MongoDB\data
Create log directory D:\MongoDB\logs
Create profile Directory D:\MongoDB\etc
Setting up the configuration file D:\MongoDB\etc\mongodb.conf
Dbpath=D:\MongoDB\data #database path
Logpath=D:\MongoDB\logs\mongodb.log #log output file path
Logappend=true #Error log adopts append mode. After configuring this option, mongodb's log will be appended to the existing log file instead of creating a new file.
Journal=true #Enable log file, enabled by default
Quiet=true #This option can filter out some useless log information. If you need to debug, please set it to false.
Port=27017 #Port number The default is 27017
Only a few common items are specified here, please refer to the official documentation for more detailed configuration http://docs.mongodb.org/manual/reference/configuration-options/
Note: The above directory is the blogger's own set of directories, the official does not have the configuration file path specification, all based on personal preferences to decide
After the configuration files and related directories have been built, use the following method to start MongoDB.
- Normal Startup
Mongod--config D:\MongoDB\etc\mongodb.conf
- Install as a Windows service
Note: Version 2.6 this way in the Win7, WIN8 64-bit version cannot be installed successfully, other systems are not tested Mongod--config D:\MongoDB\etc\mongodb.conf--install
- Using the SC installation as a Windows service
SC create MongoDB binpath= "D:\MongoDB\bin\mongod.exe--service--config=d:\mongodb\etc\mongodb.conf"
It is important to note that when a log file is specified, the log is output to the specified log file, regardless of whether it is specified using the configuration file or at the command line, and no log output is visible at the command line interface
Note:
Version 2.6 cannot install Windows Services Bug link https://jira.mongodb.org/browse/SERVER-13515
MongoDB Website: http://www.mongodb.org/
MongoDB Windows environment Installation and configuration