1024programmer Mongodb MongoDB study notes (1) Introduction and installation of MongoDB

MongoDB study notes (1) Introduction and installation of MongoDB

This is the first of a series of MongoDB study notes. It mainly introduces what is a non-relational database MongoDB, how to download it, where to download it, and how to install it correctly.

I. Introduction

Recently, I started to learn the non-relational database MongoDB, but I couldn’t find a more systematic tutorial on the blog garden. Many materials have to be consulted on the English website, which is relatively inefficient. I am not talented, so I took the opportunity of self-study to record all my experience and experience, so that interested children’s shoes can be shared and discussed. Some resources come from other blogs, aiming to gather scattered knowledge points together. If your rights are violated, please contact [email protected]. Most of the content is original, welcome to reprint and share, but don’t forget to indicate the author and the original link when reprinting.

2. Introduction to MongoDB

MongoDB is a high-performance, open source, schema-free document database, which is one of the more popular NoSql databases. It can be used as an alternative to traditional relational databases or key/value stores in many scenarios. Mongo is developed using C++. Mongo’s official website address is: http://www.mongodb.org/, readers can get more detailed information here. the

Interlude: What is NoSql?

NoSql, the full name is Not Only Sql, which refers to a non-relational database. The next-generation database mainly addresses several points: non-relational, distributed, open source, and horizontally scalable. The original purpose is for large-scale web applications. This movement started in early 2009. Usually, features are applied such as: schema freedom, support for easy replication, simple API, eventual consistency (non-ACID), large-capacity data, etc. NoSQL is used most by us as key-value storage, and of course there are other document type, column storage, graph database, xml database, etc.

Features:

  • High performance, easy to deploy, easy to use, and very convenient to store data. The main features are:
  • Collection-oriented storage, easy to store data of object type.
  • Pattern free.
  • Support dynamic query.
  • Full indexing is supported, including inner objects.
  • Support inquiries.
  • Supports replication and failover.
  • Use efficient binary data storage, including large objects (such as video, etc.).
  • Automatically handle fragmentation to support cloud-level scalability
  • Drivers for Python, PHP, Ruby, Java, C, C#, Javascript, Perl and C++ are supported, and drivers for Erlang and .NET platforms are also provided in the community.
  • The file storage format is BSON (an extension of JSON).
  • Accessible via the web.

Function:

  • Collection-oriented storage: suitable for storing data in the form of objects and JSON.
  • Dynamic query: Mongo supports rich query expressions. The query command uses JSON format tags, which can easily query the embedded objects and arrays in the document.
  • Full indexing support: including document embedded objects and arrays. Mongo’s query optimizer analyzes query expressions and generates an efficient query plan.
  • Query Monitoring: Mongo includes a monitoring tool for analyzing the performance of database operations.
  • Replication and automatic failover: Mongo database supports data replication between servers, master-slave mode and mutual replication between servers. The main goal of replication is to provide redundancy and automatic failover.
  • Efficient traditional storage: supports binary data and large objects (such as photos or pictures)
  • Auto-sharding to support cloud-level scalability: Auto-sharding supports horizontal database clusters where additional machines can be added dynamically.

Applications:

  • Website data: Mongo is very suitable for real-time insertion, update and query, and has the replication and high scalability required for real-time data storage on the website.
  • Caching: Due to its high performance, Mongo is also suitable as a caching layer for information infrastructure. After the system is restarted, the persistent cache layer built by Mongo can prevent the underlying data source from being overloaded.
  • Large size, low-value data: It may be expensive to store some data using traditional relational databases. Before that, programmers often choose traditional files for storage.
  • Highly scalable scenarios: MongoIdeal for databases consisting of tens or hundreds of servers. Mongo’s roadmap already includes built-in support for the MapReduce engine.
  • Storage of objects and JSON data: Mongo’s BSON data format is very suitable for storage and query in document format.

3. Download, install and configure

Install the Mongo database:

The latest version officially provided at the time of publishing this article is: 1.6.5. If no special statement is made, the version used in this tutorial will be this version.

  1. Step 1: Download the installation package: If it is a win system, please pay attention to whether it is a 64-bit or 32-bit version, please choose the correct version.
  2. Step 2: Create a new directory “D:\MongoDB”, unzip the downloaded installation package, find all the .exe files under the bin directory, and copy them to the newly created directory.
  3. Step 3: Create a new “data” folder under the “D:\MongoDB” directory, which will be used as the root folder for data storage.

Note: Official download address: http://www.mongodb.org/downloads

Configure the Mongo server:

Open the CMD window and enter the command as follows:
> d:
> cd D:\MongoDB
> mongod –dbpath D:\MongoDB\data

After the configuration is successful, you will see the following screen:

Enter in the browser: http://localhost:27017/, you can see the following prompt:
You are trying to access MongoDB on the native driver port. For http diagnostic access, add 1000 to the port number

In this way, the MongoDB database service has been successfully started.

Four. Postscript

Now we have initially realized the installation of MongoDB and the startup of the service. We still have a lot of work to do in the future. To enable MongoDB to be operated in our C# code, we still need a driver. Friends often find that the compilation fails after copying the code online. It is probably a problem of driver inconsistency. Next article Will explain in detail, to be continued. .

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/mongodb-study-notes-1-introduction-and-installation-of-mongodb/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索