MongoDB Cookbook - Second Edition
eBook - ePub

MongoDB Cookbook - Second Edition

  1. 370 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

MongoDB Cookbook - Second Edition

About this book

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

About This Book

  • Get to grips with the latest features of MongoDB 3
  • Interact with the MongoDB server and perform a wide range of query operations from the shell
  • From administration to automation, this cookbook keeps you up to date with the world's leading NoSQL database

Who This Book Is For

This book is engineered for anyone who is interested in managing data in an easy and efficient way using MongoDB. You do not need any prior knowledge of MongoDB, but it would be helpful if you have some programming experience in either Java or Python.

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

In Detail

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.

Style and approach

Every recipe is explained in a very simple set-by-step manner yet is extremely comprehensive.

Tools to learn more effectively

Saving Books

Saving Books

Keyword Search

Keyword Search

Annotating Text

Annotating Text

Listen to it instead

Listen to it instead

MongoDB Cookbook Second Edition


Table of Contents

MongoDB Cookbook Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Installing and Starting the Server
Introduction
Installing single node MongoDB
Getting ready
How to do it…
How it works…
See also
Starting a single node instance using command-line options
Getting ready
How to do it…
How it works…
There's more…
See also
Single node installation of MongoDB with options from the config file
Getting ready
How to do it…
How it works…
Connecting to a single node in the Mongo shell with JavaScript
Getting ready
How to do it…
How it works…
Connecting to a single node using a Java client
Getting ready
How to do it…
How it works…
Connecting to a single node using a Python client
Getting ready
How to do it…
How it works…
Starting multiple instances as part of a replica set
Getting ready
How to do it…
How it works…
There's more…
See also
Connecting to the replica set in the shell to query and insert data
Getting ready
How to do it…
How it works…
See also
Connecting to the replica set to query and insert data from a Java client
Getting ready
How to do it…
How it works…
Connecting to the replica set to query and insert data using a Python client
Getting ready
How to do it…
How it works…
Starting a simple sharded environment of two shards
Getting ready
How to do it…
How it works…
There's more…
Connecting to a shard in the shell and performing operations
Getting ready
How to do it…
How it works…
There's more…
2. Command-line Operations and Indexes
Introduction
Creating test data
Getting ready
How to do it…
How it works…
See also
Performing simple querying, projections, and pagination from Mongo shell
Getting ready
How to do it…
How it works…
Updating and deleting data from the shell
Getting ready
How to do it…
How it works…
Creating index and viewing plans of queries
Getting ready
How to do it…
How it works…
Analyzing the plan
Improving the query execution time
Improvement using indexes
Improvement using covered indexes
Some caveats of index creations
Creating a background and foreground index in the shell
Getting ready
How to do it…
How it works…
Creating and understanding sparse indexes
Getting ready
How to do it…
How it works…
Expiring documents after a fixed interval using the TTL index
Getting ready
How to do it…
How it works…
See also
Expiring documents at a given time using the TTL index
Getting ready
How to do it…
How it works…
See also
3. Programming Language Drivers
Introduction
Executing query and insert operations with PyMongo
Getting ready
How to do it…
How it works…
See also
Executing update and delete operations using PyMongo
Getting ready
How to do it…
How it works…
Implementing aggregation in Mongo using PyMongo
Getting ready
How to do it…
How it works…
Executing MapReduce in Mongo using PyMongo
Getting ready
How to do it…
How it works…
See also
Executing query and insert operations using a Java client
Getting ready
How to do it…
How it works…
See also…
Executing update and delete operations using a Java client
Getting ready
How to do it…
How it works…
See also
Implementing aggregation in Mongo using a Java client
Getting ready
How to do it…
How it works…
Executing MapReduce in Mongo using a Java client
Getting ready
How to do it…
How it works…
See also
4. Administration
Introduction
Renaming a collection
Getting ready
How to do it…
How it works…
Viewing collection stats
Getting ready
How to do it…
How it works…
See also
Viewing database stats
Getting ready
How to do it…
How it works…
How it works…
Manually padding a document
Getting ready
How to do it…
How it works…
The mongostat and mongotop utilities
Getting ready
How to do it…
How it works…
See also
Getting current executing operations and killing them
Getting ready
How to do it…
How it works…
Using profiler to profile operations
Getting ready
How to do it…
How it works…
Setting up users in Mongo
Getting ready
How to do it…
How it works…
There's more…
See also
Interprocess security in Mongo
Getting ready
How to do it…
There's more…
Modifying collection behavior using the collMod command
Getting ready
How it works…
How it works…
Setting up MongoDB as a windows service
Getting ready
How to do it…
Replica set configurations
Getting ready
Elections in a replica set
Basic configuration for a replica set
How to do it…
How it works…
Replica set member as an arbiter
Priority of replica set members
Hidden, slave delayed, and build index configuration
There's more…
Stepping down as primary from the replica set
Getting ready
How to do it…
How it works…
Exploring the local database of a replica set
Getting ready
How to do it…
How it works…
There's more…
Understanding and analyzing oplogs
Getting ready
How to do it…
How it works…
Building tagged replica sets
Getting ready
How to do it…
How it works…
WriteConcern in tagged replica sets
ReadPreference in tagged replica sets
Configuring the default shard for non-sharded collections
Getting ready
How to do it…
How it works…
Manual split and migration of chunks
Getting ready
How to do it…
How it works…
Domain-driven sharding using tags
Getting ready
How to do it…
How it works…
Exploring the config database in a sharded setup
Getting ready
How to do it…
How it works…
5. Advanced Operations
Introduction
Atomic find and modify operations
Getting ready
How to do it…
How it works…
See also
Implementing atomic counters in Mongo
Getting ready
How to do it…
How it works…
See also
Implementing server-side scripts
Getting ready
How to do it…
How it works…
Creating and tailing a capped col...

Table of contents

  1. MongoDB Cookbook Second Edition

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn how to download books offline
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 990+ topics, we’ve got you covered! Learn about our mission
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more about Read Aloud
Yes! You can use the Perlego app on both iOS and Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app
Yes, you can access MongoDB Cookbook - Second Edition by Cyrus Dasadia, Amol Nayak in PDF and/or ePUB format, as well as other popular books in Computer Science & Open Source Programming. We have over one million books available in our catalogue for you to explore.