Database Reference
In-Depth Information
1.3.4
Command-line tools
MongoDB is bundled with several command-line utilities:
mongodump and mongorestore —Standard utilities for backing up and restoring
a database. mongodump saves the database's data in its native BSON format and
thus is best used for backups only; this tool has the advantage of being usable
for hot backups which can easily be restored with mongorestore .
mongoexport and mongoimport —These utilities export and import JSON , CSV ,
and TSV data; this is useful if you need your data in widely supported formats.
mongoimport can also be good for initial imports of large data sets, although
you should note in passing that before importing, it's often desirable to adjust
the data model to take best advantage of MongoDB. In those cases, it's easier to
import the data through one of the drivers using a custom script.
mongosniff —A wire-sniffing tool for viewing operations sent to the database.
Essentially translates the BSON going over the wire to human-readable shell
statements.
mongostat —Similar to iostat ; constantly polls MongoDB and the system to
provide helpful stats, including the number of operations per second (inserts,
queries, updates, deletes, and so on.), the amount of virtual memory allocated,
and the number of connections to the server.
The remaining utilities, bsondump and monfiles , are discussed later in the topic.
1.4
Why MongoDB?
I've already provided a few reasons why MongoDB might be a good choice for your
projects. Here, I'll make this more explicit, first by considering the overall design
objectives of the MongoDB project. According to its creators, MongoDB has been
designed to combine the best features of key-value stores and relational databases.
Key-value stores, because of their simplicity, are extremely fast and relatively easy to
scale. Relational databases are more difficult to scale, at least horizontally, but admit a
rich data model and a powerful query language. If MongoDB represents a mean
between these two designs, then the reality is a database that scales easily, stores rich
data structures, and provides sophisticated query mechanisms.
In terms of use cases, MongoDB is well suited as a primary data store for web appli-
cations, for analytics and logging applications, and for any application requiring a
medium-grade cache. In addition, because it easily stores schemaless data, MongoDB
is also good for capturing data whose structure can't be known in advance.
The preceding claims are bold. In order to substantiate them, we're going to take
a broad look at the varieties of databases currently in use and contrast them with
MongoDB. Next, I'll discuss some specific MongoDB use cases and provide examples
of them in production. Finally, I'll discuss some important practical considerations for
using MongoDB.
Search WWH ::




Custom Search