프린트 하기

OS환경 : Oracle Linux 7.4 (64bit)

 

DB 환경 : Oracle Database 19.3.0.0

 

에러 : -bash: /bin/rm: Argument list too long

asm 환경의 싱글 db 사용 중 asm audit 로그가 많이 쌓여 삭제하려던 중 발생한 메세지

 

1
2
3
$ cd /oracle/app/19.3/grid/rdbms/audit
$ rm -rf ./*
-bash: /bin/rm: Argument list too long

 

 

해결 방법 : 한번에 삭제 대신 나눠서 삭제

기존 파일시스템 용량 확인

1
2
3
4
5
6
7
8
9
10
$ df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        2.0G     0  2.0G   0/dev
tmpfs           2.0G  641M  1.3G  33/dev/shm
tmpfs           2.0G  169M  1.8G   9/run
tmpfs           2.0G     0  2.0G   0/sys/fs/cgroup
/dev/sda1        10G  4.1G  5.9G  41/
/dev/sda3       2.0G   33M  2.0G   2/tmp
/dev/sda5        30G   30G   71M 100/oracle
tmpfs           394M     0  394M   0/run/user/0

/oracle 이 use 100% 임

 

 

파일 목록 확인

1
2
3
4
5
6
7
8
9
10
11
12
목록을 신규파일로 넣어 확인
$ ls > file_list.txt
 
파일 목록 확인
$ more file_list.txt
tempfile_100_10000.aud
tempfile_100_10001.aud
tempfile_100_10002.aud
tempfile_100_10003.aud
tempfile_100_10004.aud
tempfile_100_10005.aud
tempfile_100_10006.aud

 

 

방법 1. for 문을 이용한 삭제

1
2
$ cd /oracle/app/19.3/grid/rdbms/audit
$ for i in `ls` ; do rm -rf $i ; done

ls 도 안되서 명령이 제대로 실행되지 않음

 

 

방법 2. find 명령을 이용한 삭제

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
1. find 명령으로 현재경로에서 *.aud 파일을 찾은 뒤 모두 삭제
$ cd /oracle/app/19.3/grid/rdbms/audit
$ find . -name '*.aud' | xargs rm *
 
2. find 명령으로 현재경로에 존재하는 모든 파일 삭제
$ cd /oracle/app/19.3/grid/rdbms/audit
$ find . -exec rm {} \;
 
3. find 명령으로 현재경로에서 *.aud 파일을 찾은 뒤 모두 삭제
$ cd /oracle/app/19.3/grid/rdbms/audit
$ find . -name '*.aud' -exec rm {} \;
 
4. find 명령으로 현재경로에서 30일 지난 *.aud 파일을 찾은 뒤 삭제(추천)
$ cd /oracle/app/19.3/grid/rdbms/audit
$ find . -name '*.aud' -mtime +30 -exec rm {} \;
 
5. find 명령으로 현재경로에서 30일 지난 *.aud 파일을 찾은 뒤 삭제 후 삭제한 파일 목록 출력
$ cd /oracle/app/19.3/grid/rdbms/audit
$ find . -name '*.aud' -mtime +30 -exec rm {} \; -print
 
6. find 명령으로 현재경로에서 *.aud 파일 리스트을 인수로 받아 모두 삭제
$ cd /oracle/app/19.3/grid/rdbms/audit
$ find . -name '*.aud' -print0 | xargs -0 rm -f
 
7. find 명령으로 현재경로에서 *.aud 파일 리스트을 인수로 받아 1000개씩 끊어서 모두 삭제
$ find . -name '*.aud' -print0 | xargs -n1000 -0 rm -f

find 명령으로 지우더라도 양이 많은경우 시간이 꽤 걸리니 작업 가능 시간이 많지 않은경우 

파일명으로 어느정도 양을 나눠서 삭제할 필요가 있음

 

 

방법 3. ls 명령을 이용한 삭제

1
2
3
4
5
6
7
1. ls 명령으로 모두 삭제
$ cd /oracle/app/19.3/grid/rdbms/audit
$ ls | xargs rm
 
2. ls 명령으로 나온 리스트를 인수로 받아 1000개씩 끊어서 모두 삭제
$ cd /oracle/app/19.3/grid/rdbms/audit
$ ls | xargs -1000 rm -f

 

 

삭제 후 파일시스템 용량 확인

1
2
3
4
5
6
7
8
9
10
$ df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        2.0G     0  2.0G   0/dev
tmpfs           2.0G  641M  1.3G  33/dev/shm
tmpfs           2.0G  169M  1.8G   9/run
tmpfs           2.0G     0  2.0G   0/sys/fs/cgroup
/dev/sda1        10G  4.1G  5.9G  41/
/dev/sda3       2.0G   33M  2.0G   2/tmp
/dev/sda5        30G   15G   16G  49/oracle
tmpfs           394M     0  394M   0/run/user/0

/oracle이 use 49%로 여유로워짐

 

 

원인 : rm 명령으로 한번에 처리 할 수 있는 한도를 벗어남

rm 명령으로 한번에 처리 할 수 있는 한도를 벗어남 나눠서 삭제해야 명령이 정상동작함

 

 

참조 : https://positivemh.tistory.com/554

 

ASM audit file 증가 현상

OS환경 : Oracle Linux 7.4 (64bit) DB 환경 : Oracle Database 19.3.0.0 에러 : ASM audit file 증가 현상/oracle 파일시스템 full 로 인해 db 접속 불가 현상이 발생하여 원인을 찾던 중12345678910$ df -hFilesystem Size Used Avail U

positivemh.tistory.com

http://egloos.zum.com/antamis/v/653811

https://rsec.kr/?p=91

 

https://positivemh.tistory.com/1033

 

Oracle Linux 8 더미 파일 대량 생성 및 대량 삭제

OS환경 : Oracle Linux 8.1 (64bit) 방법 : Oracle Linux 8 더미 파일 대량 생성 및 대량 삭제 오라클 audit 파일을 지울때 양이 너무 많아서 Argument list too long 에러가 발생하는 경우가 있음 이 경우를 재현하기

positivemh.tistory.com