Pivotal Knowledge Base

Follow

How to Rotate the Database Logs when Greenplum is Running

Environment

Pivotal Greenplum Database () all versionGPDBs

Purpose

This article provides provide information to help rotate the logfile when the database is up and running.

Note- Please verify the script on a test cluster , before running it on production .

Procedure

Function "pg_rotate_logfile" is a handy little tool to rotate the database log when the database is up and running.

Below example helps you understand the function "pg_rotate_logfile" in practice.

  • Check the current log in the directory
flightdata=# select pg_ls_dir('pg_log') order by 1 desc;
     
             pg_ls_dir
    ----------------------------
     startup.log
     gp_era
     gpdb-2013-04-22_131246.csv
     gpdb-2013-04-22_000000.csv
[.....]
[.....]
  • Use pg_rotate_logfile to switch logfile and write to a new logfile
flightdata=#  select pg_rotate_logfile();
     pg_rotate_logfile
    -------------------
     t
    (1 row)
  • Rechecking the current log in the directory using "pg_ls_dir"
flightdata=# select pg_ls_dir('pg_log') order by 1 desc;
             pg_ls_dir
    ----------------------------
     startup.log
     gp_era
     gpdb-2013-04-22_131722.csv
     gpdb-2013-04-22_131246.csv
     gpdb-2013-04-22_000000.csv
[.....]
[.....]

Alternatively you can use/tune parameter "log_rotation_size" to rotate the logfile when they reach a certain size , by default the size is zero which means all the contents remain on a single file.

Comments

Powered by Zendesk