Search This Blog

Total Pageviews

Tuesday, 3 May 2011

Oracle Datafiles Disk I/O

Datafiles Disk IO


set pagesize 100
set linesize 200
col PERC_READS format a10
col name format a40
col PERC_WRITES like PERC_READS
SELECT df.NAME, phyrds Physical_READS,
ROUND((RATIO_TO_REPORT(phyrds) OVER ())*100, 2)|| '%' PERC_READS,
phywrts Physical_WRITES,
ROUND((RATIO_TO_REPORT(phywrts) OVER ())*100, 2)|| '%' PERC_WRITES,
phyrds + phywrts total
FROM v$datafile df, v$filestat fs, ts$ t
WHERE df.FILE# = fs.FILE#
AND df.ts# = t.ts#
-- AND t.NAME = ' xxxx '
ORDER BY phyrds DESC;

Who is using TEMP tablespace?

SQL Running out of Temporary tablespace

TEMP tablespace currently using


1.

set linesize 200
col sid format a12
col sql_text format a50
select s.sid || ',' || s.serial# sid,s.username,u.tablespace,
substr(a.sql_text, 1, (instr(a.sql_text, ' ')-1)) sql_text,
round(((u.blocks*p.value)/1024/1024),2) size_mb,s.sql_id
from v$sort_usage u, v$session s, v$sqlarea a,v$parameter p
where s.saddr = u.session_addr
and a.address (+) = s.sql_address
and a.hash_value (+) = s.sql_hash_value
and p.name = 'db_block_size'
group by s.sid || ',' || s.serial#, s.username,
substr(a.sql_text, 1, (instr (a.sql_text, ' ')-1)),u.tablespace,round(((u.blocks*p.value)/1024/1024),2),s.sql_id;



2

select
s.INST_ID node,
segfile#,
round(sum (((u.blocks*par.value)/1024/1024)),2) size_mb,s.sql_id
from
gv$sort_usage u,
gv$session s,
gv$process p,
v$parameter par
where
s.inst_id=u.inst_id AND
s.saddr = u.session_addr AND
s.paddr = p.addr AND
par.name='db_block_size'
group by
s.INST_ID,
segfile#,s.sql_id
order by 1,2
;


3.

set linesize 140
set pagesize 400
set head on
col iid for 990
col sid_serial for a11
column username format a10
col module for a13
col action for a15
col state for a10
column segfile# format 9,999 heading 'File|ID'
col orapid for 999999 Heading "orapid||Oracle|pid"
col dbpid for a6 HEADING "spid|Unix|pid"
col apppid for a10;
column program format a55
column segblk# format 999,999,999 heading 'Block|ID'

set timi off;
CLEAR COMPUTES;
break on iid

