Title Page Copyright and Credits Mastering MongoDB 4.x Second Edition About Packt Why subscribe? Packt.com Contributors About the author About the reviewers Packt is searching for authors like you Preface Who this book is for What this book covers To get the most out of this book Download the example code files Conventions used Get in touch Reviews Section 1: Basic MongoDB – Design Goals and Architecture MongoDB – A Database for Modern Web Technical requirements The evolution of SQL and NoSQL The evolution of MongoDB Major feature set for versions 1.0 and 1.2 Version 2 Version 3 Version 4 MongoDB for SQL developers MongoDB for NoSQL developers MongoDB's key characteristics and use cases Key characteristics Use cases for MongoDB MongoDB criticism MongoDB configuration and best practices Operational best practices Schema design best practices Best practices for write durability Best practices for replication Best practices for sharding Best practices for security Best practices for AWS Reference documentation MongoDB documentation Packt references Further reading  Summary Schema Design and Data Modeling Relational schema design MongoDB schema design Read-write ratio Data modeling Data types Comparing different data types Date type ObjectId Modeling data for atomic operations Write isolation Read isolation and consistency Modeling relationships One-to-one One-to-many and many-to-many Modeling data for keyword searches Connecting to MongoDB Connecting using Ruby Mongoid ODM Inheritance with Mongoid models Connecting using Python PyMODM ODM Inheritance with PyMODM models Connecting using PHP Doctrine ODM Inheritance with Doctrine Summary Section 2: Querying Effectively MongoDB CRUD Operations CRUD using the shell Scripting for the mongo shell The differences between scripting for the mongo shell and using it directly Batch inserts using the shell Batch operations using the mongo shell Administration fsync compact currentOp and killOp collMod touch MapReduce in the mongo shell MapReduce concurrency Incremental MapReduce Troubleshooting MapReduce Aggregation framework SQL to aggregation Aggregation versus MapReduce Securing the shell Authentication and authorization Authorization with MongoDB Security tips for MongoDB Encrypting communication using TLS/SSL Encrypting data Limiting network exposure Firewalls and VPNs Auditing Using secure configuration options Authentication with MongoDB Enterprise Edition Kerberos authentication LDAP authentication Summary Advanced Querying MongoDB CRUD operations CRUD using the Ruby driver Creating documents Read Chaining operations in find() Nested operations Update Delete Batch operations CRUD in Mongoid Read Scoping queries Create, update, and delete CRUD using the Python driver Creating and deleting Finding documents Updating documents CRUD using PyMODM Creating documents Updating documents Deleting documents Querying documents CRUD using the PHP driver Creating and deleting BulkWrite Read Updating documents CRUD using Doctrine Creating, updating, and deleting Read Best practices Comparison operators Update operators Smart querying Using regular expressions Querying results and cursors Storage considerations for the delete operation Change streams Introduction Setup  Using change streams Specification Important notes Production recommendations Replica sets Sharded clusters Summary Multi-Document ACID Transactions Background ACID Atomicity Consistency Isolation Phantom reads Non-repeatable reads Dirty reads Durability When do we need ACID in MongoDB ? Building a digital bank using MongoDB Setting up our data Transferring between accounts – part 1 Transferring between accounts – part 2 Transferring between accounts – part 3 E-commerce using MongoDB The best practices and limitations of multi-document ACID transactions Summary Aggregation Why aggregation? Aggregation operators Aggregation stage operators Expression operators Expression Boolean operators Expression comparison operators Set expression and array operators Expression date operators Expression string operators Expression arithmetic operators Aggregation accumulators Conditional expressions Type conversion operators Other operators Text search Variable Literal Parsing data type Limitations Aggregation use case Summary Indexing Index internals Index types Single field indexes Dropping indexes Indexing embedded fields Indexing embedded documents Background indexes Compound indexes Sorting with compound indexes Reusing compound indexes Multikey indexes Special types of indexes Text indexes Hashed indexes Time to live indexes Partial indexes Sparse indexes Unique indexes Case-insensitive Geospatial indexes 2d geospatial indexes 2dsphere geospatial indexes geoHaystack indexes Building and managing indexes Forcing index usage Hint and sparse indexes Building indexes on replica sets Managing indexes Naming indexes Special considerations Using indexes efficiently Measuring performance Improving performance Index intersection Further reading Summary Section 3: Administration and Data Management Monitoring, Backup, and Security Monitoring What should we monitor? Page faults Resident memory Virtual and mapped memory Working sets Monitoring memory usage in WiredTiger Tracking page faults Tracking B-tree misses I/O wait Read and write queues Lock percentage Background flushes Tracking free space Monitoring replication Oplog size Working set calculations Monitoring tools Hosted tools Open source tools Backups Backup options Cloud-based solutions Backups with filesystem snapshots Making a backup of a sharded cluster Making backups using mongodump Backing up by copying raw files Making backups using queuing EC2 backup and restore Incremental backups Security Authentication Authorization User roles Database administration roles Cluster administration roles Backup and restore roles Roles across all databases Superuser Network-level security Auditing security Special cases Overview Summary Storage Engines Pluggable storage engines WiredTiger Document-level locking Snapshots and checkpoints Journaling Data compression Memory usage readConcern WiredTiger collection-level options WiredTiger performance strategies WiredTiger B-tree versus LSM indexes Encrypted In-memory MMAPv1 MMAPv1 storage optimization Mixed usage Other storage engines RocksDB TokuMX Locking in MongoDB Lock reporting Lock yield Commonly used commands and locks Commands requiring a database lock Further reading Summary MongoDB Tooling Introduction MongoDB Atlas Creating a new cluster Important notes MongoDB Cloud Manager MongoDB Ops Manager MongoDB Charts MongoDB Compass MongoDB Connector for Business Intelligence (BI) An introduction to Kubernetes Enterprise Kubernetes Operator MongoDB Mobile MongoDB Stitch QueryAnywhere Rules Functions Triggers Mobile Sync Summary Harnessing Big Data with MongoDB What is big data? The big data landscape Message queuing systems Apache ActiveMQ RabbitMQ Apache Kafka Data warehousing Apache Hadoop Apache Spark Comparing  Spark with Hadoop MapReduce MongoDB as a data warehouse A big data use case Setting up Kafka  Setting up Hadoop Steps for Hadoop setup Using a Hadoop to MongoDB pipeline Setting up Spark to MongoDB Further reading Summary Section 4: Scaling and High Availability Replication Replication Logical or physical replication Different high availability types An architectural overview How do elections work? What is the use case for a replica set? Setting up a replica set Converting a standalone server into a replica set Creating a replica set Read preference Write concern Custom write concerns Priority settings for replica set members Zero priority replica set members Hidden replica set members Delayed replica set members Production considerations Connecting to a replica set Replica set administration How to perform maintenance on replica sets Re-syncing a member of a replica set Changing the oplog's size Reconfiguring a replica set when we have lost the majority of our servers Chained replication Cloud options for a replica set mLab MongoDB Atlas Replica set limitations Summary Sharding Why do we use sharding? Architectural overview Development, continuous deployment, and staging environments Planning ahead with sharding Sharding setup Choosing the shard key Changing the shard key Choosing the correct shard key Range-based sharding Hash-based sharding Coming up with our own key Location-based data Sharding administration and monitoring Balancing data – how to track and keep our data balanced Chunk administration Moving chunks Changing the default chunk size Jumbo chunks Merging chunks Adding and removing shards Sharding limitations Querying sharded data The query router Find Sort/limit/skip Update/remove Querying using Ruby Performance comparison with replica sets Sharding recovery mongos mongod Config server A shard goes down The entire cluster goes down Further reading Summary Fault Tolerance and High Availability Application design Schema-less doesn't mean schema design-less Read performance optimization Consolidating read querying Defensive coding Monitoring integrations Operations Security Enabling security by default Isolating our servers Checklists Further reading Summary Other Books You May Enjoy Leave a review - let other readers know what you think