Blame doc/admin/dbtypes.rst

Packit fd8b60
Database types
Packit fd8b60
==============
Packit fd8b60
Packit fd8b60
A Kerberos database can be implemented with one of three built-in
Packit fd8b60
database providers, called KDB modules.  Software which incorporates
Packit fd8b60
the MIT krb5 KDC may also provide its own KDB module.  The following
Packit fd8b60
subsections describe the three built-in KDB modules and the
Packit fd8b60
configuration specific to them.
Packit fd8b60
Packit fd8b60
The database type can be configured with the **db_library** variable
Packit fd8b60
in the :ref:`dbmodules` subsection for the realm.  For example::
Packit fd8b60
Packit fd8b60
    [dbmodules]
Packit fd8b60
        ATHENA.MIT.EDU = {
Packit fd8b60
            db_library = db2
Packit fd8b60
        }
Packit fd8b60
Packit fd8b60
If the ``ATHENA.MIT.EDU`` realm subsection contains a
Packit fd8b60
**database_module** setting, then the subsection within
Packit fd8b60
``[dbmodules]`` should use that name instead of ``ATHENA.MIT.EDU``.
Packit fd8b60
Packit fd8b60
To transition from one database type to another, stop the
Packit fd8b60
:ref:`kadmind(8)` service, use ``kdb5_util dump`` to create a dump
Packit fd8b60
file, change the **db_library** value and set any appropriate
Packit fd8b60
configuration for the new database type, and use ``kdb5_util load`` to
Packit fd8b60
create and populate the new database.  If the new database type is
Packit fd8b60
LDAP, create the new database using ``kdb5_ldap_util`` and populate it
Packit fd8b60
from the dump file using ``kdb5_util load -update``.  Then restart the
Packit fd8b60
:ref:`krb5kdc(8)` and :ref:`kadmind(8)` services.
Packit fd8b60
Packit fd8b60
Packit fd8b60
Berkeley database module (db2)
Packit fd8b60
------------------------------
Packit fd8b60
Packit fd8b60
The default KDB module is ``db2``, which uses a version of the
Packit fd8b60
Berkeley DB library.  It creates four files based on the database
Packit fd8b60
pathname.  If the pathname ends with ``principal`` then the four files
Packit fd8b60
are:
Packit fd8b60
Packit fd8b60
* ``principal``, containing principal entry data
Packit fd8b60
* ``principal.ok``, a lock file for the principal database
Packit fd8b60
* ``principal.kadm5``, containing policy object data
Packit fd8b60
* ``principal.kadm5.lock``, a lock file for the policy database
Packit fd8b60
Packit fd8b60
For large databases, the :ref:`kdb5_util(8)` **dump** command (perhaps
Packit fd8b60
invoked by :ref:`kprop(8)` or by :ref:`kadmind(8)` for incremental
Packit fd8b60
propagation) may cause :ref:`krb5kdc(8)` to stop for a noticeable
Packit fd8b60
period of time while it iterates over the database.  This delay can be
Packit fd8b60
avoided by disabling account lockout features so that the KDC does not
Packit fd8b60
perform database writes (see :ref:`disable_lockout`).  Alternatively,
Packit fd8b60
a slower form of iteration can be enabled by setting the
Packit fd8b60
**unlockiter** variable to ``true``.  For example::
Packit fd8b60
Packit fd8b60
    [dbmodules]
Packit fd8b60
        ATHENA.MIT.EDU = {
Packit fd8b60
            db_library = db2
Packit fd8b60
            unlockiter = true
Packit fd8b60
        }
Packit fd8b60
Packit fd8b60
In rare cases, a power failure or other unclean system shutdown may
Packit fd8b60
cause inconsistencies in the internal pointers within a database file,
Packit fd8b60
such that ``kdb5_util dump`` cannot retrieve all principal entries in
Packit fd8b60
the database.  In this situation, it may be possible to retrieve all
Packit fd8b60
of the principal data by running ``kdb5_util dump -recurse`` to
Packit fd8b60
iterate over the database using the tree pointers instead of the
Packit fd8b60
iteration pointers.  Running ``kdb5_util dump -rev`` to iterate over
Packit fd8b60
the database backwards may also retrieve some of the data which is not
Packit fd8b60
retrieved by a normal dump operation.
Packit fd8b60
Packit fd8b60
Packit fd8b60
Lightning Memory-Mapped Database module (klmdb)
Packit fd8b60
-----------------------------------------------
Packit fd8b60
Packit fd8b60
The klmdb module was added in release 1.17.  It uses the LMDB library,
Packit fd8b60
and may offer better performance and reliability than the db2 module.
Packit fd8b60
It creates four files based on the database pathname.  If the pathname
Packit fd8b60
ends with ``principal``, then the four files are:
Packit fd8b60
Packit fd8b60
* ``principal.mdb``, containing policy object data and most principal
Packit fd8b60
  entry data
