Help Center> Elastic Cloud Server> Troubleshooting> Linux Issues> Configuring atop and kdump on Linux ECSs for Performance Analysis

Configuring atop and kdump on Linux ECSs for Performance Analysis

Scenarios

This section describes how to configure atop and kdump on Linux ECSs for performance analysis.

The method for configuring atop varies with ECS OS version.

atop

kdump

  1. Precautions for Configuring kdump
  2. How kdump Works
  3. Configuring kdump
  4. Checking Whether kdump Configurations Have Taken Effect

Configuring atop on CentOS 6 or RHEL 6

  1. Run the following command to download the atop package:

    # wget https://www.atoptool.nl/download/atop-2.3.0-1.el6.x86_64.rpm

  2. Run the following command to install atop:

    # rpm -ivh atop-2.3.0-1.el6.x86_64.rpm

  3. Run the following command to modify atop configuration file:

    # vi /usr/share/atop/atop.daily

    Change the value of parameter INTERVAL to, for example, 15.
    INTERVAL=15
    ( (sleep 3; find $LOGPATH -name 'atop_*' -mtime +28 -exec rm {} \;)& ) 

    Save the file and exit the editing mode.

  4. Run the following command to start atop:

    # service atop restart

  5. Run the following command to check whether atop has been started:

    # service atop status

    If atop is running properly, it will sample system performance data every 15 seconds and save the data to the /var/log/atop/ directory.

Configuring atop on CentOS 7 or EulerOS

  1. Run the following command to download the atop package:

    # wget https://www.atoptool.nl/download/atop-2.3.0-1.el7.x86_64.rpm

    Upload the atop-2.3.0-1.el7.x86_64.rpm package to the target ECS.

  2. Run the following command to install atop:

    # rpm -ivh atop-2.3.0-1.el7.x86_64.rpm

  3. Run the following command to modify atop configuration file:

    # vi /usr/share/atop/atop.daily

    Make the following changes:

    • Change the value of INTERVAL to, for example, 10 or 15. The default value of INTERVAL is 600, and the unit is second.
    • Change the value following -mtime if needed. The default retention period of atop logs is 28 days.
    INTERVAL=15
    ( (sleep 3; find $LOGPATH -name 'atop_*' -mtime +28 -exec rm {} \;)& ) 

    Save the file and exit the editing mode.

  4. Run the following command to start atop:

    # systemctl start atop

  5. Run the following command to check the status of atop:

    # systemctl status atop

    atop.service - Atop advanced performance monitor
    Loaded: loaded (/usr/lib/systemd/system/atop.service; enabled; vendor preset: disabled)
    since 2019-04-02 11:12:30 CST; 10s ago active (running)Active: 
    Docs: man:atop(1)
    Main PID: 6251 (atop)
    CGroup: /system.slice/atop.service
    └─6251 /usr/bin/atop -R -w /var/log/atop/atop_20190402 600
    
    11:12:30 ecs-242c-test-lxy2 systemd[1]: Started Atop advanced performance monitor.
    11:12:30 ecs-242c-test-lxy2 systemd[1]: Starting Atop advanced performance monitor...
    If active(running) is displayed in the output, atop is running properly.

    In this way, atop will sample system performance data every 10 or 15 seconds and save the data to the /var/log/atop/ directory.

Configuring atop on SLES 10 or SLES 11

  1. Run the following command to download the atop package:

    # wget https://www.atoptool.nl/download/atop-1.27-3.x86_64.rpm

  2. Run the following command to install the package:

    # rpm -ivh atop-1.27-3.x86_64.rpm

  3. Run the following command to modify atop configuration file:

    # vi /etc/atop/atop.daily

    • Change the value of INTERVAL to 15. After the modification takes effect, atop will sample system performance data every 15 seconds.
    • Change the value following -mtime if needed. The default retention period of atop logs is 28 days.
    INTERVAL=15
    ( (sleep 3; find $LOGPATH -name 'atop_*' -mtime +28 -exec rm {} \;)& )   
  4. Runing the following command to restart atop:

    # service atop restart

  5. Run the following command to check whether the atop process has been started and whether the modifications have taken effect:

    # ps -elf |grep atop

    If 15 is displayed in the output, the modifications have taken effect. atop will sample system performance data every 15 seconds and save the data to the /var/log/atop/ directory.

Configuring atop on SLES 12

  1. Run the following command to download the atop package:

    # wget https://www.atoptool.nl/download/atop-2.2-3.systemd.x86_64.rpm

  2. Run the following command to install the package:

    # rpm -ivh atop-2.2-3.systemd.x86_64.rpm

  3. Run the following command to modify atop configuration file:

    # vi /etc/atop/atop.daily

    • Change the value of INTERVAL to 15. After the modification takes effect, atop will sample system performance data every 15 seconds.
    • Change the value following -mtime if needed. The default retention period of atop logs is 28 days.
    INTERVAL=15
    ( (sleep 3; find $LOGPATH -name 'atop_*' -mtime +28 -exec rm {} \;)& )   
  4. Save the file and exist. Then run the following commands to restart atop and set atop to automatically run at system startup:

    # systemctl start atop

    # systemctl enable atop

  5. Run the following command to check the status of atop:

    # systemctl status atop

    ● atop.service - Atop advanced performance monitor
    Loaded: loaded (/usr/lib/systemd/system/atop.service; enabled; vendor preset: disabled)
    Active: active (running) since Thu 2019-05-16 12:34:00 CST; 1s ago
    Docs: man:atop(1)
    Main PID: 3023 (atop)
    Tasks: 3 (limit: 512)
    CGroup: /system.slice/atop.service
    ├─3023 /usr/bin/atop -a -R -w /var/log/atop/atop_20190516 600
    ├─3037 /bin/bash /etc/atop/atop.daily
    └─3039 sleep 3
    May 16 12:34:00 ecs-6a85-sles12sp2-lxy systemd[1]: Stopped Atop advanced performance monitor.
    May 16 12:34:00 ecs-6a85-sles12sp2-lxy systemd[1]: Started Atop advanced performance monitor.
  6. Run the following command to check whether the sampling interval is 15:

    # ps -elf |grep atop

    If 15 is displayed in the output, the modifications have taken effect as expected.

Precautions for Configuring kdump

The method for configuring kdump described in this section applies only to KVM ECSs running EulerOS or CentOS 7. For details, see Documentation for Kdump.

How kdump Works

kdump, short for kernel dump, is a kernel crash dumping mechanism that allows you to save the contents of the system's memory for later analysis.

As shown in the preceding figure, the physical memory RAM is divided into two parts. One part is used to run the normal kernel, and the other part is reserved for a capture kernel. After the normal kernel is booted, kdump uses kexec to load the capture kernel to the reserved memory in both user mode and kernel mode.

In case of system crash, such as die, panic, oops, or SysRq not working, the normal kernel calls the crash_kexec() function to create a /proc/vmcore file and boots the capture kernel. Then the capture kernel copies the data in the /proc/vmcore file of the normal kernel to the newly created file and reboot the normal kernel.

