MongoDB Cookbook - Second Edition

Harness the latest features of MongoDB 3 with this collection of 80 recipes – from managing cloud platforms to app development, this book is a vital resource

MongoDB Cookbook - Second Edition

Cookbook
Cyrus Dasadia, Amol Nayak

Harness the latest features of MongoDB 3 with this collection of 80 recipes – from managing cloud platforms to app development, this book is a vital resource
$35.99
$44.99
RRP $35.99
RRP $44.99
eBook
Print + eBook
Preview in Mapt

Book Details

ISBN 139781785289989
Paperback371 pages

Book Description

MongoDB is a high-performance and feature-rich NoSQL database that forms the backbone of the systems that power many different organizations – it’s easy to see why it’s the most popular NoSQL database on the market. Packed with many features that have become essential for many different types of software professionals and incredibly easy to use, this cookbook contains many solutions to the everyday challenges of MongoDB, as well as guidance on effective techniques to extend your skills and capabilities.

This book starts with how to initialize the server in three different modes with various configurations. You will then be introduced to programming language drivers in both Java and Python. A new feature in MongoDB 3 is that you can connect to a single node using Python, set to make MongoDB even more popular with anyone working with Python. You will then learn a range of further topics including advanced query operations, monitoring and backup using MMS, as well as some very useful administration recipes including SCRAM-SHA-1 Authentication. Beyond that, you will also find recipes on cloud deployment, including guidance on how to work with Docker containers alongside MongoDB, integrating the database with Hadoop, and tips for improving developer productivity.

Created as both an accessible tutorial and an easy to use resource, on hand whenever you need to solve a problem, MongoDB Cookbook will help you handle everything from administration to automation with MongoDB more effectively than ever before.

Table of Contents

Chapter 1: Installing and Starting the Server
Introduction
Installing single node MongoDB
Starting a single node instance using command-line options
Single node installation of MongoDB with options from the config file
Connecting to a single node in the Mongo shell with JavaScript
Connecting to a single node using a Java client
Connecting to a single node using a Python client
Starting multiple instances as part of a replica set
Connecting to the replica set in the shell to query and insert data
Connecting to the replica set to query and insert data from a Java client
Connecting to the replica set to query and insert data using a Python client
Starting a simple sharded environment of two shards
Connecting to a shard in the shell and performing operations
Chapter 2: Command-line Operations and Indexes
Introduction
Creating test data
Performing simple querying, projections, and pagination from Mongo shell
Updating and deleting data from the shell
Creating index and viewing plans of queries
Creating a background and foreground index in the shell
Creating and understanding sparse indexes
Expiring documents after a fixed interval using the TTL index
Expiring documents at a given time using the TTL index
Chapter 3: Programming Language Drivers
Introduction
Executing query and insert operations with PyMongo
Executing update and delete operations using PyMongo
Implementing aggregation in Mongo using PyMongo
Executing MapReduce in Mongo using PyMongo
Executing query and insert operations using a Java client
Executing update and delete operations using a Java client
Implementing aggregation in Mongo using a Java client
Executing MapReduce in Mongo using a Java client
Chapter 4: Administration
Introduction
Renaming a collection
Viewing collection stats
Viewing database stats
Manually padding a document
The mongostat and mongotop utilities
Getting current executing operations and killing them
Using profiler to profile operations
Setting up users in Mongo
Interprocess security in Mongo
Modifying collection behavior using the collMod command
Setting up MongoDB as a windows service
Replica set configurations
Stepping down as primary from the replica set
Exploring the local database of a replica set
Understanding and analyzing oplogs
Building tagged replica sets
Configuring the default shard for non-sharded collections
Manual split and migration of chunks
Domain-driven sharding using tags
Exploring the config database in a sharded setup
Chapter 5: Advanced Operations
Introduction
Atomic find and modify operations
Implementing atomic counters in Mongo
Implementing server-side scripts
Creating and tailing a capped collection cursors in MongoDB
Converting a normal collection to a capped collection
Storing binary data in Mongo
Storing large data in Mongo using GridFS
Storing data to GridFS from Java client
Storing data to GridFS from Python client
Implementing triggers in Mongo using oplog
Flat plane 2D geospatial queries in Mongo using geospatial indexes
Spherical indexes and GeoJSON compliant data in Mongo
Implementing full text search in Mongo
Integrating MongoDB for full text search with Elasticsearch
Chapter 6: Monitoring and Backups
Introduction
Signing up for MMS and setting up an MMS monitoring agent
Managing users and groups in MMS console
Monitoring instances and setting up alerts on MMS
Setting up monitoring alerts in MMS
Back up and restore data in Mongo using out-of-the-box tools
Configuring MMS Backup service
Managing backups in MMS Backup service
Chapter 7: Deploying MongoDB on the Cloud
Introduction
Setting up and managing the MongoLab account
Setting up a sandbox MongoDB instance on MongoLab
Performing operations on MongoDB from MongoLab GUI
Setting up MongoDB on Amazon EC2 manually
Setting up MongoDB using the Docker containers
Chapter 8: Integration with Hadoop
Introduction
Executing our first sample MapReduce job using the mongo-hadoop connector
Writing our first Hadoop MapReduce job
Running MapReduce jobs on Hadoop using streaming
Running a MapReduce job on Amazon EMR
Chapter 9: Open Source and Proprietary Tools
Introduction
Developing using spring-data-mongodb
Accessing MongoDB using JPA
Accessing MongoDB over REST
Installing a GUI-based client, MongoVUE, for MongoDB