Packit fd8b60
* ``principal.mdb-lock``, a lock file for the primary database
Packit fd8b60
* ``principal.lockout.mdb``, containing the account lockout attributes
Packit fd8b60
  (last successful authentication time, last failed authentication
Packit fd8b60
  time, and number of failed attempts) for each principal entry
Packit fd8b60
* ``principal.lockout.mdb-lock``, a lock file for the lockout database
Packit fd8b60
Packit fd8b60
Separating out the lockout attributes ensures that the KDC will never
Packit fd8b60
block on an administrative operation such as a database dump or load.
Packit fd8b60
It also allows the KDC to operate without write access to the primary
Packit fd8b60
database.  If both account lockout features are disabled (see
Packit fd8b60
:ref:`disable_lockout`), the lockout database files will be created
Packit fd8b60
but will not subsequently be opened, and the account lockout
Packit fd8b60
attributes will always have zero values.
Packit fd8b60
Packit fd8b60
Because LMDB creates a memory map to the database files, it requires a
Packit fd8b60
configured memory map size which also determines the maximum size of
Packit fd8b60
the database.  This size is applied equally to the two databases, so
Packit fd8b60
twice the configured size will be consumed in the process address
Packit fd8b60
space; this is primarily a limitation on 32-bit platforms.  The
Packit fd8b60
default value of 128 megabytes should be sufficient for several
Packit fd8b60
hundred thousand principal entries.  If the limit is reached, kadmin
Packit fd8b60
operations will fail and the error message "Environment mapsize limit
Packit fd8b60
reached" will appear in the kadmind log file.  In this case, the
Packit fd8b60
**mapsize** variable can be used to increase the map size.  The
Packit fd8b60
following example sets the map size to 512 megabytes::
Packit fd8b60
Packit fd8b60
    [dbmodules]
Packit fd8b60
        ATHENA.MIT.EDU = {
Packit fd8b60
            db_library = klmdb
Packit fd8b60
            mapsize = 512
Packit fd8b60
        }
Packit fd8b60
Packit fd8b60
LMDB has a configurable maximum number of readers.  The default value
Packit fd8b60
of 128 should be sufficient for most deployments.  If you are going to
Packit fd8b60
use a large number of KDC worker processes, it may be necessary to set
Packit fd8b60
the **max_readers** variable to a larger number.
Packit fd8b60
Packit fd8b60
By default, LMDB synchronizes database files to disk after each write
Packit fd8b60
transaction to ensure durability in the case of an unclean system
Packit fd8b60
shutdown.  The klmdb module always turns synchronization off for the
Packit fd8b60
lockout database to ensure reasonable KDC performance, but leaves it
Packit fd8b60
on for the primary database.  If high throughput for administrative
Packit fd8b60
operations (including password changes) is required, the **nosync**
Packit fd8b60
variable can be set to "true" to disable synchronization for the
Packit fd8b60
primary database.
Packit fd8b60
Packit fd8b60
The klmdb module does not support explicit locking with the
Packit fd8b60
:ref:`kadmin(1)` **lock** command.
Packit fd8b60
Packit fd8b60
Packit fd8b60
LDAP module (kldap)
Packit fd8b60
-------------------
Packit fd8b60
Packit fd8b60
The kldap module stores principal and policy data using an LDAP
Packit fd8b60
server.  To use it you must configure an LDAP server to use the
Packit fd8b60
Kerberos schema.  See :ref:`conf_ldap` for details.
Packit fd8b60
Packit fd8b60
Because :ref:`krb5kdc(8)` is single-threaded, latency in LDAP database
Packit fd8b60
accesses may limit KDC operation throughput.  If the LDAP server is
Packit fd8b60
located on the same server host as the KDC and accessed through an
Packit fd8b60
``ldapi://`` URL, latency should be minimal.  If this is not possible,
Packit fd8b60
consider starting multiple KDC worker processes with the
Packit fd8b60
:ref:`krb5kdc(8)` **-w** option to enable concurrent processing of KDC
Packit fd8b60
requests.
Packit fd8b60
Packit fd8b60
The kldap module does not support explicit locking with the
Packit fd8b60
:ref:`kadmin(1)` **lock** command.