Home Page Icon
Home Page
Table of Contents for
I. Introduction to MongoDB
Close
I. Introduction to MongoDB
by Kristina Chodorow, Eoin Brazil, Shannon Bradshaw
MongoDB: The Definitive Guide, 3rd Edition
Preface
How This Book Is Organized
Getting Started with MongoDB
Developing with MongoDB
Replication
Sharding
Application Administration
Server Administration
Appendixes
Conventions Used in This Book
Using Code Examples
O’Reilly Online Learning
How to Contact Us
I. Introduction to MongoDB
1. Introduction
Ease of Use
Designed to Scale
Rich with Features…
…Without Sacrificing Speed
The Philosophy
2. Getting Started
Documents
Collections
Dynamic Schemas
Naming
Databases
Getting and Starting MongoDB
Introduction to the MongoDB Shell
Running the Shell
A MongoDB Client
Basic Operations with the Shell
Data Types
Basic Data Types
Dates
Arrays
Embedded Documents
_id and ObjectIds
Using the MongoDB Shell
Tips for Using the Shell
Running Scripts with the Shell
Creating a .mongorc.js
Customizing Your Prompt
Editing Complex Variables
Inconvenient Collection Names
3. Creating, Updating, and Deleting Documents
Inserting Documents
insertMany
Insert Validation
insert
Removing Documents
drop
Updating Documents
Document Replacement
Using Update Operators
Upserts
Updating Multiple Documents
Returning Updated Documents
4. Querying
Introduction to find
Specifying Which Keys to Return
Limitations
Query Criteria
Query Conditionals
OR Queries
$not
Type-Specific Queries
null
Regular Expressions
Querying Arrays
Querying on Embedded Documents
$where Queries
Cursors
Limits, Skips, and Sorts
Avoiding Large Skips
Immortal Cursors
II. Designing Your Application
5. Indexes
Introduction to Indexes
Creating an Index
Introduction to Compound Indexes
How MongoDB Selects an Index
Using Compound Indexes
How $ Operators Use Indexes
Indexing Objects and Arrays
Index Cardinality
explain Output
When Not to Index
Types of Indexes
Unique Indexes
Partial Indexes
Index Administration
Identifying Indexes
Changing Indexes
6. Special Index and Collection Types
Geospatial Indexes
Types of Geospatial Queries
Using Geospatial Indexes
Compound Geospatial Indexes
2d Indexes
Indexes for Full Text Search
Creating a Text Index
Text Search
Optimizing Full-Text Search
Searching in Other Languages
Capped Collections
Creating Capped Collections
Tailable Cursors
Time-To-Live Indexes
Storing Files with GridFS
Getting Started with GridFS: mongofiles
Working with GridFS from the MongoDB Drivers
Under the Hood
7. Introduction to the Aggregation Framework
Pipelines, Stages, and Tunables
Getting Started with Stages: Familiar Operations
Expressions
$project
$unwind
Array Expressions
Accumulators
Using Accumulators in Project Stages
Introduction to Grouping
The _id Field in Group Stages
Group Versus Project
Writing Aggregation Pipeline Results to a Collection
8. Transactions
Introduction to Transactions
A Definition of ACID
How to Use Transactions
Tuning Transaction Limits for Your Application
Timing and Oplog Size Limits
9. Application Design
Schema Design Considerations
Schema Design Patterns
Normalization Versus Denormalization
Examples of Data Representations
Cardinality
Friends, Followers, and Other Inconveniences
Optimizations for Data Manipulation
Removing Old Data
Planning Out Databases and Collections
Managing Consistency
Migrating Schemas
Managing Schemas
When Not to Use MongoDB
III. Replication
10. Setting Up a Replica Set
Introduction to Replication
Setting Up a Replica Set, Part 1
Networking Considerations
Security Considerations
Setting Up a Replica Set, Part 2
Observing Replication
Changing Your Replica Set Configuration
How to Design a Set
How Elections Work
Member Configuration Options
Priority
Hidden Members
Election Arbiters
Building Indexes
11. Components of a Replica Set
Syncing
Initial Sync
Replication
Handling Staleness
Heartbeats
Member States
Elections
Rollbacks
When Rollbacks Fail
12. Connecting to a Replica Set from Your Application
Client−to−Replica Set Connection Behavior
Waiting for Replication on Writes
Other Options for “w”
Custom Replication Guarantees
Guaranteeing One Server per Data Center
Guaranteeing a Majority of Nonhidden Members
Creating Other Guarantees
Sending Reads to Secondaries
Consistency Considerations
Load Considerations
Reasons to Read from Secondaries
13. Administration
Starting Members in Standalone Mode
Replica Set Configuration
Creating a Replica Set
Changing Set Members
Creating Larger Sets
Forcing Reconfiguration
Manipulating Member State
Turning Primaries into Secondaries
Preventing Elections
Monitoring Replication
Getting the Status
Visualizing the Replication Graph
Replication Loops
Disabling Chaining
Calculating Lag
Resizing the Oplog
Building Indexes
Replication on a Budget
IV. Sharding
14. Introduction to Sharding
What Is Sharding?
Understanding the Components of a Cluster
Sharding on a Single-Machine Cluster
15. Configuring Sharding
When to Shard
Starting the Servers
Config Servers
The mongos Processes
Adding a Shard from a Replica Set
Adding Capacity
Sharding Data
How MongoDB Tracks Cluster Data
Chunk Ranges
Splitting Chunks
The Balancer
Collations
Change Streams
16. Choosing a Shard Key
Taking Stock of Your Usage
Picturing Distributions
Ascending Shard Keys
Randomly Distributed Shard Keys
Location-Based Shard Keys
Shard Key Strategies
Hashed Shard Key
Hashed Shard Keys for GridFS
The Firehose Strategy
Multi-Hotspot
Shard Key Rules and Guidelines
Shard Key Limitations
Shard Key Cardinality
Controlling Data Distribution
Using a Cluster for Multiple Databases and Collections
Manual Sharding
17. Sharding Administration
Seeing the Current State
Getting a Summary with sh.status()
Seeing Configuration Information
Tracking Network Connections
Getting Connection Statistics
Limiting the Number of Connections
Server Administration
Adding Servers
Changing Servers in a Shard
Removing a Shard
Balancing Data
The Balancer
Changing Chunk Size
Moving Chunks
Jumbo Chunks
Refreshing Configurations
V. Application Administration
18. Seeing What Your Application Is Doing
Seeing the Current Operations
Finding Problematic Operations
Killing Operations
False Positives
Preventing Phantom Operations
Using the System Profiler
Calculating Sizes
Documents
Collections
Databases
Using mongotop and mongostat
19. An Introduction to MongoDB Security
MongoDB Authentication and Authorization
Authentication Mechanisms
Authorization
Using x.509 Certificates to Authenticate Both Members and Clients
A Tutorial on MongoDB Authentication and Transport Layer Encryption
Establish a CA
Generate and Sign Member Certificates
Generate and Sign Client Certificates
Bring Up the Replica Set Without Authentication and Authorization Enabled
Create the Admin User
Restart the Replica Set with Authentication and Authorization Enabled
20. Durability
Durability at the Member Level Through Journaling
Durability at the Cluster Level Using Write Concern
The w and wtimeout Options for writeConcern
The j (Journaling) Option for writeConcern
Durability at a Cluster Level Using Read Concern
Durability of Transactions Using a Write Concern
What MongoDB Does Not Guarantee
Checking for Corruption
VI. Server Administration
21. Setting Up MongoDB in Production
Starting from the Command Line
File-Based Configuration
Stopping MongoDB
Security
Data Encryption
SSL Connections
Logging
22. Monitoring MongoDB
Monitoring Memory Usage
Introduction to Computer Memory
Tracking Memory Usage
Tracking Page Faults
I/O Wait
Calculating the Working Set
Some Working Set Examples
Tracking Performance
Tracking Free Space
Monitoring Replication
23. Making Backups
Backup Methods
Backing Up a Server
Filesystem Snapshot
Copying Data Files
Using mongodump
Specific Considerations for Replica Sets
Specific Considerations for Sharded Clusters
Backing Up and Restoring an Entire Cluster
Backing Up and Restoring a Single Shard
24. Deploying MongoDB
Designing the System
Choosing a Storage Medium
Recommended RAID Configurations
CPU
Operating System
Swap Space
Filesystem
Virtualization
Memory Overcommitting
Mystery Memory
Handling Network Disk I/O Issues
Using Non-Networked Disks
Configuring System Settings
Turning Off NUMA
Setting Readahead
Disabling Transparent Huge Pages (THP)
Choosing a Disk Scheduling Algorithm
Disabling Access Time Tracking
Modifying Limits
Configuring Your Network
System Housekeeping
Synchronizing Clocks
The OOM Killer
Turn Off Periodic Tasks
A. Installing MongoDB
Choosing a Version
Windows Install
Installing as a Service
POSIX (Linux and Mac OS X) Install
Installing from a Package Manager
B. MongoDB Internals
BSON
Wire Protocol
Data Files
Namespaces
WiredTiger Storage Engine
Index
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Prev
Previous Chapter
Preface
Next
Next Chapter
1. Introduction
Part I.
Introduction to MongoDB
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset