DataGuard Setup Step by Step
DataGuard Setup Step by Step
DataGuard Setup Step by Step
Logging
Check that the primary database is in archivelog mode.
LOG_MODE
------------
NOARCHIVELOG
SQL>
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
ALTER DATABASE ARCHIVELOG;
ALTER DATABASE OPEN;
Create standby redo logs on the primary database (in case of switchovers). The
standby redo logs should be at least as big as the largest online redo log and there
should be one extra group per thread compared the online redo logs. In my case, the
following standby redo logs must be created on both servers.
If you want to use flashback database, enable it on the primary now, so it will be
enabled on the standby also. It's very useful as you will see below.
SQL>
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. For this example, the standby database
will have the value "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 a location explicitly if you prefer.
Notice the SERVICE and the DB_UNIQUE_NAME for the remote location reference the
standby location.
Service Setup
Entries for the primary and standby databases are needed in the
"$ORACLE_HOME/network/admin/tnsnames.ora" files on both servers. You can
create these using the Network Configuration Utility (netca) or manually. The
following entries were used during this setup. Notice the use of the SID, rather than
the SERVICE_NAME in the entries. This is important as the broker will need to connect
to the databases when they are down, so the services will not be present.
db11g =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = ol7-112-dg1)(PORT = 1521))
)
(CONNECT_DATA =
(SID = db11g)
)
)
db11g_stby =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = ol7-112-dg2)(PORT = 1521))
)
(CONNECT_DATA =
(SID = db11g)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ol7-112-dg1)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = db11g_DGMGRL)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0.4/db_1)
(SID_NAME = db11g)
)
)
ADR_BASE_LISTENER = /u01/app/oracle
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ol7-112-dg2)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = db11g_stby_DGMGRL)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0.4/db_1)
(SID_NAME = db11g)
)
)
ADR_BASE_LISTENER = /u01/app/oracle
Once the listener.ora changes are in place, restart the listener on both servers.
lsnrctl stop
lsnrctl start
*.db_name='db11g'
$ mkdir -p /u01/app/oracle/oradata/db11g
$ mkdir -p /u01/app/oracle/fast_recovery_area/db11g
$ mkdir -p /u01/app/oracle/admin/db11g/adump
Create a password file, with the SYS password matching that of the primary database.
$ orapwd file=/u01/app/oracle/product/11.2.0.4/db_1/dbs/orapwdb11g
password=Password1 entries=10
$ export ORACLE_SID=db11g
$ sqlplus / as sysdba
SQL> STARTUP NOMOUNT PFILE='/tmp/initdb11g_stby.ora';
Connect to RMAN, specifying a full connect string for both the TARGET and
AUXILIARY instances. Do not attempt to use OS authentication.
If you need to convert file locations, or alter any initialisation parameters, you can do
this during the DUPLICATE using the SET command.