MongoDB, a database based on distributed file storage: a detailed guide to the introduction, installation, and usage of MongoDB (graphic and text tutorials for MongoDB installation) --------- To understand MongoDB, this article is enough.

MongoDB, a database based on distributed file storage: a detailed guide to the introduction, installation, and usage of MongoDB (graphic and text tutorials for MongoDB installation) --------- To understand MongoDB, this article is enough.

MongoDb

Introduction

MongoDB is a database based on distributed file storage. Written by C++ language. It aims to provide scalable high-performance data storage solutions for WEB applications.
MongoDB is a product between relational databases and non-relational databases. It is the most functional among non-relational databases and most similar to relational databases. The data structure it supports is very loose, which is a bson format similar to json, so it can store more complex data types. The biggest feature of Mongo is that the query language it supports is very powerful. Its syntax is somewhat similar to object-oriented query language. It can almost realize most of the functions similar to single-table query of relational database, and it also supports indexing of data.

features

It is characterized by high performance, easy deployment, and easy use, and it is very convenient to store data. The main features are:

  • mongodb cluster reference mongodb cluster reference
  • Collection-oriented storage, easy to store data of object type.
  • Pattern free.
  • Support dynamic query.
  • Full indexing is supported, including internal objects.
  • Support inquiries.
  • Supports replication and failover.
  • Use efficient binary data storage, including large objects (such as video, etc.).
  • Automatically handle fragmentation to support scalability at the cloud computing level.
  • Support Golang, RUBY, Python, Java, C++, PHP, C# and other languages.
  • The file storage format is BSON (an extension of JSON).
  • Accessible via the web.

The difference between MangoDB and Mysql

MongoDB database is different from Mysql, in MongoDB:

  • The database is stored in the form of files, and the corresponding database is stored in the database directory!
  • Call the "table" in the traditional database: Collections "collection"!
  • When storing data in a collection, access it directly in JSON format!
  • The data in the collection is called: Documents "documents"!

Applicable scene

The main goal of MongoDB is to build a bridge between key/value storage (providing high performance and high scalability) and traditional RDBMS systems (rich in functions), and it combines the advantages of both. According to the description on the official website, Mongo is suitable for the following scenarios.
● 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 restarts, 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.
● High scalability scenarios: Mongo is very suitable for databases consisting of dozens or hundreds of servers. Mongo's roadmap already includes built-in support for the MapReduce engine.
● Used for object and JSON data storage: Mongo's BSON data format is very suitable for storage and query in document format.
The use of MongoDB also has some limitations, for example, it is not suitable for the following places.
● Highly transactional systems: eg banking or accounting systems. Traditional relational databases are still more suitable for applications that require a large number of atomic complex transactions.
● Traditional business intelligence applications: BI databases for specific problems will generate highly optimized query methods. For such applications, a data warehouse may be a more appropriate choice.
● Questions that require SQL.

Install

Enter the official website to download the corresponding version and system tgz file
MongoDB official website download address

insert image description here
This introduction uses the mac environment as an example, which is consistent with the operation of the linux server.
After the download is complete
, decompress and modify the file name to mongodb, store the file in the /usr/local directory, enter the mongodb file, and create data and log files.

  • mac: In the ~ directory, use to open -e .bash_profileopen the file and
    export PATH=${PATH}:/usr/local/mongodb/binpaste it into the file
  • linux: iinux can use the vim command to operate.
    Comrades who are not very proficient in vim commands can download the SSH tool, modify it locally and upload it to the server.

After the environment variable is added, use source .bash_profileto reload the environment variable file

start up

Start with the command

mongod --dbpath data --logpath log/mongod.log --logappend
或
mongod --dbpath data --logpath log/mongod.log --logappend --port=27017 —fork

Guess you like

Origin blog.csdn.net/luck_sheng/article/details/129751045