logo资料库

Mastering MongoDB 4.x - Second Edition.pdf

第1页 / 共560页
第2页 / 共560页
第3页 / 共560页
第4页 / 共560页
第5页 / 共560页
第6页 / 共560页
第7页 / 共560页
第8页 / 共560页
资料共560页,剩余部分请下载后查看
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
Mastering MongoDB 4.x Second Edition Expert techniques to run high-volume and fault-tolerant database solutions using MongoDB 4.x Alex Giamas
BIRMINGHAM - MUMBAI
Mastering MongoDB 4.x Second Edition Copyright © 2019 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. Commissioning Editor: Amey Varangaonkar Acquisition Editor: Porous Godhaa Content Development Editor: Ronnel Mathew Technical Editor: Suwarna Patil Copy Editor: Safis Editing Project Coordinator: Namrata Swetta Proofreader: Safis Editing Indexer: Rekha Nair Graphics: Tom Scaria Production Coordinator: Deepika Naik First published: November 2017 Second edition: March 2019 Production reference: 1290319 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78961-787-0 www.packtpub.com
mapt.io Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.
Why subscribe? Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals Improve your learning with Skill Plans built especially for you Get a free eBook or video every month Mapt is fully searchable Copy and paste, print, and bookmark content
Packt.com Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.packt.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at customercare@packtpub.com for more details. At www.packt.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.
分享到:
收藏