post gresql pg 보기wal 디 렉 터 리 아래 xlog 파일 의 총 크기
7917 단어 postgresqlpg walxlog
du -h --max-depth=1 ./
얻 을 수 있다.
#du -h --max-depth=1 ./
4.0K ./archive_status
193M ./
클 라 이언 트 를 통 해 어떻게 할 까요?정 답:pgls_waldir()함수.pg_ls_waldir()는 pg 10.0 에 도 입 된 함수 로 데이터베이스 WAL 디 렉 터 리 의 모든 파일 을 출력 할 수 있 습 니 다.
postgres=# select sum(size) from pg_ls_waldir();
sum
-----------
201326592
(1 row)
단 위 는 byte 이기 때문에 현재 pgwal 의 xlog 로그 의 총 크기 는 201326592/1024/1024=192 M 입 니 다.사용 가능:
postgres=# select count(*) from pg_ls_waldir();
count
-------
12
(1 row)
12.wal 로그 파일 의 개 수 를 나타 내 고 전체 크기 는 12*16=192 M 입 니 다.16 은 단일 wal 로그 파일 크기,단위 MB,WAL 로그 파일 크기 를 기본적으로 16MB 로 표시 합 니 다.
bonus:
1.단일 wal 로그 파일 크기 를 어떻게 조정 합 니까?
답:initdb 를 사용 하여 WAL 파일 크기 를 조정 합 니 다.
2、pg_ls_logdir()도 pg 10.0 버 전에 서 도입 한 함수 로 데이터베이스 로그 디 렉 터 리 의 모든 파일 을 출력 합 니 다.
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 폴 더 의 파일 을 어떻게 표시 합 니까?답:pgls_dir
postgres=# select pg_ls_dir('/data');
pg_ls_dir
----------------------
추가:potgresql 에서 wal 생 성 주파수 와 크기 보기Cwal 파일 생 성 수량
Clinux ls --full-time stat filename
Cpg_stat_file 기록 을 되 돌려 줍 니 다.
C 1 사이즈 파일 사이즈
C 2 access 마지막 방문 시간 스탬프(linux:최근 방문),
C 3 modification 마지막 수정 타임 스탬프(linux:최근 변경 C),
C 4 change 마지막 파일 상태 변경 타임 스탬프(유 닉 스 플랫폼 만 지원)(linux:최근 변경),
C 5 생 성 파일 생 성 타임 스탬프(Windows 만 지원)
C 6 isdir 하나의 boolean 은 디 렉 터 리 isdir 인지 여 부 를 표시 합 니 다.
C select * from pg_stat_file('/var/lib/postgresql/9.1/main/pg_xlog/0000000200000BBB000000A9');
C /var/lib/postgresql/9.1/main/pg_xlog
C /var/log/postgresql
C /mnt/nas_dbbackup/archivelog
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
;
이상 은 개인 적 인 경험 이 므 로 여러분 에 게 참고 가 되 기 를 바 랍 니 다.여러분 들 도 저 희 를 많이 응원 해 주시 기 바 랍 니 다.만약 잘못 이 있 거나 완전히 고려 하지 않 은 부분 이 있다 면 아낌없이 가르침 을 주시 기 바 랍 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
org.postgresql.util.PSQLException: FATAL: sorry, too many clients alreadyI am trying to connect to a Postgresql database, I am getting the following Error: You opened up more than the allowed l...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.