MongoDB Installation and use

Source: Internet
Author: User
Tags mkdir mongodb mongodb like mongodb server mongodb support
MongoDB Introduction

MongoDB is a document-oriented, open source database program that has nothing to do with the platform. MongoDB like some other NoSQL database (but not all.) Uses a JSON-structured document to store data. This is a schema that makes the data very flexible and unwanted.

Some of the more important features are: supports a variety of standard query types, such as matching (), comparison (,), or regular expressions, which can store almost any type of data, whether structured, partially structured, or even polymorphic; to extend and process more queries, simply add more machines; It is highly flexible and agile, allowing you to quickly develop applications; As a file-based database means you can store all the information about your model in a single document; You can change the schema of the database at any time; Many relational database functions can also be used in MongoDB (such as indexes).

In terms of running, there are quite a few features in MongoDB that are not available in other databases: whether you need a stand-alone server or a complete stand-alone server cluster, MongoDB can be scaled as needed; MongoDB also provides load-balancing support by automatically moving data on various slices, with automatic failover support, and if the primary server down, the new primary server will automatically start and run; MongoDB Management Services (MMS) can be used to monitor and back up MONGODB infrastructure services; Unlike relational databases, you will save quite a lot of RAM due to memory-mapped files.

Although MongoDB seems to be the database that solves many of our problems at first, it is not without flaws. A common drawback of mongodb is the lack of support for acid transactions, MongoDB support for acid transactions in specific scenarios, but not in all cases. At the single document level, acid transactions are supported (this is where most transactions occur). However, because of the distributed nature of MongoDB, transactions that handle multiple documents are not supported.

MongoDB also lacks support for natural join queries. In MongoDB's view: Documents are intended to be all-inclusive, which means that, in general, they do not need to refer to other documents. In the real world, this is not always effective because the data we use is relational. Therefore, many people think that MongoDB should be used as a supplemental database for a SQL database, but when you use MongoDB, you will find that it is wrong.

MongoDB Installation

Website Download address: http://www.mongodb.org/downloads, but download speed is very slow, often download failed. Find an alternative web site where you can download zip,http://dl.mongodb.org/dl/win32/x86_64 directly from this address and install it.

(1) Install under Windows

Download the 32-bit or 64-bit. msi file according to your system, download and double-click the file, and install it as prompted.

During installation, you can set up your installation directory by clicking on the Custom button.

Create a Data directory

MongoDB stores the data directory in the DB directory. But this data directory will not be actively created, we need to create it after the installation is complete. Note that the data directory should be placed under the root directory (such as: C:\ or D:\. , etc.).

In this tutorial, we've installed MongoDB on the C: disk, now let's create a directory of data and then create the DB directory in the data directory.

C:\>CD c:\

c:\>mkdir data

C:\>CD data

c:\data>mkdir db

c:\data>cd db

c:\data\db >

You can also create these directories through the window's explorer, not necessarily through the command line.
run MongoDB server under command line

In order to run the MongoDB server from a command prompt, you must execute the Mongod.exe file from the MongoDB directory's Bin directory.

Mongod--dbpath c:\data\db

If the execution succeeds, the following information is exported:

2015-09-25t15:54:09.212+0800 I Control  Hotfix KB2731284 or later update are not
installed, would zero-out data files
2015-09-25t15:54:09.229+0800 I JOURNAL  [Initandlisten] Journal dir=c:\data\db\j
ournal
2015-09-25t15:54:09.237+0800 I journal  [Initandlisten] Recover:no Journal fil
Es Present, no recovery needed 2015-09-25t15:54:09.290+0800
I journal  [durability] D Urability thread started
2015-09-25t15:54:09.294+0800 I control  [Initandlisten] MongoDB starting:pid=2
488 port=27017 dbpath=c:\data\db 64-bit host=win-1vonbjoce88
I  Control [Initandlisten] targetminos:windows 7/w
indows Server 2008 R2
I Control  [ Initandlisten] db version v3.0.6 ...

running the MongoDB server as a Windows service

Note that you must have administrative privileges to run the following command. Run the MongoDB server as a Windows service by executing the following command: Mongod.exe--bind_ip youripadress--logpath "C:\data\dbConf\mongodb.log"--logappend --dbpath "C:\data\db"--port yourportnumber--servicename "Yourservicename"--servicedisplayname "YourServiceName" Install

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.