Skip to content

update the procedure to enable balancer #1066

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
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 44 additions & 49 deletions source/tutorial/manage-sharded-cluster-balancer.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,34 +151,31 @@ all migration, use the following procedure:

.. code-block:: javascript

sh.stopBalancer()

#. Later, issue the following operation to enable the balancer:

.. code-block:: javascript

sh.startBalancer()
sh.setBalancerState(false)

.. note::

If a migration is in progress, the system will complete the
in-progress migration before stopping. After disabling, you can use the following
operation in the :program:`mongo` shell to determine if there are
no migrations in progress:
in-progress migration before stopping.

.. code-block:: javascript
#. To later re-enable the balancer, see :ref:`sharding-balancing-re-enable`.

use config
while( sh.isBalancerRunning() ) {
print("waiting...");
sleep(1000);
}
After disabling, you can use the following
operation in the :program:`mongo` shell to determine if there are
no migrations in progress:

The above process and the :method:`sh.setBalancerState()`,
:method:`sh.startBalancer()`, and :method:`sh.stopBalancer()` helpers
provide wrappers on the following process, which may be useful if you
need to run this operation from a driver that does not have helper
functions:
.. code-block:: javascript

use config
while( sh.isBalancerRunning() ) {
print("waiting...");
sleep(1000);
}

The :method:`sh.setBalancerState()` helper provides
a wrapper on the following process, which may be useful if you
need to run this operation from a driver that does not have helper
functions:

#. Connect to any :program:`mongos` in the cluster using the
:program:`mongo` shell.
Expand All @@ -195,11 +192,34 @@ all migration, use the following procedure:

db.settings.update( { _id: "balancer" }, { $set : { stopped: true } } , true );

#. To enable the balancer again, alter the value of "stopped" as follows:
#. To later re-enable the balancer, see :ref:`sharding-balancing-re-enable`.

.. code-block:: javascript
.. _sharding-balancing-re-enable:
.. _sharding-balancing-enable:

Enable the Balancer
-------------------

Use this procedure if you have disabled the balancer and are ready to
re-enable it:

#. Connect to any :program:`mongos` in the cluster using the
:program:`mongo` shell.

#. Issue one of the following operations to enable the balancer:

- From the :program:`mongo` shell, issue:

.. code-block:: javascript

sh.startBalancer(true)

db.settings.update( { _id: "balancer" }, { $set : { stopped: false } } , true );
- From a driver that does not have the :method:`sh.startBalancer()` helper,
issue the following from the ``config`` database:

.. code-block:: javascript

db.settings.update( { _id: "balancer" }, { $set : { stopped: false } } , true )

Disable Balancing During Backups
--------------------------------
Expand Down Expand Up @@ -231,28 +251,3 @@ is active:

When the backup procedure is complete you can reactivate
the balancer process.

.. _sharding-balancing-re-enable:

Re-enable the Balancer after Temporarily Disabling It
-----------------------------------------------------

Use this procedure if you have temporarily disabled the balancer and are
ready to re-enable it:

#. Connect to any :program:`mongos` in the cluster using the
:program:`mongo` shell.

#. Issue one of the following operations to enable the balancer:

- From the :program:`mongo` shell, issue:

.. code-block:: javascript

sh.startBalancer()

- From a driver that does not have the :method:`sh.startBalancer()` helper:

.. code-block:: javascript

db.settings.update( { _id: "balancer" }, { $set : { stopped: false } } , true );