Introduction to PostgreSQL log files

PG10.x name change

xlog                                wal                         
location                            lsn
pg_xlog_location_diff               pg_wal_lsn_diff 
pg_current_xlog_location            pg_current_wal_lsn 
pg_current_xlog_insert_location     pg_current_wal_insert_lsn
  • pg_log

This log generally records the status of the server and DB, such as various Error information, positioning slow query SQL, database startup and shutdown information, and alarm information such as frequent checkpoints, and so on. The path that comes with Linux is generally under /var/log/postgres. The log is available in .csv format and .log. I personally recommend the former one, because it is generally automatically cut by size and time. After all, it is much harder to view a huge log file than to view multiple logs of different time periods. In addition, this kind of log can be cleaned and deleted, compressed, packaged or transferred without affecting the normal operation of the DB. When we encounter that the DB cannot be started or the parameter changes do not take effect, the first thing that comes to our mind is to check this log.

  • pg_xlog

    This log is the recorded WAL information of Postgresql, that is, some transaction log information (transaction log). The default single size is 16M, and its size can be changed when the source code is installed. This information is usually named as a file like '000000010000000000000013'. These logs will be used during PITR, Replication Stream and archiving. These logs are very important and record database occurrences. Do not delete or move such log files at will, otherwise your database will be at risk of being unrecoverable.
    When your archiving or streaming replication is abnormal, transaction logs will be continuously generated, which may cause you The disk space is full, eventually causing the DB to hang or fail to get up. In this case, don't panic, you can turn off the archive or streaming replication function first, and back up the pg_xlog log to other places, but please do not delete it. Then delete the pg_xlog of the earlier time, and try to start Postgres when there is a certain space.

  • pg_clog

    The pg_clog file is also a transaction log file, but unlike pg_xlog, it records the metadata of the transaction. This log tells us which transactions are completed and which are not completed. This log file is generally very small, but its importance is quite high, and should not be deleted or changed at will.

Summary
pg_log records various error information, as well as the status information of the server and DB. Users can update and delete
pg_xlog and pg_clog to record the transaction information of the database at will. Do not delete and update at will. Remember to back up two logs when doing physical backup.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325626783&siteId=291194637