Sunteți pe pagina 1din 14

Data Guard Active Standby Database Setup using RMAN Duplicate on Windows Server

Introduction................................................................................................................................................... 2
Configuration Steps ....................................................................................................................................... 2
Network configuration .................................................................................................................................. 2
Hosts File ....................................................................................................................................................... 3
Creating "oracle" User ................................................................................................................................... 3
Assigning Full Control to "oracle" User to the Drives.................................................................................... 4
Environment Variables .................................................................................................................................. 4
Windows Firewall .......................................................................................................................................... 4
Oracle Installation ......................................................................................................................................... 5
Primary Server Setup..................................................................................................................................... 5
Service Setup ................................................................................................................................................. 7
Create Standby Controlfile and PFILE............................................................................................................ 8
STANDBY Server ............................................................................................................................................ 9
Change Computer Name ............................................................................................................................... 9
Network configuration .................................................................................................................................. 9
Creating directories on the Standby Server .................................................................................................. 9
Create Service.............................................................................................................................................. 10
Creation of Service using "oradim" ............................................................................................................. 10
Copy Control File and PFILE on Standby Server .......................................................................................... 11
Create Standby Redo Logs on Primary Server ............................................................................................. 12
RMAN Duplicate .......................................................................................................................................... 13
Start REDO APPLY ........................................................................................................................................ 13
Test Log Transport ....................................................................................................................................... 13
References ................................................................................................................................................... 14
Introduction

In this set up I used :


 Two Oracle VMs/Boxes with Windows Server 2008 Server operating system already installed
 Oracle Database 11.2.0.4 will be used and
 Domain name is not used in this setup

Configuration Steps

1st Server Name "orasys1" (physical)

 Oracle Enterprise Database (11.2.0.4) will be created on this host


 3 Drives were assigned (Drives E, F and G)
 Drive E - Oracle Home
 Drive F - oradata
 Drive G - fast_recovery_area/recovery_area

To Change Computer Name

 Login as Administrator to change Computer name to "orasys1"


 Navigation:
 From "Start" -> Computer -> System Properties -> Change Settings - click on Change
 Type "orasys1" in the "computer name" box
 In the "workgroup" box "WORKGROUP" is already selected. If it is not then select "workgroup"
 Restart the System

Network configuration

I choose to use the default DNS Server IP of Oracle Virtual Box.


See the section "VirtualBox Network Setup" from the below link, If you want to set up Networking on
"Oracle Virtual Box"

http://www.oracle-base.com/articles/12c/oracle-db-12cr1-rac-installation-on-oracle-linux-6-using-
virtualbox.php

Navigation :

 From "Start" ->on "Network" -> "Network and Sharing Center" -> "Manage Network
Connections" - right click on "Local Area Connections" -> uncheck "internet protocol version 6"
(We configure with Internet Protocol Version 4)
 Click on "Internet Protocol Version 4 (TCP/IPv4)"
 Click on "Properties" in this window and
 Select "use the following IP Address", It is :

 IP Address - 192.168.56.101
 Subnet Mask - 255.255.255.0
 Default Gateway - 192.168.56.1 and
 In the preferred DNS Server - 192.168.56.1
 Click "OK" and again "OK" to exit

Hosts File

 This may not be a compulsion on Windows but I want to make sure that I mention the IP and
Host name in this Hosts file.
 To amend host name in the host file we use "notepad" at the prompt to open the Hosts File.
 C:\> notepad \windows\system32\drivers\etc\hosts
 We write the IP Address and Host Name (we are not using any domain in this setup and we will
mention only Host Name and it works).
 In this way " 192.168.56.101 orasys1 ". I usually type the IP and press "TAB" Key once and then
write the hostname.
 To keep things easier I typed the second Host Name and IP in the next line in advance.
 It was " 192.168.56.102 orasys2 ". Save the Hosts file.

Creating "oracle" User

 To open "Server Manager " directly from CMD Window, type at the prompt :
%systemroot%\system32\compmgmtlauncher.exe OR
 Navigate:
 open "Server manager" -> expand "Configuration" and "Local Users and Groups" and finally right
