MongoDB
Last updated
Was this helpful?
Last updated
Was this helpful?
MongoDB is a general purpose, document-based, distributed database built for modern application developers and for the cloud era.
→ , ,
: presentations, webinars, white papers
Flexible schema
Performance
High Availability
Primary / Secondaries architecture
BSON storage (Binary JSON)
support of for encoding a variety of geographic data structures
ACID transactions
Sharding
A replica set is a group of mongod
processes that maintain the same data set. Replica sets provide redundancy and high availability.
A node of the replica set can be: Primary, Secondary, Arbitrer.
Read preference
Write concern
Read concern
Indexes gets have better read time but have an impact on write time.
Index Types:
Single Field
Compound Index
Multikey Index
Geospatial Index
Text Indexes
Hashed Indexes
Index Properties:
Unique Indexes
Partial Indexes
Sparse Indexes
TTL Indexes (Time To Live)
The storage engine that is used can be seen with the command db.serverStatus()
. It is a mongod
option: --storageEngine
.
In March 2015, there were two choices: MMAPv1 (original) and WiredTiger (new).
Wired Tiger is new in MongoDB 3.0. It is the first pluggable storage engine.
Features:
Document level locking
Compression
Snappy (default) - fast
Zlib - more compression
None
Lacks some pitfalls of MMAPv1
Performance gains
Background:
Built separately from MongoDB
Used by other's DB
Open source
Internals:
Stores data in btrees
Writes are initially separate, incorporated later
Two caches
WT caches - 1/2 of RAM (default)
FS cache
Checkpoint: every minute or more
No need for a journal
4.4
June 09, 2020
You'll download a file like mongodb-win32-x86_64-2008plus-ssl-4.0.4.zip
Unzip the content of the archive in a program folder (for example D:\Programs
folder)
Rename the folder with something explicit like mongodb-community-4.0.4
You can either update your PATH globally on your machine or do it when you need it (or through a bat file)
The following command must return a valid output
MongoDB shell version v4.0.4 git version: f288a3bdf201007f3693c58e140056adf8b04839 allocator: tcmalloc modules: none build environment: distmod: 2008plus-ssl distarch: x86_64 target_arch: x86_64
If you followed the steps to have the Mongo Shell, you'll be able to launch easily a MongoDB server locally (mongod
).
You can then connect with the MongoDB Shell:
Check the images already downloaded locally
Get the image for a specific version of MongoDB
Start the container
Introduced in June 2020, avalable as a standalone package, it provides a fully functional JavaScript/Node.js environment for interacting with MongoDB deployments. It can be used to test queries and operations directly with one database.
Import the data into your MongoDB server
You can also import the data to your Atlas cluster
mtools is a collection of helper scripts to parse, filter, and visualize MongoDB log files (mongod, mongos). mtools also includes mlaunch, a utility to quickly set up complex MongoDB test environments on a local machine.
You'll need Python (2 or 3) to install and use it.
MongoDB indexes use a data structure.
See also - February 12, 2020
Store large data:
,
Go to the , select "Server", then "MongoDB Community Server" edition, chose the target platform and version and let the download complete.
→
→ , , ,
Download the zip file export from .
dbKoda holds a collection of sample data: .
More information on , .
- May 28, 2021