You are on page 1of 10

Manual Standby Database under Oracle Standard ... http://www.databasejournal.com/features/oracle/ar...

IT Professionals Developers Solutions eBook Library Webopedia Login Register

Free Newsletters: Search Database Journal:

DatabaseDaily

MS SQL SQL Scripts & Database DBA


Oracle DB2 Access MySQL PostgreSQL Sybase PHP Links
SQL Etc Samples Forum Videos

Database Journal | DBA Support | SQLCourse | SQLCourse2

Best Practices for Developing a Web Site: Checklists, Tips, Strategies & More. Download Exclusive eBook Now.

SQL Server/Oracle Administrator II/III


Federal Reserve Bank of Minneaplis
US-MN-Minneapolis

Post A Job | Post A Resume


» Database Journal Home
» DBA Videos
» Database Articles Featured Database Articles Usted esta tratando de acces
» Database Tutorials que ha sido denagada por po
MS SQL
ORACLE protección en el contenido we

Oracle
URL: e1.cdn.qnsr.com/cgi/d/2
June 14, 2007
MS Access /641874/549914/i0.html?;y=h
MySQL Manual Standby Database under Oracle Standard Edition //www.databasejournal.com/f
DB2 /article.php/3682421/Manual-
By Sean Hull
Database-under-Oracle-Stand
» RESOURCES
Database Tools Oracle's Standby technology has been rebranded as
DataGuard in recent versions of Oracle. Oracle has added a
SQL Scripts & Samples
layer of technology automation on top of the standby
Links
technology, making automatic Standby technology
» Database Forum seamless. But what about the folks on Standard Edition
» DBA Jobs Oracle? Are they left out in the cold?
» Sitemap
Well, it turns out that it is still possible to create a
News Via RSS Feed *manual* standby database on Oracle SE. Here's how you
do it.

1. First you need to create the initial standby


database. Here are the steps to do that:

a. Put the primary database in archivelog mode, if it is


not already, and add at least LOG_ARCHIVE_DEST and

1 of 10 02/04/2011 04:20 PM
Manual Standby Database under Oracle Standard ... http://www.databasejournal.com/features/oracle/ar...

LOG_ARCHIVE_START to your init.ora.


Be a Marketplace Partner SQL> SHUTDOWN IMMEDIATE
SQL> STARTUP MOUNT
SQL> ALTER SYSTEM ARCHIVE LOG START;

Your trusted Web b. Next, create a hotbackup of the primary database.


Host since 1997 Although you can do this with RMAN, it is probably
easiest to just do it manually so you know what is going
on. For each tablespace do:
Business EMail SQL> alter tablespace EXAMPLE begin backup;
SQL> !cp example01.dbf /my/db/backup/
SQL> !cp example02.dbf /my/db/backup/
SQL> !cp example03.dbf /my/db/backup/
Visit the SQL> alter tablespace EXAMPLE end backup;
Internet.com eBook
In the above example, the '!' symbol tells sqlplus to run
Library for the command from the shell, so we're using the Unix 'cp'
Technology command to make copies of those files (which are now
Professionals frozen in backup mode) in another location.

c. Now, create a standby controlfile from primary


