国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務器之家:專注于服務器技術及軟件下載分享
分類導航

Mysql|Sql Server|Oracle|Redis|MongoDB|PostgreSQL|Sqlite|DB2|mariadb|Access|數據庫技術|

服務器之家 - 數據庫 - PostgreSQL - postgresql 如何查看pg_wal目錄下xlog文件總大小

postgresql 如何查看pg_wal目錄下xlog文件總大小

2021-03-23 21:06怠惰的小小白 PostgreSQL

這篇文章主要介紹了postgresql 如何查看pg_wal目錄下xlog文件總大小的操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧

當然如果你登錄服務器所在主機,直接在$PGDAT/pg_wal下執行:

?
1
du -h --max-depth=1 ./

可以得到。

?
1
2
3
#du -h --max-depth=1 ./
4.0K  ./archive_status
193M  ./

如果通過客戶端怎么做呢?

答案:pg_ls_waldir()函數。pg_ls_waldir()是pg 10.0引入的函數,可以輸出數據庫WAL目錄的所有文件。

?
1
2
3
4
5
postgres=# select sum(size) from pg_ls_waldir();  
  sum
-----------
 201326592
(1 row)

單位是byte,所以當前pg_wal的xlog日志總大小為201326592/1024/1024=192M。

也可以使用:

?
1
2
3
4
5
postgres=# select count(*) from pg_ls_waldir();
 count
-------
  12
(1 row)

12表示wal日志文件個數,總大小12*16=192M。

16表示單個wal日志文件大小,單位MB,WAL 日志文件大小默認為16MB。

bonus:

1、怎么調整單個wal日志文件大小?

答:使用 initdb 調整WAL文件大小。

2、pg_ls_logdir() 也是pg10.0版本引入的函數,輸出數據庫日志目錄的所有文件。

?
1
2
3
4
5
postgres=# select * from 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、如何列出/data文件夾中的文件?

答:pg_ls_dir

?
1
2
3
postgres=# select pg_ls_dir('/data');
   pg_ls_dir   
----------------------

補充:postgresql 查看wal生成頻率和大小

–wal 文件生成數量

–linux ls --full-time stat filename

–pg_stat_file返回一個記錄,其中包含

– 1 size 文件尺寸

– 2 access 最后訪問時間戳(linux:最近訪問) 、

– 3 modification 最后修改時間戳(linux:最近更改–) 、

– 4 change 最后文件狀態改變時間戳(只支持 Unix 平臺)(linux:最近改動) 、

– 5 creation 文件創建時間戳(只支持 Windows)

– 6 isdir 一個boolean指示它是否為目錄 isdir

?
1
2
3
4
select * from pg_stat_file('/var/lib/postgresql/9.1/main/pg_xlog/0000000200000BBB000000A9');
– /var/lib/postgresql/9.1/main/pg_xlog
– /var/log/postgresql
– /mnt/nas_dbbackup/archivelog
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
with tmp_file as (
  select t1.file,
      t1.file_ls,
      (pg_stat_file(t1.file)).size as size,
      (pg_stat_file(t1.file)).access as access,
      (pg_stat_file(t1.file)).modification as last_update_time,
      (pg_stat_file(t1.file)).change as change,
      (pg_stat_file(t1.file)).creation as creation,
      (pg_stat_file(t1.file)).isdir as isdir
   from (select dir||'/'||pg_ls_dir(t0.dir) as file,
          pg_ls_dir(t0.dir) as file_ls
       from ( select '/var/lib/postgresql/9.1/main/pg_xlog'::text as dir
           --需要修改這個物理路徑
           --select '/mnt/nas_dbbackup/archivelog'::text as dir
           --select setting as dir from pg_settings where name='log_directory'
          ) t0
      ) t1
   where 1=1
   order by (pg_stat_file(file)).modification desc
)
select to_char(date_trunc('day',tf0.last_update_time),'yyyymmdd') as day_id,
    sum(case when date_part('hour',tf0.last_update_time) >=0 and date_part('hour',tf0.last_update_time) <24 then 1 else 0 end) as wal_num_all,
    sum(case when date_part('hour',tf0.last_update_time) >=0 and date_part('hour',tf0.last_update_time) <1 then 1 else 0 end) as wal_num_00_01,
    sum(case when date_part('hour',tf0.last_update_time) >=1 and date_part('hour',tf0.last_update_time) <2 then 1 else 0 end) as wal_num_01_02,
    sum(case when date_part('hour',tf0.last_update_time) >=2 and date_part('hour',tf0.last_update_time) <3 then 1 else 0 end) as wal_num_02_03,
    sum(case when date_part('hour',tf0.last_update_time) >=3 and date_part('hour',tf0.last_update_time) <4 then 1 else 0 end) as wal_num_03_04,
    sum(case when date_part('hour',tf0.last_update_time) >=4 and date_part('hour',tf0.last_update_time) <5 then 1 else 0 end) as wal_num_04_05,
    sum(case when date_part('hour',tf0.last_update_time) >=5 and date_part('hour',tf0.last_update_time) <6 then 1 else 0 end) as wal_num_05_06,
    sum(case when date_part('hour',tf0.last_update_time) >=6 and date_part('hour',tf0.last_update_time) <7 then 1 else 0 end) as wal_num_06_07,
    sum(case when date_part('hour',tf0.last_update_time) >=7 and date_part('hour',tf0.last_update_time) <8 then 1 else 0 end) as wal_num_07_08,
    sum(case when date_part('hour',tf0.last_update_time) >=8 and date_part('hour',tf0.last_update_time) <9 then 1 else 0 end) as wal_num_08_09,
    sum(case when date_part('hour',tf0.last_update_time) >=9 and date_part('hour',tf0.last_update_time) <10 then 1 else 0 end) as wal_num_09_10,
    sum(case when date_part('hour',tf0.last_update_time) >=10 and date_part('hour',tf0.last_update_time) <11 then 1 else 0 end) as wal_num_10_11,
    sum(case when date_part('hour',tf0.last_update_time) >=11 and date_part('hour',tf0.last_update_time) <12 then 1 else 0 end) as wal_num_11_12,
    sum(case when date_part('hour',tf0.last_update_time) >=12 and date_part('hour',tf0.last_update_time) <13 then 1 else 0 end) as wal_num_12_13,
    sum(case when date_part('hour',tf0.last_update_time) >=13 and date_part('hour',tf0.last_update_time) <14 then 1 else 0 end) as wal_num_13_14,
    sum(case when date_part('hour',tf0.last_update_time) >=14 and date_part('hour',tf0.last_update_time) <15 then 1 else 0 end) as wal_num_14_15,
    sum(case when date_part('hour',tf0.last_update_time) >=15 and date_part('hour',tf0.last_update_time) <16 then 1 else 0 end) as wal_num_15_16,
    sum(case when date_part('hour',tf0.last_update_time) >=16 and date_part('hour',tf0.last_update_time) <17 then 1 else 0 end) as wal_num_16_17,
    sum(case when date_part('hour',tf0.last_update_time) >=17 and date_part('hour',tf0.last_update_time) <18 then 1 else 0 end) as wal_num_17_18,
    sum(case when date_part('hour',tf0.last_update_time) >=18 and date_part('hour',tf0.last_update_time) <19 then 1 else 0 end) as wal_num_18_19,
    sum(case when date_part('hour',tf0.last_update_time) >=19 and date_part('hour',tf0.last_update_time) <20 then 1 else 0 end) as wal_num_19_20,
    sum(case when date_part('hour',tf0.last_update_time) >=20 and date_part('hour',tf0.last_update_time) <21 then 1 else 0 end) as wal_num_20_21,
    sum(case when date_part('hour',tf0.last_update_time) >=21 and date_part('hour',tf0.last_update_time) <22 then 1 else 0 end) as wal_num_21_22,
    sum(case when date_part('hour',tf0.last_update_time) >=22 and date_part('hour',tf0.last_update_time) <23 then 1 else 0 end) as wal_num_22_23,
    sum(case when date_part('hour',tf0.last_update_time) >=23 and date_part('hour',tf0.last_update_time) <24 then 1 else 0 end) as wal_num_23_24
