Zum Hauptinhalt springen
Nicht aus der Schweiz? Besuchen Sie lehmanns.de

The Definitive Guide to MongoDB (eBook)

The NoSQL Database for Cloud and Desktop Computing
eBook Download: PDF
2011 | 1st ed.
XX, 328 Seiten
Apress (Verlag)
978-1-4302-3052-6 (ISBN)

Lese- und Medienproben

The Definitive Guide to MongoDB - Peter Membrey, Eelco Plugge, DUPTim Hawkins
Systemvoraussetzungen
62,99 inkl. MwSt
(CHF 61,50)
Der eBook-Verkauf erfolgt durch die Lehmanns Media GmbH (Berlin) zum Preis in Euro inkl. MwSt.
  • Download sofort lieferbar
  • Zahlungsarten anzeigen

MongoDB, a cross-platform NoSQL database, is the fastest-growing new database in the world. MongoDB provides a rich document-oriented structure with dynamic queries that you'll recognize from RDBMS offerings such as MySQL. In other words, this is a book about a NoSQL database that does not require the SQL crowd to re-learn how the database world works!

MongoDB has reached 1.0 and boasts 50,000+ users. The community is strong and vibrant and MongoDB is improving at a fast rate. With scalable and fast databases becoming critical for today's applications, this book shows you how to install, administer and program MongoDB without pretending SQL never existed.



Hailing from the U.K., Peter Membrey has worked for Red Hat, holds a RHCE certification, and worked and taught at a number of educational institutions since the beginning of his career. He knows what Linux users like and need, and hopes that CentOS will get the kudos it deserves. He lives in Hong Kong and is teaching and consulting on all matters to do with Linux Enterprise networking, while studying for his master's degree.
MongoDB, a cross-platform NoSQL database, is the fastest-growing new database in the world. MongoDB provides a rich document-oriented structure with dynamic queries that you'll recognize from RDBMS offerings such as MySQL. In other words, this is a book about a NoSQL database that does not require the SQL crowd to re-learn how the database world works! MongoDB has reached 1.0 and boasts 50,000+ users. The community is strong and vibrant and MongoDB is improving at a fast rate. With scalable and fast databases becoming critical for today s applications, this book shows you how to install, administer and program MongoDB without pretending SQL never existed.

Hailing from the U.K., Peter Membrey has worked for Red Hat, holds a RHCE certification, and worked and taught at a number of educational institutions since the beginning of his career. He knows what Linux users like and need, and hopes that CentOS will get the kudos it deserves. He lives in Hong Kong and is teaching and consulting on all matters to do with Linux Enterprise networking, while studying for his master's degree.

