Configuring Core Dumps
Learn how to configure core dumps to troubleshoot system crashes and application failures effectively.
Table of Contents
Date: 01-26-2016, updated 7/29/2024
If slapd ever crashes, it's useful to have the server save a core dump file that can be used later to analyze the cause of the crash. Core dump files contain a snapshot of all the in-memory data of slapd at the time of the crash. By default, most Linux systems don't create core dump files for slapd, but it's relatively easy to enable them.
Remove Core Dump File Size Limits
Core files will be equal in size to the amount of memory slapd is using at the time the core file is created. The default core file size limits in systemd prevent the creation of core files for slapd (DefaultLimitCORE=0:infinity
in /etc/systemd/system.conf
).
To relax these limits for slapd:
1. Check for the file /etc/systemd/system/symas-openldap-servers.service.d/override.conf
ls /etc/systemd/system/symas-openldap-servers.service.d/override.conf
2. If the file does not exist, create it.
touch /etc/systemd/system/symas-openldap-servers.service.d/override.conf
3. Add LimitCORE=infinity
under the [Service]
heading in the file and save.
vi /etc/systemd/system/symas-openldap-servers.service.d/override.conf
[Service]
LimitCORE=infinity
4. Reload the systemd daemons with:
systemctl daemon-reload
5. Restart slapd with:
systemctl restart slapd
Change Core Dump File Location
The default location for core dump files when using systemd is /var/lib/systemd/coredump
. Depending on how your system is configured, the /var
directory may not have sufficient space to store a core file. If the core file is larger than the space available in /var
, the core file will be truncated and will be unusable for analysis and may fill the disk partition that /var
is mounted on, causing further issues.
To avoid this, it is recommended to compare the amount of available space in /var
with the maximum possible size of the ldap database:
To get the available space in /var
run:
df -h /var
Get the maxsize or olcDbMaxsize setting in your slapd configuration. The value of this setting is in bytes, so use the formula maxsize/1,000,000,000
to get the database size in gigabytes.
Compare the two values. If the maximum database size is larger that the available space in /var
, you'll need to change the core dump file location using the following steps.
1. Find a directory with enough available space using:
df -h
2. Create a directory in a location with enough space with:
mkdir -p /<path>/core
3. Modify the kernel.core_pattern system setting with the new path:
a. To temporarily set the core pattern:
echo "/tmp/core/%e_%t_%s" > /proc/sys/kernel/core_pattern
This setting will take immediate effect and remain until the server is rebooted.
b. To permanently set the core pattern, replace the kernel.core_pattern
setting in /usr/lib/sysctl.d/50-coredump.conf
with:
kernel.core_pattern=/tmp/core/%e_%t_%s
For this setting to take effect the server must be rebooted.
Note: Due to a limitation in systemd, changing the core pattern will prevent the core dump event from being seen in the coredumpctl utility, however the core file will still be present.
Update slapd User Dump Permission
If the slapd daemon is run by a user other than root, the system needs to be configured to allow core dumps from non-root users. To allow core dumps from non-root users, the fs.suid_dumpable
system setting needs to be updated to a value of 2
.
The system setting must be changed if:
-
OpenLDAP 2.5/6: The file
/etc/default/symas-openldap
is present and theSLAPD_OPTIONS
setting is present and has “-u <user>” and “-g <group>” set to non-root users. -
OpenLDAP 2.4: Check the file
/opt/symas/etc/openldap/symas-openldap.conf
. If the SLAPD_USER and SLAPD_GROUP settings are non-root users, or theEXTRA_SLAPD_ARGS
setting contains “-u <user> -g <group>” with non-root users.
To change the setting temporarily (the setting will immediately take effect and will not persist across reboots):
echo “2” > /proc/sys/fs/suid_dumpable
To change the setting permanently (requires a server reboot to take effect):
Add/set in /etc/sysctl.conf
:
fs.suid_dumpable=2
Reboot the server.
Update abrt Settings
In Red Hat Enterprise Linux and possibly some RHEL variants like CentOS, Rocky, etc. Linux, core dumps may be handled by the Automated Bug Reporting Tool (abrt
) and requires additional configuration.
Check if abrt
is installed with:
dnf list available | grep abrt
or
yum list installed | grep abrt
If abrt
is installed, set the following in /etc/abrt/abrt-action-save-package-data.conf
:
OpenGPGCheck=no
ProcessUnpackaged=no
For servers running Red Hat Enterprise Linux, additional configuration may be necessary. See this Red Hat documentation for more information.
Testing Core Dump Creation
Once configuration is complete, you can test core dump creation by killing the slapd process with kill signals 6 (SIGABRT
) or 11 (SIGSEGV
):
kill -6 $(pidof slapd)
kill -11 $(pidof slapd)
If the core pattern has not changed you can use:
coredumpctl -l
to check for detailed information on the core dump.
If the core pattern has been changed, check the directory set in the core pattern for the presence of the core file.