Database Reference
In-Depth Information
Chapter 9
Database Administration
In this chapter, we will walk you through some of the basic administrative operations you can perform on a MongoDB
server. We will also show how to automate some of those activities, such as backing up your server.
Because MongoDB is a nonrelational database system, many of the more traditional functions that a DB
administrator would perform are not required. For example, it's not necessary to create new databases, collections, or
fields on the server, because MongoDB will create these elements on the fly as you access them. Therefore, in the vast
majority of cases you don't need to manage databases and schemas.
This freedom from having to predefine everything, however, can result in the unintended creation of elements,
such as extraneous collections and fields in documents. Administrators and developers will occasionally need to clear
out unused data elements from databases, particularly during the development phase of a project, when change is
often rapid. They may have to try many approaches before finally settling on a solution and cleaning up the databases.
MongoDB's ease of use encourages this explorative mode of development; however, it can also result in clutter in your
datastores because the amount of effort required to create data structures has fallen almost to nothing.
A contributing factor to this clutter, and one of the more significant differences between MongoDB and SQL
databases, is that all object and element names in MongoDB are case-sensitive on all platforms. Thus, the foo and Foo
collection names refer to two completely different collections. Therefore, you need to be careful with your database
and collection naming to avoid accidentally creating multiple databases that differ only in the case of the name.
(There is, however, one exception to this, as of MongoDB 2.4: you can no longer create databases whose names differ
only in case, as doing so will generate an error.)
The different versions of these databases will fill up your disk, and they can create a lot of confusion for
developers and end users of the system by allowing them to connect to incomplete or unintended sets of data.
In this chapter, you will learn how to perform all the following tasks:
Back up and restore your MongoDB system.
MongoDB shell (invoked with the mongo command) to perform common tasks.
Use the supplied
Control access to your server with authentication.
Monitor your database instances.
Before diving into those tasks, however, we'll begin by looking at the tools used to carry out many of them.
Using Administrative Tools
An administrator needs tools suitable for performing the day-to-day tasks of keeping the server running smoothly.
There are some very good tools available in the MongoDB package, as well as an evolving collection of useful
third-party tools. The following sections cover some of the most important tools available, as well as how to use them.
 
Search WWH ::




Custom Search