Oracle DG:状态检查脚本
也没啥好说的,直接看代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
[oracle@oracleme ~]$ cat check_dg.sh export ORACLE_SID=$1 sqlplus / as sysdba<<EOF select instance_name,status from v\$instance; select name,database_role,open_mode from v\$database; select thread#,max(sequence#) "Sequence" from v\$archived_log where applied='YES' group by thread# order by thread#; select count(*) from v\$datafile; show parameter pfile; show parameter control_files; show parameter background; show parameter local_listener; select sum(bytes)/1024/1024/1024 "Summary Size of GB" from v\$datafile; set linesize 400 col client_pid for a20 select process,pid,client_pid,status,delay_mins,known_agents,active_agents from v\$managed_standby order by process; set linesize 400 col name for a65 select name,thread#,sequence#,to_char(first_time,'yyyy-mm-dd hh24:mi:ss') "First",to_char(next_time,'yyyy-mm-dd hh24:mi:ss') "Next",applied from v\$archived_log,(select max(sequence#) "SEQ#" from v\$archived_log where applied='YES') b where sequence# between b.seq#-5 and b.seq#+9 order by sequence#; EOF [oracle@oracleme ~]$ [oracle@oracleme ~]$ sh check_dg.sh orcl SQL*Plus: Release 12.2.0.1.0 Production on Wed May 30 15:42:23 2018 Copyright (c) 1982, 2016, Oracle. All rights reserved. Connected to: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production SQL> INSTANCE_NAME STATUS -------------------------------- ------------------------ orcl OPEN SQL> NAME DATABASE_ROLE ------------------ -------------------------------- OPEN_MODE ---------------------------------------- ORCL PHYSICAL STANDBY READ ONLY SQL> THREAD# Sequence ---------- ---------- 1 70 SQL> COUNT(*) ---------- 11 SQL> NAME TYPE ------------------------------------ ---------------------- VALUE ------------------------------ spfile string /home/app/oracle/12c/release_2 /db_1/dbs/spfileorcl.ora SQL> NAME TYPE ------------------------------------ ---------------------- VALUE ------------------------------ control_files string /home/app/oracle/oradata/ORCL/ controlfile/o1_mf_fd8x9qp0_.ct l, /home/app/oracle/fast_recov ery_area/orcl/ORCL/controlfile /o1_mf_fd8x9qwm_.ctl SQL> NAME TYPE ------------------------------------ ---------------------- VALUE ------------------------------ background_core_dump string partial background_dump_dest string /home/app/oracle/12c/release_2 /db_1/rdbms/log SQL> NAME TYPE ------------------------------------ ---------------------- VALUE ------------------------------ local_listener string LISTENER_ORCL SQL> SQL> Summary Size of GB ------------------ 3.59375 SQL> SQL> SQL> SQL> PROCESS PID CLIENT_PID STATUS DELAY_MINS KNOWN_AGENTS ACTIVE_AGENTS ------------------ ------------------------------------------------ -------------------- ------------------------ ---------- ------------ ------------- ARCH 10823 10823 CONNECTED 0 0 0 ARCH 10829 10829 CONNECTED 0 0 0 ARCH 10833 10833 CONNECTED 0 0 0 ARCH 10831 10831 CONNECTED 0 0 0 DGRD 10827 N/A ALLOCATED 0 0 0 DGRD 10825 N/A ALLOCATED 0 0 0 RFS 1901 2324 IDLE 0 0 0 7 rows selected. SQL> SQL> SQL> SQL> NAME THREAD# SEQUENCE# First Next APPLIED ----------------------------------------------------------------- ---------- ---------- -------------------------------------- -------------------------------------- ------------------ /home/app/oracle/arch_log/1_65_972571706.dbf 1 65 2018-04-25 13:54:32 2018-04-26 01:41:13 YES /home/app/oracle/arch_log/1_66_972571706.dbf 1 66 2018-04-26 01:41:13 2018-04-26 22:26:05 YES /home/app/oracle/arch_log/1_67_972571706.dbf 1 67 2018-04-26 22:26:05 2018-04-27 03:01:02 YES /home/app/oracle/arch_log/1_68_972571706.dbf 1 68 2018-04-27 03:01:02 2018-04-27 22:27:46 YES /home/app/oracle/arch_log/1_69_972571706.dbf 1 69 2018-04-27 22:27:46 2018-04-28 06:01:15 YES /home/app/oracle/arch_log/1_70_972571706.dbf 1 70 2018-04-28 06:01:15 2018-04-28 13:26:11 YES /home/app/oracle/arch_log/1_71_972571706.dbf 1 71 2018-04-28 13:26:11 2018-04-28 20:07:06 NO /home/app/oracle/arch_log/1_72_972571706.dbf 1 72 2018-04-28 20:07:06 2018-04-29 00:00:55 NO /home/app/oracle/arch_log/1_73_972571706.dbf 1 73 2018-04-29 00:00:55 2018-04-29 10:09:32 NO /home/app/oracle/arch_log/1_74_972571706.dbf 1 74 2018-04-29 10:09:32 2018-04-29 16:50:39 NO /home/app/oracle/arch_log/1_75_972571706.dbf 1 75 2018-04-29 16:50:39 2018-04-29 22:31:01 NO NAME THREAD# SEQUENCE# First Next APPLIED ----------------------------------------------------------------- ---------- ---------- -------------------------------------- -------------------------------------- ------------------ /home/app/oracle/arch_log/1_76_972571706.dbf 1 76 2018-04-29 22:31:01 2018-04-30 10:00:59 NO /home/app/oracle/arch_log/1_77_972571706.dbf 1 77 2018-04-30 10:00:59 2018-04-30 23:06:05 NO /home/app/oracle/arch_log/1_78_972571706.dbf 1 78 2018-04-30 23:06:05 2018-05-01 15:58:37 NO /home/app/oracle/arch_log/1_79_972571706.dbf 1 79 2018-05-01 15:58:37 2018-05-01 23:10:30 NO 15 rows selected. SQL> SQL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production [oracle@oracleme ~]$ |
——————————————
Done。