Wednesday 10 September 2014

SQL Query to check how much RMAN backup completed so for .

1st Query
==========
--Query to check the size how much MB RMAN May Take

select sum(Bytes/1024/1024) AS SIZE_MB from dba_segments;


2nd Query
=============

-- Query to check the how much RMAN has taken backup so far

select to_char(completion_time,'dd/mm/yyyy') "DATE",sum(blocks)*8/1024 "Backup IN MB" 
from v$backup_datafile
group by to_char(completion_time,'dd/mm/yyyy')
having to_char(completion_time,'dd/mm/yyyy')= to_char(sysdate,'dd/mm/yyyy');




Note : 1. Will only show completed size after first channel completion.... else shows 0
       2. Will only show for the current sysdate ,. 
            which means how much ever completed at 23:59. 
            again if you trigger the query after 00:00 it will calculate for current date and shows 0 until it completes the next channel
           
Note :
====
please use the commands carefully before executing in your server 
its advised to test in test server.

Note : 
====
Implementing or trying any of the advice from this blog is at your own risk.

Monday 8 September 2014

[SOLVED] RMAN Restore failed with error ORA-19870,ORA-19504, ORA-27086 Permission denied Restore to different host

[SOLVED] RMAN Restore failed with error ORA-19870,ORA-19504,  

Note :
please use the commands carefully before executing in your server 
its advised to test in test server.

Note : 
Implementing or trying any of the advice from this blog is at your own risk.  



ORA-27086 Permission denied 

Backup Taken in Lab Server 1

and Restoration tested in different Server.


Below is the error noticed and restoration completed for other peice but not completed for one peice

ORA-19870: error reading backup piece bk_ug4p912_s98820_p1_t855090210
ORA-19504: failed to create file "/u01/ORCL_APPT_2.dbf"
ORA-27086: unable to lock file - already in use
Linux : 13: Permission denied

ORA-19870: error reading backup piece bk_uikpekrcs_s97876_p1_t854224284
ORA-19507: failed to retrieve sequential file, handle="bk_uikpeks_s97876_p1_t854224284", parms=""
ORA-27029: skgfrtrv: sbtrestore returned error
ORA-19511: Error received from media manager layer, error text:
   Backup file <bk_uikpekrcs_s97876_p1_t854224284> not found in DISK
failover to previous backup

But backup peice is available in backed up location


====

After analysing  below error
ORA-19870: error reading backup piece bk_ug4p912_s98820_p1_t855090210
ORA-19504: failed to create file "/u01/ORCL_APPT_2.dbf"
ORA-27086: unable to lock file - already in use --------------------- <<<<<<< Note this error, can lead you to solution.
Linux : 13: Permission denied

Understood the error

One source Server backup was taken the datafile ORCL_APPTSB_2 name was repeated but if different mount point. like below

File # 5 belongs to /u01/ORCL_APPT_2.dbf  ---- >>>> belongs to /u01
File # 6 belongs to /u02/ORCL_APPT_2.dbf  ---- >>>> belongs to /u02 ----<<<<<

When restoring the file it restores to same destination in /u01 and throws below error
ORA-19870: error reading backup piece bk_ug4p912_s98820_p1_t855090210
ORA-19504: failed to create file "/u01/ORCL_APPT_2.dbf"
ORA-27086: unable to lock file - already in use
Linux : 13: Permission denied



Solution 

=====

Set newname to datafile 6 to '/u01/ORCL_APPTSB_2_2.dbf'; solved the issue.

For datafile 5 let it be same