Configuring kdump

  1. Run the following command to check whether kexec-tools has been installed:

    # rpm -q kexec-tools

  2. If it is not installed, run the following command to install it:

    # yum install -y kexec-tools

  3. Run the following command to enable kdump to run at startup by default:

    # systemctl enable kdump

  4. Run the following command to check whether the crashkernel parameter has been configured, which is used to reserve memory for the capture kernel.

    # grep crashkernel /proc/cmdline

  5. If there is command output, this parameter has been configured. If no output is displayed, set this parameter by editing file /etc/default/grub.
    GRUB_TIMEOUT=5
    GRUB_DEFAULT=saved
    GRUB_DISABLE_SUBMENU=true
    GRUB_TERMINAL_OUTPUT="console"
    GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=rhel00/root rd.lvm.lv=rhel00/swap
    rhgb quiet"
    GRUB_DISABLE_RECOVERY="true"
  6. Locate parameter GRUB_CMDLINE_LINUX and add crashkernel=auto after it.
  7. Run the following command for the configuration to take effect:

    # grub2-mkconfig -o /boot/grub2/grub.cfg

  8. Open the /etc/kdump.conf file, locate parameter path, and add /var/crash after it.
    path  /var/crash

    By default, the file is saved in the /var/crash directory.

    You can save the file to another directory, for example, /home/kdump. Then add /home/kdump after parameter path:
    path   /home/kdump

    There must be enough space in the specified path for storing the vmcore file. It is recommended that the available space be greater than or equal to the RAM size. You can also store the vmcore file on a shared device such as SAN or NFS.

  9. Set the vmcore dump level.

    Add the following content to file /etc/kdump.conf. If these parameters exist, skip this step.

    core_collector makedumpfile -d 31 -c

    where

    -c indicates compressing the vmcore file.

    -d indicates leaving out irrelevant data. Generally, the value following -d is 31, which is calculated based on the following values. You can adjust the value if needed.

    zero pages   = 1
    cache pages   = 2
    cache private = 4
    user  pages   = 8
    free  pages   = 16
  10. Set kernel parameters.

    Some kernel parameters control that when kdump will be triggered. It is recommended that you enable all the following parameters and set them as follows:

    kernel.hardlockup_panic=1
    kernel.panic=5
    kernel.panic_on_oops=1
    kernel.softlockup_panic=1
    kernel.unknown_nmi_panic=1
    kernel.nmi_watchdog=1
  11. Modify the preceding parameters in file /etc/sysctl.conf file and save the file. In addition, you can add the following parameters to the /etc/sysctl.conf file:
    kernel.panic_on_io_nmi=1
    kernel.panic_on_warn=1
  12. Run the following command to restart the system for the configurations to take effect:

    # reboot

Checking Whether kdump Configurations Have Taken Effect

  1. Run the following command and check whether crashkernel=auto is displayed in the output:

    # cat /proc/cmdline |grep crashkernel

    BOOT_IMAGE=/boot/vmlinuz-3.10.0-514.44.5.10.h142.x86_64 root=UUID=6407d6ac-c761-43cc-a9dd-1383de3fc995 ro crash_kexec_post_notifiers softlockup_panic=1 panic=3 reserve_kbox_mem=16M nmi_watchdog=1 rd.shell=0 fsck.mode=auto fsck.repair=yes net.ifnames=0 spectre_v2=off nopti noibrs noibpb crashkernel=auto LANG=en_US.UTF-8
  2. Run the following command and check whether the values of the parameters in bold are the same as the following:

    # sysctl -a |grep panic

    kernel.hardlockup_panic = 1
    kernel.hung_task_panic = 0
    kernel.panic = 5
    kernel.panic_on_io_nmi = 0
    kernel.panic_on_oops = 1
    kernel.panic_on_stackoverflow = 0
    kernel.panic_on_unrecovered_nmi = 0
    kernel.panic_on_warn = 0
    kernel.softlockup_panic = 1
    kernel.unknown_nmi_panic = 1
    vm.panic_on_oom = 0
  3. Run the following command and check whether the configuration in the output is correct:

    # grep core_collector /etc/kdump.conf |grep -v ^"#"

    core_collector makedumpfile -l --message-level 1 -d 31
  4. Run the following command and check whether the path configuration in the output is correct:

    # grep path /etc/kdump.conf |grep -v ^"#"

    path /var/crash
  5. Run the following command and check whether the value of Active in the output is active (exited):

    # systemctl status kdump

    ● kdump.service - Crash recovery kernel arming
    Loaded: loaded (/usr/lib/systemd/system/kdump.service; enabled; vendor preset: enabled)
    Active: active (exited) since Tue 2019-04-09 19:30:24 CST; 8min ago
    Process: 495 ExecStart=/usr/bin/kdumpctl start (code=exited, status=0/SUCCESS)
    Main PID: 495 (code=exited, status=0/SUCCESS)
    CGroup: /system.slice/system-hostos.slice/kdump.service
  6. Run the following test command:

    # echo c > /proc/sysrq-trigger

    After the command is executed, kdump will be triggered, the system will be restarted, and a generated vmcore file will be saved to the path specified by path.

  7. Run the following command to check whether the vmcore file has been generated in the specified path, for example, /var/crash/:

    # ll /var/crash/