About MongoDB
Mongdb is a cross-platform, document-oriented database that enables high performance, high availability, and easy scalability, and is an open source database system based on distributed file storage. In the case of high load, adding more nodes can guarantee the performance of the server.
MongoDB is also a product between a relational database and a non-relational database, the most versatile of the non-relational databases, most like relational databases. Instead of using relational models primarily for better extensibility, MongoDB no longer has the concept of "row", which operates primarily on two concepts: Collections (collection) and documents.
Features of MongoDB
- MongoDB features include collection-oriented storage, schema freedom, rich query statements and multilevel indexes, replication set mechanism, easy to level expansion, pluggable storage engine, cross-platform multi-language support, etc.
- MongoDB is simple to install and provides a document-oriented storage function, which is easier to operate.
- MongoDB provides replication, high availability, and automatic sharding capabilities. If the load increases (requiring more storage space and greater processing power), it can be distributed across other nodes in the computer network, which is called sharding.
- The Mongo supports rich query expressions. Query directives use a JSON-style tag to easily query objects and arrays embedded in the document.
- MongoDB supports a variety of programming languages: Ruby, Python, Java, C + +, PHP, C #, and more.
MongoDB Areas of Application
MongoDB can provide scalable, high-performance data storage solutions for WEB applications. MongoDB's main areas of application are Web site data, distributed scenarios, data caches, and JSON document format storage. For Internet applications with large data volumes, high concurrency, and weak transactions, the built-in horizontal expansion mechanism provides data processing capabilities from millions of to 1 billion levels that can be well suited to the requirements of Web2.0 and mobile Internet application datastores.
Installation of MongoDB 4.0
MongoDB provides the installation package on the Linux platform, which can be downloaded from the official website Http://www.mongodb.org/downloads. This time we choose to use the latest version of MongoDB4.0 to install and experiment.
Setting Kernel parameters
Echo 0 > /proc/sys/vm/zone_reclaim_mode
Sysctl -w vm.zone_reclaim_mode=0 #permanent setting
Echo never > /sys/kernel/mm/transparent_hugepage/enabled
Echo never > /sys/kernel/mm/transparent_hugepage/defrag
MongoDB Logical Storage structure
The logical structure of MongoDB consists of three parts: Document, Collection (collection) and database. The document is the core concept of MongoDB, it is the smallest unit of MongoDB logical storage, the equivalent of a row of records in a relational database, a collection of multiple documents, a collection equivalent to the concept of tables in a relational database, several constituent databases.
SQL Terminology/Concepts |
MongoDB Terminology/Concepts |
Explanation/Description |
Database |
Database |
Database |
Table |
Collection |
Database Tables/Collections |
Row |
Document |
Data record lines/documents |
Column |
Field |
Data fields/Fields |
Index |
Index |
Index |
Table joins |
|
Table connection, MongoDB not supported |
Primary key |
Primary key |
Primary key, MongoDB automatically sets the _id field as the primary key |
MongoDB Basic Operations
Backing up, recovering databases
MongoDB Security Management
MongoDB security management mainly includes MongoDB's secure access control and user rights assignment.
MongoDB Monitoring
MongoDB database detailed, and MongoDB4.0 version of the installation