From 2df4e3aaefea768939a509ea816d8b86babe02ee Mon Sep 17 00:00:00 2001 From: ravind Date: Fri, 15 Dec 2017 21:17:48 -0500 Subject: [PATCH 1/2] DOCS-11134: Update oplog resize tutorial to use replSetResizeOplog --- source/core/replica-set-oplog.txt | 13 +- .../reference/command/replSetResizeOplog.txt | 27 ++- source/tutorial/change-oplog-size.txt | 222 ++++-------------- 3 files changed, 65 insertions(+), 197 deletions(-) diff --git a/source/core/replica-set-oplog.txt b/source/core/replica-set-oplog.txt index 4028833e83c..996bf03a9cd 100644 --- a/source/core/replica-set-oplog.txt +++ b/source/core/replica-set-oplog.txt @@ -95,13 +95,12 @@ without becoming too stale to continue replicating. However, most replica sets have much lower operation volumes, and their oplogs can hold much higher numbers of operations. -Before :program:`mongod` creates an oplog, you can specify its size -with the :setting:`~replication.oplogSizeMB` option. Once you have started -a replica set member for the first time, use the :dbcommand:`replSetResizeOplog` -to dynamically change the oplog size. If you are using the MMAPv1 storage -engine, follow the :doc:`/tutorial/change-oplog-size` procedure to change -the oplog size. - +Before :program:`mongod` creates an oplog, you can specify its size with +the :setting:`~replication.oplogSizeMB` option. Once you have started a +replica set member for the first time, use the +:dbcommand:`replSetResizeOplog` to change the oplog size. +:dbcommand:`replSetResizeOplog` enables you to resize the oplog +dynamically without restarting the :program:`mongod` process. Workloads that Might Require a Larger Oplog Size ------------------------------------------------ diff --git a/source/reference/command/replSetResizeOplog.txt b/source/reference/command/replSetResizeOplog.txt index db2ba3c1251..1292300256e 100644 --- a/source/reference/command/replSetResizeOplog.txt +++ b/source/reference/command/replSetResizeOplog.txt @@ -17,16 +17,12 @@ Definition .. versionadded:: 3.6 - The :dbcommand:`replSetResizeOplog` dynamically resizes a replica - set member's oplog to satisfy the operational needs in a replica - set. It bypasses the need to perform a maintenance - operation to resize the oplog. The command may only be run against the - ``admin`` database. + Use the :dbcommand:`replSetResizeOplog` administrative command to + change the size of a replica set member's oplog. + :dbcommand:`replSetResizeOplog` enables you to resize the oplog + dynamically without restarting the :program:`mongod` process. - This feature is only available for nodes running on the WiredTiger - storage engine. If you are using the MMAPv1 storage engine, see - :doc:`/tutorial/change-oplog-size` to follow the maintenance - procedure. + You must run this command against the ``admin`` database. The command has the following form: @@ -40,6 +36,19 @@ Definition in megabytes, while the oplog size is stored in bytes. The size parameter must also be over 990 megabytes. +Behavior +-------- + +You can only use :dbcommand:`replSetResizeOplog` on +:program:`mongod` instances running with the +:ref:`Wired Tiger storage engine `. + +Changing the oplog size of a given replica set member with +:dbcommand:`replSetResizeOplog` does not change the oplog size of any +other member in the replica set. You must run +:dbcommand:`replSetResizeOplog` on each replica set member in your +cluster to change the oplog size for all members. + Example -------- diff --git a/source/tutorial/change-oplog-size.txt b/source/tutorial/change-oplog-size.txt index 8a63f1fae1b..063733c7fc0 100644 --- a/source/tutorial/change-oplog-size.txt +++ b/source/tutorial/change-oplog-size.txt @@ -10,208 +10,68 @@ Change the Size of the Oplog :depth: 1 :class: singlecol -The :term:`oplog` exists internally as a :term:`capped collection`, so -you cannot modify its size in the course of normal operations. In most -cases the :ref:`default oplog size ` is an -acceptable size; however, in some situations you may need a larger or -smaller oplog. For example, you might need to change the oplog size -if your applications perform large numbers of multi-updates or -deletes in short periods of time. +.. versionadded:: 3.6 -This tutorial describes how to resize the oplog when using the MMAPv1 -storage engine. If you are using WiredTiger, see -:doc:`/reference/command/replSetResizeOplog` to dynamically change the oplog size. +This procedure changes the size of the oplog on each member of a +replica set using the :dbcommand:`replSetResizeOplog` command, starting +with the :term:`secondary` members before proceeding to the +:term:`primary`. -For a detailed explanation of oplog sizing, see :ref:`replica-set-oplog-sizing`. -For details of how oplog size affects :term:`delayed members ` and affects :term:`replication lag`, see -:ref:`replica-set-delayed-members`. +.. important:: -Overview --------- + You can only run :dbcommand:`replSetResizeOplog` on + replica set member's running with the + :ref:`Wired Tiger storage engine `. -To change the size of the oplog, you must perform maintenance on each -member of the replica set in turn. The procedure requires: stopping -the :program:`mongod` instance and starting as a standalone instance, -modifying the oplog size, and restarting the member. +Perform these steps on each :term:`secondary` replica set member +*first*. Once you have changed the oplog size for all secondary +members, perform these steps on the :term:`primary`. -.. important:: Always start rolling replica set maintenance with the - secondaries, and finish with the maintenance on primary member. +A. Connect to the replica set member +------------------------------------ -Procedure ---------- +Connect to the replica set member using the :program:`mongo` shell: -- Restart the member in standalone mode. +.. code-block:: shell - .. tip:: Always use :method:`rs.stepDown()` to force the primary to - become a secondary, before stopping the server. This facilitates - a more efficient election process. + mongo --host : -- Recreate the oplog with the new size and with an old oplog entry as - a seed. +.. note:: -- Restart the :program:`mongod` instance as a member of the replica - set. + If the replica set enforces :ref:`authentication `, + you must authenticate as a user with privileges to modify the + ``local`` database, such as the :authrole:`clusterManager` or + :authrole:`clusterAdmin` role. -Restart a Secondary in Standalone Mode on a Different Port -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +B. (Optional) Verify the current size of the oplog +-------------------------------------------------- -Shut down the :program:`mongod` instance for one of the non-primary -members of your replica set. For example, to shut down, use the -:method:`db.shutdownServer()` method: +To view the current size of the oplog, switch to the ``local`` +database and run :method:`db.collection.stats()` against the +``oplog.rs`` collection. :method:`~db.collection.stats()` displays the +oplog size as :data:`~collStats.maxSize`. -.. code-block:: sh - - use admin - db.shutdownServer() - -Restart this :program:`mongod` as a standalone instance -running on a different port and *without* -the :option:`--replSet ` parameter. Use a command -similar to the following: - -.. include:: /includes/warning-bind-ip-security-considerations.rst - -.. code-block:: sh - - mongod --port 37017 --dbpath /srv/mongodb --bind_ip localhost, - -Create a Backup of the Oplog (Optional) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Optionally, backup the existing oplog on the standalone instance, as -in the following example: - -.. code-block:: sh - - mongodump --db local --collection 'oplog.rs' --port 37017 - -Recreate the Oplog with a New Size and a Seed Entry -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Save the last entry from the oplog. For example, connect to the instance -using the :program:`mongo` shell, and enter the following command to -switch to the ``local`` database: +The following operation displays the oplog size using the +:method:`db.collection.stats()` command and +:data:`~collStats.maxSize`: .. code-block:: javascript use local + db.oplog.rs.stats().maxSize -In :program:`mongo` shell scripts you can use the following operation -to set the ``db`` object: - -.. code-block:: javascript - - db = db.getSiblingDB('local') - -Ensure that the ``temp`` temporary collection is empty by dropping the -collection: +The ``maxSize`` field displays the collection size in bytes. -.. code-block:: javascript - - db.temp.drop() - -Retrieve the latest oplog entry by sorting on reverse :term:`natural order`. -Modify the entry to set ``op`` to "n" (representing a no-op) and clear the -``o`` and ``o2`` fields. Then insert the modified oplog entry into a temporary -collection. - -.. _last-oplog-entry: +C. Change the oplog size of the replica set member +-------------------------------------------------- -.. code-block:: javascript - - var oplogEntry = db.oplog.rs.find().sort({$natural: -1}).limit(1).next(); - oplogEntry.op = 'n'; // Change the entry to a no-op. - oplogEntry.o = {}; // Remove any update modifiers that would prevent saving the oplog entry to a normal collection. - oplogEntry.o2 = {}; - db.temp.insert(oplogEntry); +To change the size, run the :dbcommand:`replSetResizeOplog` passing +the desired size in megabytes as the ``size`` parameter. The +specified size must be greater than ``990``, or 990 megabytes. -To see this oplog entry, use the following operation: +The following operation changes the oplog size of the replica set +member to 16 gigabytes, or 16000 megabytes. .. code-block:: javascript - db.temp.find() - -Remove the Existing Oplog Collection -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Drop the old ``oplog.rs`` collection in the ``local`` database. Use -the following command: - -.. code-block:: javascript - - db = db.getSiblingDB('local') - db.oplog.rs.drop() - -This returns ``true`` in the shell. - -Create a New Oplog -~~~~~~~~~~~~~~~~~~ - -Use the :dbcommand:`create` command to create a new oplog of a -different size. Specify the ``size`` argument in bytes. A value of -``2 * 1024 * 1024 * 1024`` will create a new oplog that's 2 gigabytes: - -.. code-block:: javascript - - db.runCommand( { create: "oplog.rs", capped: true, size: (2 * 1024 * 1024 * 1024) } ) - -Upon success, this command returns the following status: - -.. code-block:: javascript - - { "ok" : 1 } - -Insert the Last Entry of the Old Oplog into the New Oplog -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Insert the previously inserted latest entry from the old oplog into the new -oplog. For example: - -.. code-block:: javascript - - db.oplog.rs.insert( db.temp.findOne() ) - -To confirm the entry is in the new oplog, use the following operation: - -.. code-block:: javascript - - db.oplog.rs.find() - -Restart the Member -~~~~~~~~~~~~~~~~~~ - -Stop the server. For example, from the :program:`mongo` shell, you can -issue the following: - -.. code-block:: javascript - - use admin - db.shutdownServer() - -Restart the :program:`mongod` as a member of the replica set on its -usual port. From the system prompt (**not** the :program:`mongo` -shell): - -.. code-block:: sh - - mongod --replSet rs0 --dbpath /srv/mongodb --bind_ip localhost, - -.. include:: /includes/warning-bind-ip-security-considerations.rst - -The replica set member will recover and "catch up" before it is -eligible for election to primary. - -Repeat Process for all Members that may become Primary -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Repeat this procedure for all members you want to change the size of -the oplog. Repeat the procedure for the primary as part of the -following step. - -Change the Size of the Oplog on the Primary -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -To finish the rolling maintenance operation, step down the primary with the -:method:`rs.stepDown()` method and repeat the oplog resizing procedure -above. + db.adminCommand({replSetResizeOplog: 1, size: 16000}) From ed4264c63d3be9208b1dc45be2d05df431612aa9 Mon Sep 17 00:00:00 2001 From: ravind Date: Wed, 20 Dec 2017 17:34:36 -0500 Subject: [PATCH 2/2] DOCS-11134: RFM fixes --- source/tutorial/change-oplog-size.txt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/source/tutorial/change-oplog-size.txt b/source/tutorial/change-oplog-size.txt index 063733c7fc0..34456a3c216 100644 --- a/source/tutorial/change-oplog-size.txt +++ b/source/tutorial/change-oplog-size.txt @@ -51,10 +51,7 @@ database and run :method:`db.collection.stats()` against the ``oplog.rs`` collection. :method:`~db.collection.stats()` displays the oplog size as :data:`~collStats.maxSize`. -The following operation displays the oplog size using the -:method:`db.collection.stats()` command and -:data:`~collStats.maxSize`: - +.. class:: copyable-code .. code-block:: javascript use local