Monday, 16 March 2015

Backing up archived logs is very important. But why?

Consider a situation, when you do not have the recent backup of your database. Let me explain a bit.

Suppose you took a backup of the database around 2 or more hours ago but the database is up and running and constantly having frequent transactions. If any disaster occurs at this very moment  you will loose all the data of this 2 or more hours.

Now suppose we have the recent archived log backup. How is this gonna help?

So now we have 2 things

1. Old database backup (2 hours old)
2. Recent archived log backup ( Very recent)

We will able to restore and recover our database up to the record of the last archived log backup. And therefore data-loss will be minimum. This is basically called Roll-forward recovery that is to restore a damaged database to the most recent state before a failure occurred.

The restore and recover portion is same as the RMAN backup recovery of the database. Same steps.

Now how do we actually maintain this process of  backing up the archived logs. Have a look on the following process.

RMAN> alter system switch logfile;

Basically we force a log switch with this command.

When we fire this, 2 more things happen

1. Checkpoint occurs
2. That currently active redo group is archived

We run this command depending upon the nos of the redo log groups, if we have 3 redo log groups we run this 3 times just to ensure.

Then we take the backup of archived logs using

RMAN> backup archivelog all;

And that's it.

Some companies/organizations take the archived log backup after every 15 mins or so, depending upon the frequency of transactions for that particular database.

P.S. Please keep in mind, that the database needs to be in  mode. Well obviously. :)


That's all for now. Do not hesitate to correct or include any points or information that I have mentioned wrongly or missed completely. Your feedback is highly appreciated.

Thanks
Subhajit

Thursday, 12 March 2015

Restore controlfile in NOCATALOG mode

We have already discussed that how we shall backup and restore controlfile while we are in catalog mode using catalof database. You can find it here http://letstalkoracle.blogspot.in/2015/03/backup-restore-controlfile-using-rman.html

Now what if  we are not in catalog mode, means we are not using any catalog database. Can we still backup and restore the controlfile? The answer is yes.

Let's see how,

First we shall have to open RMAN, and connect to the target database in this way:

RMAN> connect target/

Now the backing up of the controlfile is the same as we do in case of CATALOG MODE.

Now coming to the restore part,

We can't write just RESTORE CONTROLFILE in nocatalog mode,

We have to write  it this way

RMAN> restore controlfile from '/RMAN backup location/backup piece name';

Consider this as an example,

RMAN> restore controlfile from '/u01/app/oracle/backup/1hq16igb_1_1';

And our controlfile will be restored fully.

And the rest of the procedure is the same as we do in case of catalog mode. You can find it here, http://letstalkoracle.blogspot.in/2015/03/backup-restore-controlfile-using-rman.html

That's all for now. Do not hesitate to correct or include any points or information that I have mentioned wrongly or missed completely. Your feedback is highly appreciated.

Thanks
Subhajit

Monday, 2 March 2015

Backup and restore controlfile using RMAN

Today we are gonna take the backup and then delete the controlfile and then again restore the same uing RMAN.

So let's do it. :)

Startup your target database.

Open RMAN prompt on the target environment and connect to your catalog database. If you haven't started the listener on the catalog host and the catalog database then please go ahead do it first.

Follow these steps. (rman/rman here are the username and the password catdb is the tns service on the target host for the catalog server).

RMAN> connect catalog rman/rman@catdb

connected to recovery catalog database

RMAN> connect target/

connected to target database: BASE (DBID=1899780213)

RMAN> backup current controlfile;

Wait until you see finished backup.

Then go to your RMAN backup location you will find the backup that has been just taken.

Now time to delete all the controlfile from every location. You might have 2 or more controlfile in different locations. Delete those.

Now shutdown your target database. And again then starup and see what happens :)

You will find this error

ORA-00205: error in identifying control file, check alert log for more info

Now open RMAN again and then connect to your catalog then

RMAN> connect target/

connected to target database:  (not mounted)

You see not mounted because you had that error identifying controlfile.

No worries you have the RMAN backup. So let's restore.

Do these

RMAN> restore controlfile;

RMAN> alter database mount;

RMAN> recover database;

RMAN> alter database open resetlogs; 

database opened
new incarnation of database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
 

So finally the target database is open now. You can check the status on the sql prompt.

That's all for now. Do not hesitate to correct or include any points or information that I have mentioned wrongly or missed completely. Your feedback is highly appreciated.

Thanks
Subhajit