What You Will Learn

  • Install, configure, and administer MongoDB sharded clusters and replica sets
  • Begin writing applications using MongoDB in Java and Python languages
  • Initialize the server in three different modes with various configurations
  • Perform cloud deployment and introduce PaaS for Mongo
  • Discover frameworks and products built to improve developer productivity using Mongo
  • Take an in-depth look at the Mongo programming driver APIs in Java and Python
  • Set up enterprise class monitoring and backups of MongoDB

Authors

Table of Contents

Chapter 1: Installing and Starting the Server
Introduction
Installing single node MongoDB
Starting a single node instance using command-line options
Single node installation of MongoDB with options from the config file
Connecting to a single node in the Mongo shell with JavaScript
Connecting to a single node using a Java client
Connecting to a single node using a Python client
Starting multiple instances as part of a replica set
Connecting to the replica set in the shell to query and insert data
Connecting to the replica set to query and insert data from a Java client
Connecting to the replica set to query and insert data using a Python client
Starting a simple sharded environment of two shards
Connecting to a shard in the shell and performing operations
Chapter 2: Command-line Operations and Indexes
Introduction
Creating test data
Performing simple querying, projections, and pagination from Mongo shell
Updating and deleting data from the shell
Creating index and viewing plans of queries
Creating a background and foreground index in the shell
Creating and understanding sparse indexes
Expiring documents after a fixed interval using the TTL index
Expiring documents at a given time using the TTL index
Chapter 3: Programming Language Drivers
Introduction
Executing query and insert operations with PyMongo
Executing update and delete operations using PyMongo
Implementing aggregation in Mongo using PyMongo
Executing MapReduce in Mongo using PyMongo
Executing query and insert operations using a Java client
Executing update and delete operations using a Java client
Implementing aggregation in Mongo using a Java client
Executing MapReduce in Mongo using a Java client
Chapter 4: Administration
Introduction
Renaming a collection
Viewing collection stats
Viewing database stats
Manually padding a document
The mongostat and mongotop utilities
Getting current executing operations and killing them
Using profiler to profile operations
Setting up users in Mongo
Interprocess security in Mongo
Modifying collection behavior using the collMod command
Setting up MongoDB as a windows service
Replica set configurations
Stepping down as primary from the replica set
Exploring the local database of a replica set
Understanding and analyzing oplogs
Building tagged replica sets
Configuring the default shard for non-sharded collections
Manual split and migration of chunks
Domain-driven sharding using tags
Exploring the config database in a sharded setup
Chapter 5: Advanced Operations
Introduction
Atomic find and modify operations
Implementing atomic counters in Mongo
Implementing server-side scripts
Creating and tailing a capped collection cursors in MongoDB
Converting a normal collection to a capped collection
Storing binary data in Mongo
Storing large data in Mongo using GridFS
Storing data to GridFS from Java client
Storing data to GridFS from Python client
Implementing triggers in Mongo using oplog
Flat plane 2D geospatial queries in Mongo using geospatial indexes
Spherical indexes and GeoJSON compliant data in Mongo
Implementing full text search in Mongo
Integrating MongoDB for full text search with Elasticsearch
Chapter 6: Monitoring and Backups
Introduction
Signing up for MMS and setting up an MMS monitoring agent
Managing users and groups in MMS console
Monitoring instances and setting up alerts on MMS
Setting up monitoring alerts in MMS
Back up and restore data in Mongo using out-of-the-box tools
Configuring MMS Backup service
Managing backups in MMS Backup service
Chapter 7: Deploying MongoDB on the Cloud
Introduction
Setting up and managing the MongoLab account
Setting up a sandbox MongoDB instance on MongoLab
Performing operations on MongoDB from MongoLab GUI
Setting up MongoDB on Amazon EC2 manually
Setting up MongoDB using the Docker containers
Chapter 8: Integration with Hadoop
Introduction
Executing our first sample MapReduce job using the mongo-hadoop connector
Writing our first Hadoop MapReduce job
Running MapReduce jobs on Hadoop using streaming
Running a MapReduce job on Amazon EMR
Chapter 9: Open Source and Proprietary Tools
Introduction
Developing using spring-data-mongodb
Accessing MongoDB using JPA
Accessing MongoDB over REST
Installing a GUI-based client, MongoVUE, for MongoDB

Book Details

ISBN 139781785289989
Paperback371 pages
Read More

Read More Reviews