click on "Users" and open "New User"
 In the "User Name" box we write "oracle"
 Check only "password never expires"
 Click on "create" to create "oracle" User
 In the window "Users" we should now see the user "oracle"
 Double click on "oracle" User
 "Oracle Properties" window pops up. Click on "Member Of" (we assign the User "oracle" in the
Administrator Group. It is a must.)
 Click on "add" and now "select groups" window should pop up
 Click on "advanced " and again on "find now"
 In the column "Name" we would see "Administrators". Click on "Administrators" and now click
"OK"
 We should now see "the_host_name\administrators" in the box "enter the object names to
select"
 Click " OK " and "Apply"
Assigning Full Control to "oracle" User to the Drives

Assigning Full Control to "oracle" User to the Drives E, F and G :

 Click "start" -> "computer" -> right click on Drive "E" and select "properties"
 Click on "security" and on "edit"
 Click on "add"
 Write "oracle" in the box "enter the object names to select " and click on "check names".
"the_host_name\oracle" should be now seen
 Click on "ok"
 Click on the User "oracle" and now we click or put a check mark to "full control" under "allow"
 Click "ok". This way the User "oracle" has full control over the Drive
 Verify:
In the "group or usernames" find the user "oracle" and click on it. We will see a "right check
mark" next to "full control"
 We repeat the same step for the Drives "F" and "G"

Environment Variables

 Log in as "oracle" User


 Open the "System Properties" Window (Navigation: Start -> Control Panel -> System and Security
-> System -> Change Settings)
 We do the following :
 Click on the Advanced tab and then on "Environment Variables" button
 Edit both the "TEMP" and "TMP" Environment Variables to be "%WINDIR%\temp", which is
"C:\Windows\temp"

 To set ORACLE_HOME Variable:


 Click "New" write ORACLE_HOME in "Variable Name" and the Path of it in "Variable Value"
 In my case, I typed "E:\app\oracle\product\11.2.4\dbhome" in the "Variable Value"

 To set PATH Variable:


 Click "New" and type PATH in "Variable Name" and in "Variable Value" the
"%ORACLE_HOME%\bin;%PATH%"
 Click the "OK" and then "Apply" and
 "OK" to exit from of the window

Windows Firewall

 We can turn the Firewall off logged in as "oracle" User.


 We turn the Windows Firewall to off to prevent it from interfering with the sever
communication.
 We can turn it on later and open up any required ports if we want to.
 Navigation:
 "Server Manager -> Local Server -> Windows Firewall -> Public: On -> Turn Windows Firewall to
off"

Oracle Installation

 Login as "oracle" User and we install Oracle Software and create Database
 The Oracle Software is saved on my Shared Folder of Oracle Virtual Box. So, this folder is a
Network Folder
 Navigation: From "Start" open "network" and open the shared folder accessed from the guest
system OR start -> computer -> open the folder in "network location"
 Double click on "set up" (Note: we use the same "sys" password for Primary and Standby)
 Prefer the "Desktop Class" or "Server Class" type of Installation that is suitable to you during the
Installation. I prefer to test always with "Server class " installation
 I set Oracle SID as "db11g" and Global Database Name as "db11g.world"
 I completed the installation with :
 Drive E - Oracle Home
 Drive F - oradata
 Drive G - fast_recovery_area/recovery_area
 We should now make a note or check the locations of oradata (that means, the location of
database files), admin, diag and fast_recovery_area/recovery_area (if enabled)

Primary Server Setup

Note: Some steps are copied from the below link and modified as suitable for this installation
http://www.oracle-base.com/articles/11g/data-guard-setup-11gr2.php

Logging

Check that the primary database is in Archivelog mode

SELECT log_mode FROM v$database;

LOG_MODE
------------
NOARCHIVELOG

SQL>

if it is not in Archivelog mode, we switch the primary database to Archivelog mode,


it is done in this manner :

SQL>shutdown immediate;
SQL> startup mount;
SQL> alter database archivelog;
SQL> alter database open;

We can verify further using the below SQL Statements:


SQL> show parameter log_archive_dest_1;
SQL> show parameter log_archive_dest_2;
SQL> show parameter log_archive_format;

Enabled forced logging by issuing the following command