from tmp_file tf0
where 1=1
 and tf0.file_ls not in ('archive_status')
group by to_char(date_trunc('day',tf0.last_update_time),'yyyymmdd')
order by to_char(date_trunc('day',tf0.last_update_time),'yyyymmdd') desc
;

以上為個人經驗,希望能給大家一個參考,也希望大家多多支持服務器之家。如有錯誤或未考慮完全的地方,望不吝賜教。

原文鏈接:https://blog.csdn.net/qq_35462323/article/details/105835770

延伸 · 閱讀

精彩推薦
Weibo Article 1 Weibo Article 2 Weibo Article 3 Weibo Article 4 Weibo Article 5 Weibo Article 6 Weibo Article 7 Weibo Article 8 Weibo Article 9 Weibo Article 10 Weibo Article 11 Weibo Article 12 Weibo Article 13 Weibo Article 14 Weibo Article 15 Weibo Article 16 Weibo Article 17 Weibo Article 18 Weibo Article 19 Weibo Article 20 Weibo Article 21 Weibo Article 22 Weibo Article 23 Weibo Article 24 Weibo Article 25 Weibo Article 26 Weibo Article 27 Weibo Article 28 Weibo Article 29 Weibo Article 30 Weibo Article 31 Weibo Article 32 Weibo Article 33 Weibo Article 34 Weibo Article 35 Weibo Article 36 Weibo Article 37 Weibo Article 38 Weibo Article 39 Weibo Article 40
主站蜘蛛池模板: 美女扒开尿口来摸 | 日韩精品一区二区三区在线播放 | 激情五月婷婷 | 国产精品美女久久久久久久久久久 | 视频1区 | 国产福利91精品一区二区三区 | 国产午夜精品美女视频明星a级 | 成人精品 | 黄色小视频在线观看 | 黄色片网站 | 精品欧美乱码久久久久久 | 日日久 | 99久久婷婷国产综合精品电影 | 一级片视频在线观看 | 亚洲啪啪网站 | 综合婷婷 | 激情欧美日韩一区二区 | 精品国产仑片一区二区三区 | 亚洲无线看 | 成人在线不卡 | 成人亚洲 | 欧美福利| 一级黄色大片 | 成人在线视频网址 | 中文字幕精品一区久久久久 | 依人久久久| 欧美日韩国产综合视频 | 免费在线观看黄色 | 这里只是精品 | 国产精品日韩一区二区 | 不卡av电影在线观看 | 亚洲最新无码中文字幕久久 | 久久久精品456亚洲影院 | 欧美黄视频| 亚洲国产精品视频一区二区三区 | 日韩影院一区 | 高清视频一区二区三区 | 久草福利在线视频 | 中文字幕在线观看 | 亚洲精品乱码久久久久久按摩观 | 精品一区二区免费视频 |