Manually create a standby database

This post talks only about manually creating a standby database.

Configuring Dataguard CLI (DGMGRL) and dataguard through the Grid Control will be discussed later on in other subjects.

Since this blog is under oracle 10g, I will consider the databases to use spfiles.

To ease the difficulty, I will also consider that the folder structure on the primary database and the standby database are the same.

I will also try to describe the expected error when something is not done properly

The creation of a standby database consists of 3 parts:

1) Creation of standby spfile, controlfile, password file

2) Connectivity configuration (Listener, tnsnames)

3) Standby restoration, recovery and management



The databases’ instance names are: THTEST10

The primary database unique name is: THTEST10

The standby database unique name is: THTESTDG

Creation of standby spfile, controlfile, password file

1) Create the SPFILE for production and standby

On the production database:

Connect to sqlplus:

C:\> set oracle_sid=thtest10

C:\>sqlplus “/ as sysdba”

SQL>create pfile=’initthtest10.ora’ from spfile=’spfilethtest10.ora’;

From the file generated, initthtest10.ora, we are going to modify a bunch of parameters before converting it into spfile again.

If they don’t exist, add:






modify the archiving parameter:

*.log_archive_dest_1=’location=g:\oradata\THTEST10\arch valid_for=(ONLINE_LOGFILE,ALL_ROLES) db_unique_name=THTEST10′

The point is to add the optional values VALID_FOR and DB_UNIQUE_NAME. If they are missing, they might result into errors at the DGMGRL configuration time.

Make sure the host is specified in the parameter below:


Most of these parameters can be modified using the command when using a spfile.

SQL>alter system set <parameter name> = ‘value’ scope=both;

But some parameters, such as db_unique_name will require to modify the parameter file before hand, hence a shutdown of the DB is required.

It’s not possible to modify it while the DB is on.

On the standby database

Copy the modified init file and modify it again to fit standby requirements.

*.LOG_ARCHIVE_DEST_1=’location=g:\oradata\THTEST10\arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) db_unique_name=THTESTDG’

Finally, don’t forget to convert the pfile to spfile again and make sure both your primary and standby starts with a spfile.

2) Create the control file for the standby

On the production server, type the following command:

C:\>sqlplus connect / as sysdba
SQL>alter database create standby controlfile as ‘d:\somewhere\control01.ctl’;

Move the control file to the location specified in your spfile. If there’s more than one, just make a copy of the freshly generated one, and rename it.

2) Create the password file for the standby

Simply copy it from production to standby.

Connectivity configuration (Listener, tnsnames)

Notice the green bold service names in the pfile in the step above.

These will be specified in the tnsnames.ora and through it, our databases will communicate.

It is important to have both databases specified on both servers.

The tnsnames.ora file should look like this:




