在程序异常或者崩溃时,cores对于debugging很是有用。咱们推荐你们在master和segment服务器上启用core generation。本文将详细描述如何在linux系统上开启这项设置。node
在操做以前,咱们首先确认一下服务器上和core文件相关的当前设置。你可使用如下命令来确认core generation是否已经被禁用。如下内容表示有效禁用了core file generation。 (core文件的大小被限制为了0, 即禁用)linux
gpadmin$ ulimit -a core file size (blocks, -c) 0
下面的两个步骤将启用core file generation:数据库
1.容许系统生成任意大小的core文件服务器
以root用户打开 /etc/security/limits.d/corefiles.conf 文件(你可能须要建立一个全新的文件)并输入如下命令app
# Core file size set to unlimited gpadmin - core unlimited
保存文件并以gpadmin用户身份登陆,并确认soft与hard limit均设置为无限制(unlimited):spa
[root@hdp1 ~]# su - gpadmin [gpadmin@hdp1 ~]$ ulimit -S -c unlimited [gpadmin@hdp1 ~]$ ulimit -H -c unlimited
2. 定义core file的命名约定和位置操作系统
以root用户打开文件/etc/sysctl.d/cores_sysctl.conf并添加如下行(如下以RHEL操做系统举例)debug
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
确保您选择的位置具备权限1777。不然,gpadmin将没法写入核心文件。code
3. 加载上面添加的位置orm
使用如下命令加载配置文件:
[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 ~]#
4. 验证
使用如下命令验证配置是否已经生效:
[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
注意:Greenplum数据库须要从新启动,以确保这些更改有效。另外, 在操做系统上, 还须要从新登陆一次以确保当前会话获取配置中的更改。
从新启动Greenplum后,此命令将有助于验证Greenplum 进程的运行限制:
cat /proc/$(pgrep -f silent)/limits
你们在使用过程当中遇到问题,欢迎前往ask.greenplum.cn提问。
得到更多关于Greenpum的技术干货,请访问Greenplum中文社区网。