在程序異常或者崩潰時,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中文社區網。