MongoDB: The Definitive Guide: Powerful and Scalable Data Storage
Book information
Description
Manage your data with a system designed to support modern application development. Updated for MongoDB 4.2, the third edition of this authoritative and accessible guide shows you the advantages of using document-oriented databases. You’ll learn how this secure, high-performance system enables flexible data models, high availability, and horizontal scalability. Authors Shannon Bradshaw, Eoin Brazil, and Kristina Chodorow provide guidance for database developers, advanced configuration for system administrators, and use cases for a variety of projects. NoSQL newcomers and experienced MongoDB users will find updates on querying, indexing, aggregation, transactions, replica sets, ops management, sharding and data administration, durability, monitoring, and security. In six parts, this book shows you how to: Work with MongoDB, perform write operations, find documents, and create complex queriesIndex collections, aggregate data, and use transactions for your applicationConfigure a local replica set and learn how replication interacts with your applicationSet up cluster components and choose a shard key for a variety of applicationsExplore aspects of application administration and configure authentication and authorizationUse stats when monitoring, back up and restore deployments, and use system settings when deploying MongoDB Copyright Table of Contents 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 Part I. Introduction to MongoDB Chapter 1. Introduction Ease of Use Designed to Scale Rich with Features… …Without Sacrificing Speed The Philosophy Chapter 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 Chapter 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 Chapter 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 Part II. Designing Your Application Chapter 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 Chapter 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 Chapter 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 Chapter 8. Transactions Introduction to Transactions A Definition of ACID How to Use Transactions Tuning Transaction Limits for Your Application Timing and Oplog Size Limits Chapter 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 Part III. Replication Chapter 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 Chapter 11. Components of a Replica Set Syncing Initial Sync Replication Handling Staleness Heartbeats Member States Elections Rollbacks When Rollbacks Fail Chapter 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 Chapter 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 Part IV. Sharding Chapter 14. Introduction to Sharding What Is Sharding? Understanding the Components of a Cluster Sharding on a Single-Machine Cluster Chapter 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 Chapter 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 Chapter 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 Part V. Application Administration Chapter 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 Chapter 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 Chapter 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 Part VI. Server Administration Chapter 21. Setting Up MongoDB in Production Starting from the Command Line File-Based Configuration Stopping MongoDB Security Data Encryption SSL Connections Logging Chapter 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 Chapter 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 Chapter 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 Appendix A. Installing MongoDB Choosing a Version Windows Install Installing as a Service POSIX (Linux and Mac OS X) Install Installing from a Package Manager Appendix B. MongoDB Internals BSON Wire Protocol Data Files Namespaces WiredTiger Storage Engine Index About the Authors Colophon
Similar books
MongoDB: Powerful and Scalable Data Storage
2019 · EPUB
MongoDB: The Definitive Edition. Powerful and Scalable Data Storage.
2019 · EPUB
MongoDB: The Definitive Guide: Powerful and Scalable Data Storage 3rd Edition
MongoDB: The Definitive Guide
2015 · PDF
Scaling MongoDB: Sharding, Cluster Setup, and Administration
2011 · PDF
MongoDB: The Definitive Guide: Powerful and Scalable Data Storage
2010 · PDF
MongoDB: The Definitive Guide, 2nd Edition: Powerful and Scalable Data Storage
2013 · PDF
MongoDB The Definitive Guide
2013 · PDF