1. v$database 查看当前数据库的角色和保护模式
- primary库查看
column NAME format a10 column PROTECTION_MODE format a20 column PROTECTION_LEVEL format a20 column DATABASE_ROLE format a20 select NAME,PROTECTION_MODE,PROTECTION_LEVEL,DATABASE_ROLE from v$database; NAME PROTECTION_MODE PROTECTION_LEVEL DATABASE_ROLE ---------- -------------------- -------------------- -------------------- USERDATA MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE PRIMARY
- standby库查看
column NAME format a10 column PROTECTION_MODE format a20 column PROTECTION_LEVEL format a20 column DATABASE_ROLE format a20 select NAME,PROTECTION_MODE,PROTECTION_LEVEL,DATABASE_ROLE from v$database; NAME PROTECTION_MODE PROTECTION_LEVEL DATABASE_ROLE ---------- -------------------- -------------------- -------------------- USERDATA MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE PHYSICAL STANDBY
2. v$archive_dest 对于当前实例,显示Data Guard配置中的所有目标,包括每个目标的当前值,模式和状态.
- primay库查看
column DEST_ID format 99 column DEST_NAME format a20 column STATUS format a10 column TARGET format a10 column ARCHIVER format a10 column SCHEDULE format a10 column DESTINATION format a30 column LOG_SEQUENCE format 999999 column PROCESS format a10 column TRANSMIT_MODE format a15 column VALID_TYPE format a15 column DB_UNIQUE_NAME format a15 select DEST_ID,DEST_NAME,STATUS,TARGET,ARCHIVER,SCHEDULE,DESTINATION,LOG_SEQUENCE,PROCESS,TRANSMIT_MODE,VALID_TYPE,DB_UNIQUE_NAME from v$archive_dest where dest_id in (1,2);
DEST_ID DEST_NAME STATUS TARGET ARCHIVER SCHEDULE DESTINATION LOG_SEQUENCE PROCESS TRANSMIT_MODE VALID_TYPE DB_UNIQUE_NAME ------- -------------------- ---------- ---------- ---------- ---------- ------------------------------ ------------ ---------- --------------- --------------- --------------- 1 LOG_ARCHIVE_DEST_1 VALID PRIMARY ARCH ACTIVE /u01/app/oracle/arch 13 ARCH SYNCHRONOUS ALL_LOGFILES NONE 2 LOG_ARCHIVE_DEST_2 VALID STANDBY LGWR ACTIVE userdata2 14 LGWR ASYNCHRONOUS ONLINE_LOGFILE userdata2
- standby库查看
column DEST_ID format 99 column DEST_NAME format a20 column STATUS format a10 column TARGET format a10 column ARCHIVER format a10 column SCHEDULE format a10 column DESTINATION format a30 column LOG_SEQUENCE format 999999 column PROCESS format a10 column TRANSMIT_MODE format a15 column VALID_TYPE format a15 column DB_UNIQUE_NAME format a15 select DEST_ID,DEST_NAME,STATUS,TARGET,ARCHIVER,SCHEDULE,DESTINATION,LOG_SEQUENCE,PROCESS,TRANSMIT_MODE,VALID_TYPE,DB_UNIQUE_NAME from v$archive_dest where dest_id in (1,2); DEST_ID DEST_NAME STATUS TARGET ARCHIVER SCHEDULE DESTINATION LOG_SEQUENCE PROCESS TRANSMIT_MODE VALID_TYPE DB_UNIQUE_NAME ------- -------------------- ---------- ---------- ---------- ---------- ------------------------------ ------------ ---------- --------------- --------------- --------------- 1 LOG_ARCHIVE_DEST_1 VALID LOCAL ARCH ACTIVE /u01/app/oracle/arch 13 ARCH SYNCHRONOUS ALL_LOGFILES NONE 2 LOG_ARCHIVE_DEST_2 VALID REMOTE LGWR PENDING userdata1 0 LGWR ASYNCHRONOUS ONLINE_LOGFILE userdata1
3. v$archive_dest_status 显示归档重做日志目标的运行环境和配置信息,此视图中的信息不会在实例关闭时持续存在
- primay库查看
column DEST_NAME format a20 column STATUS format a10 column TYPE format a10 column DATABASE_MODE format a18 column RECOVERY_MODE format a25 column DESTINATION format a20 column STANDBY_LOGFILE_COUNT format 999999 column STANDBY_LOGFILE_ACTIVE format 999999 column ARCHIVED_SEQ# format 9999999 column APPLIED_SEQ# format 999999 column DB_UNIQUE_NAME format a15 column GAP_STATUS format a10 select DEST_NAME,STATUS,TYPE,DATABASE_MODE,RECOVERY_MODE,DESTINATION,STANDBY_LOGFILE_COUNT,STANDBY_LOGFILE_ACTIVE,ARCHIVED_SEQ#,APPLIED_SEQ#,GAP_STATUS from v$archive_dest_status where DEST_ID in(1,2); DEST_NAME STATUS TYPE DATABASE_MODE RECOVERY_MODE DESTINATION STANDBY_LOGFILE_COUNT STANDBY_LOGFILE_ACTIVE ARCHIVED_SEQ# APPLIED_SEQ# GAP_STATUS -------------------- ---------- ---------- ------------------ ------------------------- -------------------- --------------------- ---------------------- ------------- ------------ ---------- LOG_ARCHIVE_DEST_1 VALID LOCAL OPEN IDLE /u01/app/oracle/arch 0 0 13 0 LOG_ARCHIVE_DEST_2 VALID PHYSICAL MOUNTED-STANDBY MANAGED REAL TIME APPLY userdata2 4 1 13 12 NO GAP
- standby库查看
column DEST_NAME format a20 column STATUS format a10 column TYPE format a10 column DATABASE_MODE format a18 column RECOVERY_MODE format a25 column DESTINATION format a20 column STANDBY_LOGFILE_COUNT format 999999 column STANDBY_LOGFILE_ACTIVE format 999999 column ARCHIVED_SEQ# format 9999999 column APPLIED_SEQ# format 999999 column DB_UNIQUE_NAME format a15 column GAP_STATUS format a10 select DEST_NAME,STATUS,TYPE,DATABASE_MODE,RECOVERY_MODE,DESTINATION,STANDBY_LOGFILE_COUNT,STANDBY_LOGFILE_ACTIVE,ARCHIVED_SEQ#,APPLIED_SEQ#,GAP_STATUS from v$archive_dest_status where DEST_ID in(1,2); DEST_NAME STATUS TYPE DATABASE_MODE RECOVERY_MODE DESTINATION STANDBY_LOGFILE_COUNT STANDBY_LOGFILE_ACTIVE ARCHIVED_SEQ# APPLIED_SEQ# GAP_STATUS -------------------- ---------- ---------- ------------------ ------------------------- -------------------- --------------------- ---------------------- ------------- ------------ ---------- LOG_ARCHIVE_DEST_1 VALID LOCAL MOUNTED-STANDBY MANAGED REAL TIME APPLY /u01/app/oracle/arch 0 0 13 0 LOG_ARCHIVE_DEST_2 VALID UNKNOWN UNKNOWN IDLE userdata1 0 0 0 0
4. v$archived_log 从控制文件显示归档日志信息,包括归档日志名称。 在联机重做日志成功归档或清除之后插入存档日志记录(如果日志被清除,则名称列为NULL)。 如果日志被存档两次,将存在两个具有相同THREAD#,SEQUENCE#和FIRST_CHANGE#的归档日志记录,但使用不同的名称。 当从备份集或副本还原归档日志并且每当使用RMAN COPY命令创建日志的副本时,还会插入存档日志记录。
- primary库查看
column name format a60 select DEST_ID,NAME,SEQUENCE#,ARCHIVED,APPLIED,FIRST_CHANGE#,NEXT_CHANGE# from v$archived_log order by SEQUENCE#; DEST_ID NAME SEQUENCE# ARCHIVED APPLIED FIRST_CHANGE# NEXT_CHANGE# ------- ------------------------------------------------------------ ---------- --------- --------------------------- ------------- ------------ 1 /u01/app/oracle/arch/1_4_947274260.dbf 4 YES NO 990659 998756 1 /u01/app/oracle/arch/1_5_947274260.dbf 5 YES NO 998756 999037 1 /u01/app/oracle/arch/1_6_947274260.dbf 6 YES NO 999037 1078164 1 /u01/app/oracle/arch/1_7_947274260.dbf 7 YES NO 1078164 1078294 1 /u01/app/oracle/arch/1_8_947274260.dbf 8 YES NO 1078294 1082109 2 userdata2 8 YES YES 1078294 1082109 2 userdata2 9 YES YES 1082109 1092150 1 /u01/app/oracle/arch/1_9_947274260.dbf 9 YES NO 1082109 1092150 1 /u01/app/oracle/arch/1_10_947274260.dbf 10 YES NO 1092150 1092157 2 userdata2 10 YES YES 1092150 1092157 2 userdata2 11 YES YES 1092157 1092306 1 /u01/app/oracle/arch/1_11_947274260.dbf 11 YES NO 1092157 1092306 2 userdata2 12 YES YES 1092306 1177894 1 /u01/app/oracle/arch/1_12_947274260.dbf 12 YES NO 1092306 1177894 2 userdata2 13 YES NO 1177894 1237022 1 /u01/app/oracle/arch/1_13_947274260.dbf 13 YES NO 1177894 1237022 16 rows selected.
- standby库查看
column name format a60 select DEST_ID,NAME,SEQUENCE#,ARCHIVED,APPLIED,FIRST_CHANGE#,NEXT_CHANGE# from v$archived_log order by SEQUENCE#; DEST_ID NAME SEQUENCE# ARCHIVED APPLIED FIRST_CHANGE# NEXT_CHANGE# ------- -------------------------------------------------- ---------- --------- --------------------------- ------------- ------------ 1 /u01/app/oracle/arch/1_7_947274260.dbf 7 YES YES 1078164 1078294 2 /u01/app/oracle/arch/1_8_947274260.dbf 8 YES YES 1078294 1082109 2 /u01/app/oracle/arch/1_9_947274260.dbf 9 YES YES 1082109 1092150 1 /u01/app/oracle/arch/1_10_947274260.dbf 10 YES YES 1092150 1092157 1 /u01/app/oracle/arch/1_11_947274260.dbf 11 YES YES 1092157 1092306 1 /u01/app/oracle/arch/1_12_947274260.dbf 12 YES YES 1092306 1177894 1 /u01/app/oracle/arch/1_13_947274260.dbf 13 YES IN-MEMORY 1177894 1237022
5. v$log 显示控制文件中的日志文件信息
- primay库查看
column STATUS format a10 column NEXT_CHANGE# format 9999999999999999999999 select * from v$log order by GROUP#; GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARCHIVED STATUS FIRST_CHANGE# FIRST_TIME NEXT_CHANGE# NEXT_TIME ---------- ---------- ---------- ---------- ---------- ---------- --------- ---------- ------------- ------------------- ----------------------- ------------------- 1 1 13 104857600 512 1 YES INACTIVE 1177894 2017-06-24 05:06:02 1237022 2017-06-24 18:09:11 2 1 14 104857600 512 1 NO CURRENT 1237022 2017-06-24 18:09:11 281474976710655 3 1 12 104857600 512 1 YES INACTIVE 1092306 2017-06-23 08:01:31 1177894 2017-06-24 05:06:02
- standby库查看
select * from v$log order by GROUP#; GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARCHIVED STATUS FIRST_CHANGE# FIRST_TIME NEXT_CHANGE# NEXT_TIME ---------- ---------- ---------- ---------- ---------- ---------- --------- ---------- ------------- ------------------- ------------ ------------------- 1 1 13 104857600 512 1 YES CLEARING 1177894 2017-06-24 05:06:02 1237022 2017-06-24 18:09:11 2 1 14 104857600 512 1 YES CURRENT 1237022 2017-06-24 18:09:11 1092306 2017-06-23 08:01:31 3 1 12 104857600 512 1 YES CLEARING 1092306 2017-06-23 08:01:31 1177894 2017-06-24 05:06:02
6. v$managered_standby 显示与Data Guard环境中的物理备用数据库相关的某些Oracle数据库进程的当前状态信息。 实例关闭后,此视图不会持续。
- primary库查看
select process,pid,status,thread#,sequence#,block#,blocks from v$managed_standby; PROCESS PID STATUS THREAD# SEQUENCE# BLOCK# BLOCKS --------------------- ------ ---------- ------------------------------------ ---------- ---------- ---------- ARCH 3149 CLOSING 1 13 176128 122 ARCH 3153 CLOSING 1 7 1 143 ARCH 3157 CONNECTED 0 0 0 0 ARCH 3161 CLOSING 1 12 161792 1250 LNS 3165 WRITING 1 14 136743 1
- standby库查看
select process,pid,status,thread#,sequence#,block#,blocks from v$managed_standby;
PROCESS PID STATUS THREAD# SEQUENCE# BLOCK# BLOCKS ---------- ---------- -------------------- ---------- ---------- ---------- ---------- ARCH 22035 CLOSING 1 11 2048 350 ARCH 22039 CLOSING 1 13 176128 122 ARCH 22043 CONNECTED 0 0 0 0 ARCH 22047 CLOSING 1 12 161792 1250 RFS 22100 IDLE 0 0 0 0 RFS 22082 IDLE 1 14 137051 1 RFS 22086 IDLE 0 0 0 0 MRP0 28028 APPLYING_LOG 1 14 137051 204800
7. v$dataguard_stats 显示主数据库生成的重做数据在备用数据库上尚不可用,显示如果主数据库在查询此视图时崩溃,可能会丢失多少重做数据。 您可以在Data Guard配置中的备用数据库的任何实例上查询此视图。 如果在主数据库上查询此视图,则列值将被清除。
- standby库查看
select * from v$dataguard_stats; NAME VALUE UNIT TIME_COMPUTED DATUM_TIME ------------------------- -------------------- ------------------------------ -------------------- -------------------- transport lag +00 00:00:00 day(2) to second(0) interval 06/25/2017 07:03:30 06/25/2017 07:03:29 apply lag +00 00:00:00 day(2) to second(0) interval 06/25/2017 07:03:30 06/25/2017 07:03:29 apply finish time +00 00:00:00.000 day(2) to second(3) interval 06/25/2017 07:03:30 estimated startup time 12 second 06/25/2017 07:03:30
8. v$dataguard_config 显示使用DB_UNIQUE_NAME和LOG_ARCHIVE_CONFIG初始化参数定义的唯一数据库名称,从配置中的任何数据库提供的Data Guard视图都可以看到
- primay/standby库查看
select * from v$dataguard_config; DB_UNIQUE_NAME ------------------------------------------------------------------------------------------ userdata1 userdata2
9. x$logbuf_readhist 记录LNS从redo log buffer里面读取redo数据的历史信息并将其传输到备库端的命中率
- primary库查看
column ADDR format a20 column INDX format 99 column INST_ID format 99 column BUFSIZE format a15 column RDMEMBLKS format a15 column RDDISKBLKS format a15 column HITRATE format 999 column BUFINFO format a30 select * from x$logbuf_readhist; ADDR INDX INST_ID BUFSIZE RDMEMBLKS RDDISKBLKS HITRATE BUFINFO -------------------- ---- ------- --------------- --------------- --------------- ------- ------------------------------ 00007FC98CEAC358 0 1 3592K 470667 25688 94 TARGET-90 00007FC98CEAC358 1 1 4310K 475699 20656 95 00007FC98CEAC358 2 1 5029K 480267 16088 96 00007FC98CEAC358 3 1 5747K 485401 10954 97 00007FC98CEAC358 4 1 6466K 491368 4987 98 00007FC98CEAC358 5 1 7184K 496314 41 99 CURRENT 00007FC98CEAC358 6 1 7902K 496314 41 99 00007FC98CEAC358 7 1 8621K 496314 41 99 00007FC98CEAC358 8 1 9339K 496314 41 99 00007FC98CEAC358 9 1 10058K 496314 41 99 00007FC98CEAC358 10 1 10776K 496314 41 99 00007FC98CEAC358 11 1 11494K 496314 41 99 00007FC98CEAC358 12 1 12213K 496314 41 99 00007FC98CEAC358 13 1 12931K 496314 41 99 00007FC98CEAC358 14 1 13650K 496314 41 99 00007FC98CEAC358 15 1 14368K 496314 41 99