介绍
本篇文章为大家展示了怎么在postgresql中查看pg_wal目录下的xlog文件大小,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。
当然如果你登录服务器所在主机,直接在$ PGDAT/pg_wal下执行:
du -h ——max-depth=1,。/
可以得到。
# du -h ——max-depth=1。/4.0 k 。/archive_status 193 m ,。/
如果通过客户端怎么做呢?
答案:pg_ls_waldir()函数.pg_ls_waldir()是10.0 pg引入的函数,可以输出数据库的WAL目录的所有文件。
postgres=#, select 和(大小),得到pg_ls_waldir (),,,, ,,sum ----------- ,201326592 (1,行)
单位是字节,所以当前pg_wal的xlog日志总大小为201326592/1024/1024=192。
也可以使用:
postgres=#, select count(*),得到pg_ls_waldir (); ,count ------- ,12 (1,行)
12表示细胞膜日志文件个数,总大小12 * 16=192。
16表示单个细胞膜日志文件大小,单位MB,细胞膜日志文件大小默认为16 MB。
<强>奖金:强>
1,怎么调整单个细胞膜日志文件大小?
答:使用initdb调整的wal文件大小。
2, pg_ls_logdir()也是pg10.0版本引入的函数、输出数据库日志目录的所有文件。
postgres=#, select *,得到pg_ls_logdir (); ,,,,,,,name ,,,,,,, |, size , |,,, modification ,, - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ,postgresql - 2020 - 04 - 28 - _092020.log |, 2277343, |, 2020 - 04 - 29, 11:34:56 + 08年 ,postgresql - 2020 - 04 - 28 - _092020.csv |, 140050, |, 2020 - 04 - 29, 11:34:56 + 08年
3,如何列出/数据文件夹中的文件?
答:pg_ls_dir
postgres=#, select pg_ls_dir(& # 39;/数据# 39;); ,,pg_ls_dir ,,, - - - - - - - - - - - - - - - - - - - - - - -
<强>补充:postgresql查看细胞膜生成频率和大小强>
细胞膜文件生成数量
linux ls -全职stat文件名
-pg_stat_file返回一个记录,其中包含
- 1大小文件尺寸
- 2访问最后访问时间戳(linux:最近访问),
- 3修改最后修改时间戳(linux:最近更改),
- 4变化最后文件状态改变时间戳(只支持Unix平台)(linux:最近改动),
- 5创建文件创建时间戳(只支持Windows)
- 6 isdir一个布尔指示它是否为目录isdir
安康;select *,得到pg_stat_file (& # 39;/var/lib/postgresql/9.1/主/pg_xlog/0000000200000 bbb000000a9& # 39;); 安康;/var/lib/postgresql/9.1/主/pg_xlog 安康,/var/log/postgresql 安康;/mnt/nas_dbbackup/archivelog
with tmp_file as ( select 才能;t1.file, ,,,,,t1.file_ls, ,,,,,(pg_stat_file (t1.file)) .size as 大小, ,,,,,(pg_stat_file (t1.file)) .access as 访问, ,,,,,(pg_stat_file (t1.file)) .modification as last_update_time, ,,,,,(pg_stat_file (t1.file)) .change as 改变, ,,,,,(pg_stat_file (t1.file)) .creation as 创建、 ,,,,,(pg_stat_file (t1.file)) .isdir as isdir ,才能得到(select dir | | & # 39;/& # 39; | | pg_ls_dir (t0.dir), as 文件, ,,,,,,,,,pg_ls_dir (t0.dir), as file_ls ,,,,,,得到(,select & # 39;/var/lib/postgresql/9.1/主/pg_xlog& # 39;:: text as dir ,,,,,,,,,,,需要修改这个物理路径 ,,,,,,,,,,,select & # 39;/mnt/nas_dbbackup archivelog # 39;:: text as dir ,,,,,,,,,,,select setting as dir 得到pg_settings where name=& # 39; log_directory& # 39; ,,,,,,,,),t0 ,,,,,),t1 ,,where 1=1 ,,order by (pg_stat_file(文件).modification desc ), select to_char (date_trunc(& # 39;天# 39;,tf0.last_update_time), & # 39;名称# 39;),as day_id, ,,,总和(case when  date_part(& # 39;小时# 39;,tf0.last_update_time),在=0,以及date_part(& # 39;小时# 39;,tf0.last_update_time), & lt; 24, then 1, else 0,结束),as wal_num_all, ,,,总和(case when  date_part(& # 39;小时# 39;,tf0.last_update_time),在=0,以及date_part(& # 39;小时# 39;,tf0.last_update_time), & lt; 1, then 1, else 0,结束),as wal_num_00_01, ,,,总和(case when  date_part(& # 39;小时# 39;,tf0.last_update_time),祝辞=1,以及date_part(& # 39;小时# 39;,tf0.last_update_time), & lt; 2, then 1, else 0,结束),as wal_num_01_02, null null null null null null null null null null null null null null null null null null null null null null null null null null null null怎么在postgresql中查看pg_wal目录下的xlog文件大小