Cores are useful for debugging when a program fails or crashes. We recommend that you enable Core Generation on master and Segment servers. This article describes in detail how to enable this setting on a Linux system.

Before doing this, let’s first confirm the current Settings on the server related to the core files. You can use the following command to verify that Core Generation has been disabled. The following indicates that core File Generation is effectively disabled. (Core file size is limited to 0, i.e. disabled)

gpadmin$ ulimit -a
core file size (blocks, -c) 0
Copy the code

The following two steps will enable Core File Generation:

1. Allow the system to generate core files of any size

The root user to turn on/etc/security/limits. D/corefiles. Conf file (you may need to create a new file) and enter the following command

# Core file size set to unlimited
 gpadmin - core unlimited
Copy the code

Save the file and log in as user gpadmin. Make sure soft and Hard limit are set to Unlimited:

 [root@hdp1 ~]# su - gpadmin
 [gpadmin@hdp1 ~]$ ulimit -S -c
 unlimited
 [gpadmin@hdp1 ~]$ ulimit -H -c
 unlimited
Copy the code

2. Define the naming convention and location of core file

Open the /etc/sysctl.d/cores_sysctl.conf file as the root user and add the following lines (the following uses RHEL as an example) :

kernel.core_uses_pid = 1
kernel.core_pattern = /<directory>/core-%e-%s-%u-%g-%p-%t {Choose the directory where you want to place the core files, their size may range in GB's, so choose it appropriately} where: kernel.core_uses_pid = 1 - Appends the coring processes PID to the core file name. kernel.core_pattern = /
      
       /core-%e-%s-%u-%g-%p-%t - When the application terminates abnormally, a core file should appear in the /tmp. The kernel.core_pattern sysctl controls exact location of core file. You can define the core file name with the following template whih can contain % specifiers which are substituted by the following values when a core file is created: %% - A single % character %p - PID of dumped process %u - real UID of dumped process %g - real GID of dumped process %s - number of signal causing dump %t - time of dump (seconds since 0:00h, 1 Jan 1970) % H-hostname (same as' nodename 'returned by uname(2)) % E-executable filename
      Copy the code

Make sure the location you select has permission 1777. Otherwise, gpadmin will not be able to write to the core file.

3. Load the locations added above

Use the following command to load the configuration file:

[root@hdp1 ~]# sysctl -p /etc/sysctl.d/cores_sysctl.conf
 kernel.core_uses_pid = 1
 kernel.core_pattern = /var/crash/user/core-%e-%s-%u-%g-%p-%t
 [root@hdp1 ~]# 
Copy the code

4. Verify

Run the following command to verify that the configuration has taken effect:

[root@hdp1 ~]# sysctl kernel.core_pattern
kernel.core_pattern = /var/crash/user/core-%e-%s-%u-%g-%p-%t
[root@hdp1 ~]# sysctl kernel.core_uses_pid
kernel.core_uses_pid = 1
Copy the code

Note: The Greenplum database needs to be restarted to ensure that these changes are valid. Also, on the operating system, you need to log in again to ensure that the current session gets the changes in the configuration.

After restarting Greenplum, this command will help verify the running limits of the Greenplum process:

cat /proc/$(pgrep -f silent)/limits
Copy the code

If you have any questions, please go to ask.greenplum.

For more technical know-how on Greenpum, please visit Greenplum’s Chinese community website.