-
Notifications
You must be signed in to change notification settings - Fork 1.7k
DOCS-1594: tutorial for restoring database into RS #1283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
===================================== | ||
Restore a Database into a Replica Set | ||
===================================== | ||
|
||
.. default-domain:: mongodb | ||
|
||
Restore Database into a Single Node Replica Set | ||
----------------------------------------------- | ||
|
||
#. Obtain backup files, for example, from a :program:`mongodump`, or | ||
an MMS Backup restore. See | ||
:doc:`/tutorial/backup-databases-with-binary-database-dumps/` for | ||
more about restoring with :program:`mongodump` or `Restore from a | ||
Stored Snapshot | ||
<http://mms.mongodb.com/help/backup/tutorial/restore-from-point-in-time-snapshot/>`_ | ||
in the MMS documentation for instructions detailing how to restore | ||
using MMS Backup. | ||
|
||
#. Start a :program:`mongod` using your new data directory as its | ||
``dbpath``: | ||
|
||
.. code-block:: sh | ||
|
||
mongod --dbpath /data/db | ||
|
||
#. Convert your standalone :program:`mongod` process to a single node | ||
replica set by shutting down the :program:`mongod` instance, and | ||
restarting it with the ``--replSet`` option, as in the following | ||
example: | ||
|
||
.. code-block:: sh | ||
|
||
mongod --dbpath /data/db --replSet <replName> | ||
|
||
#. Connect to the :program:`mongod` instance. | ||
|
||
#. User :method:`rs.initiate()` to initiate the new replica set. | ||
|
||
|
||
Add Members to the Replica Set | ||
------------------------------ | ||
|
||
You restore the secondary members of a replica set in two ways: by | ||
manually copying the database files into their data directory, or | ||
through :ref:`initial sync <replica-set-initial-sync>`. The following | ||
sections provide instructions for each approach. | ||
|
||
.. note:: | ||
|
||
If your database is large, initial sync can take a long time to | ||
complete. For large databases, it might be preferable to copy the | ||
database files onto each host. | ||
|
||
Copy Database Files and Restart :program:`mongod` Instance | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
#. Shut down your :program:`mongod` instance. | ||
|
||
#. Copy your :term:`primary's <primary>` data directory (generally, | ||
``/data/db``) to the data directories of the other members of the | ||
replica set. These will become :term:`secondaries <secondary>`. | ||
|
||
#. In a :program:`mongo` shell connected to the :term:`primary`, add | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. they will need to restart primary mongod first. |
||
the :term:`secondaries <secondary>` to the replica set using | ||
:method:`rs.add()`. For more information about deploying a replica | ||
set, see: :doc:`/tutorial/deploy-replica-set`. | ||
|
||
Update Secondaries using Initial Sync | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
If you do not want to manually copy the data directories onto each | ||
member of your replica set, you can choose to add members to the | ||
replica set and catch them up using initial sync. | ||
|
||
#. Ensure that the data directories on the prospective replica set | ||
members are empty. | ||
|
||
#. Add the members to the replica set. :ref:`Initial Sync | ||
<replica-set-initial-sync>` will copy the data from the | ||
:term:`primary` to the other members of the replica set. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't oplogSize option be mentioned?