MongoDB
MongoDB is a leading document-oriented NoSQL database that revolutionizes data storage with its flexible schema design, horizontal scalability, and rich query capabilities, making it ideal for modern applications handling diverse data types.
Supported Versions and Architectures
- Versions: MongoDB 3.6 and above (for MongoDB 3.4 and below, use "MongoDB Below 3.4" connector)
- Architectures: Replica sets and sharded clusters, including secondary node sync
Supported Data Types
Category | Data Types |
---|---|
Strings and Code | String, JavaScript, Symbol |
Numeric Types | Double, Int32, Int64, Decimal128 |
Document and Array | Document, Array |
Binary and ObjectId | Binary, ObjectId |
Boolean Type | Boolean |
Date and Timestamp | Date, Timestamp |
Special Types | Min Key, Max Key, Null |
Quick Setup Guide
1. Configure Replica Set
For standalone instances, convert to single-member replica set:
rs.initiate()
2. Create Database User
- Specific database access
- All databases access
use admin
db.createUser({
user: "xpipes",
pwd: "your_password",
roles: [
{ role: "read", db: "your_database" },
{ role: "read", db: "local" },
{ role: "read", db: "config" },
{ role: "clusterMonitor", db: "admin" }
]
})
use admin
db.createUser({
user: "xpipes",
pwd: "your_password",
roles: [
{ role: "readAnyDatabase", db: "admin" },
{ role: "clusterMonitor", db: "admin" }
]
})
3. Configure Oplog (for incremental sync)
Ensure oplog can store at least 24 hours of data:
db.runCommand({replSetResizeOplog: 1, size: 16384}) // 16GB
4. Sharded Cluster Setup
For sharded clusters:
- Stop the balancer:
sh.stopBalancer()
- Clean orphaned documents:
db.runCommand({cleanupOrphaned: "db.collection"})
- Create users on each shard's primary node
Limitations
- Sharded clusters: Requires stopping balancer during initial sync
- Standalone instances: Must be converted to replica set for incremental sync
- User permissions: Sharded clusters need users created on each shard