select name db_unique_name switchover_status database_role open_mode protection_mode protection_level from v$database;
On Standby
NAME | DB_UNIQUE_NAME | SWITCHOVER_STATUS | DATABASE_ROLE | OPEN_MODE | PROTECTION_MODE | PROTECTION_LEVEL |
---|---|---|---|---|---|---|
ORCL | ALPHA | NOT ALLOWED | PHYSICAL STANDBY | READ ONLY WITH APPLY | MAXIMUM PERFORMANCE | MAXIMUM PERFORMANCE |
NAME | DB_UNIQUE_NAME | SWITCHOVER_STATUS | DATABASE_ROLE | OPEN_MODE | PROTECTION_MODE | PROTECTION_LEVEL |
---|---|---|---|---|---|---|
ORCL | orcl | TO STANDBY | PRIMARY | READ WRITE | MAXIMUM PERFORMANCE | MAXIMUM PERFORMANCE |
To display redo information like redo data generated by the primary database that is not available on the standby database and how much redo has not been applied to the standby database.
select * from v$dataguard_stats;
On Standby
SOURCE_DBID | SOURCE_DB_UNIQUE_NAME | NAME | VALUE | UNIT | TIME_COMPUTED | DATUM_TIME | CON_ID |
---|---|---|---|---|---|---|---|
1700090799 | orcl | transport lag | +00 00:00:00 | day(2) to second(0) interval | 05/27/2024 13:40:58 | 05/27/2024 13:40:56 | 0 |
1700090799 | orcl | apply lag | +00 00:00:00 | day(2) to second(0) interval | 05/27/2024 13:40:58 | 05/27/2024 13:40:56 | 0 |
1700090799 | orcl | apply finish time | +00 00:00:00.000 | day(2) to second(3) interval | 05/27/2024 13:40:58 | 0 | |
0 | estimated startup time | 22 | second | 05/27/2024 13:40:58 | 0 |
To Check for messages/errors
select * from v$dataguard_status order by facility, timestamp desc;
On the Standby Database
FACILITY | SEVERITY | DEST_ID | MESSAGE_NUM | ERROR_CODE | CALLOUT | TIMESTAMP | MESSAGE | CON_ID |
---|---|---|---|---|---|---|---|---|
Log Apply Services | Informational | 0 | 12 | 0 | NO | 27-MAY-24 13:00:25 | Media Recovery Log /u01/app/oracle/oradata/ORCL/arch/ora_1_86_1172310070.arc | 0 |
Log Apply Services | Warning | 0 | 13 | 0 | NO | 27-MAY-24 13:00:25 | Media Recovery Waiting for T-1.S-87 (in transit) | 0 |
Log Apply Services | Informational | 0 | 11 | 0 | NO | 27-MAY-24 13:00:24 | Managed Recovery starting Real Time Apply | 0 |
Log Apply Services | Control | 0 | 10 | 0 | YES | 27-MAY-24 13:00:19 | Background Managed Recovery process started | 0 |
Log Apply Services | Control | 0 | 9 | 0 | YES | 27-MAY-24 13:00:19 | Starting Managed Recovery process for Physical Standby | 0 |
Log Transport Services | Control | 0 | 8 | 0 | YES | 27-MAY-24 12:50:30 | Completed archiving T-1.S-86 | 0 |
Log Transport Services | Control | 0 | 7 | 0 | YES | 27-MAY-24 12:50:29 | Beginning to archive T-1.S-86 (SCN:0x0000000001a98eff-SCN:0x0000000001a9ac89) | 0 |
Remote File Server | Informational | 0 | 6 | 0 | NO | 27-MAY-24 12:50:28 | Opened LNO:5 for DBID:1700090799 B-1172310070.T-1.S-86 | 0 |
Remote File Server | Informational | 0 | 5 | 0 | NO | 27-MAY-24 12:50:27 | krsr_rfs_atc: Identified database type as 'PHYSICAL STANDBY': Client is FAL (PID:10731) | 0 |
Remote File Server | Informational | 0 | 4 | 0 | NO | 27-MAY-24 12:50:27 | Opened LNO:4 for DBID:1700090799 B-1172310070.T-1.S-87 | 0 |
Remote File Server | Informational | 0 | 3 | 0 | NO | 27-MAY-24 12:50:26 | Primary database is in MAXIMUM PERFORMANCE mode | 0 |
Remote File Server | Informational | 0 | 2 | 0 | NO | 27-MAY-24 12:50:26 | krsr_rfs_atc: Identified database type as 'PHYSICAL STANDBY': Client is Foreground (PID:10739) | 0 |
Remote File Server | Informational | 0 | 1 | 0 | NO | 27-MAY-24 12:50:26 | krsr_rfs_atc: Identified database type as 'PHYSICAL STANDBY': Client is ASYNC (PID:10755) | 0 |
On the primary
FACILITY | SEVERITY | DEST_ID | MESSAGE_NUM | ERROR_CODE | CALLOUT | TIMESTAMP | MESSAGE | CON_ID |
---|---|---|---|---|---|---|---|---|
Log Transport Services | Control | 0 | 6 | 0 | YES | 21-SEP-24 17:27:21 | Beginning to archive LNO:3 T-1.S-87 | 0 |
Log Transport Services | Warning | 0 | 3 | 12541 | NO | 21-SEP-24 17:24:13 | Check whether the listener is up and running. | 0 |
Log Transport Services | Warning | 0 | 5 | 12541 | NO | 21-SEP-24 17:24:13 | Check whether the listener is up and running. | 0 |
Log Transport Services | Control | 0 | 4 | 0 | YES | 21-SEP-24 17:24:13 | Completed archiving T-1.S-86 | 0 |
Log Transport Services | Control | 0 | 2 | 0 | YES | 21-SEP-24 17:24:11 | Beginning to archive T-1.S-86 (SCN:0x0000000001a98eff-SCN:0x0000000001a9ac89) | 0 |
Log Transport Services | Warning | 0 | 1 | 12541 | NO | 21-SEP-24 17:24:06 | Check whether the listener is up and running. | 0 |
To display current status information for specific physical standby database background processes.
select process, status, thread#, sequence#, block#, blocks from v$managed_standby;
On the standby DatabasePROCESS | STATUS | THREAD# | SEQUENCE# | BLOCK# | BLOCKS |
---|---|---|---|---|---|
ARCH | CONNECTED | 0 | 0 | 0 | 0 |
DGRD | ALLOCATED | 0 | 0 | 0 | 0 |
DGRD | ALLOCATED | 0 | 0 | 0 | 0 |
ARCH | CONNECTED | 0 | 0 | 0 | 0 |
ARCH | CLOSING | 1 | 86 | 14336 | 339 |
ARCH | CONNECTED | 0 | 0 | 0 | 0 |
ARCH | CONNECTED | 0 | 0 | 0 | 0 |
ARCH | CONNECTED | 0 | 0 | 0 | 0 |
ARCH | CONNECTED | 0 | 0 | 0 | 0 |
ARCH | CONNECTED | 0 | 0 | 0 | 0 |
ARCH | CONNECTED | 0 | 0 | 0 | 0 |
ARCH | CONNECTED | 0 | 0 | 0 | 0 |
ARCH | CONNECTED | 0 | 0 | 0 | 0 |
ARCH | CONNECTED | 0 | 0 | 0 | 0 |
ARCH | CONNECTED | 0 | 0 | 0 | 0 |
ARCH | CONNECTED | 0 | 0 | 0 | 0 |
ARCH | CONNECTED | 0 | 0 | 0 | 0 |
ARCH | CONNECTED | 0 | 0 | 0 | 0 |
ARCH | CONNECTED | 0 | 0 | 0 | 0 |
ARCH | CONNECTED | 0 | 0 | 0 | 0 |
ARCH | CONNECTED | 0 | 0 | 0 | 0 |
ARCH | CONNECTED | 0 | 0 | 0 | 0 |
ARCH | CONNECTED | 0 | 0 | 0 | 0 |
ARCH | CONNECTED | 0 | 0 | 0 | 0 |
ARCH | CONNECTED | 0 | 0 | 0 | 0 |
ARCH | CONNECTED | 0 | 0 | 0 | 0 |
ARCH | CONNECTED | 0 | 0 | 0 | 0 |
ARCH | CONNECTED | 0 | 0 | 0 | 0 |
ARCH | CONNECTED | 0 | 0 | 0 | 0 |
ARCH | CONNECTED | 0 | 0 | 0 | 0 |
ARCH | CONNECTED | 0 | 0 | 0 | 0 |
ARCH | CONNECTED | 0 | 0 | 0 | 0 |
RFS | IDLE | 1 | 87 | 49456 | 1 |
RFS | IDLE | 1 | 0 | 0 | 0 |
RFS | IDLE | 0 | 0 | 0 | 0 |
MRP0 | APPLYING_LOG | 1 | 87 | 49456 | 409600 |
To find logs received and applied on the physical standby database
select 'last_logs_applied : ' as lastlog_applied, to_char(next_time, 'DD-MON-YY HH24:MI:SS') FROM V$ARCHIVED_LOG
WHERE SEQUENCE# = (SELECT MAX(SEQUENCE#) FROM V$ARCHIVED_LOG WHERE APPLIED = 'YES')
union
select 'last_logs_received : ' as lastlog_received, to_char(next_time, 'DD-MON-YY HH24:MI:SS') FROM V$ARCHIVED_LOG
WHERE SEQUENCE# = (SELECT MAX(SEQUENCE#) FROM V$ARCHIVED_LOG );
LASTLOG_APPLIED | LOG_TIME |
---|---|
last_logs_applied : | 21-SEP-24 17:24:10 |
last_logs_received : | 21-SEP-24 17:24:10 |
To monitor efficient recovery operations as well as to estimate the time required to complete the current operation in progress:
SELECT TO_CHAR(START_TIME 'DD-MON-RR HH24:MI:SS') start_time, item, round(sofar/1024,2) "MB/Sec"
FROM v$recovery_progress;
START_TIME | item | MB/Sec | |
---|---|---|---|
27-MAY-24 13:00:24 | Active Apply Rate | 0.9 | |
27-MAY-24 13:00:24 | Average Apply Rate | 0.01 | |
27-MAY-24 13:00:24 | Maximum Apply Rate | 1.33 | |
27-MAY-24 13:00:24 | Redo Applied | 0.03 | |
27-MAY-24 13:00:24 | Recovery ID | 0 | |
27-MAY-24 13:00:24 | Last Applied Redo | 0 | |
27-MAY-24 13:00:24 | Active Time | 0.17 | |
27-MAY-24 13:00:24 | Apply Time per Log | 0.15 | |
27-MAY-24 13:00:24 | Checkpoint Time per Log | 0.02 | |
27-MAY-24 13:00:24 | Elapsed Time | 3.5 | |
27-MAY-24 13:00:24 | Standby Apply Lag | 0 |
To see if standby redo logs have been created.
The standby redo logs should be the same size as the online redo logs. There should be (( # of online logs per thread + 1) * # of threads) standby redo logs. A value of 0 for the thread# means the log has never been allocated.
SELECT THREAD#, GROUP#, SEQUENCE#, BYTES, ARCHIVED, STATUS FROM V$STANDBY_LOG ORDER BY THREAD#, GROUP#;
On Standby
THREAD# | GROUP# | SEQUENCE# | BYTES | ARCHIVED | STATUS |
---|---|---|---|---|---|
1 | 4 | 87 | 209715200 | YES | ACTIVE |
1 | 5 | 0 | 209715200 | NO | UNASSIGNED |
1 | 6 | 0 | 209715200 | NO | UNASSIGNED |
1 | 8 | 0 | 209715200 | NO | UNASSIGNED |
1 | 9 | 0 | 209715200 | NO | UNASSIGNED |
1 | 10 | 0 | 52428800 | YES | UNASSIGNED |
1 | 11 | 0 | 52428800 | YES | UNASSIGNED |
1 | 12 | 0 | 52428800 | YES | UNASSIGNED |
1 | 13 | 0 | 52428800 | YES | UNASSIGNED |
1 | 14 | 0 | 209715200 | YES | UNASSIGNED |
1 | 23 | 0 | 209715200 | YES | UNASSIGNED |
To produce a list of defined archive destinations.
It shows if they are enabled, what process is servicing that destination, if the destination is local or remote, and if remote what the current mount ID is. For a physical standby we should have at least one remote destination that points the primary set.
On Standby
SELECT THREAD#, DEST_ID, DESTINATION, GVAD.STATUS ,TARGET, SCHEDULE, PROCESS, MOUNTID
FROM
gv$archive_dest gvad, gv$instance gvi
WHERE gvad.inst_id = gvi.inst_id
AND destination IS NOT NULL
ORDER BY THREAD#, DEST_ID;
THREAD# | DEST_ID | DESTINATION | STATUS | TARGET | SCHEDULE | PROCESS | MOUNTID |
---|---|---|---|---|---|---|---|
1 | 1 | /u01/app/oracle/oradata/ORCL/arch/ | VALID | LOCAL | ACTIVE | ARCH | 0 |
1 | 2 | orcl | VALID | REMOTE | PENDING | LGWR | 0 |
1 | 32 | /u01/app/oracle/oradata/ORCL/arch/ | VALID | LOCAL | ACTIVE | RFS | 0 |
On Primary
THREAD# | DEST_ID | DESTINATION | STATUS | TARGET | SCHEDULE | PROCESS | MOUNTID |
---|---|---|---|---|---|---|---|
1 | 1 | /u01/app/oracle/oradata/ORCL/arch/ | VALID | PRIMARY | ACTIVE | ARCH | 0 |
1 | 2 | alpha | VALID | STANDBY | PENDING | LGWR | 0 |
Verify the last sequence# received and the last sequence# applied to standby database.
SELECT al.thrd "thread", almax "last seq received", lhmax "last seq applied"
FROM (
SELECT THREAD# thrd,MAX(SEQUENCE#) almax FROM V$ARCHIVED_LOG
WHERE RESETLOGS_CHANGE#=(SELECT RESETLOGS_CHANGE# FROM V$DATABASE) GROUP BY THREAD#) al,
(SELECT THREAD# thrd, MAX(SEQUENCE#) lhmax FROM v$log_history
WHERE RESETLOGS_CHANGE#=(SELECT RESETLOGS_CHANGE# FROM V$DATABASE) GROUP BY THREAD#) lh
WHERE al.thrd = lh.thrd;
Thread | Last seq received | Last seq applied |
---|---|---|
1 | 86 | 86 |
Additional check queries for dataguard
Check V$ARCHIVE_GAP for gaps between physical and standby database
To determine gaps in archive logs on the standby database.
Since fal_server and fal_client parameters are configured, dataguard should automatically resolve the archive log gaps by requesting the primary
database to send the missing archive logs.
But if you dont have the archive logs that the physical standby database needs, there will be gaps and the standby database will be out of sync.
You will nned to take remedial actions to resolve these gaps.
SQL> SELECT * FROM V$ARCHIVE_GAP;
Check that the CONTROL_FILE_RECORD_KEEP_TIME initialization
parameter is defined to a value that is sufficiently large
enough to maintain adequate log switch information to resolve
archivelog gaps.
SQL> select current_scn, SCN_TO_TIMESTAMP(current_scn) from v$database; --scn 38558373
SQL> select scn_to_timestamp(38558373) from dual;
Check V$ARCHIVE_DEST for errors
SQL> SELECT DEST_NAME, STATUS, ERROR FROM V$ARCHIVE_DEST WHERE STATUS='ERROR';
Show received archived logs on physical standby
select registrar, creator, thread#, sequence#, first_change#, next_change# from v$archived_log;
On the standby databaseREGISTRAR | CREATOR | THREAD# | SEQUENCE# | FIRST_CHANGE# | NEXT_CHANGE# |
---|---|---|---|---|---|
SRMN | SRMN | 1 | 55 | 27606843 | 27607362 |
SRMN | SRMN | 1 | 56 | 27607362 | 27607378 |
RFS | ARCH | 1 | 57 | 27607378 | 27628657 |
RFS | ARCH | 1 | 60 | 27660505 | 27662145 |
RFS | ARCH | 1 | 58 | 27628657 | 27634661 |
RFS | ARCH | 1 | 80 | 27845564 | 27847264 |
RFS | ARCH | 1 | 83 | 27868242 | 27870109 |
RFS | ARCH | 1 | 59 | 27634661 | 27660505 |
RFS | ARCH | 1 | 63 | 27692884 | 27694317 |
RFS | ARCH | 1 | 62 | 27690134 | 27692884 |
RFS | ARCH | 1 | 64 | 27694317 | 27696037 |
RFS | ARCH | 1 | 65 | 27696037 | 27697757 |
RFS | ARCH | 1 | 61 | 27662145 | 27690134 |
RFS | ARCH | 1 | 67 | 27700405 | 27702113 |
RFS | ARCH | 1 | 66 | 27697757 | 27700405 |
RFS | ARCH | 1 | 68 | 27702113 | 27704788 |
RFS | ARCH | 1 | 70 | 27706268 | 27707669 |
RFS | ARCH | 1 | 69 | 27704788 | 27706268 |
RFS | ARCH | 1 | 71 | 27707669 | 27788297 |
RFS | ARCH | 1 | 73 | 27808587 | 27811370 |
RFS | ARCH | 1 | 72 | 27788297 | 27808587 |
RFS | ARCH | 1 | 74 | 27811370 | 27813762 |
RFS | ARCH | 1 | 75 | 27813762 | 27816515 |
RFS | ARCH | 1 | 77 | 27833851 | 27836836 |
RFS | ARCH | 1 | 76 | 27816515 | 27833851 |
RFS | ARCH | 1 | 78 | 27836836 | 27843320 |
RFS | ARCH | 1 | 79 | 27843320 | 27845564 |
RFS | ARCH | 1 | 82 | 27864004 | 27868242 |
RFS | ARCH | 1 | 81 | 27847264 | 27864004 |
RFS | ARCH | 1 | 84 | 27870109 | 27873939 |
RFS | ARCH | 1 | 85 | 27873939 | 27889407 |
RFS | ARCH | 1 | 86 | 27889407 | 27896969 |
Show archived logs sent on primary database
select registrar, creator, thread#, sequence#, first_change#, next_change# from v$archived_log;
REGISTRAR | CREATOR | THREAD# | SEQUENCE# | FIRST_CHANGE# | NEXT_CHANGE# |
---|---|---|---|---|---|
FGRD | FGRD | 1 | 36 | 25310399 | 25382027 |
FGRD | FGRD | 1 | 37 | 25382027 | 25385638 |
FGRD | FGRD | 1 | 39 | 26418577 | 26440791 |
FGRD | FGRD | 1 | 40 | 26440791 | 26449986 |
FGRD | FGRD | 1 | 42 | 26452145 | 26461635 |
FGRD | FGRD | 1 | 56 | 27607362 | 27607378 |
FGRD | FGRD | 1 | 49 | 27515902 | 27515929 |
FGRD | FGRD | 1 | 53 | 27558959 | 27575544 |
FGRD | FGRD | 1 | 54 | 27575544 | 27606843 |
FGRD | FGRD | 1 | 55 | 27606843 | 27607362 |
FGRD | FGRD | 1 | 44 | 27464914 | 27471593 |
ARCH | ARCH | 1 | 21 | 18033611 | 18091783 |
ARCH | ARCH | 1 | 22 | 18091783 | 18099255 |
ARCH | ARCH | 1 | 23 | 18099255 | 19115685 |
ARCH | ARCH | 1 | 24 | 19115685 | 20164793 |
ARCH | ARCH | 1 | 25 | 20164793 | 20260810 |
ARCH | ARCH | 1 | 26 | 20260810 | 21275680 |
ARCH | ARCH | 1 | 27 | 21275680 | 22276846 |
ARCH | ARCH | 1 | 28 | 22276846 | 23278152 |
ARCH | ARCH | 1 | 29 | 23278152 | 24279303 |
ARCH | ARCH | 1 | 30 | 24279303 | 24280983 |
ARCH | ARCH | 1 | 31 | 24280983 | 24282447 |
ARCH | ARCH | 1 | 32 | 24282447 | 24284156 |
ARCH | ARCH | 1 | 33 | 24284156 | 24285937 |
ARCH | ARCH | 1 | 34 | 24285937 | 24287291 |
ARCH | ARCH | 1 | 35 | 24287291 | 25310399 |
ARCH | ARCH | 1 | 38 | 25385638 | 26418577 |
Physical Standby Data Guard useful SQL scripts
Verify Data Guard Implementation
Verify Data Guard Implementation
Thought for the day
Humility is the fear of the Lord;
its wages are riches and honor and life.
Proverbs 4:4
A good name is more desirable than great riches;
to be esteemed is better than silver or gold.
Proverbs 4:1
No comments:
Post a Comment