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 MarsDB 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 MarsDB from his laptop and delete archivelogs.
- DBA verified that a tnsentry called “MarsDB” is already setup in his local tnsnames.ora file.
- He used “tnsping MarsDB” 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 (NA5099) 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 NA5099@MarsDB
or
connect target sys@MarsDB
or
connect target system@MarsDB
|
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 perfome 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 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 '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;
|
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.
No comments:
Post a Comment