We’ll discuss the configuration of kdump on an Oracle Linux server.All steps and procedures explained and performed are based on Oracle Linux release 7.
What is kdump?
Kdump is the crash dump mechanism of the Linux kernel
which allows us to save the system memory contents for analysis. Oracle
recommends that you enable the kdump feature as it helps Oracle Linux
support to find the root cause whenever a server panics or crashes.
To help identify the cause of the crash in case of a system failure,
a memory image called the vmcore is created by kdump. An exclusive system
memory portion will be requisite for kdump to be enabled. Being exclusive, this
memory is not available for other purposes. Kdump utilizes kexec to boot
to a second kernel whenever the system crashes.
What is kexec?
Kexec is a quick boot mechanism that allows the Linux kernel
to boot from within a kernel context that is already running without going
through the bootloader stage.
Pre-requisites for kdump are:
- That the kexec-tools package be installed on the server.
- And a certain amount of memory be reserved for kdump. This is for kexec to boot in to the secondary kernel.
- And a path be specified for the memory dump to be stored and it should have sufficient free space.
It is also necessary that the kdump service be running.
kdump mainly uses 3 files; the grub configuration file.
This is where we specify the crash kernel parameter to reserve memory for kdump.
Next the /etc/kdump.conf file, which is the kdump configuration file. This is
where we set the location for storing the dump file and also the core
collector filtering level that will be the make dumpfile command.
And the default behavior to take if the dump fails. And it
also relies on the kdump initramfs file, which will be present
under the /boot directory.
Let's go through a quick demo on how to configure kdump and
generate a dump from it.
Firstly, we need to make sure that the kexec-tools package
is installed on the server. As it is not installed, so let's go ahead and do the installation
first. Now the package is installed.
Next we have to verify the crashkernel parameter in
the grub configuration file. This is done via the /etc/default/grub file,
since we are using grub2. Here we set the crashkernel parameter
and reserve a certain amount of memory for kdump.
The value for crashkernel can be either auto or a
specific amount of memory. We can see that it is set to 256M at an offset of
64M on the server. For larger servers with higher amount of physical memory,
for example 128GB of physical memory, it is recommended to set
crashkernel to 512M. And similarly, for even larger servers, a higher amount of
memory needs to be reserved for kdump.
Once the crashkernel parameter is added to the
/etc/default/grub file, the grub configuration file needs to be rebuilt. For
that, we use the grub2-mkconfig command. The grub entries for
each installed kernel was updated.
Let's see the grub configuration file. We see that the
crashkernel parameter was added to the kernel entries in the grub configuration
file. Once the grub configuration is updated, the server needs to be rebooted
for the changes to take effect. I have already rebooted the server previously. Next,
we have to configure kdump service, which is done via the /etc/kdump.conf
file.
Here we see that the path parameter is set to /var/crash.
This is the default path. This is used to specify the location for the memory
dump to be stored. It is essential that the location have sufficient space.
Next the core collector needs to be configured and we’ll be
using makedumpfile as our core collector. The -d option is for the dump_level
parameter. Dump level specifies the unnecessary pages for analysis.
These pages are not copied to the memory dump. The message_level parameter is for
setting the message types that need to be collected.
Users can restrict outputs printed by setting the message
level. Default value for message level is 7. Here we are setting it to 1.
After making changes to the kdump configuration file, the
kdump service needs to be restarted. While restarting the kdump service, the initramfs
file is rebuilt to update the changes. It will be present under the /boot
directory. Let's see the file.
The kdump initramfs file is generated. To ensure that
the kdump configuration is proper and a vmcore will be generated when the
server crashes, we can trigger a manual crash of the server and verify that the
dump is being generated.
This is done by echoing the 'c' character to the / proc /
sysrq-trigger file. Sysrq is a magic key, and these keys are a combination of
keys that can be pressed, and no matter what else it does, the kernel can
respond to it unless it is absolutely locked.
Echoing a character 'c' to the sysrq-trigger file causes the
server to crash by a null pointer dereference. Before triggering
a crash, make sure that a downtime is available for the activity
in case the server is a live production system.
Let's crash the server. Now we are in the serial console
of the server. We can see that the dump is being collected and that is has
completed collecting it. Once the dump is collected the server goes for a normal
reboot. The time required to collect the dump varies based on the amount of
memory that needs to be dumped.
Now the system is rebooting and it is up now. Let's check
the path where we had configured the dump to be collected. Check under /var/crash.
We see that a directory with timestamp was created. There are two files under
it, that is the vmcore file and the vmcore-dmesg file.
We find that it is a data file. And the size is considerably
small as the server has only 4GB of memory. So the kdump configuration
was successful and a memory dump is generated. In case the server
crashed at any time, we can be sure that the vmcore will be
generated.
Ending Comment:
You can upload the vmcore file to Oracle
support for analysis. Some useful links and few ‘my oracle support
knowledge documents’ can be accessed by logging in to support.oracle.com. Please go through them for more information on kdump and
known issues.

Comments
Post a Comment
Please do not add any spam link in the comment box.