Contents

About the Authors

About the Technical Reviewers

Acknowledgments

Introduction

images Part 1: MongoDB Basics

images Chapter 1: Introduction to MongoDB

Reviewing the MongoDB Philosophy

Using the Right Tool for the Right Job

Lacking Innate Support for Transactions

JSON and MongoDB

Adopting a Nonrelational Approach

Opting for Performance vs. Features

Running the Database Anywhere

Fitting Everything Together

Generating or Creating a Key

Using Keys and Values

Implementing Collections

Understanding Databases

Reviewing the Feature List

Using Document-Oriented Storage (BSON)

Supporting Dynamic Queries

Indexing Your Documents

Leveraging Geospatial Indexes

Profiling Queries

Updating Information In-Place

Storing Binary Data

Replicating Data

Implementing Sharding

Using Map and Reduce Functions

The All-New Aggregation Framework

Getting Help

Visiting the Website

Chatting with the MongoDB Developers

Cutting and Pasting MongoDB Code

Finding Solutions on Google Groups

Leveraging the JIRA Tracking System

Summary

images Chapter 2: Installing MongoDB

Choosing Your Version

Understanding the Version Numbers

Installing MongoDB on Your System

Installing MongoDB under Linux

Installing MongoDB under Windows

Running MongoDB

Prerequisites

Surveying the Installation Layout

Using the MongoDB Shell

Installing Additional Drivers

Installing the PHP Driver

Confirming That Your PHP Installation Works

Installing the Python Driver

Confirming That Your PyMongo Installation Works

Summary

images Chapter 3: The Data Model

Designing the Database

Drilling Down on Collections

Using Documents

Creating the _id Field

Building Indexes

Impacting Performance with Indexes

Implementing Geospatial Indexing

Querying Geospatial Information

Using MongoDB in the Real World

Summary

images Chapter 4: Working with Data

Navigating Your Databases

Viewing Available Databases and Collections

Inserting Data into Collections

Querying for Data

Using the Dot Notation

Using the Sort, Limit, and Skip Functions

Working with Capped Collections, Natural Order, and $natural

Retrieving a Single Document

Using the Aggregation Commands

Working with Conditional Operators

Leveraging Regular Expressions

Updating Data

Updating with update( )

Implementing an Upsert with the save( ) Command

Updating Information Automatically

Specifying the Position of a Matched Array

Atomic Operations

Modifying and Returning a Document Atomically

Renaming a Collection

Removing Data

Referencing a Database

Referencing Data Manually

Referencing Data with DBRef

Implementing Index-Related Functions

Surveying Index-Related Commands

Forcing a Specified Index to Query Data

Constraining Query Matches

Summary

images Chapter 5: GridFS

Filling in Some Background

Working with GridFS

Getting Started with the Command-Line Tools

Using the _id Key

Working with Filenames

Determining a File’s Length

Working with Chunk Sizes

Tracking the Upload Date

Hashing Your Files

Looking Under MongoDB’s Hood

Using the search Command

Deleting

Retrieving Files from MongoDB

Summing Up mongofiles

Exploiting the Power of Python

Connecting to the Database

Accessing the Words

Putting Files into MongoDB

Retrieving Files from GridFS

Deleting Files

Summary

images Part 2: Developing with MongoDB

images Chapter 6: PHP and MongoDB

Comparing Documents in MongoDB and PHP

MongoDB Classes

Connecting and Disconnecting

Inserting Data

Listing Your Data

Returning a Single Document

Listing All Documents

Using Query Operators

Querying for Specific Information

Sorting, Limiting, and Skipping Items

Counting the Number of Matching Results

Grouping Data with the Aggregation Framework

Specifying the Index with Hint

Refining Queries with Conditional Operators

Regular Expressions

Modifying Data with PHP

Updating via update( )

Saving Time with Update Operators

Upserting Data with save( )

Modifying a Document Atomically

Deleting Data

DBRef

Retrieving the Information

GridFS and the PHP Driver

Storing Files

Adding More Metadata to Stored Files

Retrieving Files

Deleting Data

Summary

images Chapter 7: Python and MongoDB

Working with Documents in Python

Using PyMongo Modules

Connecting and Disconnecting

Inserting Data

Finding Your Data

Finding a Single Document

Finding Multiple Documents

Using Dot Notation

Returning Fields

Simplifying Queries with sort( ), limit( ), and skip( )

