Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
MongoDB High Availability

You're reading from   MongoDB High Availability Design and implement a highly available server using the latest features of MongoDB.

Arrow left icon
Product type Paperback
Published in Jul 2014
Publisher
ISBN-13 9781783986729
Length 164 pages
Edition 1st Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
Afshin Mehrabani Afshin Mehrabani
Author Profile Icon Afshin Mehrabani
Afshin Mehrabani
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Understanding the MongoDB Architecture and Processes FREE CHAPTER 2. Understanding MongoDB's Failures and Limitations 3. Clustering in MongoDB 4. Utilizing a Replica Set 5. Replica Set in Action 6. Understanding the Concept of Sharding 7. Sharding in Action 8. Analyzing and Improving Database Performance 9. Migrating Instances and Reducing Downtime 10. Monitoring and Troubleshooting the Database Index

Import and export tools

The tools in this group are used to export or restore files from the database. Mainly, components in this category are classified into two different groups. This includes components that work with binary data or interact with common data formats such as JSON, CSV, and so on.

Using import and export tools

In order to import or export binary data from and into the database, developers can use tools in this group. We use tools and utilities in this category to create or restore backups for our MongoDB server. In further chapters, we will discuss the backup strategies in detail.

The following are the tools that are available to perform these kinds of tasks:

  • mongodump
  • mongorestore
  • bsondump
  • mongooplog

Understanding mongodump

This process comes in handy when developers or system administrators want to create a dump file from a database in the binary format. This utility and other related tools are useful for MongoDB backup strategies.

The mongodump process is able to retrieve data from either mongod or mongos processes.

Note

For more information on mongodump, visit the MongoDB documentation page at http://docs.mongodb.org/manual/reference/program/mongodump/.

Utilizing mongorestore

This process is used to restore and write the binary files that are generated by the mongodump process into the database server. To restore data, mongorestore can establish a new database or use an existing database. Just like the mongodump instance, mongorestore can connect to a mongos instance or it can connect directly to the mongod process.

Note

To read more about mongostore, you can visit the MongoDB documentation page at http://docs.mongodb.org/manual/reference/program/mongorestore/.

Learning about bsondump

The bsondump process is used to convert the BSON format data to common data formats such as JSON. Essentially, bsondump comes in handy when developers want to convert dump files that are generated by mongodump to human-readable formats.

A very simple usage of this command is shown in the following command line:

bsondump data.bson>data.json

Understanding mongooplog

The mongooplog is a utility that duplicates oplog from one server to another server, for instance, in order to perform a migration task. In order to perform the migration operation, mongooplog accepts two parameters, the from and to server addresses.

Note

What is oplog?

The oplog or operation log is a capped collection (a fixed-sized collection) of data that keeps the record of all data altering operations. In further chapters, we will explain this feature in detail.

The following is a simple usage of this command:

mongooplog --from server1 --host server2

The preceding command line will connect to the MongoDB instance of server1 and copy the entire oplog to server2 instance.

Using data tools

In this group, we have two utilities that help us generate or import data in human-readable formats such as JSON or CSV into or from the MongoDB instance. These are mentioned in the following lists:

  • mongoimport
  • mongoexport

Understanding mongoexport

In order to export data in JSON or CSV formats from the MongoDB instance, developers can use this utility.

The following is a simple usage of this command:

mongoexport --db mydb --collection posts --out export.json

The preceding command line will connect to a local instance of MongoDB, retrieve all records from the posts collection of the mydb database in the JSON format, and write all outputs to the export.json file.

Utilizing mongoimport

The mongoimport utility can help you import the produced export files in JSON, CSV or TSV formats into the MongoDB instance. The export files can be generated from either mongoexport or from other third-party export tools.

The following example is a basic usage of this command:

mongoimport --db mydb --collection posts --file export.json

The preceding command line will import the export.json entries into the posts collection of the mydb database. The same instruction can be used for other data formats using the --type option.

You have been reading a chapter from
MongoDB High Availability
Published in: Jul 2014
Publisher:
ISBN-13: 9781783986729
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime