From b4df9fe8d5e88a641cf40ade0687099f2b61574a Mon Sep 17 00:00:00 2001 From: Bob Grabar Date: Tue, 28 Aug 2012 11:47:06 -0400 Subject: [PATCH 1/4] DOCS-408 change a secondary to an arbiter --- source/faq/replica-sets.txt | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/source/faq/replica-sets.txt b/source/faq/replica-sets.txt index 1f8afc34fd1..2215801a7d5 100644 --- a/source/faq/replica-sets.txt +++ b/source/faq/replica-sets.txt @@ -34,7 +34,7 @@ inaccessible, the other members can autonomously :term:`elect ` one of the other members of the set to be the new "primary". By default, clients send all reads to the primary; -however, ":term:`read preference`" is configurable at the +however, :term:`read preference` is configurable at the client level on a per-connection basis, which makes it possible to send reads to secondary nodes instead. @@ -78,7 +78,7 @@ For example, a deployment may maintain a :term:`primary` and :term:`secondary` in an East-coast data center along with a :term:`secondary` member for disaster recovery in a West-coast data center. -.. seealso:: ":doc:`/tutorial/deploy-geographically-distributed-replica-set`" +.. seealso:: :doc:`/tutorial/deploy-geographically-distributed-replica-set` Can MongoDB replicate over a "noisy" connection? ------------------------------------------------ @@ -202,6 +202,23 @@ all arbiters on secure networks, as with all MongoDB components. .. see:: The overview of :ref:`Arbiter Members of Replica Sets `. +How do you change a secondary to an arbiter? +-------------------------------------------- + +To change a secondary to an arbiter, you start an arbiter on a new port +and then shut down the secondary. + +Specifically, you start a new mongod instance as a member of the replica +set and on a different port from the secondary. You do so while the +secondary is still running. You then make the new mongod an arbiter +using the :method:`rs.addArb()` method. Once the new arbiter is attached +to the replica set, shut down the secondary. + +If you have an application connection string referencing the old +secondary, remove the reference. + +.. seealso:: :ref:`arbiters` and :method:`rs.addArb()` + Which members of a replica set vote in elections? ------------------------------------------------- From 8ad3e7b18a0a972f194494f47c1e36714b9b19a0 Mon Sep 17 00:00:00 2001 From: Bob Grabar Date: Tue, 28 Aug 2012 15:02:58 -0400 Subject: [PATCH 2/4] DOCS-408 ongoing edits --- .../convert-secondary-into-arbiter.txt | 105 ++++++++++++++++++ source/faq/replica-sets.txt | 17 --- 2 files changed, 105 insertions(+), 17 deletions(-) create mode 100644 draft/tutorial/convert-secondary-into-arbiter.txt diff --git a/draft/tutorial/convert-secondary-into-arbiter.txt b/draft/tutorial/convert-secondary-into-arbiter.txt new file mode 100644 index 00000000000..11adf9bd0fb --- /dev/null +++ b/draft/tutorial/convert-secondary-into-arbiter.txt @@ -0,0 +1,105 @@ +================================= +Convert a Secondary to an Arbiter +================================= + +.. default-domain:: mongodb + +Synopsis +-------- + +This document presents two possible procedures for converting a :term:`secondary` +to an :term:`arbiter`. You may: + +#. Start the arbiter on the same port by first shutting down the secondary. + + For this procedure, see :ref:`replica-set-convert-secondary-to-arbiter-same-port`. + +#. Start the arbiter on a new port. + + For this procedure, see :ref:`replica-set-convert-secondary-to-arbiter`. + +.. seealso:: + + - :ref:`replica-set-arbiters` + - :doc:`/reference/replica-configuration` + - :doc:`/administration/replication-architectures` + - :method:`rs.addArb()` and :method:`rs.remove()` + +Procedures +---------- + +.. _replica-set-convert-secondary-to-arbiter-same-port: + +Convert a Secondary to an Arbiter and Reuse the Port Number +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +#. Remove the :term:`secondary` from the :term:`replica set` by calling + the :method:`rs.remove()` method in the :program:`mongo` shell: + + .. code-block:: javascript + + rs.remove("*hostname*") + +#. Ensure that the secondary has been removed from the replica set by + calling the :method:`rs.config()` method in the :program:`mongo` + shell. + + .. code-block:: javascript + + rs.config() + +#. Shut down the secondary. + +#. Move the secondary's data directory to an archive folder. For example: + + .. code-block:: sh + + mv /data/db /data/db-old + + Optionally, you can remove the data entirely. + +#. Modify your application so that MongoDB queries don't reach + the secondary. + +#. Restart the :program:`mongod` instance for the secondary *without specifying a database*. + Do specify the port number and replica set. You can use the same port + number you used before. Issue a command similar to the following: + + .. code-block:: sh + + mongod --port 27050 --replSet rs + +#. In the :program:`mongo` shell, convert the secondary to an arbiter + using the :method:`rs.addArb()` method: + + .. code-block:: javascript + + rs.addArb("*hostname*") + +#. Ensure that the arbiter has been added to the replica set by + calling the :method:`rs.config()` method in the :program:`mongo` + shell. + + .. code-block:: javascript + + rs.config() + +.. _replica-set-convert-secondary-to-arbiter: + +Convert a Secondary to an Arbiter while the Secondary is Still Running +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +#. Start a new mongod instance as a member of the replica set and on a + different port from the secondary. + +#. Make the new mongod an arbiter using the :method:`rs.addArb()` + method. + +#. Once the new arbiter is attached to the replica set, shut down the + secondary. + +#. If you have an application connection string referencing the old + secondary, remove the reference. + +#. To confirm the new configuration, call :method:`rs.config()` in the + :program:`mongo` shell. diff --git a/source/faq/replica-sets.txt b/source/faq/replica-sets.txt index 2215801a7d5..ce1e852eee2 100644 --- a/source/faq/replica-sets.txt +++ b/source/faq/replica-sets.txt @@ -202,23 +202,6 @@ all arbiters on secure networks, as with all MongoDB components. .. see:: The overview of :ref:`Arbiter Members of Replica Sets `. -How do you change a secondary to an arbiter? --------------------------------------------- - -To change a secondary to an arbiter, you start an arbiter on a new port -and then shut down the secondary. - -Specifically, you start a new mongod instance as a member of the replica -set and on a different port from the secondary. You do so while the -secondary is still running. You then make the new mongod an arbiter -using the :method:`rs.addArb()` method. Once the new arbiter is attached -to the replica set, shut down the secondary. - -If you have an application connection string referencing the old -secondary, remove the reference. - -.. seealso:: :ref:`arbiters` and :method:`rs.addArb()` - Which members of a replica set vote in elections? ------------------------------------------------- From 5051169fdf88a033319e6cc8bfffcccc757c5717 Mon Sep 17 00:00:00 2001 From: Bob Grabar Date: Tue, 28 Aug 2012 16:04:26 -0400 Subject: [PATCH 3/4] DOCS-408 new proc to convert secondary to arbiter --- .../convert-secondary-into-arbiter.txt | 131 +++++++++++++----- 1 file changed, 100 insertions(+), 31 deletions(-) diff --git a/draft/tutorial/convert-secondary-into-arbiter.txt b/draft/tutorial/convert-secondary-into-arbiter.txt index 11adf9bd0fb..296cbc32855 100644 --- a/draft/tutorial/convert-secondary-into-arbiter.txt +++ b/draft/tutorial/convert-secondary-into-arbiter.txt @@ -7,23 +7,25 @@ Convert a Secondary to an Arbiter Synopsis -------- -This document presents two possible procedures for converting a :term:`secondary` -to an :term:`arbiter`. You may: +To convert a secondary to an arbiter you have two options: -#. Start the arbiter on the same port by first shutting down the secondary. +#. Run the arbiter on the same port number as you ran the secondary. + In this option, you must shut down the secondary and remove its data + before restarting and reconfiguring it as an arbiter. For this procedure, see :ref:`replica-set-convert-secondary-to-arbiter-same-port`. -#. Start the arbiter on a new port. +#. Run the arbiter on a new port number. In this option, you can + reconfigure the server as an arbiter before shutting down the + instance running as a secondary. For this procedure, see :ref:`replica-set-convert-secondary-to-arbiter`. .. seealso:: - :ref:`replica-set-arbiters` - - :doc:`/reference/replica-configuration` - - :doc:`/administration/replication-architectures` - - :method:`rs.addArb()` and :method:`rs.remove()` + - :ref:`replica-set-arbiter-nodes` + - :method:`rs.addArb()` Procedures ---------- @@ -34,15 +36,16 @@ Convert a Secondary to an Arbiter and Reuse the Port Number ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #. Remove the :term:`secondary` from the :term:`replica set` by calling - the :method:`rs.remove()` method in the :program:`mongo` shell: + the :method:`rs.remove()` method while connected to the current + :term:`primary` in the :program:`mongo` shell: .. code-block:: javascript - rs.remove("*hostname*") + rs.remove("*hostname:port number*") #. Ensure that the secondary has been removed from the replica set by - calling the :method:`rs.config()` method in the :program:`mongo` - shell. + calling the :method:`rs.config()` method while connected to the current + primary in the :program:`mongo` shell: .. code-block:: javascript @@ -61,45 +64,111 @@ Convert a Secondary to an Arbiter and Reuse the Port Number #. Modify your application so that MongoDB queries don't reach the secondary. -#. Restart the :program:`mongod` instance for the secondary *without specifying a database*. - Do specify the port number and replica set. You can use the same port - number you used before. Issue a command similar to the following: +#. Create a new, empty data directory to point to when restarting the + :program:`mongod` instance. You can reuse the previous name. For + example: .. code-block:: sh - mongod --port 27050 --replSet rs + mkdir /data/db -#. In the :program:`mongo` shell, convert the secondary to an arbiter - using the :method:`rs.addArb()` method: +#. Restart the :program:`mongod` instance for the secondary, specifying + the port number, the empty data directory, and the replica set. You + can use the same port number you used before. Issue a command similar + to the following: + + .. code-block:: sh + + mongod --port 27021 --dbpath /data/db --replSet rs + +#. In the :program:`mongo` shell connected to the current primary, + convert the secondary to an arbiter using the :method:`rs.addArb()` + method: .. code-block:: javascript - rs.addArb("*hostname*") + rs.addArb("*hostname:port number*") -#. Ensure that the arbiter has been added to the replica set by - calling the :method:`rs.config()` method in the :program:`mongo` - shell. +#. Verify the arbiter is added to the replica set by calling the + :method:`rs.config()` method in the :program:`mongo` shell (connected + to the current primary). .. code-block:: javascript rs.config() + The arbiter member should include the following field and value: + + .. code-block:: javascript + + "arbiterOnly" : true + .. _replica-set-convert-secondary-to-arbiter: -Convert a Secondary to an Arbiter while the Secondary is Still Running -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Convert a Secondary to an Arbiter Running on a New Port Number +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +#. Create a new, empty data directory. For example: + + .. code-block:: sh + + mkdir /data/db-temp + +#. Start a new :program:`mongod` instance on a different port from the + secondary, specifying the new data directory and the existing replica + set. Issue a command similar to the following: + + .. code-block:: sh + + mongod --port 27021 --dbpath /data/db --replSet rs + +#. In the :program:`mongo` shell connected to the current primary, + convert the secondary to an arbiter using the :method:`rs.addArb()` + method: + + .. code-block:: javascript + + rs.addArb("*hostname:port number*") + +#. Verify the arbiter is added to the replica set by calling the + :method:`rs.config()` method in the :program:`mongo` shell (connected + to the current primary). + + .. code-block:: javascript + + rs.config() + + The arbiter member should include the following field and value: -#. Start a new mongod instance as a member of the replica set and on a - different port from the secondary. + .. code-block:: javascript -#. Make the new mongod an arbiter using the :method:`rs.addArb()` - method. + "arbiterOnly" : true -#. Once the new arbiter is attached to the replica set, shut down the - secondary. +#. Shut down the secondary. #. If you have an application connection string referencing the old secondary, remove the reference. -#. To confirm the new configuration, call :method:`rs.config()` in the - :program:`mongo` shell. +#. Remove the :term:`secondary` from the :term:`replica set` by calling + the :method:`rs.remove()` method while connected to the current + :term:`primary` in the :program:`mongo` shell: + + .. code-block:: javascript + + rs.remove("*hostname:port number*") + +#. Ensure that the secondary has been removed from the replica set by + calling the :method:`rs.config()` method while connected to the current + primary in the :program:`mongo` shell: + + .. code-block:: javascript + + rs.config() + +#. Move the secondary's data directory to an archive folder. For example: + + .. code-block:: sh + + mv /data/db /data/db-old + + Optionally, you can remove the data entirely. From 0985c96ee68469af8d2ea66d73af596f7e052c65 Mon Sep 17 00:00:00 2001 From: Bob Grabar Date: Tue, 28 Aug 2012 16:44:57 -0400 Subject: [PATCH 4/4] DOCS-408 proc to convert secondary to arbiter --- .../convert-secondary-into-arbiter.txt | 49 +++++++++---------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/draft/tutorial/convert-secondary-into-arbiter.txt b/draft/tutorial/convert-secondary-into-arbiter.txt index 296cbc32855..390697cd1b2 100644 --- a/draft/tutorial/convert-secondary-into-arbiter.txt +++ b/draft/tutorial/convert-secondary-into-arbiter.txt @@ -4,6 +4,11 @@ Convert a Secondary to an Arbiter .. default-domain:: mongodb +You can convert a secondary member to an arbiter either by shutting down +the secondary and restarting it as an arbiter, or by starting the +arbiter on a new port and then shutting down the instance of the +secondary. This document describes both procedures. + Synopsis -------- @@ -41,11 +46,10 @@ Convert a Secondary to an Arbiter and Reuse the Port Number .. code-block:: javascript - rs.remove("*hostname:port number*") + rs.remove(":") -#. Ensure that the secondary has been removed from the replica set by - calling the :method:`rs.config()` method while connected to the current - primary in the :program:`mongo` shell: +#. Verify that the replica set no longer includes the secondary by + calling the :method:`rs.config()` method in the :program:`mongo` shell: .. code-block:: javascript @@ -59,7 +63,7 @@ Convert a Secondary to an Arbiter and Reuse the Port Number mv /data/db /data/db-old - Optionally, you can remove the data entirely. + .. optional:: You may remove the data instead. #. Modify your application so that MongoDB queries don't reach the secondary. @@ -81,23 +85,21 @@ Convert a Secondary to an Arbiter and Reuse the Port Number mongod --port 27021 --dbpath /data/db --replSet rs -#. In the :program:`mongo` shell connected to the current primary, - convert the secondary to an arbiter using the :method:`rs.addArb()` - method: +#. In the :program:`mongo` shell convert the secondary to an arbiter + using the :method:`rs.addArb()` method: .. code-block:: javascript - rs.addArb("*hostname:port number*") + rs.addArb(":") -#. Verify the arbiter is added to the replica set by calling the - :method:`rs.config()` method in the :program:`mongo` shell (connected - to the current primary). +#. Verify the arbiter belongs to the replica set by calling the + :method:`rs.config()` method in the :program:`mongo` shell. .. code-block:: javascript rs.config() - The arbiter member should include the following field and value: + The arbiter member should include the following: .. code-block:: javascript @@ -128,17 +130,16 @@ Convert a Secondary to an Arbiter Running on a New Port Number .. code-block:: javascript - rs.addArb("*hostname:port number*") + rs.addArb(":") -#. Verify the arbiter is added to the replica set by calling the - :method:`rs.config()` method in the :program:`mongo` shell (connected - to the current primary). +#. Verify the arbiter belongs to the replica set by calling the + :method:`rs.config()` method in the :program:`mongo` shell. .. code-block:: javascript rs.config() - The arbiter member should include the following field and value: + The arbiter member should include the following: .. code-block:: javascript @@ -150,16 +151,14 @@ Convert a Secondary to an Arbiter Running on a New Port Number secondary, remove the reference. #. Remove the :term:`secondary` from the :term:`replica set` by calling - the :method:`rs.remove()` method while connected to the current - :term:`primary` in the :program:`mongo` shell: + the :method:`rs.remove()` method in the :program:`mongo` shell: .. code-block:: javascript - rs.remove("*hostname:port number*") + rs.remove(":") -#. Ensure that the secondary has been removed from the replica set by - calling the :method:`rs.config()` method while connected to the current - primary in the :program:`mongo` shell: +#. Verify that the replica set no longer includes the secondary by + calling the :method:`rs.config()` method in the :program:`mongo` shell: .. code-block:: javascript @@ -171,4 +170,4 @@ Convert a Secondary to an Arbiter Running on a New Port Number mv /data/db /data/db-old - Optionally, you can remove the data entirely. + .. optional:: You may remove the data instead. \ No newline at end of file