Business Insurance database:
for the IT services ALTER DATABASE CREATE STANDBY CONTROLFILE AS '/oracle/dbs/stbycf.ctl';
industry
d. At this point, you want to copy everything over to the
standby server including datafiles, standby controlfile &
Business Insurance config files:
for the IT services $ scp /my/db/backup/*.dbf oracle@192.168.0.10:/export/home/oracle/
industry
e. From the standby machine, edit the standby init.ora
file. Use this parameter to tell Oracle where files on the
primary database will be located on the standby. For
example if you had files in /ora/oracle on primary, and
they are moved to /export/home/oracle on standby, this
would work for you:

DB_FILE_NAME_CONVERT='/ora/oracle','/export/home/oracle'

Note that you can use MULTIPLE pairs of values here, if


you have files in different locations. Alternatively, you
can startup and mount the standby database then issue:

SQL> alter database rename file '/ora/oracle/myfile.dbf' to /export/home/oracle/myfile.dbf

Now you're also likely to have a new location for your


archived redo log files, and that's where the parameter
LOG_FILE_NAME_CONVERT comes into play.

Important note, neither of these two parameters work


for the ONLINE redolog files. Those you will have to
rename yourself. If you do not do so, you will get an MARKETPLACE
error at the time you try to SWITCHOVER your standby
database. Such errors are easily remedied by running
that command.

f. Now, it's time to start the standby instance and mount


it.

SQL> startup nomount pfile=/export/home/oracle/admin/SEAN/pfile/initSEAN.standby

2 of 10 02/04/2011 04:20 PM
Manual Standby Database under Oracle Standard ... http://www.databasejournal.com/features/oracle/ar...

SQL> atler database mount standby database;

g. Almost there. Lastly, we need to recover the standby


database using the AUTO option. Note that you should build a simple shell script to startup
these commands. A name like manual_standby.sh would work well. You can then run this p
every half hour, from cron to apply any new archived redolog files that have showed up via
move_standby.sh below.

SQL> recover standby database;


AUTO

h. Now, of course, you'll want to test your standby database. You do this by starting up in r

SQL> alter database open read only;

i. Don't forget to put it back in standby mode so that when your manual_standby.sh script r
won't return errors.

SQL> shutdown immediate;


SQL> startup nomount pfile=/export/home/oracle/admin/SEAN/pfile/initSEAN.standby
SQL> atler database mount standby database;

2. What scripts should run via cron on the primary and standby database?

As we mentioned earlier, a script called manual_standby.sh would work well on the standby da
applies new archived redologs that have arrived from the production system. Run it every half
that works for you. The database must be mounted in standby mode (not read-only) or this scr

You'll also want a script on the production server. Name it move_standby.sh, and run it every
start with. This can use rsync to move redolog files from production to standby. A command lik

$ rsync -e ssh -Pazv /ora/oracle/arch/ oracle@remote:/export/home/oracle/arch/

Note that you may want to adjust options to ssh to your needs. In addition, this presumes you
configured. Read up on the ssh-keygen command. The .ssh directory contains a public key, wh
to the standby machine, and put in the "authorized_keys" file. ssh will then login without a pas
ssh as the transport mechanism, so it also executes without a password. Rsync is very smart a
blocks and pieces of files that are different, so it is very fast, and also does checksums to guara

3. Is the standby database behind the production database?


internet.commerce

Be a Commerce Partner Yes, keep in mind we are creating a manual standby database. The standby database will tend
production by about half the size of a redolog file. So if those files are 100M, and you generate
Phone Cards
Prepaid Calling Card transactions in 30 minutes, then on average standby will be fifteen minutes behind.
Televisions
Virtual Server 4. What types of changes and statements on production will not be automatically app
IT Legal Contracts
Web Hosting In database parlance, any PHYSICAL changes to the db, plus any commands, issues with the N
Promote Your Website
Host your Site
Physical changes include creation of new tablespaces, adding new datafiles, renaming datafiles
Desktop Computers datafiles, altering redolog files, altering controlfiles and so on. In addition, primary database p
VPS Hosting commands using the UNRECOVERABLE option will not be propagated to the standby database.
Website Hosting
Site Hosting
There are specific and detailed instructions for making some of these physical changes on the s
Business Liability
Liability Insurance manually, however in many cases recreating the entire standby database per the instructions a
best option.

5. How can we verify that the standby database is up to date?

If you already have the manual_standby.sh script running from cron, disable it.

Then login with sqlplus and issue:

3 of 10 02/04/2011 04:20 PM
Manual Standby Database under Oracle Standard ... http://www.databasejournal.com/features/oracle/ar...

SQL> alter database open read only;


Zynga Adds Mobile
Games Developer Now that you have the database open read-only, run whatever SQL commands you want to in
Area/Code
some change which you know about on production. When you are done, shutdown, and startup
Cloud, Virtualization again. Don't forget to reenable manual_standby.sh in the crontab.
Driving 2011 IT
Spending 6. What happens if the standby system restarts?
CoreTrace to Offer You could have it automatically start the standby database. In that case, be sure to just check
Whitelisted Linux, Mac
Apps want to do it manually in those instances, fire up sqlplus and then issue:

SQL> startup nomount pfile=/export/home/oracle/admin/SEAN/pfile/initSEAN.standby


SQL> alter database mount standby database;

internet.com 7. What kind of messages can I expect to see in the standby alert.log?
IT
Developer The alert.log is going to have a lot of extra messages since we are repeatedly trying to RECOV
Internet News or may not be new transaction logs. When it does this it will say, "looking for archived logfile 1
Small Business
found". On the other hand, if it finds it, it will say that it is applying it. You can use unix comma
Personal Technology
"less" to scan through the alert.log file quickly.
Search internet.com
Advertise 8. What other scripts should be put in place?
Corporate Info
Newsletters
Tech Jobs a. a script to cleanup old archived redo logs on primary.
E-mail Offers
b. a script to cleanup old archived redo logs on standby

c. a script to rotate and archive the alert.log file when it gets large

d. a script to watch the alert.log file for ORA-xxxxx errors and report them to nagios if it fin
primary and standby)

e. a script to login (via ssh autologin) and check what the latest archived redolog file is, and
to the standby and check the alert.log file to verify that those transactions have been applie

9. How do we switchover in the event of a failure of the primary?

Switchover *can* be done with a script, however I recommend with our manual standby datab
monitor for emergencies on production and (b) manually perform the failover if necessary. This
positives. Also, it allows you to ship additional redolog data if you have it available from produ

The switchover is a two-step process.

a. Apply remaining redo as we have done before with commands in manual_standby.sh.

b. Startup the database normally, in a read-write mode.

10. What network changes need to happen to failover?

The listener.ora file should be already configured. You can use the same config as primary with
you can give this db a different tnsname. For instance, you could call primary SEANA and stand
your application server configs, when you failover, your database connection configurations ne
point to SEANB. The app servers will probably also need to be restarted at this point.

11. Why can't the primary ship redologs and synchronous changes?

Basically they call it a *manual* standby database for a reason. DataGuard supports options t
following:

LOG_ARCHIVE_DEST_3='SERVICE=stby1 LGWR SYNC AFFIRM'

4 of 10 02/04/2011 04:20 PM
Manual Standby Database under Oracle Standard ... http://www.databasejournal.com/features/oracle/ar...

LOG_ARCHIVE_DEST_STATE_3=ENABLE

Again, these are not available in Oracle SE.

12. Once we've failed over, how do we switch back to the primary?

Switching back to the primary database involves these steps:

a. Follow the steps in item 1 above to create a standby database on what was the primary s

b. If you want to be perfectly clean syncing, do the following:

SQL> shutdown immediate


SQL> startup restrict
SQL> alter system switch logfile
SQL> shutdown immediate

c. Copy over the last archived redolog files

d. Apply them and switchover as described in item 8 above.

13. Are there special init.ora parameters? What makes our standby database special

The main two things that make it a standby database are:

a. The standby control file (created from primary)

- alter database create standby controlfile as '/my/path/to/standby.ctl

b. The process of mounting as a standby database

- startup nomount pfile=standby.ora

- alter database mount standby database;

There are of course some init.ora parameters which are special for the standby database as we

DB_FILE_NAME_CONVERT
LOG_FILE_NAME_CONVERT

So if you do a "shutdown immediate" on the standby, you would start again with:

SQL> startup nomount pfile=/export/home/oracle/admin/SEAN/pfile/initSEAN.standby


SQL> alter database mount standby database;

Conclusion:

Standby database technology in Oracle is a powerful high availability solution. Even if you're u
you can still take advantage of these features built into Oracle, with just a little scripting, hand
ample monitoring. Do your research, test, test, and test again on a development server. And d
monitor all your logfiles for errors. Following these guidelines, you should be in very good shap
cost.

» See All Articles by Columnist Sean Hull

Tools:

5 of 10 02/04/2011 04:20 PM
Manual Standby Database under Oracle Standard ... http://www.databasejournal.com/features/oracle/ar...

Add databasejournal.com to your favorites

Add databasejournal.com to your browser search box


IE 7 | Firefox 2.0 | Firefox 1.5.x

Receive news via our XML/RSS feed

Oracle Archives

7 Comments (click to add your comment)

By mzarick April 29 2009 11:23 AMPDT

nice article with good explanations. I just wanted to point out that there is a tool that allows you
keeping your standby databases in sync. TvdStandby by Trivadis. See http://www.trivadis.com
/fileadmin/user_upload/Solutions/Technologieberatung/Admin_Tools/PDF_EN
/TvdStandby_070603_en.pdf.
Features: support for RAC and ASM, Graceful Switchover, even with ASM. Housekeeping and
Monitoring. Regards mzarick

Reply to this comment

By srinivas May 20 2009 9:06 AMPDT

excellent article.

Thanks
Srinivas

Reply to this comment

By dan August 13 2009 4:18 AMPDT

Excellent article , tried this. When i query select * V$archived_log on standby ; I get no rows selected.
Why?

Reply to this comment

By Alistair Wall August 24 2009 7:06 AMPDT

In step 9, you have to run

alter database activate standby database;

before shutdown and normal start

Reply to this comment

6 of 10 02/04/2011 04:20 PM
Manual Standby Database under Oracle Standard ... http://www.databasejournal.com/features/oracle/ar...

By Sharon August 31 2009 2:51 PMPDT

I have a 10g linux oracle db. I followed all the steps, but run into problem when I did step 1.g

> recover standby database;

ORA-00279: change 2342934 generated on 8/27/2009 15:40:31 needed for thread 1


ORA-00289: suggestions: /path/to/arch/sid/1_833_682861383.arc
ORA-00280: change 2342934 for thread 1 is in sequence #833

AUTO

ORA-00317: file type 0 in header is not log file


ORA-00334: archived log: '/path/to/arch/sid/1_833_682861383.arc'

ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01195: online backup of file 1 needs more recovery to be consistent
ORA-01110: datafile 1: '/opt/oracle/oradata/sid/system01.dbf'

Please advise. Thanks

Reply to this comment

By kirik17 January 29 2010 1:34 AMPDT

to start standby database as primary:

check database role


SELECT OPEN_MODE,PROTECTION_MODE,DATABASE_ROLE FROM V$DATABASE;

ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH;

ALTER DATABASE ACTIVATE PHYSICAL STANDBY DATABASE;

here you can check that database role changed to 'PRIMARY'


SELECT OPEN_MODE,PROTECTION_MODE,DATABASE_ROLE FROM V$DATABASE;

ALTER DATABASE OPEN;

Reply to this comment

By thr January 4 2011 9:12 PMPDT

I've been looking for an article like this for some time. Very informative. I do have questions on some
of the steps:

1) Do I need to create the standby database using dbca first before copying the primary's data files
and config files over in step (1d)?

2)By config files you mean the tnsnames.ora, listener.ora, control and the init.ora files?

thanks for the clarifications.

Reply to this comment

Comment and Contribute

7 of 10 02/04/2011 04:20 PM
Manual Standby Database under Oracle Standard ... http://www.databasejournal.com/features/oracle/ar...

Your
name/nickname

Your email

XHTML: You can use these tags: <b> <u> <i>

(Maximum characters: 1200). You have 1200 characters left.

Please type the alphanumeric characters above and click "Submit" to continue.What's this?

I cannot read this. Please generate a New Image


See our comment policy.

Submit Your Comment

The Future of IT Continuity: Check out this webcast to see what it will take to get there.
You're Not Ready For Internal Cloud: Check Out Why.
Discover the opportunities and risks involved with virtualization. Read more.
How much will an IT security breach cost you? IBM and industry leaders share their insights.
Virtual Event: The Future of IT Continuity. Register now to see what will happen to IT continuity.

Latest Forum
Oracle Forum
Topic By Replies Updat

8 of 10 02/04/2011 04:20 PM
Manual Standby Database under Oracle Standard ... http://www.databasejournal.com/features/oracle/ar...

Converting value 8 to 8.000000 deepak1234 1 January 24th, 12


oracle installation britto116 2 January 5th, 07:3
Oracle Error TomD 0 January 4th, 05:0
Select Statement inet 1 January 3rd, 09:5

Pagina web bloqueada

Usted esta tratando de accesar una página


que ha sido denagada por políticas de
protección en el contenido web.

URL: e1.cdn.qnsr.com/cgi/d/2305/0/203
/641873/549914/i0.html?;y=http%3A
//www.databasejournal.com/features/oracle
/article.php/3682421/Manual-Standby-
Database-under-Oracle-Standard-

The Network for Technology Professionals

Search:

About Internet.com
Copyright 2011 QuinStreet Inc. All Rights Reserved.

Legal Notices, Licensing, Permissions, Privacy Policy.


Advertise | Newsletters | E-mail Offers

Solutions
Whitepapers and eBooks

9 of 10 02/04/2011 04:20 PM
Manual Standby Database under Oracle Standard ... http://www.databasejournal.com/features/oracle/ar...

PHP for Windows Showcase MORE WHITEPAPERS, EBOOKS, AND ARTICLES


Resource: PHP for Windows Showcase

Webcasts
On Demand Webcast: Essentials for Managing Your SAP Applications MORE WEBCASTS, PODCASTS, AND VIDEOS
Software License Operations - Cleaning Up the Backoffice

Downloads and eKits


MORE DOWNLOADS, EKITS, AND FREE TRIALS

Tutorials and Demos


Exceptional Web Experiences MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES
Internet.com Hot List: Get the Inside Scoop on IT and Developer Products

10 of 10 02/04/2011 04:20 PM