The core dump feature allows the operating system to store the current memory status of a program to a file when the program terminates abnormally.
The Linux operating system generates a core dump file to store the memory status when a process terminates abnormally because of the default action of certain signals.
The signals whose Action is Core in the following figure can cause the Linux operating system to generate core dump files.
Use the core dump feature in ECI
Before Elastic Container Instance (ECI) allows you to specify the naming rule and storage location of core dump files, you cannot customize such information because virtual machines (VMs) used by ECI are managed by Alibaba Cloud.
The core dump files are generated based on the default naming rule and stored in the default location.
/ # cd /pod/ /pod # ls data /pod # ping www.aliyun.com PING www.aliyun.com (220.127.116.11): 56 data bytes 64 bytes from 18.104.22.168: seq=0 ttl=47 time=25.496 ms 64 bytes from 22.214.171.124: seq=1 ttl=47 time=25.510 ms 64 bytes from 126.96.36.199: seq=2 ttl=47 time=25.640 ms 64 bytes from 188.8.131.52: seq=3 ttl=47 time=25.507 ms ^\Quit (core dumped) /pod # ls core.45 data /pod #
As shown in the preceding command output, the core dump file is named in the core.Process ID format and stored in the working directory of the pod. When an ECI is released, its core dump files are deleted. In this case, you cannot obtain and analyze the generated the core dump files.
CorePattern = "/xx/xx/core"
Alternatively, you can use an annotation to specify such information in a YAML configuration file of Kubernetes:
annotations: k8s.aliyun.com/eci-core-pattern: "/xx/xx/core"
'Volume.1.Name': 'default-volume1', 'Volume.1.Type': 'NFSVolume', 'Volume.1.NFSVolume.Path': '/dump/', 'Volume.1.NFSVolume.Server': '143b24822a-gfn3.cn-beijing.nas.aliyuncs.com', 'Container.1.VolumeMount.1.Name': 'default-volume1', 'Container.1.VolumeMount.1.MountPath': '/pod/data/dump/', 'CorePattern':'/pod/data/dump/core-eci',
Based on the preceding configuration, the nfs volume is mounted to the /pod/data/dump/ directory of the ECI and the directory for storing core dump files is set to /pod/data/dump/core. In this way, all core dump files generated by the ECI are stored in the /pod/data/dump/ directory and synchronized to the nfs volume. The core dump files are not deleted when the ECI is released. You can still obtain and analyze these core dump files after the ECI is released.
1. Trigger a core dump in a directory of the ECI:
/ # ls bin dev etc home pod proc root sys tmp usr var / # ping www.aliyun.com PING www.aliyun.com (184.108.40.206): 56 data bytes 64 bytes from 220.127.116.11: seq=0 ttl=47 time=26.351 ms 64 bytes from 18.104.22.168: seq=1 ttl=47 time=26.395 ms 64 bytes from 22.214.171.124: seq=2 ttl=47 time=26.366 ms 64 bytes from 126.96.36.199: seq=3 ttl=47 time=26.378 ms 64 bytes from 188.8.131.52: seq=4 ttl=47 time=26.357 ms ^\Quit (core dumped) / # ls bin dev etc home pod proc root sys tmp usr var / # cd /pod/data/dump/ /pod/data/dump # ls core-eci.12
Based on the preceding command output, the naming rule and directory of core dump files take effect as expected.
/ # cd /pod/data/dump/ /pod/data/dump # ls core-eci.12
The core dump file is not deleted with the released ECI. In this case, you can use the core dump file for offline analysis.
For more information about the core dump feature, see http://man7.org/linux/man-pages/man5/core.5.html.