PostgreSQL 日志详解

文章详细介绍了PostgreSQL的三种日志:pg_log(数据库运行日志)、pg_xlog(WAL日志,重做日志)和pg_clog(事务提交日志)。pg_log用于记录错误信息、慢查询和状态变化,可自定义路径和文件名。pg_xlog是重要的事务日志,用于PITR和流复制,不应随意删除。pg_clog存储事务元数据。文章还提及了日志管理和磁盘空间管理的重要性。

一、PostgreSQL有3种日志: 

1)pg_log(数据库运行日志)   内容可读    默认关闭的,需要设置参数启动 

2)pg_xlog(WAL 日志,即重做日志)    内容一般不具有可读性        强制开启  ->wal

3)pg_clog(事务提交日志,记录的是事务的元数据)  内容一般不具有可读性    强制开启 

pg_xlog和pg_clog一般是在$PGDATA/下面的文件夹下,pg_log默认路径是$PGDATA/pg_log,通常可自定义路径和文件名 

[root@pg ~]# cd /home/pgsql/9.1/data/ 

You have mail in /var/spool/mail/root 

[root@pg data]# ll 

total 460 

drwx------ 19 postgres postgres   4096 Nov 27 17:58 base 

drwx------  2 postgres postgres   4096 Jan 13 18:58 global 

drwx------  2 postgres postgres   4096 Jan 14 02:36 pg_clog     --clog 

-rw-------  1 postgres postgres   3513 Dec  4 09:36 pg_hba.conf 

-rw-------  1 postgres postgres   1636 Mar 31  2015 pg_ident.conf 

drwx------  2 postgres postgres   4096 Jan 14 04:35 pg_log         --log 

drwx------  4 postgres postgres   4096 Mar 31  2015 pg_multixact 

drwx------  2 postgres postgres   4096 Dec 10 10:37 pg_notify 

drwx------  2 postgres postgres   4096 Mar 31  2015 pg_serial 

drwx------  2 postgres postgres   4096 Jan 14 10:23 pg_stat_tmp 

drwx------  2 postgres postgres  20480 Jan 14 09:56 pg_subtrans 

drwx------  3 postgres postgres   4096 Mar 31  2015 pg_tblspc 

drwx------  2 postgres postgres   4096 Mar 31  2015 pg_twophase 

-rw-------  1 postgres postgres      4 Mar 31  2015 PG_VERSION 

drwx------  3 postgres postgres 360448 Jan 14 10:17 pg_xlog     --xlog 

-rw-------  1 postgres postgres  19278 Jan  7 11:13 postgresql.conf 

-rw-------  1 postgres postgres     56 Dec  4 09:39 postmaster.opts 

-rw-------  1 postgres postgres     70 Dec 10 10:37 postmaster.pid 

-rw-r--r--  1 postgres postgres    434 Mar 31  2015 serverlog 

[postgres@pg data]$ more postgresql.conf 

log_destination = 'stderr'                

logging_collector = on

log_directory = 'pg_log'        &nb

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值