SQL > ALTER DATABASE FORCE LOGGING

Initialization Parameters

Check the setting for the DB_NAME and DB_UNIQUE_NAME parameters. In this case they are both set to
"DB11G" on the primary database.

SQL> show parameter db_name

NAME TYPE VALUE


------------------------------------ ----------- ------------------------------
db_name string DB11G

SQL> show parameter db_unique_name

NAME TYPE VALUE


------------------------------------ ----------- ------------------------------
db_unique_name string DB11G

The DB_NAME of the standby database will be the same as that of the primary, but it must have a
different DB_UNIQUE_NAME value.

The DB_UNIQUE_NAME values of the primary and standby database should be used in the DG_CONFIG
setting of the LOG_ARCHIVE_CONFIG parameter.

For this example, the standby database will have the value "DB11G_STBY".

ALTER SYSTEM SET LOG_ARCHIVE_CONFIG= 'DG_CONFIG=(DB11G,DB11G_STBY)' ;

Set suitable remote archive log destinations. In this case I'm using the fast recovery area for the local
location, but you could specify an location explicitly if you prefer.

Notice the SERVICE and the DB_UNIQUE_NAME for the remote location reference the standby location.

ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=db11g_stby NOAFFIRM ASYNC


VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=DB11G_STBY';
ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE;
The LOG_ARCHIVE_FORMAT and LOG_ARCHIVE_MAX_PROCESSES parameters must be set to
appropriate values and the REMOTE_LOGIN_PASSWORDFILE must be set to exclusive.

ALTER SYSTEM SET LOG_ARCHIVE_FORMAT='%t_%s_%r.arc' SCOPE=SPFILE;


ALTER SYSTEM SET LOG_ARCHIVE_MAX_PROCESSES=30;
ALTER SYSTEM SET REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE SCOPE=SPFILE;

In addition to the previous setting, it is recommended to make sure the primary is ready to switch roles
to become a standby.

For that to work properly we need to set the following parameters.

Adjust the *_CONVERT parameters to account for your filename and path differences between the
servers.

ALTER SYSTEM SET FAL_SERVER=DB11G_STBY;


--ALTER SYSTEM SET DB_FILE_NAME_CONVERT='DB11G_STBY','DB11G' SCOPE=SPFILE;
--ALTER SYSTEM SET LOG_FILE_NAME_CONVERT='DB11G_STBY','DB11G' SCOPE=SPFILE;
ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO;

Remember, some of the parameters are not modifiable, so the database will need to be restarted before
they take effect.

Service Setup

Entries for the primary and standby databases are needed in the tnsnames.ora files on both servers.

First we setup this on Primary.

"C:\ notepad %ORACLE_HOME%\network\admin\tnsnames.ora". You can create these using the


Network Configuration Utility (netca) or manually. The following entries were used during this setup.

DB11G =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = orasys1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = DB11G.WORLD)
)
)

DB11G_STBY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = orasys2)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = DB11G.WORLD)
)
)

Create Standby Controlfile and PFILE

Create a controlfile for the standby database by issuing the following command on the primary database.

ALTER DATABASE CREATE STANDBY CONTROLFILE AS 'E:\db11g_stby.ctl';

Create a parameter file for the standby database.

CREATE PFILE='E:\initDB11G_stby.ora' FROM SPFILE;

Amend the PFILE making the entries relevant for the standby database. I'm making a replica of the
original server, so in my case I only had to amend the following parameters. (I just wrote the below
parameters at the end of the file)

*.db_unique_name='DB11G_STBY'
*.fal_server='DB11G'
*.log_archive_dest_2='SERVICE=db11g ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
DB_UNIQUE_NAME=DB11G'

*.log_archive_dest_2='SERVICE=db11g ASYNC VALID_FOR=(ONLINE_LOGFILES, PRIMARY_ROLE)


DB_UNIQUE_NAME=DB11G'

Make a note or recheck the locations of oradata, controlfile, fast_recover_area etc. from the PFILE
(initDB11G_stby.ora)

Copy Files to the Standby Server (Virtual Box Shared Folder)

Copy Files to the Standby Server using Oracle Virtual Box Shared Folder