Title Page 1
Copyright Page 2
Contents at a Glance 4
Table of Contents 5
About the Authors 16
About the Technical Reviewer 17
Acknowledgments 18
Introduction 20
PART I Basics 21
Chapter 1 Introduction to MongoDB 22
Reviewing the MongoDB Philosophy 22
Using the Right Tool for the Right Job 22
Lacking Innate Support for Transactions 24
Drilling Down on JSON and How It Relates to MongoDB 24
Adopting a Non-Relational Approach 26
Opting for Performance vs. Features 27
Running the Database Anywhere 28
Fitting Everything Together 28
Generating or Creating a Key 28
Using Keys and Values 29
Implementing Collections 30
Understanding Databases 30
Reviewing the Feature List 30
Using Document-Orientated Storage (BSON) 30
Supporting Dynamic Queries 31
Indexing Your Documents 32
Leveraging Geospatial Indexes 32
Profiling Queries 33
Updating Information In-Place 33
Storing Binary Data 33
Replicating Data 34
Implementing Auto Sharding 34
Using Map and Reduce Functions 35
Getting Help 35
Visiting the Website 35
Chatting with the MongoDB Developers 35
Cutting and Pasting MongoDB Code 36
Finding Solutions on Google Groups 36
Leveraging the JIRA Tracking System 36
Summary 36
Chapter 2 Installing MongoDB 37
Choosing Your Version 37
Understanding the Version Numbers 38
Installing MongoDB on Your System 38
Installing MongoDB Under Linux 38
Installing MongoDB Through the Repositories 39
Installing MongoDB Manually 39
Installing MongoDB Under Windows 40
Running MongoDB 40
Prerequisites 40
Surveying the Installation Layout 41
Using the MongoDB Shell 41
Installing Additional Drivers 42
Installing the PHP driver 43
Getting MongoDB for PHP 43
Installing PHP on Unix-based Platforms Automatically 44
Installing PHP on Unix-Based Platforms Manually 45
Installing PHP on Windows 46
Confirming Your PHP Installation Works 46
Connecting to and Disconnecting from the PHP Driver 47
Installing the Python Driver 48
Installing PyMongo under Linux 48
Installing PyMongo Automatically 48
Installing PyMongo Manually 49
Installing PyMongo Under Windows 49
Confirming Your PyMongo Installation Works 51
Summary 51
Chapter 3 The Data Model 52
Designing the Database 52
Drilling Down on Collections 53
Using Documents 55
Embedding vs. Referencing Information in Documents 56
Creating the _id Field 57
Building Indexes 58
Impacting Performance with Indexes 59
Implementing Geospatial Indexing 59
Querying Geospatial Information 60
Using MongoDB in the Real World 63
Summary 63
Chapter 4 Working with Data 64
Navigating Your Databases 64
Viewing Available Databases and Collections 64
Inserting Data into Collections 65
Querying for Data 66
Using the Dot Notation 68
Using the Sort, Limit, and Skip Functions 69
Working with Capped Collections, Natural Order, and $natural 70
Retrieving a Single Document 72
Using the Aggregation Commands 72
Returning the Number of Documents with Count() 72
Retrieving Unique Values with Distinct() 72
Grouping Your Results 73
Working with Conditional Operators 74
Performing Greater and Less Than Comparisons 75
Retrieving All Documents but Those Specified 76
Specifying an Array of Matches 76
Finding a Value Not in an Array 76
Matching all Attributes in a Document 76
Searching for Multiple Expressions in a Document 77
Retrieving a Document with $slice 77
Searching for Odd/Even Integers 78
Filtering Results with $size 78
Returning a Specific Field Object 79
Matching Results Based on the BSON Type 79
Matching an Entire Array 80
$not (meta-operator) 81
Specifying Additional Query Expressions 82
Leveraging Regular Expressions 82
Updating Data 82
Updating with update() 82
Implementing an Upsert with the save() Command 83
Updating Information Automatically 83
Incrementing a Value with $inc 83
Setting a Field’s Value 84
Deleting a Given Field 84
Appending a Value to a Specified Field 85
Specifying Multiple Values in an Array 85
Adding Data to an Array with $addToSet 85
Removing Elements from an Array 86
Removing Each Occurrence of a Specified Value 87
Removing Multiple Elements from an Array 87
Specifying the Position of a Matched Array 87
Atomic Operations 88
Using the Update if Current Method 89
Modifying and Returning a Document Atomically 90
Renaming a Collection 91
Removing Data 91
Referencing a Database 92
Referencing Data Manually 92
Referencing Data with DBRef 93
Implementing Index-Related Functions 95
Surveying Index-Related Commands 97
Forcing a Specified Index to Query Data 97
Constraining Query Matches 97
Summary 98
Chapter 5: GridFS 99
Filling in Some Background 99
Working with GridFS 100
Getting Started with the Command-Line Tools 101
Using the _id Key 102
Working with Filenames 102
Determining a File’s Length 102
Working with Chunk Sizes 103
Tracking the Upload Date 103
Hashing Your Files 103
Looking Under MongoDB’s Hood 104
Using the Search Command 106
Deleting 106
Retrieving Files from MongoDB 107
Summing up mongofiles 107
Exploiting the Power of Python 107
Connecting to the Database 108
Accessing the Words 109
Putting Files into MongoDB 109
Retrieving Files from GridFS 110
Deleting Files 110
Summary 111
PART II Developing 112
Chapter 6 PHP and MongoDB 113
Comparing Documents in MongoDB and PHP 113
MongoDB Classes 114
Connecting and Disconnecting 115
Inserting Data 116
Listing Your Data 118
Returning a Single Document 118
Listing All Documents 119
Using Query Operators 120
Querying for Specific Information 120
Sorting, Limiting, and Skipping Items 121
Counting the Number of Matching Results 122
Grouping Data with Map/Reduce 123
Specifying the Index with Hint 125
Refining Queries with Conditional Operators 125
Using the $lt, $gt, $lte, and $gte Operators 126
Finding Documents that Don’t Match a Value 128
Matching Any of Multiple Values with $in 128
Matching All Criteria in a Query with $all 129
Searching for Multiple Expressions with $or 129
Retrieving a Specified Number of Items with $slice 130
Determining Whether a Field Has a Value 131
Regular Expressions 132
Modifying Data with PHP 133
Updating via update() 133
Saving Time with Modifier Operators 135
Increasing the Value of a Specific Key with $inc 135
Changing the Value of a Key with $set 136
Deleting a Field with $unset 136
Appending a Value to a Specified Field with $push 137
Adding Multiple Values to a Key with $pushAll 137
Adding Data to an Array with $addToSet 137
Removing an Element from an Array with $pop 138
Removing Each Occurrence of a Value with $pull 139
Removing Each Occurrence of Multiple Elements 139
Upserting Data with save() 139
Modifying a Document Atomically 140
Deleting Data 143
DBRef 144
Retrieving the Information 146
GridFS and the PHP Driver 146
Storing Files 147
Adding More Metadata to Stored Files 147
Retrieving Files 148
Deleting Data 149
Summary 149
Chapter 7 Python and MongoDB 150
Working with Documents in Python 150
Using PyMongo Modules 151
Connecting and Disconnecting 151
Inserting Data 152
Finding Your Data 153
Finding a Single Document 153
Finding Multiple Documents 154
Using Dot Notation 155
Returning Fields 155
Simplifying Queries with Sort, Limit, and Skip 156
Aggregating Queries 158
Counting Items with Count() 158
Counting Unique Items with Distinct() 158
Grouping Data with map_reduce() 159
Specifying an Index with Hint() 160
Refining Queries with Conditional Operators 161
Using the $lt, $gt, $lte, and $gte Operators 161
Searching for Non-Matching Values with $ne 163
Specifying an Array of Matches with $in 163
Specifying Against an Array of Matches with $nin 164
Finding Documents that Match an Array’s Values 164
Specifying Multiple Expressions to Match with $or 164
Retrieving Items from an Array with $slice 165
Conducting Searches with Regular Expression 166
Modifying the Data 167
Updating Your Data 167
Modifier Operators 169
Increasing an Integer Value with $inc 169
Changing an Existing Value with $set 169
Removing a Key/Value Field with $unset 170
Adding a Value to an Array with $push 170
Adding Multiple Values to an Array with $pushAll 171
Adding a Value to an Existing Array with $addToSet 171
Removing an Element from an Array with $pop 172
Removing a Specific Value with $pull 172
Saving Documents Quickly with Save() 173
Modifying a Document Atomically 174
Putting the Parameters to Work 174
Deleting Data 175
Creating a Link Between Two Documents 176
Retrieving the Information 178
Summary 179
Chapter 8 Creating a Blog Application with the PHP Driver 180
Designing the Application 181
Listing the Posts 182
Paging with PHP and MongoDB 184
Looking at a Single Post 185
Specifying Additional Variables 186
Viewing and Adding Comments 187
Searching the Posts 188
Adding, Deleting, and Modifying Posts 189
Adding a New Post 190
Editing a Post 191
Deleting a Post 192
Creating the Index Pages 193
Recapping the blog Application 194
Summary 203
PART III Advanced 204
Chapter 9 Database Administration 205
Using Administrative Tools 206
mongo, the MongoDB Console 206
Using Third-Party Administration Tools 206
Backing up the MongoDB Server 206
Creating a Backup 101 206
Backing up a Single Database 209
Backing up a Single Collection 209
Digging Deeper into Backups 209
Restoring Individual Databases or Collections 210
Restoring a Single Database 211
Restoring a Single Collection 211
Automating Backups 211
Using a Local Datastore 211
Using a Remote (Cloud-Based) Datastore 214
Backing up Large Databases 215
Using a Slave Server for Backups 215
Creating Snapshots with a Journaling Filesystem 215
Disk Layout to Use with Volume Managers 217
Importing Data into MongoDB 218
Exporting Data from MongoDB 219
Securing Your Data 220
Restricting Access to a MongoDB Server 220
Protecting Your Server with Authentication 220
Adding an Admin User 221
Enabling Authentication 221
Authenticating in the mongo Console 221
Changing a User’s Credentials 222
Adding a Read-Only User 223
Deleting a User 223
Using Authenticated Connections in a PHP Application 224
Managing Servers 224
Starting a Server 224
Reconfiguring a Server 225
Getting the Server’s Version 226
Getting the Server’s Status 226
Shutting Down a Server 228
Using MongoDB Logfiles 229
Validating and Repairing Your Data 229
Repairing a Server 229
Validating a Single Collection 230
Repairing Collection Validation Faults 231
Repairing a Collection’s Indexes 232
Repairing a Collection’s Datafiles 232
Upgrading MongoDB 233
Monitoring MongoDB 233
Rolling Your Own Stat Monitoring Tool 234
Using the mongod Web Interface 235
Summary 235
Chapter 10 Optimization 237
Optimizing Your Server Hardware for Performance 237
Understanding How MongoDB Uses Memory 237
Choosing the Right Database Server Hardware 238
Evaluating Query Performance 238
MongoDB Profiler 238
Enabling and Disabling the DB Profiler 239
Finding Slow Queries 239
Analyzing a Specific Query with explain() 240
Using Profile and explain() to Optimize a Query 241
Managing Indexes 244
Listing Indexes 245
Creating a Simple Index 245
Creating a Compound Index 246
Creating Subdocument Compound Indexes 246
Constructing a Compound Index Manually 246
Specifying Index Options 247
Creating an Index in the Background with {background:true} 247
Killing the Indexing Process 247
Creating an Index with a Unique Key {unique:true} 248
Dropping Duplicates Automatically with {dropdups:true} 248
Dropping an Index 248
Re-Indexing a Collection 249
How MongoDB Selects Which Indexes It Will Use 249
Using Hint() to Force Using a Specific Index 250
Optimizing the Storage of Small Objects 250
Summary 251
Chapter 11 Replication 252
Spelling Out MongoDB’s Replication Goals 253
Improving Scalability 253
Improving Durability/Reliability 253
Providing Isolation 254
Drilling Down on the Oplog 254
Implementing Single Master/Single Slave Replication 255
Setting Up a Master/Slave Replication Configuration 256
Examining the Slave 257
Implementing Single Master/Multiple Slave Replication 259
Configuring a Master/Slave Replication System 259
Resynchronizing a Master/Slave Replication System 260
Issuing a Manual Resync Command to the Slave 261
Resyncing by Deleting the Slaves Datafiles 261
Resyncing a Slave with the --fastsync Option 261
Implementing Multiple Master/Single Slave Replication 262
Setting up a Multiple Master/Slave Replication Configuration 262
Exploring Various Replication Scenarios 265
Implementing Cascade Replication 265
Implementing Master/Master Replication 265
Implementing Interleaved Replication 266
Using Replica Pairs 267
Resolving Server Disputes with an Arbiter 272
Implementing Advanced Clustering with Replica Sets 273
Creating a Replica Set 275
Getting a Replica Set Member Up and Running 276
Adding a Server to a Replica Set 277
Managing Replica Sets 278
Inspecting an Instance’s Status with rs.status() 279
Forcing a New Election with rs.stepDown() 280
Determining If a Member is the Primary Server 281
Configuring the Options for Replica Set Members 282
Organization of the Members Structure 282
Exploring the Options Available in the Settings Structure 283
Determining the Status of Replica Sets 284
Connecting to a Replica Set from Your Application 284
Viewing Replica Set Status with the Web Interface 285
Summary 286
Chapter 12 Sharding 287
Exploring the Need for Sharding 287
Partitioning Horizontal and Vertical Data 288
Partitioning Data Vertically 288
Partitioning Data Horizontally 288
Analyzing a Simple Sharding Scenario 289
Implementing Sharding with MongoDB 290
Setting Up a Sharding Configuration 292
Adding a New Shard to the Cluster 295
Removing a Shard from the Cluster 297
Determining How You’re Connected 298
Listing the Status of a Sharded Cluster 298
Using Replica Sets to Implement Shards 300
Sharding to Improve Performance 300
Summary 301
Index 302

Erscheint lt. Verlag 27.1.2011
Zusatzinfo XX, 328 p.
Verlagsort Berkeley
Sprache englisch
Themenwelt Mathematik / Informatik Informatik Datenbanken
Mathematik / Informatik Informatik Programmiersprachen / -werkzeuge
Schlagworte Database • database administration • DBMS
ISBN-10 1-4302-3052-5 / 1430230525
ISBN-13 978-1-4302-3052-6 / 9781430230526
Informationen gemäß Produktsicherheitsverordnung (GPSR)
Haben Sie eine Frage zum Produkt?
PDFPDF (Wasserzeichen)

DRM: Digitales Wasserzeichen
Dieses eBook enthält ein digitales Wasser­zeichen und ist damit für Sie persona­lisiert. Bei einer missbräuch­lichen Weiter­gabe des eBooks an Dritte ist eine Rück­ver­folgung an die Quelle möglich.

Dateiformat: PDF (Portable Document Format)
Mit einem festen Seiten­layout eignet sich die PDF besonders für Fach­bücher mit Spalten, Tabellen und Abbild­ungen. Eine PDF kann auf fast allen Geräten ange­zeigt werden, ist aber für kleine Displays (Smart­phone, eReader) nur einge­schränkt geeignet.

Systemvoraussetzungen:
PC/Mac: Mit einem PC oder Mac können Sie dieses eBook lesen. Sie benötigen dafür einen PDF-Viewer - z.B. den Adobe Reader oder Adobe Digital Editions.
eReader: Dieses eBook kann mit (fast) allen eBook-Readern gelesen werden. Mit dem amazon-Kindle ist es aber nicht kompatibel.
Smartphone/Tablet: Egal ob Apple oder Android, dieses eBook können Sie lesen. Sie benötigen dafür einen PDF-Viewer - z.B. die kostenlose Adobe Digital Editions-App.

Buying eBooks from abroad
For tax law reasons we can sell eBooks just within Germany and Switzerland. Regrettably we cannot fulfill eBook-orders from other countries.

Mehr entdecken
aus dem Bereich
Der Leitfaden für die Praxis

von Christiana Klingenberg; Kristin Weber

eBook Download (2025)
Carl Hanser Fachbuchverlag
CHF 48,80