Pages

Wednesday, July 3, 2019

How to delete archivelogs from the RMAN

How to delete archivelogs from the RMAN?
Problem: DBA wants to delete archivelogs from RMAN. Other details are below:
Database version is 11g R2
Database is called orcl which is hosted on Windows Server 2008 R2.
Database is not in recovery catalog.
DBA has Oracle 11g Client installed on his laptop.
DBA wants to connect “externally (via  listener)” to orcl from his laptop and delete archivelogs.
DBA verified that a tnsentry called “orcl” is already setup in his local tnsnames.ora file.
He used “tnsping orcl” command to verify the connectivity.

Solution:
Click on start
In the run box, type "cmd" and hit enter.
At the command prompt, type "rman" and hit enter.
At the RMAN> prompt, type the following (see below) and hit enter. It will prompt you for the password. If you have a user (tms) which has the "dba" granted to it, then you use that as well. For example, depending on which user you are using you can try one of the following.
connect target tms@orcl
or
connect target  sys@orcl
or
connect target  system@orcl

Once you are connected, then you can use the following to delete archivelogs with one of the following commands. You can choose the commands depending on your situation.


1.  To delete all Archivelogs withou backing them up:
delete archivelog all;



2.  To backup all archivelogs which are not already backed up atleast one time --And then perfom deletion
delete archivelog all backed up 1 times to device type disk;



3.  To delete archivelog upto a time which are not already backed up.
If they are already backed up, RMAN will just delete them. If they are not backed up atleast one time, then RMAN will back them up first before deleting
delete archivelog until time '2007-04-30:09:30:50' backed up 1 times to device type disk;


4.  To delete archivelog upto a time (without backing them up):
delete archivelog until time "to_date('OCT 31 2008 23:00:00','Mon DD YYYY HH24:MI:SS')";



5.  To delete archivelog two days or older which are not already backed up.
[If they are already backed up, RMAN will juste delete them. If they are not backed up atleast one time, then RMAN will back them up first before deleting]
delete archivelog until time 'sysdate-2' backed up 1 times to device type disk;


6.  To delete archivelogs "immediately" which are older than 2 days
delete force archivelog until time 'sysdate-2';


7.  To delete all archivelogs that are not backed up atleast one time, and then delete them
backup archivelog all not backed up 1 times delete input;

8.  To keep 1 hour of archivelog and delete all
delete archivelog until time 'sysdate-1/24';



Note-1: you can use “noprompt’ if you dont want RMAN to prompt you before deleting the archivelogs.
Note-2: you can use “force” if archivelogs are missing from the OS and you want to clean out the RMAN repository.


1 comment:

  1. Baccarat | Table games | FBCasino
    "I have to try https://casinowed.com/merit-casino/ these four variations for real money febcasino.com and https://septcasino.com/review/merit-casino/ have some of the best prices goyangfc.com in Vegas, so I definitely go casinowed.com

    ReplyDelete