IBM Support

How to Cause the Postgres Log (pg.log) to Always Rotate at 1 GB

Troubleshooting


Problem

By default, Netezza rotates the Postgres database log (pg.log) file on a daily basis if it exceeds 1 GB. However, because this action occurs at 4 a.m., there is a chance that the file could grow from 0.9 GB to 2 GB during the workday or into the night. If it grew to exceed 2 GB which is a Linux limit, the host could become locked. You might choose to move the “logrotate” script from the cron.daily folder to the cron.hourly folder which would execute “/etc/logrotate.d/netezza” on a more frequent (hourly) basis. However this could adversely affect other Netezza component logs. 

Resolving The Problem

You can configure the Netezza system to rotate the pg.log file when it reaches 1 GB in size by doing the following:

1. Create a file called /etc/logrotatepg.conf which contains the following information:


# see "man logrotate" for details
# rotate log files weekly
weekly


# keep 4 weeks worth of backlogs
rotate 4


# create new (empty) log files after rotating old ones
create



2. Create another file called /etc/netezza.pg which contains the following information:
/nz/kit/log/postgres/pg.log {
size 1024M
rotate 28
missingok
postrotate
pkill -HUP -u nz -f postmaster 2>/dev/null || true
endscript
}



3. Using the crontab -e command, make the following entries:
59 * * * * /usr/sbin/logrotate /etc/logrotatepg.conf /etc/netezza.pg




4. Edit the /etc/logrotate.d/netezza file to remove pg.log information. (If you do not, the pg.log will rotate every time it reaches 1 GB and daily.)

[{"Product":{"code":"SSULQD","label":"IBM PureData System"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":null,"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"1.0.0","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Historical Number

NZ491892

Document Information

Modified date:
17 October 2019

UID

swg21575139