Download
Go to official website download: http://www.mongodb.org/downloads
Because it is under window, so I downloaded the MSI format, a fool-type installation. installation
This and ordinary installation software EXE, always point to the next step, halfway to change the installation path
The following is the version I installed
Mongodb-win32-x86_64-2008plus-ssl-3.4.1-signed.msi
1
Configuration
After installation, you also need to configure, such as the data installation path of the database, log path and so on to create the data directory
MongoDB stores the data directory in the DB directory. However, this data directory is not actively created, and we need to create it after the installation is complete.
My directory is D:\data\db, where DB folder also needs to be created, will not automatically generate boot MongoDB
D:\Program Files\mongodb\server\3.4\bin\mongod.exe--dbpath D:\data\db
1
but it's too much trouble to start, and we can't start it every time, so we'll configure it as a window service: Create a directory for log files and configuration files
Configuration file directory: D:\data\config\mongod.cfg
Log file directory: D:\data\dblog\
Then we'll configure Mongod.cfg,
Systemlog:
destination:file
path:d:\data\dblog\mongod.log
logappend:true
storage:
Journal:
enabled:true
dbpath:d:\data\db
Net:
port:27017
1 2 3 4 5 6 7 8 9 10
Systemlog System Log Configuration:
Destination:file:
Description: Log output destination, can be specified as "file" or "syslog", the expression output to the log file, if not specified, will be output to the standard output.
Path:d:\data\dblog\mongod.log
Description: The path of the log, where D:\data\dblog this path was created by myself. After the Mongod.log is started, it is automatically generated.
Logappend:true:
Description: If true, the log will continue to be added at the end of the existing log when Mongod/mongos is restarted. Otherwise, the current log file is backed up and a new log file is created, and the default is False.
Storage Data Storage configuration:
Journal:
Enabled:true
1 2
Description: Whether to turn on journal Log persistent storage, journal log for data recovery, is the most basic feature of mongod, usually used for failure recovery. The default for the 64-bit system is true,32, which defaults to false, and is recommended for mongod processes only.
Dbpath:d:\data\db
1
Description: The location where the MongoDB data is stored.
NET:
port:27017
1 2
Description: Mongod/mongos listening port, default is 27017, but because MongoDB has 2 typical schema patterns: replica set and Sharding, if the developer deploys multiple Mongod instances on one node, you need to be careful to modify this port to avoid collisions. Installation Services
When configured above, execute in CMD (with Administrator privileges):
D:\Program files\mongodb\server\3.4\bin>mongod.exe--config "D:\data\config\mongod.cfg"--install
1
Start MongoDB Service
Then execute: net start MongoDB
D:\Program files\mongodb\server\3.4\bin>net start MongoDB
MongoDB service is starting
: MongoDB Service has started successfully.
1 2 3
Note: If you start an error, you can view the log.
For example, when I start up, it appears:
The MongoDB service is starting.
The MongoDB service could not be started.
system error.
system error 1067 has occurred. The
process terminated unexpectedly.
1 2 3 4 5 6 7 8
Later when I went to view the log, I found:
Log path: D:\Program files\mongodb\data\dblog\mongod.log
This path is also configured in the Mongod.cfg file itself.
2017-02-17t22:10:50.491+0800 I CONTROL [Initandlisten] options: {config: "D:\Program files\mongodb\data\config\ Mongod.cfg ", net: {port:27017}, Service:true, storage: {dbPath:" D:\Program files\mongodb\data\db ", Journal: {Enable D:true}}, Systemlog: {destination: "file", Logappend:true, Path: "D:\Program Files\mongodb\data\dblog\mongod.log"}}
2017-02-17t22:10:50.492+0800 I STORAGE [Initandlisten] Exception in initandlisten:29 Data directory D:\Program files\mongodb\data\db not found., terminating
1 2
This means that the DB folder was not found because I did not create it and only created the Data folder. Close MongoDB Service
net stop MongoDB
1
Show:
D:\Program files\mongodb\server\3.4\bin>net Stop MongoDB
MongoDB service is stopping.
System error.
system error 1067 has occurred. The
process terminated unexpectedly. The
MongoDB service has stopped successfully.
1 2 3 4 5 6 7 8 9
Remove Windows Services
# Writing a
D:\Program files\mongodb\server\3.4\bin>
mongod--config D:\MongoData\cfg\mongod.cfg--remove
#写法二
D:\Program files\mongodb\server\3.4\bin>
mongod.exe--config "D:\data\config\mongod.cfg"--remove
1 2 3 4 5 6
Reference Address:
http://www.dexcoder.com/dexcoder/article/2962
http://shift-alt-ctrl.iteye.com/blog/2242907
http://www.dexcoder.com/dexcoder/article/2962