The easiest way I found is just copy or cut or move the 2 files (db11g_stby.ctl and initDB11G_stby.ora
that we created in the last step) from the Drive E to the shared folder of Oracle virtual Box (In my case,
the 1st Host "orasys1" had already a shared folder with 11G Oracle Software.

So, I just moved them to this location. (Make sure these 2 files are easily visible to you in the shared
folder). In addition to these 2 files I also coped the listener.ora and tnsname.ora just in case of need of
them.

I just attached this Oracle Virtual Box Shared folder (11G Oracle Software) again to the Host "orasys2"
where Standby Database will be created.
STANDBY Server

 2nd host name orasys2 (Standby Host)


 Oracle Software only will be installed
 3 Drives were assigned (Drives E, F and G)
 Drive E: is for Oracle Home, F: for "oradata" and G: for "fast_recovery_area /recovery_area".

Change Computer Name


To change the Computer name to "orasys 2"

This step is found above.

Network configuration

 From "Start" -> click on "network" -> click on "network and sharing center" -> "manage network
connections" -> right click on "local area connections" -> uncheck "internet protocol version 6"
(We configure with Internet Protocol Version 4)
 Click on "internet protocol version 4 (TCP/IPv4)" and now click on the "properties" in this
window and select "use the following IP Address"
 IP Address - 192.168.56.102
 Subnet Mask - 255.255.255.0
 Default Gateway - 192.168.56.1
 In the preferred DNS Server - 192.168.56.1
 Click "OK" and again "OK"

Creating directories on the Standby Server


Creating directories on Host "orasys2" which is a Standby Server

We create the necessary Directories on the Standby.


I just created the directories keeping a note from " initDB11G_stby.ora " file.
We need to create directories for " oradata, fast_recovery_area/recovery_area and adump "

On Windows we can create directories using "md" Command (make directory).


An example using "md " command to create multiple directories
C:\> md E:\test\folder1\folder2

Hosts File

 This may not be a compulsion on Windows but I want to make sure that I mention the IP and
Host name in the Hosts File.
 To amend Host Name in the Host File we use "notepad" at the Command prompt. In this way
 C:\> notepad \windows\system32\drivers\etc\hosts
 We write the IP Address and Host Name (As we are not using any Domain in this setup I
mentioned only Host Name and it works).
 In this way " 192.168.56.102 orasys2". I usually type the IP and press "TAB" Key once and write
the Host Name.
 To keep things easier I typed " 192.168.56.101 orasys1 " in the next line which is the IP Address
and Host Name of the 1st Host that we created already. Save the file.

Creating "oracle" User

Creating "oracle" User: This step is found above.

Assigning Full Control to "oracle" to the Drives E, F and G

This step is found above.

Environment Variables

This step is found above.

Windows Firewall

This step is found above.

Create Service

 We open cmd window with "run as administrator"


 Click "start" and in the " start search " box write "cmd". We'd see "cmd " now but do not open
 Right click on "cmd" and select "run as administrator" to open cmd window as Administrator.
Click on "continue".
 Verify : On the top of the window we now see this cmd window is running as Administrator
 To see difference : Click "start" and in the " start search " box write "cmd" and just open it.
Compare the two command windows now.
 We get errors when we create an Oracle Instance opening a cmd window not as an
Administrator

Creation of Service using "oradim"

 The first step is to create a Service (cmd window is opened with "run as administrator")
 While you are in cmd window just type "oradim" and the "oradim" usage help is displayed
 Enter the same "sys" password for "-intpwd" that you created for the primary database. The full
command to create Service is :
 C:\> oradim -new -sid db11g -intpwd <password> -startmode manual
 Verify: Open "Services" and just click on any service and then press 'o' key (Oracle related
services are saved with the letter "o". We save our time to search in this way)
 A Service with a name "oracleservicedb11g" should be visible now. Note the status of it. It
should be in the State "manual"
 The password file will be saved in %ORACLE_HOME%\database Folder
Copy Control File and PFILE on Standby Server

 Open the Virtual Box Shared folder attached to this Host


 Copy the File "db11g_stby.ctl" to the location "F:\oradata\DB11G\" and rename it (right click on
the file and click on "rename") to "control01.ctl"
 Copy the file "db11g_stby.crl" to the location "G:\fast_recovery_area or recovery_area\DB11G\ "
and rename (right click on the file and click on "rename") it to " control02.ctl "
 Copy the file " intDB11G_stby.ora " and save in the location "%ORACLE_HOME%\database\"

Listener.ora

When using active duplicate, the standby server requires static listener configuration in a "listener.ora"
file. In this case I used the following configuration.

"C:\ notepad %ORACLE_HOME%\network\admin\listener.ora"

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = DB11G.WORLD)
(ORACLE_HOME = E:\app\oracle\product\11.2.4\dbhome)
(SID_NAME = DB11G)
)
)

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = orasys2)(PORT = 1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)

ADR_BASE_LISTENER = E:\app\oracle

tnsnames. ora

"C:\ notepad %ORACLE_HOME%\network\admin\tnsnames.ora".

You can create this using the Network Configuration Utility (netca) or manually. The following entries
were used during this setup.

DB11G =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = orasys1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = DB11G.WORLD)
)
)

DB11G_STBY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = orasys2)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = DB11G.WORLD)
)
)

Create Standby Redo Logs on Primary Server

The DUPLICATE command automatically creates the standby redo logs on the standby. To make sure the
primary database is configured for switchover, we must create the standby redo logs on the primary
server. In my case it is

ALTER DATABASE ADD STANDBY LOGFILE ('F:\oradata\DB11G\onlinelog\standby_redo01.log') SIZE 50M;


ALTER DATABASE ADD STANDBY LOGFILE ('F:\oradata\DB11G\onlinelog\standby_redo02.log') SIZE 50M;
ALTER DATABASE ADD STANDBY LOGFILE ('F:\oradata\DB11G\onlinelog\standby_redo03.log') SIZE 50M;
ALTER DATABASE ADD STANDBY LOGFILE ('F:\oradata\DB11G\onlinelog\standby_redo04.log') SIZE 50M;

Make sure the listener is started on the standby server.

C:\> lsnrctl status If it is not running then C:\> lsnrctl start

On Standby Server

C:\> set ORACLE_SID=DB11G


C:\> sqlplus sys as sysdba

SQL> STARTUP NOMOUNT

On Primary Server

Connect to RMAN on the Primary specifying a full connect string for both the TARGET and AUXILIARY
instances.
C:\> rman TARGET sys/password@DB11G AUXILIARY sys/password@DB11G_STBY
RMAN Duplicate

Now we issue the following DUPLICATE command

DUPLICATE TARGET DATABASE


FOR STANDBY
FROM ACTIVE DATABASE
DORECOVER
SPFILE
SET db_unique_name='DB11G_STBY' COMMENT 'Is standby'
SET LOG_ARCHIVE_DEST_2='SERVICE=db11g ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
DB_UNIQUE_NAME=DB11G'
SET FAL_SERVER='DB11G' COMMENT 'Is primary'
NOFILENAMECHECK;

Start REDO APPLY

Start the Redo Apply process on Standby Server using

SQL>ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

Test Log Transport

On the primary server, check the latest archived redo log and force a log switch

ALTER SESSION SET nls_date_format='DD-MON-YYYY HH24:MI:SS';

SELECT sequence#, first_time, next_time


FROM v$archived_log
ORDER BY sequence#;

ALTER SYSTEM SWITCH LOGFILE;

Check the new archived redo logs have arrived at the standby server and have been applied using

ALTER SESSION SET nls_date_format='DD-MON-YYYY HH24:MI:SS';

SELECT sequence#, first_time, next_time, applied


FROM v$archived_log
ORDER BY sequence#;
References

The below articles helped me out to play Oracle on Windows Server:


http://www.oracle-base.com/articles/11g/data-guard-setup-11gr2.php

Oradim Utility on Windows:

http://www.dba-oracle.com/tips_oradim_utility.htm

And also the below links were helpful too:

http://nadeemmohammed.wordpress.com/2012/05/24/how-to-create-oracle-11g-database-manually-
on-windows/

http://neeraj-dba.blogspot.in/2011/10/active-standby-database-in-oracle-11g.html

S-ar putea să vă placă și