【GP常见问题】避坑系列 Ⅲ|如何在服务器上启用core generation

在程序异常或者崩溃时,cores 对于 debugging 非常有用。我们推荐大家在 master 和 segment 服务器上启用 core generation。本文将详细描述如何在 linux 系统上开启这项设置。

在操作之前,我们首先确认一下服务器上和 core 文件相关的当前设置。你可以使用以下命令来确认 core generation 是否已经被禁用。以下内容表示有效禁用了 core file generation。( core文件的大小被限制为了0, 即禁用 )

<code>gpadmin$ ulimit -a
core file size (blocks, -c) 0/<code>

启用

下面的两个步骤将启用 core file generation:

1.允许系统生成任意大小的core文件

以 root 用户打开 /etc/security/limits.d/corefiles.conf 文件( 你可能需要创建一个全新的文件 )并输入以下命令

<code># Core file size set to unlimited
gpadmin - core unlimited/<code>

保存文件并以 gpadmin 用户身份登录,并确认 soft 与 hard limit 均设置为无限制(unlimited):

<code> [root@hdp1 ~]# su - gpadmin
[gpadmin@hdp1 ~]$ ulimit -S -c
unlimited
[gpadmin@hdp1 ~]$ ulimit -H -c
unlimited/<code>

2. 定义 core file 的命名约定和位置

以 root 用户打开文件 /etc/sysctl.d/cores_sysctl.conf 并添加以下行(以下以RHEL操作系统举例)

<code>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 = /<directory>/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/<directory>/<directory>/<code>

确保您选择的位置具有权限1777。否则,gpadmin 将无法写入核心文件。

3. 加载上面添加的位置

<code>使用以下命令加载配置文件:/<code>
<code>[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 ~]# /<code>

验证

使用以下命令验证配置是否已经生效:

<code>[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/<code>

注意:Greenplum 数据库需要重新启动,以确保这些更改有效。另外,在操作系统上,还需要重新登录一次以确保当前会话获取配置中的更改。

重新启动 Greenplum 后,此命令将有助于验证 Greenplum 进程的运行限制:

<code>cat /proc/$(pgrep -f silent)/limits/<code>

大家在使用过程中遇到问题,欢迎前往 ask.greenplum.cn 提问。




分享到:


相關文章: