Pythian has openings for MySQL and MS SQL Server DBAs in each of our offices in Ottawa, Canada; Boston, USA; Dubai, UAE; and Hyderabad, India. If you are a MySQL and/or SQL Server DBA and would like to evaluate this opportunity, please send us your résumé with an introductory paragraph to hr@pythian.com.

Oracle: Standby Automatic File Management

By paulm May 30th, 2007 at 10:17 am
Posted in Group Blog PostsOracle

So you have followed the recipes to create a standby database, setup the database to switch logs automatically, and now, as with any good database, the space required to support the application grows and grows and grows.

Eventually, using your monitoring software (in my case, Pythian’s avail or dailies), you get an alert suggesting that you will need to add additional space. In this case you are going to add a datafile to a tablespace, or add a brand new tablespace.

You add the datafile on the primary and minutes later are paged with these kind of errors:

File #5 added to control file as 'UNNAMED00005' because
the parameter STANDBY_FILE_MANAGEMENT is set to MANUAL
The file should be manually created to continue.
MRP0: Background Media Recovery terminated with error 1274
Fri Apr  8 10:00:22 2005
Some recovered datafiles maybe left media fuzzy
Media recovery may continue but open resetlogs may fail

Basically, the standby is having some trouble applying the changes it has received from the primary redo log because the datafile is not there.

You can use the Oracle parameter standby_file_management along as:

  1. Your standby database doesn’t have major differences in datafile locations.
  2. The standby database is not using raw devices to store your datafiles.

This parameter set to AUTO means that Oracle will handle creating the new datafile on the standby if you add one or more on the primary.

But right now you are stuck with this new datafile and nowhere to go.

Method 1

Add the datafile to the standby database.

Oracle documentation: 9iR2, 10gR1 and 10gR2.

  1. Determine the impact of taking the tablespace offline!
  2. Take the tablespace offline OR put in backup mode: ALTER TABLESPACE name BEGIN BACKUP;
  3. Make a copy of the file locally.
  4. Bring the tablespace online OR take out of backup mode: ALTER TABLESPACE name END BACKUP;
  5. Copy the file to the standby server.
  6. ALTER SYSTEM ARCHIVE LOG CURRENT;

Method 2

ALTER DATABASE CREATE DATAFILE (on the standby).

  1. RECOVER MANAGED STANDBY DATABASE CANCEL;
  2. select file#,name from v$datafile where name like '%UNNAMED%';
  3. ALTER DATABASE CREATE DATAFILE ‘unnamed datafile’ AS ‘proper filename’;
  4. RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

Save yourself the hassle, just alter system set STANDBY_FILE_MANAGEMENT = AUTO;

Update: Thanks to Sverre for pointing out you can use tablespace hotbackup mode instead of tablespace offline.

Have Fun!
Paul.

Related Articles:

RMAN Duplicate command to create physical standby

Using ARCHIVE_LAG_TARGET to automatically switch logs

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Slashdot
  • Google
  • del.icio.us
  • Facebook
  • bodytext
  • Technorati
  • TwitThis
  • Reddit
  • Spurl
  • De.lirio.us
  • Furl
  • blogmarks
  • Ma.gnolia
  • E-mail this story to a friend!

2 Responses to “Oracle: Standby Automatic File Management”

  1. Sverre Says:

    For method 1, can’t you just put the tablespace in backup mode and copy the needed files to the standby?

  2. Paul M Says:

    Yep checked that method and it works fine. I will update the article.

Leave a Reply

Filling out the following captcha not only allows us to cut down on automated blogspam but also helps digitize books. Please feel free to send comments on this approach directly to Paul at vallee@pythian.com.

NOTE: After submitting your comment, verify that it is added to the blog. New comments will be marked as "waiting for moderation" (we only moderate for spam). If the level of spam is as low as we hope, we will bypass this step.