Skip to content

Commit be171b8

Browse files
committed
DOCS-8616: no-downtime security sharded cluster
1 parent b6eacce commit be171b8

10 files changed

+731
-8
lines changed

source/core/security-internal-authentication.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ see :doc:`/tutorial/upgrade-keyfile-to-x509`.
9595
/tutorial/enforce-keyfile-access-control-in-existing-replica-set-without-downtime
9696
/tutorial/deploy-replica-set-with-keyfile-access-control
9797
/tutorial/enforce-keyfile-access-control-in-existing-sharded-cluster
98-
/tutorial/deploy-sharded-cluster-with-keyfile-access-control
98+
/tutorial/enforce-keyfile-access-control-in-existing-sharded-cluster-no-downtime
99+
/tutorial/deploy-sharded-cluster-with-keyfile-access-control
99100
/tutorial/configure-x509-member-authentication
100101
/tutorial/upgrade-keyfile-to-x509

source/includes/extracts-keyfile-info.yaml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
ref: _keyfile-intro
22
content: |
33
4-
The contents of the :ref:`keyfile <internal-auth-keyfile>` serves as
5-
the shared password for the members of the {{deployment}}. The
6-
content of the keyfile must be the same for all members of the
4+
With :ref:`keyfile <internal-auth-keyfile>` authentication, the
5+
{{components}} in the {{deployment}} use the contents of the keyfile as the
6+
shared password for authenticating other members in the deployment. Only
7+
{{components}} with the correct keyfile can join the {{deployment}}.
8+
9+
The content of the keyfile must be the same for all members of the
710
{{deployment}}.
811
912
You can generate a keyfile using any method you choose. The contents
@@ -24,22 +27,30 @@ source:
2427
ref: _keyfile-intro
2528
replacement:
2629
deployment: replica set
30+
components: :program:`mongod` instances
2731
---
2832
ref: keyfile-intro-sharded-cluster
2933
source:
3034
file: extracts-keyfile-info.yaml
3135
ref: _keyfile-intro
3236
replacement:
3337
deployment: sharded cluster
38+
components: :program:`mongod` or :program:`mongos` instances
3439
---
3540
ref: _keyfile-distribution
3641
content: |
37-
Copy the keyfile to each server hosting the {{deployment}} members. Use a
38-
consistent location for each server.
42+
43+
Copy the keyfile to each server hosting the {{deployment}} members. For
44+
simplicity in configuration and maintenance, save the keyfile to a
45+
consistent location for each server, such as the file path specified in
46+
the {{programs}} :setting:`storage.dbPath` setting.
3947
4048
.. important::
41-
Do not use shared network locations or storage mediums such as USB
42-
drives for storing the keyfile.
49+
50+
If the {{programs}} cannot access the keyfile, they cannot communicate
51+
with the {{deployment}}. Avoid storing the keyfile on storage mediums
52+
that can be easily disconnected from the hardware hosting the
53+
{{programs}}, such as a USB drive or a network attached storage device.
4354
4455
Ensure that the user running the {{programs}} can access the keyfile.
4556
---
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
stepnum: 1
2+
level: 4
3+
title: "Remove ``transitionToAuth`` from the ``mongod`` configuration file."
4+
ref: modify-config-files
5+
pre: |
6+
7+
Remove the :setting:`security.transitionToAuth` key and its value from the
8+
configuration file created during this tutorial.
9+
10+
.. code-block:: yaml
11+
12+
security:
13+
keyFile: <path-to-keyfile>
14+
---
15+
stepnum: 2
16+
level: 4
17+
ref: restart-mongod
18+
title: "Restart the ``mongod`` with the updated configuration file."
19+
source:
20+
file: steps-enable-authentication-in-shardcluster-nodowntime-transition-config.yaml
21+
ref: restart-mongod
22+
post: |
23+
24+
At the end of this section, the config server replica set should be up and
25+
running fully enforcing authentication.
26+
27+
Users and client applications *must* specify authentiation credentials when
28+
connecting to the config server replica set.
29+
replacement:
30+
status: "updated"
31+
...
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
stepnum: 1
2+
level: 4
3+
title: "Remove ``transitionToAuth`` from the ``mongos`` configuration file"
4+
ref: modify-config-files
5+
pre: |
6+
7+
Remove the :setting:`security.transitionToAuth` key and its value from the
8+
configuration file created during this tutorial.
9+
10+
.. code-block:: yaml
11+
12+
security:
13+
keyFile: <path-to-keyfile>
14+
15+
---
16+
stepnum: 2
17+
level: 4
18+
ref: restart-mongos
19+
title: "Restart the ``mongos`` with the updated configuration file."
20+
pre: |
21+
22+
Connect to the :program:`mongos` and use the :method:`db.shutdownServer()`
23+
method against the ``admin`` database to safely shut down the
24+
:program:`mongos`.
25+
26+
Restart one :program:`mongos` at a time to ensure that clients
27+
can connect to the sharded cluster. If your cluster has only one
28+
:program:`mongos`, this step results in downtime while the :program:`mongos`
29+
is offline.
30+
31+
.. code-block:: javascript
32+
33+
db.getSiblingDB("admin").shutdownServer()
34+
35+
You can then start the :program:`mongos` specifying the updated
36+
configuration file, specifying the path to the config file using
37+
:option:`--config`.. This configuration file no longer contains the
38+
:setting:`security.transitionToAuth` setting, but retains the
39+
:setting:`security.keyFile` setting.
40+
41+
.. example::
42+
43+
The following operation starts the :program:`mongos` specifying
44+
the updated configuration file, here named ``mongos-secure.conf``.
45+
The ``<path>`` represents the system path to the folder containing
46+
the configuration file.
47+
48+
.. code-block:: shell
49+
50+
mongos --config <path>/mongos-secure.conf
51+
52+
.. note::
53+
54+
MongoDB deployments running on :abbr:`Windows (Microsoft Windows)` use
55+
the ``.cfg`` file extension instead of ``.conf``.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
stepnum: 1
2+
level: 4
3+
title: "Remove ``transitionToAuth`` from the ``mongod`` configuration file"
4+
ref: modify-configuration
5+
source:
6+
file: steps-enable-authentication-in-shardcluster-nodowntime-auth-config.yaml
7+
ref: modify-config-files
8+
---
9+
stepnum: 2
10+
level: 4
11+
title: "Restart the ``mongod`` with the new configuration file."
12+
ref: restart-mongod
13+
source:
14+
file: steps-enable-authentication-in-shardcluster-nodowntime-transition-config.yaml
15+
ref: restart-mongod
16+
post: |
17+
18+
At the end of this section, the shard replica set should be up and
19+
running fully enforcing authentication.
20+
21+
Users and client applications *must* specify authentiation credentials when
22+
connecting to the shard replica set.
23+
replacement:
24+
status: "updated"
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
stepnum: 1
2+
level: 4
3+
title: "Add ``transitionToAuth: true`` to the ``mongod`` configuration file."
4+
ref: modify-config-files
5+
pre: |
6+
7+
Copy the existing {{program}} configuration file and name the copy to
8+
distinguish it, for example, by adding ``-secure`` to the filename. You will
9+
use this new configuration file to transition the {{program}} to enforce
10+
authentication in the sharded cluster. Retain the original configuration
11+
file for backup purposes.
12+
13+
Add the following settings to the new configuration file.
14+
15+
.. list-table::
16+
:header-rows: 1
17+
:widths: 30 70
18+
19+
* - Setting
20+
- Value
21+
22+
* - :setting:`security.transitionToAuth`
23+
- ``true``
24+
25+
* - :setting:`security.keyFile`
26+
- Path to the keyfile.
27+
28+
If using a different internal authentication mechanism, specify that
29+
mechanism instead of :setting:`security.keyFile`.
30+
31+
The new configuration file should contain all of the configuration settings
32+
previously used by the {{program}}, as well as the new security
33+
settings.
34+
35+
.. code-block:: yaml
36+
37+
security:
38+
transitionToAuth: true
39+
keyFile: <path-to-keyfile>
40+
replacement:
41+
program: :program:`mongod`
42+
---
43+
stepnum: 2
44+
level: 4
45+
ref: restart-mongod
46+
title: "Restart the ``mongod`` with the new configuration file."
47+
pre: |
48+
49+
Connect to the :program:`mongod` and use the :method:`db.shutdownServer()`
50+
method against the ``admin`` database to safely shut down the
51+
:program:`mongod`.
52+
53+
.. code-block:: javascript
54+
55+
db.getSiblingDB("admin").shutdownServer()
56+
57+
If you are performing this step on the :term:`primary`, you must first use
58+
the :method:`rs.stepDown()` method against the ``admin`` database to step
59+
down the primary and trigger an election. You can use the
60+
:method:`rs.status()` method to ensure the replica set elected a new primary.
61+
62+
Once you step down the primary, you can then shut it down using the
63+
:method:`db.shutdownServer()` method against the ``admin`` database.
64+
65+
.. code-block:: javascript
66+
67+
db.getSiblingDB("admin").rs.stepDown()
68+
db.getSiblingDB("admin").shutdownServer()
69+
70+
You can then restart the :program:`mongod` with the {{status}} configuration
71+
file, specifying the path to the config file using :option:`--config`.
72+
73+
.. example::
74+
75+
The following operation starts the replica set member specifying
76+
the {{status}} configuration file, here named ``mongod-secure.conf``.
77+
The ``<path>`` represents the system path to the folder containing
78+
the configuration file.
79+
80+
.. code-block:: shell
81+
82+
mongod --config <path>/mongod-secure.conf
83+
84+
.. note::
85+
86+
MongoDB deployments running on :abbr:`Windows (Microsoft Windows)` use
87+
the ``.cfg`` file extension instead of ``.conf``.
88+
replacement:
89+
status: "new"
90+
post: |
91+
92+
Include additional settings as appropriate to your deployment. Refer to
93+
the :ref:`configuration-options` documentation for a complete list of
94+
configuration file options.
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
stepnum: 1
2+
level: 4
3+
title: "Add ``transitionToAuth: true`` to the ``mongos`` configuration file"
4+
ref: modify-config-files
5+
pre: |
6+
7+
Copy the existing {{program}} configuration file and name the copy to
8+
distinguish it, for example, by adding ``-secure`` to the filename. You will
9+
use this new configuration file to transition the {{program}} to enforce
10+
authentication in the sharded cluster. Retain the original configuration
11+
file for backup purposes.
12+
13+
Add the following settings to the new configuration file.
14+
15+
.. list-table::
16+
:header-rows: 1
17+
:widths: 30 70
18+
19+
* - Setting
20+
- Value
21+
22+
* - :setting:`security.transitionToAuth`
23+
- ``true``
24+
25+
* - :setting:`security.keyFile`
26+
- Path to the keyfile.
27+
28+
If using a different internal authentication mechanism, specify that
29+
mechanism instead of :setting:`security.keyFile`.
30+
31+
The new configuration file should contain all of the configuration settings
32+
previously used by the {{program}}, as well as the new security
33+
settings.
34+
35+
.. code-block:: yaml
36+
37+
security:
38+
transitionToAuth: true
39+
keyFile: <path-to-keyfile>
40+
replacement:
41+
program: :program:`mongos`
42+
---
43+
stepnum: 2
44+
level: 4
45+
ref: restart-mongos
46+
title: "Restart the ``mongos`` with the new configuration file."
47+
pre: |
48+
49+
Connect to the :program:`mongos` and use the :method:`db.shutdownServer()`
50+
method against the ``admin`` database to safely shut down the
51+
:program:`mongos`.
52+
53+
Restart one :program:`mongos` at a time to ensure that clients
54+
can connect to the sharded cluster. If your cluster has only one
55+
:program:`mongos`, this step results in downtime while the :program:`mongos`
56+
is offline.
57+
58+
.. code-block:: javascript
59+
60+
db.getSiblingDB("admin").shutdownServer()
61+
62+
You can then start the :program:`mongos` with the new configuration
63+
file, specifying the path to the config file using :option:`--config`.
64+
65+
.. example::
66+
67+
The following operation starts the :program:`mongos` specifying
68+
the updated configuration file, here named ``mongos-secure.conf``.
69+
The ``<path>`` represents the system path to the folder containing
70+
the configuration file.
71+
72+
.. code-block:: shell
73+
74+
mongos --config <path>/mongos-secure.conf
75+
76+
.. note::
77+
78+
MongoDB deployments running on :abbr:`Windows (Microsoft Windows)` use
79+
the ``.cfg`` file extension instead of ``.conf``.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
stepnum: 1
2+
level: 4
3+
title: "Add ``transitionToAuth: true`` to the ``mongod`` configuration file."
4+
ref: modify-configuration
5+
source:
6+
file: steps-enable-authentication-in-shardcluster-nodowntime-transition-config.yaml
7+
ref: modify-config-files
8+
---
9+
stepnum: 2
10+
level: 4
11+
title: "Restart the ``mongod`` with the new configuration file."
12+
ref: restart-mongod
13+
source:
14+
file: steps-enable-authentication-in-shardcluster-nodowntime-transition-config.yaml
15+
ref: restart-mongod
16+
replacement:
17+
status: "new"
18+
...

0 commit comments

Comments
 (0)