Configuration and installation of MongoDB under window

Source: Internet
Author: User
Tags log log openssl openssl version

Objective

MongoDB is a database based on distributed file storage. Written by the C++ language, support Windows,linux,osx,solaris platform, the default port 27017 is, is a very efficient nosql database.

My test environment: WINDOW10 64-bit

My installation path: D:\mongodb

I study MongoDB's notebook: MongoDB

Configuring MongoDB I also met two key issues, documenting the blog's desire to build MongoDB's peers, to successfully complete the configuration.

Installation

: Http://www.mongodb.org/downloads

Select Download version:

I downloaded the latest version of the ZIP format.

Note that: 1, starting from the mongodb2.2 version, MongoDB is not supported WINDOWXP

Reference: Heart Know Blog

inch 2.2, MongoDB does not support Windows XP. Please use the more recent version of Windows to use the more recent releases of MongoDB.
2, if the operating system for Windows Server R2 or window 7, need to enter the Microsoft official website to download patches
 - 7. Install a hotfix to resolve a issue with memory mapped files on Windows.

Also here special attention is needed:
After the download is completed, you will get a exe file, but this can not be directly installed on this file, you need to unzip it, extract the Windows6.1-KB2731284-v3-x64.msu files, this time can be installed, then restart can

3, 64-bit mongodb will not be able to run startup configuration 1 on 32-bit Windows, create a directory to hold MongoDB data,

Here I create in D:\mongodb\data\db, open cmd (here I use Git Bash), go to the MongoDB Bin directory, run the command below

Mongod--dbpath="D:\mongodb\data\db"

And then there was the first question I met,

 .- A-29T22: -:02.229+0800I CONTROL [Initandlisten] MongoDB starting:pid=10220port=27017Dbpath=c:\program files\mongodb\db --bit host=Lenovo .- A-29T22: -:02.234+0800I CONTROL [Initandlisten] Targetminos:windows7/windows Server -R2 .- A-29T22: -:02.235+0800I CONTROL [Initandlisten] DB version v3.4.1 .- A-29T22: -:02.237+0800I CONTROL [initandlisten] git Version:5e103c4f5583e2566a45d740225dc250baacfbd7 .- A-29T22: -:02.238+0800I CONTROL [Initandlisten] OpenSSL Version:openssl1.0.1t-fips3May . .- A-29T22: -:02.240+0800I CONTROL [Initandlisten] Allocator:tcmalloc .- A-29T22: -:02.241+0800I CONTROL [Initandlisten] Modules:none .- A-29T22: -:02.241+0800I CONTROL [Initandlisten] Build environment: .- A-29T22: -:02.243+0800I CONTROL [Initandlisten] distmod:2008plus-SSL .- A-29T22: -:02.244+0800I CONTROL [Initandlisten] distarch:x86_64 .- A-29T22: -:02.245+0800I CONTROL [Initandlisten] target_arch:x86_64 .- A-29T22: -:02.246+0800I CONTROL [Initandlisten] options: {storage: {dbPath:"C:\Program files\mongodb\db" } } .- A-29T22: -:02.249+0800I STORAGE [Initandlisten] exceptioninchInitandlisten: -Attempted to create aLockFile on a read-Only Directory:c:\program files\mongodb\db, terminating .- A-29T22: -:02.251+0800I NETWORK [Initandlisten] shutdown:going to close listening sockets ... .- A-29T22: -:02.255+0800I NETWORK [Initandlisten] shutdown:going to flush diaglog ... .- A-29T22: -:02.256+0800I CONTROL [Initandlisten] now exiting .- A-29T22: -:02.257+0800I CONTROL [Initandlisten] shutting down with code: -

Finally appeared shutting down with code:100,

I found the answer in the heart of the blog, because: we entered the command prompt is only normal mode, so there is no way to create a file problem, switch to administrator mode, rerun the command:

It can then start normally.

2. I add the MONGO command to the PATH environment variable,

So I don't have to go into the bin of MongoDB every time to execute the MONGO command.

3. Set MongoDB as Windows service,

Using the Administrator: Command prompt, switch to the directory where the MongoDB directory is installed bin , run the following command, MongoDB set the Windows service:

Mongod--dbpath="D:\mongodb\data\db" --logpath="D:\mongodb\data\log " " MongoDB " " MongoDB " --install

Parameter interpretation:

--dbpath=   Data directory for "D:\mongodb\data\db" MongoDB  
--logpath= "D:\mongodb\data\log"--logappend Specifies the log file. And the log is output in an append way
--servicename "MongoDB"--servicedisplayname "MongoDB" Windows Server name and display name for MongoDB
--directoryperdb indicates that each DB will create a new directory

To be installed, in contrast to the--remove

Start the command to stop the MongoDB service
Start mongodb:net start MongoDB stop mongodb:net stop MongoDB

Then I ran into a second problem , after the server was successfully installed, it started, found that it could not start, and looked at the log log file, and there was this information:

 .- A-29t23:Wuyi:23.705+0800I CONTROL [Initandlisten] Options: {service:true, storage: {dbPath:"D:\mongodb\data\db", Directoryperdb:true}, Systemlog: {destination:"file", Logappend:true, Path:"D:\mongodb\data\log\mongodb.log" } } .- A-29t23:Wuyi:23.706+0800I-[Initandlisten] detected data filesinchC:\Program Files\mongodb\db created by the'Wiredtiger'Storage engine, so setting the active storage engine to'Wiredtiger'. .- A-29t23:Wuyi:23.707+0800I STORAGE [Initandlisten] exceptioninchInitandlisten: theRequested option conflicts with current storage engine option forDirectoryperdb; You requestedtrueBut the current server storage isAlreadySetTofalseand cannot be changed, terminating .- A-29t23:Wuyi:23.707+0800I NETWORK [Servicestopworker] shutdown:going to close listening sockets ... .- A-29t23:Wuyi:23.707+0800I NETWORK [Servicestopworker] shutdown:going to flush diaglog ... .- A-29t23:Wuyi:23.707+0800I CONTROL [Servicestopworker] now exiting .- A-29t23:Wuyi:23.707+0800I CONTROL [Servicestopworker] shutting down with code: the

The general meaning is that the storage engine conflicts, (previously started the MongoDB service on the command line, and then in the data directory generated data files)

At this time we can find the storage.bson file in the data directory and delete it.

We can start the database by adding to the MONGO command in the environment variable, so that we can perform some operations from the command line.

 Here we have been able to use MongoDB to carry out the work, I encountered two problems in the heart of the blog also found the answer.
Postscript

My MongoDB notebook is mainly to record MONGO document learning situation, will be constantly updated.

  

Blog will share some of the development of the experience and problems encountered in the learning phase finally resolved, will persist, but also very happy to see every day the blog park has a lot of people to share knowledge.

Configuration and installation of MongoDB under window

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.