select distinct
s.INST_ID iid,
lpad(s.sid,5)||','|| Lpad(s.serial#,5) sid_serial,
p.pid orapid,
p.spid dbpid,
s.USERNAME,
round(sum (((u.blocks*par.value)/1024/1024)),2) size_mb,
s.status,
s.state,
u.SQL_ID,
segfile#,
s.module,
s.action
from
gv$sort_usage u,
gv$session s,
gv$process p,
v$parameter par
where
s.inst_id=u.inst_id AND
s.saddr = u.session_addr AND
s.paddr = p.addr AND
par.name='db_block_size'
group by
s.INST_ID,
lpad(s.sid,5)||','|| Lpad(s.serial#,5),
p.pid,
p.spid,
s.USERNAME,
s.status,
s.state,
u.SQL_ID,
segfile#,
s.module,
s.action
order by 1,2
;



4

SELECT S.sid || ',' || S.serial# sid_serial, S.username,
T.blocks * TBS.block_size / 1024 / 1024 mb_used, T.tablespace,
T.sqladdr address, Q.hash_value, Q.sql_text
FROM v$sort_usage T, v$session S, v$sqlarea Q, dba_tablespaces TBS
WHERE T.session_addr = S.saddr
AND T.sqladdr = Q.address (+)
AND T.tablespace = TBS.tablespace_name
ORDER BY S.sid;

5.


PROMPT consuption by instances, tempfiles:

select
s.INST_ID iid,
segfile#,
round(sum (((u.blocks*par.value)/1024/1024)),2) size_mb
from
gv$sort_usage u,
gv$session s,
gv$process p,
v$parameter par
where
s.inst_id=u.inst_id AND
s.saddr = u.session_addr AND
s.paddr = p.addr AND
par.name='db_block_size'
group by
s.INST_ID,
segfile#
order by 1,2
;

sqlplus Command Line History

sqlplus Command Line History Doskey functionality in sqlplus on linux platform sqlplus History sql doskey ( like old days on dos ) sqlplus doskey

rlwrap is a Command Line History and Editing in SQL*Plus and RMAN on Linux


http://utopia.knoware.nl/~hlub/uck/rlwrap/


wget http://utopia.knoware.nl/~hlub/uck/rlwrap/rlwrap-0.37.tar.gz

apt-amd-02:/home/anujs/Downloads/rlwrap-0.37 # wget http://utopia.knoware.nl/~hlub/uck/rlwrap/rlwrap-0.37.tar.gz
--2011-05-03 12:44:25--  http://utopia.knoware.nl/~hlub/uck/rlwrap/rlwrap-0.37.tar.gz
Resolving utopia.knoware.nl... 213.197.30.29
Connecting to utopia.knoware.nl|213.197.30.29|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 251438 (246K) [application/x-gzip]
Saving to: `rlwrap-0.37.tar.gz'

100%[==========================================================================================================================================>] 251,438     1.12M/s   in 0.2s    

2011-05-03 12:44:25 (1.12 MB/s) - `rlwrap-0.37.tar.gz' saved [251438/251438]


or


rpm 


Download your RPM according to your OS

apt-amd-02:/home/anujs/Downloads # cat /etc/issue
Welcome to openSUSE 11.3 "Teal" - Kernel \r (\l).


rlwrap-0.30-56.1.x86_64.rpm


Download software from  this site as per your OS

http://rpm.pbone.net/index.php3?stat=3&search=rlwrap&srodzaj=3


OpenSuSE  ftp.opensuse.org/distribution/11.2/repo/oss/suse/x86_64/rlwrap-0.30-56.1.x86_64.rpm


install this RPM 


apt-amd-02:/home/anujs/Downloads # rpm -Uvh rlwrap-0.30-56.1.x86_64.rpm
Preparing...                ########################################### [100%]
        package rlwrap-0.30-56.1.x86_64 is already installed


go to oracle user

su - oracle

edit your .bash_profile with following line


alias hsqlplus='rlwrap sqlplus'
alias hman='rlwrap rman'
alias hsql='rlwrap sqlplus'
alias sql="rlwrap -i -f ~/.sqlplus_history -H ~/.sqlplus_history -s 30000 sqlplus"
touch ~/.sqlplus_history



this will store 30000 line in .sqlplus_history file 

or

export RLWRAP_EDITOR="vim +%L -c 'syntax on' -c 'set filetype=sql'"
alias sysdba='rlwrap -m -s5000 sqlplus / as sysdba'




oracle@apt-amd-02:~> hsqlplus

SQL*Plus: Release 11.2.0.1.0 Production on Tue May 3 11:54:26 2011

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

Enter user-name: scott/tiger

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select * from tab;

TNAME                          TABTYPE  CLUSTERID
------------------------------ ------- ----------
BONUS                          TABLE
DEPT                           TABLE
EMP                            TABLE
SALGRADE                       TABLE
T                              TABLE

sql> 

now if you press arrow key, you will able to see previous commands !!!!!!!!!!!!!!!!!!!!!!!!


=====================================================================================================================================


download !!

 wget ftp://ftp.pbone.net/mirror/archive.fedoraproject.org/epel/6/x86_64/Packages/r/rlwrap-0.42-1.el6.x86_64.rpm
 
--2022-03-10 07:51:15--  ftp://ftp.pbone.net/mirror/archive.fedoraproject.org/epel/6/x86_64/Packages/r/rlwrap-0.42-1.el6.x86_64.rpm
           => ‘rlwrap-0.42-1.el6.x86_64.rpm’
Resolving ftp.pbone.net (ftp.pbone.net)... 93.179.225.212
Connecting to ftp.pbone.net (ftp.pbone.net)|93.179.225.212|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD (1) /mirror/archive.fedoraproject.org/epel/6/x86_64/Packages/r ... done.
==> SIZE rlwrap-0.42-1.el6.x86_64.rpm ... 95240
==> PASV ... done.    ==> RETR rlwrap-0.42-1.el6.x86_64.rpm ... done.
Length: 95240 (93K) (unauthoritative)

100%[===================================================================================================================================================>] 95,240       166KB/s   in 0.6s

2022-03-10 07:51:17 (166 KB/s) - ‘rlwrap-0.42-1.el6.x86_64.rpm’ saved [95240]


rpm -ivh rlwrap-0.42-1.el6.x86_64.rpm
warning: rlwrap-0.42-1.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:rlwrap-0.42-1.el6                ################################# [100%]




su - oracle
 touch /home/oracle/.oracle_keywords
 
 
 alias sqlplus='/usr/bin/rlwrap -if $HOME/.oracle_keywords $ORACLE_HOME/bin/sqlplus'
 
 rlwrap sqlplus / as sysdba
 
 
  rlwrap sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Thu Mar 10 07:54:51 2022

Copyright (c) 1982, 2016, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> select * from dual;

D
-
X

 

Friday, 29 April 2011

Oracle Block recovey using RMAN

RMAN Block RECOVERY
perform Block Media Recovery using RMAN
ORA-01578: ORACLE data block corrupted
RMAN RECOVER BLOCK


SQL> select FILE_NAME from dba_data_files ;

FILE_NAME
--------------------------------------------------------------------------------
/opt/app/oracle/oradata/orcl/users01.dbf
/opt/app/oracle/oradata/orcl/undotbs01.dbf
/opt/app/oracle/oradata/orcl/sysaux01.dbf
/opt/app/oracle/oradata/orcl/system01.dbf
/opt/app/oracle/oradata/orcl/example01.dbf



SQL> create tablespace anujtest datafile '/opt/app/oracle/oradata/orcl/anujtest.dbf' size 10m
autoextend on next 5m extent management local segment space management auto ;

Tablespace created.


apt-lnxtst-01:ORCL\sys> create user anujtest identified by anujtest default tablespace anujtest quota unlimited on anujtest ;

User created.



grant connect , resource to anujtest ;


apt-lnxtst-01:ORCL\sys> conn anujtest/anujtest
Connected.


orcl\anujtest> connect / as sysdba
Connected.



apt-lnxtst-01:ORCL\sys>conn anujtest/anujtest
Connected.

orcl\anujtest> create table test as select * from all_objects ;
Table created.



SQL> connect / as sysdba
Connected.
SQL> col FILE_NAME format a50
SQL> select FILE_NAME,FILE_ID from dba_data_files;

FILE_NAME FILE_ID
-------------------------------------------------- ----------
/opt/app/oracle/oradata/orcl/users01.dbf 4
/opt/app/oracle/oradata/orcl/undotbs01.dbf 3
/opt/app/oracle/oradata/orcl/sysaux01.dbf 2
/opt/app/oracle/oradata/orcl/system01.dbf 1
/opt/app/oracle/oradata/orcl/example01.dbf 5
/opt/app/oracle/oradata/orcl/anujtest.dbf 6 <<<<<<<<<<<<-------

6 rows selected.


RMAN> connect target /

connected to target database: ORCL (DBID=1267852645)

RMAN> backup datafile 6 tag=good;

Starting backup at 29-APR-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=53 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=/opt/app/oracle/oradata/orcl/anujtest.dbf
channel ORA_DISK_1: starting piece 1 at 29-APR-11
channel ORA_DISK_1: finished piece 1 at 29-APR-11
piece handle=/opt/app/oracle/flash_recovery_area/ORCL/backupset/2011_04_29/o1_mf_nnndf_GOOD_6vnsol06_.bkp tag=GOOD comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 29-APR-11



RMAN> list backup;


List of Backup Sets
===================


BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1 Full 7.48M DISK 00:00:01 29-APR-11
BP Key: 1 Status: AVAILABLE Compressed: NO Tag: GOOD
Piece Name: /opt/app/oracle/flash_recovery_area/ORCL/backupset/2011_04_29/o1_mf_nnndf_GOOD_6vnsol06_.bkp
List of Datafiles in backup set 1
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
6 Full 7522958 29-APR-11 /opt/app/oracle/oradata/orcl/anujtest.dbf


RMAN>Ctrl+d or exit

Recovery Manager complete.


SQL> col SEGMENT_NAME format a20



SQL> r
1 select segment_name , header_file , header_block from dba_segments
2 where segment_name = 'TEST'
3* and owner = 'ANUJTEST'

SEGMENT_NAME HEADER_FILE HEADER_BLOCK
-------------------- ----------- ------------
TEST 6 130



to get file name



col name format a70
select a.name from v$datafile a , dba_segments b
where a.file#=b.header_file and b.segment_name='TEST'

NAME
----------------------------------------------------------------------
/opt/app/oracle/oradata/orcl/anujtest.dbf



The header of the table is in block 130, so if the block 131 or so are corrupted we will get an error when we try to select data from the table.
Lets corrupt block 12 using the "dd" command in Linux.



oracle@apt-amd-02:/opt/app/oracle/oradata/orcl> dd of=anujtest.dbf bs=8192 conv=notrunc seek=130 << EOF
anuj Corrupted.
EOF

0+1 records in
0+1 records out
16 bytes (16 B) copied, 0.000109246 s, 146 kB/s


SQL> select count(*) from anujtest.test ; ----- because whole table in cache

COUNT(*)
----------
55632

SQL> alter system flush buffer_cache;

System altered.

SQL> select count(*) from anujtest.test ;
select count(*) from anujtest.test
*
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 6, block # 130)
ORA-01110: data file 6: '/opt/app/oracle/oradata/orcl/anujtest.dbf'



oracle@apt-amd-02:/opt/app/oracle/oradata/orcl> rman

Recovery Manager: Release 11.2.0.1.0 - Production on Fri Apr 29 07:45:30 2011

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

RMAN> connect target /

connected to target database: ORCL (DBID=1267852645)

RMAN> BLOCKRECOVER DATAFILE 6 BLOCK 130;

Starting recover at 29-APR-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=50 device type=DISK

channel ORA_DISK_1: restoring block(s)
channel ORA_DISK_1: specifying block(s) to restore from backup set
restoring blocks of datafile 00006
channel ORA_DISK_1: reading from backup piece /opt/app/oracle/flash_recovery_area/ORCL/backupset/2011_04_29/o1_mf_nnndf_GOOD_6vnsol06_.bkp
channel ORA_DISK_1: piece handle=/opt/app/oracle/flash_recovery_area/ORCL/backupset/2011_04_29/o1_mf_nnndf_GOOD_6vnsol06_.bkp tag=GOOD
channel ORA_DISK_1: restored block(s) from backup piece 1
channel ORA_DISK_1: block restore complete, elapsed time: 00:00:01

starting media recovery
media recovery complete, elapsed time: 00:00:08

Finished recover at 29-APR-11

RMAN>


now block recovered


SQL> select count(*) from anujtest.test ;

COUNT(*)
----------
55632

ORA-19809: limit exceeded for recovery files



if following error occurred on Oracle database or database hanged due to this error


Errors in file /opt/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_arc3_1202.trc:
ORA-19809: limit exceeded for recovery files
ORA-19804: cannot reclaim 44131328 bytes disk space from 4070572032 limit
ARC3: Error 19809 Creating archive log file to '/opt/app/oracle/flash_recovery_area/ORCL/archivelog/2011_04_29/o1_mf_1_330_%u_.arc'




check space is fill !!!!!!!!!

set lines 100
col name format a60
select name
, floor(space_limit / 1024 / 1024) "Size MB"
, ceil(space_used / 1024 / 1024) "Used MB"
from v$recovery_file_dest
order by name
/



oracle@apt-amd-02:~> id
uid=1001(oracle) gid=1000(oinstall) groups=1000(oinstall)
oracle@apt-amd-02:~> rman

Recovery Manager: Release 11.2.0.1.0 - Production on Fri Apr 29 06:56:30 2011

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.


RMAN> connect target /

connected to target database: ORCL (DBID=1267852645)

RMAN> delete force archivelog until time 'sysdate -1'; ---- delete some archive log file

using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=50 device type=DISK
List of Archived Log Copies for database with db_unique_name ORCL
=====================================================================

Key Thrd Seq S Low Time
------- ---- ------- - ---------
91 1 330 A 13-APR-11
Name: /opt/app/oracle/flash_recovery_area/ORCL/archivelog/2011_04_29/o1_mf_1_330_6vnqzs5c_.arc

92 1 331 A 13-APR-11
Name: /opt/app/oracle/flash_recovery_area/ORCL/archivelog/2011_04_29/o1_mf_1_331_6vnr0q87_.arc

93 1 332 A 13-APR-11
Name: /opt/app/oracle/flash_recovery_area/ORCL/archivelog/2011_04_29/o1_mf_1_332_6vnr0x7c_.arc


Do you really want to delete the above objects (enter YES or NO)? yes
deleted archived log
archived log file name=/opt/app/oracle/flash_recovery_area/ORCL/archivelog/2011_04_29/o1_mf_1_330_6vnqzs5c_.arc RECID=91 STAMP=749717522
deleted archived log
archived log file name=/opt/app/oracle/flash_recovery_area/ORCL/archivelog/2011_04_29/o1_mf_1_331_6vnr0q87_.arc RECID=92 STAMP=749717587
deleted archived log
archived log file name=/opt/app/oracle/flash_recovery_area/ORCL/archivelog/2011_04_29/o1_mf_1_332_6vnr0x7c_.arc RECID=93 STAMP=749717596
Deleted 3 objects


check all the file deleted ....

RMAN> delete force archivelog until time 'sysdate -1';

released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=50 device type=DISK
specification does not match any archived log in the repository

========================================================================================================================================

error 

************************************************************************
2025-01-09T03:30:43.218396-05:00
Errors in file /u01/app/oracle/diag/rdbms/ugaryd/ugaryd1/trace/ugaryd1_tt00_8810.trc:
ORA-19809: limit exceeded for recovery files
ORA-19804: cannot reclaim 105906176 bytes disk space from 1073741824 bytes limit
2025-01-09T03:31:43.253212-05:00
Errors in file /u01/app/oracle/diag/rdbms/ugaryd/ugaryd1/trace/ugaryd1_tt00_8810.trc:
ORA-19815: WARNING: db_recovery_file_dest_size of 1073741824 bytes is 100.00% used, and has 0 remaining bytes available.
2025-01-09T03:31:43.253469-05:00
************************************************************************
You have following choices to free up space from recovery area:
1. Consider changing RMAN RETENTION POLICY. If you are using Data Guard,
   then consider changing RMAN ARCHIVELOG DELETION POLICY.
2. Back up files to tertiary device such as tape using RMAN
   BACKUP RECOVERY AREA command.
3. Add disk space and increase db_recovery_file_dest_size parameter to
   reflect the new space.
4. Delete unnecessary files using RMAN DELETE command. If an operating
   system command was used to delete files, then use RMAN CROSSCHECK and
   DELETE EXPIRED commands.
************************************************************************

cat /u01/app/oracle/diag/rdbms/ugaryd/ugaryd1/trace/ugaryd1_tt00_8810.trc|more


*** 2025-01-09T02:04:41.313767-05:00
*** SESSION ID:(200.33043) 2025-01-09T02:04:41.313824-05:00
*** CLIENT ID:() 2025-01-09T02:04:41.313835-05:00
*** SERVICE NAME:(SYS$BACKGROUND) 2025-01-09T02:04:41.313841-05:00
*** MODULE NAME:() 2025-01-09T02:04:41.313847-05:00
*** ACTION NAME:() 2025-01-09T02:04:41.313853-05:00
*** CLIENT DRIVER:() 2025-01-09T02:04:41.313858-05:00

ORA-19815: WARNING: db_recovery_file_dest_size of 1073741824 bytes is 100.00% used, and has 0 remaining bytes available.
2025-01-09 02:04:41.315*:KRA:kra.c@2332:kraalert(): ************************************************************************
2025-01-09 02:04:41.315*:KRA:kra.c@2334:kraalert(): You have following choices to free up space from recovery area:
2025-01-09 02:04:41.315*:KRA:kra.c@2336:kraalert(): 1. Consider changing RMAN RETENTION POLICY. If you are using Data Guard,
2025-01-09 02:04:41.315*:KRA:kra.c@2338:kraalert():    then consider changing RMAN ARCHIVELOG DELETION POLICY.
2025-01-09 02:04:41.315*:KRA:kra.c@2340:kraalert(): 2. Back up files to tertiary device such as tape using RMAN
2025-01-09 02:04:41.315*:KRA:kra.c@2342:kraalert():    BACKUP RECOVERY AREA command.
2025-01-09 02:04:41.315*:KRA:kra.c@2345:kraalert(): 3. Add disk space and increase db_recovery_file_dest_size parameter to
2025-01-09 02:04:41.315*:KRA:kra.c@2347:kraalert():    reflect the new space.
2025-01-09 02:04:41.315*:KRA:kra.c@2349:kraalert(): 4. Delete unnecessary files using RMAN DELETE command. If an operating
2025-01-09 02:04:41.315*:KRA:kra.c@2351:kraalert():    system command was used to delete files, then use RMAN CROSSCHECK and
2025-01-09 02:04:41.315*:KRA:kra.c@2353:kraalert():    DELETE EXPIRED commands.
2025-01-09 02:04:41.315*:KRA:kra.c@2355:kraalert(): ************************************************************************
ORA-19809: limit exceeded for recovery files
ORA-19804: cannot reclaim 105906176 bytes disk space from 1073741824 bytes limit
krsi_dest_check: Exception when reserving disk space for OMF, or getting file name or creating test file
krsd_check_stuck_arch: inactive mandatory LAD:1



check space 

set linesize 300
col FILE_TYPE for a30
col PERCENT_SPACE_USED for 999.99 heading 'PERCENT_SPACE_USED%'   
SELECT NVL(FRAU.FILE_TYPE, 'Total:') FILE_TYPE,
       SUM(ROUND(FRAU.PERCENT_SPACE_USED / 100 * RFD.SPACE_LIMIT / 1024 / 1024 / 1024,3)) USED_GB,
       SUM(FRAU.PERCENT_SPACE_USED) PERCENT_SPACE_USED,
       SUM(FRAU.PERCENT_SPACE_RECLAIMABLE) PERCENT_SPACE_RECLAIMABLE,
       SUM(ROUND(FRAU.PERCENT_SPACE_RECLAIMABLE / 100 * RFD.SPACE_LIMIT / 1024 / 1024 / 1024,3)) RECLAIM_GB,
       SUM(FRAU.NUMBER_OF_FILES) NUMBER_OF_FILES,
       SUM(FRAU.PERCENT_SPACE_USED) PERCENT_SPACE_USED
  FROM V$FLASH_RECOVERY_AREA_USAGE FRAU, V$RECOVERY_FILE_DEST RFD
GROUP BY ROLLUP(FILE_TYPE);




FILE_TYPE                      USED       PERCENT_SPACE_USED% PERCENT_SPACE_RECLAIMABLE RECLAIM    NUMBER_OF_FILE PERCENT_SPACE_USED%
------------------------------ ---------- ------------------- ------------------------- ---------- -------------- -------------------
ARCHIVED LOG                   1942M                   189.65                         0 0          27                          189.65
AUXILIARY DATAFILE COPY        0                          .00                         0 0          0                              .00
BACKUP PIECE                   0                          .00                         0 0          0                              .00
CONTROL FILE                   13M                       1.27                         0 0          1                             1.27
FLASHBACK LOG                  0                          .00                         0 0          0                              .00
FOREIGN ARCHIVED LOG           0                          .00                         0 0          0                              .00
IMAGE COPY                     0                          .00                         0 0          0                              .00
REDO LOG                       0                          .00                         0 0          0                              .00
Total:                         1955M                   190.92                         0 0          28                          190.92

9 rows selected.



SQL> show parameter DB_RECOVERY_FILE_DEST_SIZE

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest_size           big integer 1G



ALTER SYSTEM SET DB_RECOVERY_FILE_DEST_SIZE = 10G scope=both sid='*';

 alter system set db_recovery_file_dest='+FRA' scope=both sid='*';

alter system switch logfile;



delete force archivelog all completed before 'sysdate-1/24';


set linesize 300
col FILE_TYPE for a30
col PERCENT_SPACE_USED for 999.99 heading 'PERCENT_SPACE_USED%'   
col USED_GB for 999.99
col "PERCENT_SPACE_USED%" for 999.99 
col 'PERCENT_SPACE_RECLAIMABLE%' for 999.99
col RECLAIM for a10
col NUMBER_OF_FILES for a14
col USED for a10
SELECT NVL(FRAU.FILE_TYPE, 'Total:') FILE_TYPE,
    dbms_xplan.format_size(SUM(ROUND(FRAU.PERCENT_SPACE_USED / 100 * RFD.SPACE_LIMIT ))) USED,
       SUM(FRAU.PERCENT_SPACE_USED) PERCENT_SPACE_USED,
    SUM(FRAU.PERCENT_SPACE_RECLAIMABLE) PERCENT_SPACE_RECLAIMABLE,
       dbms_xplan.format_size(SUM(ROUND(FRAU.PERCENT_SPACE_RECLAIMABLE / 100 * RFD.SPACE_LIMIT ))) RECLAIM,
       dbms_xplan.format_Number(SUM(FRAU.NUMBER_OF_FILES)) NUMBER_OF_FILES,
     SUM(FRAU.PERCENT_SPACE_USED) PERCENT_SPACE_USED
  FROM V$FLASH_RECOVERY_AREA_USAGE FRAU, V$RECOVERY_FILE_DEST RFD
GROUP BY ROLLUP(FILE_TYPE);

FILE_TYPE                      USED       PERCENT_SPACE_USED% PERCENT_SPACE_RECLAIMABLE RECLAIM    NUMBER_OF_FILE PERCENT_SPACE_USED%
------------------------------ ---------- ------------------- ------------------------- ---------- -------------- -------------------
ARCHIVED LOG                   1942M                   189.65                         0 0          27                          189.65
AUXILIARY DATAFILE COPY        0                          .00                         0 0          0                              .00
BACKUP PIECE                   0                          .00                         0 0          0                              .00
CONTROL FILE                   13M                       1.27                         0 0          1                             1.27
FLASHBACK LOG                  0                          .00                         0 0          0                              .00
FOREIGN ARCHIVED LOG           0                          .00                         0 0          0                              .00
IMAGE COPY                     0                          .00                         0 0          0                              .00
REDO LOG                       0                          .00                         0 0          0                              .00
Total:                         1955M                   190.92                         0 0          28                          190.92

9 rows selected.



run { 
crosscheck backupset of database;
crosscheck backupset of controlfile;
crosscheck backupset of archivelog all;
crosscheck backup;
delete noprompt expired backup;
delete force  noprompt obsolete;
delete expired archivelog all;
delete noprompt obsolete;
delete noprompt obsolete orphan;
crosscheck archivelog all;
delete expired archivelog all;
CROSSCHECK COPY OF CONTROLFILE;
}



Thursday, 21 April 2011

Unix Delete files by inode number

How to delete file using inode number?
Remove a file on linux using the inode number
remove a file with funny characters
Delete files by inode number

#pwd
/tmp

#ls -lia ----- i for inode

30401152 -rw-r--r-- 1 root root 0 2011-04-21 09:24 "la*
59544366 drwx------ 2 anujs users 6 2011-04-21 09:27 plugtmp-33


30401152 is inode number .

find /tmp -inum 30401152 -exec rm -i {} \;

or
apt-amd-02:/tmp # rm '"la*'

Wednesday, 20 April 2011

Oracle memory leak info

How to check if oracle instance is leaking memory

Oracle memory leak info


col name format a20
select sid, substr(name,1,30) name , value , value/(1024*1024) "MB"
from v$statname a, v$sesstat b
where a.statistic# = b.statistic#
and name like '%a memory'
order by sid, name;

set linesize 200
col name format a20
col MACHINE format a15
col PROGRAM format a10
col MODULE format a10
col USERNAME format a10
col SCHEMANAME format a10
col OSUSER format a10

select b.sid, substr(name,1,30) name, value , value/(1024*1024) "MB", c.serial#,c.status,c.username,c.schemaname,c.osuser,c.machine,
-- c.terminal,
c.program,c.module,state,logon_time
from v$statname a, v$sesstat b,v$session c
where a.statistic# = b.statistic#
and name like '%a memory'
and b.sid=c.sid
and osuser!='oracle'
order by status,MB desc,sid, name;




set linesize 200
col name format a20
col MACHINE format a15
col PROGRAM format a10
col MODULE format a10
col USERNAME format a10
col SCHEMANAME format a10
col OSUSER format a10

select b.sid, substr(name,1,30), value , value/(1024*1024) "MB",s.sid ssid, s.serial#,
-- ,s.sid ssid,
s.status,s.username,s.schemaname,s.osuser,s.machine,
-- s.terminal,
--s.program,
s.module,state,logon_time,substr(p.spid,1,8) spid,
--substr(sa.sql_text,1,2000) txt
sa.sql_id
from v$statname a, v$sesstat b,v$session s, v$process p ,v$sqlarea sa
where a.statistic# = b.statistic#
and name like '%a memory'
and b.sid=s.sid
and osuser!='oracle'
and p.addr = s.paddr
and s.sql_address = sa.address(+)
and s.sql_hash_value = sa.hash_value(+)
order by status,MB desc,sid, name;


set long 4000
select sql_text from v$sqlarea where sql_id='&1'

Oracle DBA

anuj blog Archive