Skip to content

Commit 9c78931

Browse files
author
Dave Cuthbert
authored
DOCS-11500 BACKPORT (#1712)
1 parent 0f9d5c4 commit 9c78931

File tree

1 file changed

+93
-3
lines changed

1 file changed

+93
-3
lines changed

source/tutorial/control-access-to-mongodb-with-kerberos-authentication.txt

Lines changed: 93 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,102 @@ control the :binary:`~bin.mongod` instance, you can set the ``KRB5_KTNAME``
7878
variable in the default environment settings file instead of setting
7979
the variable each time.
8080

81-
For ``.rpm`` packages, the default environment settings file is
81+
Recent versions of Red Hat and Debian-based systems use ``systemd``.
82+
Older versions use ``init`` for system initialization. Follow the
83+
appropriate instructions to configure the ``KRB5_KTNAME`` variable for
84+
your system.
85+
86+
``systemd`` Configuration Files
87+
```````````````````````````````
88+
89+
``systemd`` stores configuration in unit files. Update the unit file to
90+
set the ``KRB5_KTNAME`` variable.
91+
92+
.. procedure::
93+
:style: normal
94+
95+
.. step:: Find the unit file
96+
97+
.. code-block:: shell
98+
99+
sudo systemctl cat mongod
100+
101+
The ``systemctl`` command returns the file location and displays its
102+
contents.
103+
104+
.. step:: Set ``KRB5_KTNAME``
105+
106+
To set the ``KRB5_KTNAME`` variable, edit the following line to reflect
107+
the location of your ``keytab`` file:
108+
109+
.. code-block:: shell
110+
111+
Environment="KRB5_KTNAME=<path-to-your-mongod.keytab-file>"
112+
113+
.. step:: Edit the unit file
114+
115+
Add the edited line to the unit file. The edited unit file will
116+
resemble:
117+
118+
.. code-block:: shell
119+
:copyable: false
120+
:emphasize-lines: 9
121+
122+
[Unit]
123+
Description=High-performance, schema-free document-oriented database
124+
After=network.target
125+
Documentation=https://docs.mongodb.org/manual
126+
127+
[Service]
128+
User=mongodb
129+
Group=mongodb
130+
ExecStart=/usr/bin/mongod --config /etc/mongod.conf
131+
Environment="KRB5_KTNAME=/etc/mongod.keytab"
132+
PIDFile=/var/run/mongodb/mongod.pid
133+
# file size
134+
LimitFSIZE=infinity
135+
# cpu time
136+
LimitCPU=infinity
137+
# virtual memory size
138+
LimitAS=infinity
139+
# open files
140+
LimitNOFILE=64000
141+
# processes/threads
142+
LimitNPROC=64000
143+
# locked memory
144+
LimitMEMLOCK=infinity
145+
# total threads (user+kernel)
146+
TasksMax=infinity
147+
TasksAccounting=false
148+
149+
# Recommended limits for for mongod as specified in
150+
# http://docs.mongodb.org/manual/reference/ulimit/#recommended-settings
151+
152+
[Install]
153+
WantedBy=multi-user.target
154+
155+
.. step:: Reload the updated unit file:
156+
157+
.. code-block:: shell
158+
159+
sudo systemctl daemon-reload
160+
161+
.. step:: Restart the :binary:`mongod` service
162+
163+
.. code-block:: shell
164+
165+
sudo systemctl restart mongod
166+
167+
``init`` Configuration Files
168+
````````````````````````````
169+
170+
For ``.rpm`` installations, the default environment settings file is
82171
:file:`/etc/sysconfig/mongod`.
83172

84-
For ``.deb`` packages, the file is :file:`/etc/default/mongodb`.
173+
For ``.deb`` installations, the file is :file:`/etc/default/mongodb`.
85174

86-
Set the ``KRB5_KTNAME`` value in a line that resembles the following:
175+
Set the ``KRB5_KTNAME`` value by adding a line that resembles the
176+
following:
87177

88178
.. code-block:: javascript
89179

0 commit comments

Comments
 (0)