Aggregating Queries

Specifying an Index with hint( )

Refining Queries with Conditional Operators

Conducting Searches with Regular Expressions

Modifying the Data

Updating Your Data

Modifier Operators

Saving Documents Quickly with save( )

Modifying a Document Atomically

Putting the Parameters to Work

Deleting Data

Creating a Link Between Two Documents

Retrieving the Information

Summary

images Chapter 8: Advanced Queries

Text Search

Text Search Costs and Limitations

Enabling Text Search

Using Text Search

Text Indexes in Other Languages

Compound Indexing with Text Indexes

The Aggregation Framework

$group

$limit

$match

$sort

$unwind

$skip

MapReduce

How MapReduce Works

Setting Up Testing Documents

Working with Map functions

Advanced MapReduce

Debugging MapReduce

Summary

images Part 3: Advanced MongoDB with Big Data

images Chapter 9: Database Administration

Using Administrative Tools

mongo, the MongoDB Console

Using Third-Party Administration Tools

Backing Up the MongoDB Server

Creating a Backup 101

Backing Up a Single Database

Backing Up a Single Collection

Digging Deeper into Backups

Restoring Individual Databases or Collections

Restoring a Single Database

Restoring a Single Collection

Automating Backups

Using a Local Datastore

Using a Remote (Cloud-Based) Datastore

Backing Up Large Databases

Using a Hidden Secondary Server for Backups

Creating Snapshots with a Journaling Filesystem

Disk Layout to Use with Volume Managers

Importing Data into MongoDB

Exporting Data from MongoDB

Securing Your Data by Restricting Access to a MongoDB Server

Protecting Your Server with Authentication

Adding an Admin User

Enabling Authentication

Authenticating in the mongo Console

MongoDB User Roles

Delegated Credentials

Changing a User’s Credentials

Adding a Read-Only User

Deleting a User

Using Authenticated Connections in a PHP Application

Managing Servers

Starting a Server

Reconfiguring a Server

Getting the Server’s Version

Getting the Server’s Status

Shutting Down a Server

Using MongoDB Logfiles

Validating and Repairing Your Data

Repairing a Server

Validating a Single Collection

Repairing Collection Validation Faults

Repairing a Collection’s Datafiles

Compacting a Collection’s Datafiles

Upgrading MongoDB

Rolling Upgrade of MongoDB

Monitoring MongoDB

Using the MongoDB Management Service (MMS)

Summary

images Chapter 10: Optimization

Optimizing Your Server Hardware for Performance

Understanding How MongoDB Uses Memory

Understanding Working Set Size

Choosing the Right Database Server Hardware

Evaluating Query Performance

The MongoDB Profiler

Analyzing a Specific Query with explain( )

Using the Profiler and explain( ) to Optimize a Query

Managing Indexes

Listing Indexes

Creating a Simple Index

Creating a Compound Index

Specifying Index Options

Creating an Index in the Background with {background:true}

Creating an Index with a Unique Key {unique:true}

Dropping Duplicates Automatically with {dropdups:true}

Creating Sparse Indexes with {sparse:true}

TTL Indexes

Text Search Indexes

Dropping an Index

Reindexing a Collection

How MongoDB Selects Which Indexes It Will Use

Using hint( ) to Force Using a Specific Index

Optimizing the Storage of Small Objects

Summary

images Chapter 11: Replication

Spelling Out MongoDB’s Replication Goals

Improving Scalability

Improving Durability/Reliability

Providing Isolation

Replication Fundamentals

What Is a Primary?

What Is a Secondary?

What Is an Arbiter?

Drilling Down on the Oplog

Implementing a Replica Set

Creating a Replica Set

Getting a Replica Set Member Up and Running

Adding a Server to a Replica Set

Adding an Arbiter

Replica Set Chaining

Managing Replica Sets

Configuring the Options for Replica Set Members

Connecting to a Replica Set from Your Application

Summary

images Chapter 12: Sharding

Exploring the Need for Sharding

Partitioning Horizontal and Vertical Data

Partitioning Data Vertically

Partitioning Data Horizontally

Analyzing a Simple Sharding Scenario

Implementing Sharding with MongoDB

Setting Up a Sharding Configuration

Determining How You’re Connected

Listing the Status of a Sharded Cluster

Using Replica Sets to Implement Shards

The Balancer

Hashed Shard Keys

Tag Sharding

Summary

Index

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.227.49.160