(ADDRESS = (PROTOCOL = TCP) (HOST = primaryserver)(PORT=1521)









(ADDRESS = (PROTOCOL = TCP) (HOST = standbyserver)(PORT=1521)




(UR = A)



Notice the value (UR=A) in the CONNECT_DATA of the tns entry THTESTDG.WORLD.

This will allow the primary database to connect remotely to a database in nomount or mount mode. It’s a feature introduced in oracle 10g.

Don’t forget to create the listeners on both servers.

Standby restoration, recovery and management

Finally the interesting part.

Before starting to work on the standby, take a hot backup of your primary database:

C:\>set oracle_sid=thtest10

C:\>RMAN target /

RMAN> backup database plus archive log not backed up 1 times;

Copy the backups to the standby. The folder structure for your backups should be the same as well to simplify.

On the standby server

Create an oracle service for your standby database with the oradim command

C:\>oradim -NEW -SID THTEST10 -startmode manual -shutmode n

Since the spfile is already located in ORACLE_HOME\database it doesn’t need to be mentioned.
Same for the password file which should be here already from the 1st step.

Restore and recover your database using RMAN

C:\ set oracle_sid=thtest10

RMAN target /

RMAN> restore database;

… (a log of things happens here)

RMAN> recover database;

… (archive logs are applied)

Now that the database is recovered, we will need to copy the redo logs from production to the standby.
That is required because this standby database will not be open with the resetlogs command therefore the redo logs will not be generated.
So, go back to production and copy the redo logs.
Make sure they are not accessed in order to copy it. To check the status of your redo log groups, connect as sysdba and use the following query:

SQL> select group#, status from v$log;


You can copy the groups with status INACTIVE. The group with a status CURRENT can’t be copied right now but we will force switch to another group:

SQL>alter system switch logfile;

SQL> select group#, status from v$log;


Now it’s ok to copy group# 3 to the standby server

Switching to automatic recovery

Previously, to recover the database with RMAN we had to set the database to mount mode. We must now shutdown and go into mount standby mode. That’s how it works:

SQL> startup nomount;

SQL>alter database mount standby database;

SQL>recover automatic standby database;

You should get ORA- messages: ORA-00279 ORA-00289 ORA-00280 ORA-0027. This is a normal behavior. The OS message saying that it’s not finding a missing archive log is normal too since at a certain point it will reach the latest archive and the next one is not generated yet. Result: it fails but we like it.

Cancel the operation by simply typing cancel. When the media recovery is canceled, you should get an error message as follow:

ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get
error below
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: ‘D:\ORACLE\ORADATA\OE\SYSTEM01.DBF’
ORA-01112: media recovery not started

This is normal too. There will be no open resetlogs anyway.

We can now move to:

Switching the standby into managed recovery mode

SQL>recover managed standby database;

This command will not return the hand to you.

Any further sql query will have to be run from another command line.

Testing your newly created standby database

Go to the primary database and type the command:

SQL>alter system switch logfile;

This command will generate a new archive log file.

You should see it’s generation in the alert log.

You should be able to see the standby database fetching it and applying it to the standby database.

You should also see the newly moved archive log in the archive folder.

If it’s not working

Investigate the following:

Are the listeners working?
Are the tnsnames.ora configured to reflect the parameters specified in log_archive_dest_2?
Is the parameter *.service_names=’THTEST10.WORLD’ reflecting the service_name specified in tnsnames.ora (in connect_data)?

These should be a good starter. This process is very rigorous. Read the error message carefully and comply to what it requires.

We will see next how to configure dataguard to manage the primary and standby database.



6 Responses to “Manually create a standby database”

  1. 1 Pech matine
    December 4, 2008 at 8:45 am

    Dear Sir,

    I need to do standby database on not the same structure on both servers. Can you give me how to configure parameter on both servers?

    oh!one thing I want to do with RMAN. Can you help me?


  2. 2 Alexwebmaster
    March 3, 2009 at 12:44 pm

    Hello webmaster
    I would like to share with you a link to your site
    write me here preonrelt@mail.ru

  3. July 5, 2010 at 12:26 pm

    Is the above steps applicable for 11g rel 2 also to do data guard hand on.

    what is (UR = A) and how to confifure listner in 11g. which file to modify endpoints_listener.ora or listener.ora.

    bye the way my 11g clusterware is staring listener.

    in fact i like to complete the task in 11g mentioned below:



  4. September 28, 2014 at 6:31 pm

    After I initially commented I appear to have clicked the -Notify me when new comments are added- checkbox and from now
    on each time a comment is added I get 4 emails with the same comment.
    Perhaps there is a means you are able to remove me from
    that service? Thanks a lot!

  5. December 7, 2016 at 4:12 pm

    Es memor que adquieras ⅼos batidos pata perder peso еn sitios offline ү
    on-lіne dе confianza siemprᥱ aⅼ frente de un profesional qque tе pueda asesorar ɑnte una
    duda concreta.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

October 2007
« Aug   Nov »


Blog Stats

  • 515,599 DB lovers

%d bloggers like this: