Documente Academic
Documente Profesional
Documente Cultură
Physical Standby
Logical Standby
Physical Standby
Logical Standby
o 5.Monitoring
o 11.How does auditing work on a standby ? If it is enabled on the primary what happens to
the standby ?
o 13.The Standby Site Does Not Receive Logs Archived by the Primary Database
o 15.ORA-16181 Error
Physical Standby Databases are updated on the basis of block-for-block. The physical standby
database cannot perform both managed recovery and read-only operations at the same time, but
can switch between them
Logical Standby
To startup a physical standby database, use SQL*Plus to connect to the database with administrator
privileges, and then use the SQL*Plus STARTUP command with the NOMOUNT option.
If both the primary and standby databases are offline, then always start the standby database before
starting the primary database.
Once it is mounted, the database can receive archived redo data from the primary database.
The following example shows how to start a standby database:
Logical Standby
After the standby database is converter to logical standby, you can open it as a normal database and the
start the SQL apply to apply changes from primary.
An archive gap is a range of archived redo logs created whenever the standby system
is unable to receive the next archived redo log generated by the primary database.
For example, an archive gap occurs when the network becomes unavailable and automatic
archiving from the primary database to the standby database stops. When the network is
available again, automatic transmission of the redo data from the primary database to
the failed standby database resumes.
The missing archived redo logs are the gap. The gap is automatically detected and resolved.
An archive gap can occur whenever the primary database archives a log, but the log is not
archived to the standby site. Every minute, the primary database polls its standby databases
to see if there is a gap in the sequence of archived redo logs. The polling between the primary
and standby databases is sometimes referred to as a heartbeat. The primary database polls
the standby databases serially.
The following sections describe how to query the appropriate views to determine which logs
are missing on the standby database.
On a physical standby database
To determine if there is an archive gap on your physical standby database, query the V$ARCHIVE_GAP
view as shown in the following example:
SQL> SELECT * FROM V$ARCHIVE_GAP;
THREAD# LOW_SEQUENCE# HIGH_SEQUENCE#
----------- ------------- --------------
1 7 10
The output from the previous example indicates your physical standby database is currently
missing logs from sequence 7 to sequence 10 for thread 1. After you identify the gap, issue
the following SQL statement on the primary database to locate the archived redo logs on your
primary database (assuming the local archive destination on the primary database is
LOG_ARCHIVE_DEST_1):
SQL> SELECT NAME FROM V$ARCHIVED_LOG WHERE THREAD#=1 AND DEST_ID=1 AND SEQUENCE#
BETWEEN 7 AND 10;
NAME
--------------------------------------------------------------------------------
/primary/thread1_dest/arcr_1_7.arc
/primary/thread1_dest/arcr_1_8.arc
/primary/thread1_dest/arcr_1_9.arc
Copy these logs to your physical standby database and register them using the ALTER DATABASE
REGISTER LOGFILE statement on your physical standby database. For example:
SQL> ALTER DATABASE REGISTER LOGFILE
'/physical_standby1/thread1_dest/arcr_1_7.arc';
SQL> ALTER DATABASE REGISTER LOGFILE
'/physical_standby1/thread1_dest/arcr_1_8.arc';
:
:
After you register these logs on the physical standby database, you can restart managed recovery
operations.
To determine if there is an archive gap, query the DBA_LOGSTDBY_LOG view on the logical standby
database. For example, the following query indicates there is a gap in the sequence of archived
redo logs because it displays two files for THREAD 1 on the logical standby database. (If there
are no gaps, the query will show only one file for each thread.) The output shows that the highest
registered file is sequence number 10, but there is a gap at the file shown as sequence number 6:
SQL> SELECT THREAD#, SEQUENCE#, FILE_NAME FROM DBA_LOGSTDBY_LOG L WHERE
NEXT_CHANGE# NOT IN
(SELECT FIRST_CHANGE# FROM DBA_LOGSTDBY_LOG WHERE L.THREAD# = THREAD#) ORDER BY
THREAD#,SEQUENCE#;
Copy the missing logs to the logical standby system and register them using the ALTER DATABASE
REGISTER LOGICAL LOGFILE statement on your logical standby database. For example:
SQL> ALTER DATABASE REGISTER LOGICAL LOGFILE /disk1/oracle/dbs/log-1292880008_10.arc;
After you register these logs on the logical standby database, you can restart log apply services.
For both physical and logical standby databases, Data Guard performs gap detection and resolution
automatically. Normally no extra configuration settings are required.
5.Monitoring
5.1 Monitoring Log Apply Services for Physical Standby Databases
To monitor the status of archived redo logs and obtain information on log apply services on
a physical standby database, query the fixed views listed in this section.
V$MANAGED_STANDBY
V$ARCHIVE_DEST_STATUS
V$ARCHIVED_LOG
V$LOG_HISTORY
V$DATAGUARD_STATUS
The following events are automatically administered by log transport services and log apply services,
and therefore require no intervention by the database administrator:
A SQL ALTER DATABASE statement is issued with the ENABLE THREAD or DISABLE THREAD clause.
The status of a tablespace changes (changes to read/write or read-only, placed online or taken offline).
DDL statements are executed the same way on the primary database and the logical standby database.
If the underlying file structure is the same on both databases, the DDL will execute on the standby
database as expected.
If an error was caused by a DDL transaction containing a file specification that did not match in
the logical standby database environment, perform the following steps to fix the problem:
Use the ALTER SESSION DISABLE GUARD statement to bypass the database guard so you can make
modifications
to the logical standby database:
SQL> ALTER SESSION DISABLE GUARD;
Execute the DDL statement, using the correct file specification, and then re-enable the database guard.
For example:
SQL> ALTER TABLESPACE t_table
ADD DATAFILE '/dbs/t_db.f' SIZE 100M REUSE;
SQL> ALTER SESSION ENABLE GUARD;
Start SQL Apply on the logical standby database and skip the failed transaction.
SQL> ALTER DATABASE START LOGICAL STANDBY APPLY IMMEDIATE
SKIP FAILED TRANSACTION;
Or manually copy the new file over if the standby control file has been updated. For example:
1. Take copy of newly created datafile from primary database and copy to standby server where
sufficient space is available.
2. Rename datafile manually using alter database rename datafile command on standby database to
take effect on controlfile if the file structure is different with primary.
3. Apply archive log files on standby to make standby on sync.
In some situations, the problem that caused the transaction to fail can be corrected and SQL Apply
restarted without skipping the transaction. An example of this might be when available space is
exhausted. Do not let the primary and logical standby databases diverge when skipping DDL
transactions. You should manually execute a compensating transaction in place of the skipped
transaction.
For details how to manage Logical Standby Database DDL, please refer to
A.9.1.1 DDL Transactions Containing File Specifications on
http://download.oracle.com/docs/cd/B19306_01/server.102/b14239/toc.htm
To prevent DDL failed in Logical Standby Database, some DDL should be defined within skip handler. For
details how to, please refer to
9.4.4 Setting up a Skip Handler for a DDL Statement
http://download.oracle.com/docs/cd/B19306_01/server.102/b14239/toc.htm
The <standby> is Oracle Net Service Name. It contains net work protocol, host address, port, and SID
that the listeners for standby databases.
If the output of the query does not help you, please refer to
http://download.oracle.com/docs/cd/B19306_01/server.102/b14239/toc.htm Or metlink
14.What to Do If SQL Apply Operations to a Logical Standby
Database Stop
Log apply services cannot apply unsupported DML statements, DDL statements, and Oracle supplied
packages to a logical standby database in SQL apply mode.
When an unsupported statement or package is encountered, SQL apply operations stop. For details of
troubleshooting, please refer to 'A Troubleshooting Data Guard' from
http://download.oracle.com/docs/cd/B19306_01/server.102/b14239/toc.htm
Further reference:
For 10g, http://download.oracle.com/docs/cd/B19306_01/server.102/b14239/toc.htm
For 9i, http://download.oracle.com/docs/cd/B10501_01/server.920/a96653/toc.htm
For RAC,
http://download.oracle.com/docs/cd/B19306_01/server.102/b14239/rac_support.htm#SBYDB01700
15.ORA-16181 Error
When you start log apply and get error like ORA-16181, please set MAX_SGA < SHARED_POOL_SIZE *
75%
for example, we have 1GB shared pool size and get error when max_sga is on 1GB.
SQL> ALTER DATABASE START LOGICAL STANDBY APPLY;
ALTER DATABASE START LOGICAL STANDBY APPLY
*
ERROR at line 1:
ORA-16181: SGA specified for Logical Standby is too large
ORA-06512: at "SYS.DBMS_INTERNAL_LOGSTDBY", line 540
ORA-06512: at line 1
NAME
------------------------------
VALUE
--------------------------------------------------------------------------------
MAX_SGA
1024
Database altered.