ORA-01555で始まる行とその関連SQL文のアラート・ログの内容をキャプチャする必要があります。2つのパターン間で複数のグループを検索してキャプチャする
ファイルの内容は以下の通りです:
Sat Oct 21 12:11:40 2017
Thread 1 advanced to log sequence 143 (LGWR switch)
Current log# 5 seq# 143 mem# 0:
Sat Oct 21 12:12:22 2017
Thread 1 cannot allocate new log, sequence 144
Private strand flush not complete
Current log# 5 seq# 143 mem# 0:
Sat Oct 21 12:12:22 2017
ORA-01555 caused by SQL statement below (SQL ID: 1sfgms7z66zrs, SCN: 0x0401.1e45bbc4):
Sat Oct 21 12:11:48 2017
CREATE INDEX AAD_SAA_ADB_RESULTS_AUD_GTI1 ON AAD_PS_SAA_ADB_RESULTS_AUD_GT (
rpt_date
)
Sat Oct 21 12:20:56 2017
Thread 1 advanced to log sequence 153 (LGWR switch)
Current log# 6 seq# 153 mem# 0:
+REDO_VOL1/DSS1STG/ONLINELOG/group_6.262.957710915
Current log# 6 seq# 153 mem# 1:
+REDO_VOL1/DSS1STG/ONLINELOG/group_6.263.957710917
Sat Oct 21 12:21:11 2017
ORA-01555 caused by SQL statement below (SQL ID: 9ad5awvfvsfd9, Query
Duration=6444 sec, SCN: 0x0401.1e53de65):
Sat Oct 21 12:21:11 2017
SELECT a.EMPLID, a.TEST_ID, a.TEST_COMPONENT, a.SCORE
FROM
ODS_PSE.PS_STDNT_TEST_COMP a,
DSS_RDS.IR_STU_TST_SCR_SAT_VLD_DT_ST b
where
a.TEST_COMPONENT in ('VE','MA')
AND a.EMPLID = b.PRSN_UNIV_ID
AND ROUND(a.SCORE) = a.SCORE
AND a.TEST_ID = b.STU_TST_CD
AND a.TEST_DT = b.TEST_DT
AND a.LS_DATA_SOURCE = b.LS_DATA_SOURCE
UNION
SELECT a.EMPLID, a.TEST_ID, a.TEST_COMPONENT, a.SCORE
FROM
ODS_PSE.PS_STDNT_TEST_COMP a,
DSS_RDS.IR_STU_TST_SCR_SAT_VLD_DT_ST b
where
a.TEST_COMPONENT in ('ERWS','MSS','MT','RT','WLT')
AND a.EMPLID = b.PRSN_UNIV_ID
AND (
(ROUND(a.SCORE) = a.SCORE and a.TEST_COMPONENT in
('ERWS','MSS','RT','WLT'))
or (a.SCORE BETWEEN 10 AND 40 and a.TEST_COMPONENT in ('MT'))
)
AND a.TEST_ID = b.STU_TST_CD
AND a.TEST_DT = b.TEST_DT
AND a.LS_DATA_SOURCE = b.LS_DATA_SOURCE
Sat Oct 21 13:05:01 2017
Thread 1 advanced to log sequence 173 (LGWR switch)
Current log# 5 seq# 173 mem# 0: +REDO_VOL1/DSS1STG/ONLINELOG/group_5.257.957710909
Current log# 5 seq# 173 mem# 1: +REDO_VOL1/DSS1STG/ONLINELOG/group_5.256.957710911
私はキャプチャしたい内容は次のとおりです。ここで
ORA-01555 caused by SQL statement below (SQL ID: 1sfgms7z66zrs, SCN: 0x0401.1e45bbc4):
Sat Oct 21 12:11:48 2017
CREATE INDEX AAD_SAA_ADB_RESULTS_AUD_GTI1 ON AAD_PS_SAA_ADB_RESULTS_AUD_GT (
rpt_date
)
ORA-01555 caused by SQL statement below (SQL ID: 9ad5awvfvsfd9, Query
Duration=6444 sec, SCN: 0x0401.1e53de65):
Sat Oct 21 12:21:11 2017
SELECT a.EMPLID, a.TEST_ID, a.TEST_COMPONENT, a.SCORE
FROM
ODS_PSE.PS_STDNT_TEST_COMP a,
DSS_RDS.IR_STU_TST_SCR_SAT_VLD_DT_ST b
where
a.TEST_COMPONENT in ('VE','MA')
AND a.EMPLID = b.PRSN_UNIV_ID
AND ROUND(a.SCORE) = a.SCORE
AND a.TEST_ID = b.STU_TST_CD
AND a.TEST_DT = b.TEST_DT
AND a.LS_DATA_SOURCE = b.LS_DATA_SOURCE
UNION
SELECT a.EMPLID, a.TEST_ID, a.TEST_COMPONENT, a.SCORE
FROM
ODS_PSE.PS_STDNT_TEST_COMP a,
DSS_RDS.IR_STU_TST_SCR_SAT_VLD_DT_ST b
where
a.TEST_COMPONENT in ('ERWS','MSS','MT','RT','WLT')
AND a.EMPLID = b.PRSN_UNIV_ID
AND (
(ROUND(a.SCORE) = a.SCORE and a.TEST_COMPONENT in
('ERWS','MSS','RT','WLT'))
or (a.SCORE BETWEEN 10 AND 40 and a.TEST_COMPONENT in ('MT'))
)
AND a.TEST_ID = b.STU_TST_CD
AND a.TEST_DT = b.TEST_DT
AND a.LS_DATA_SOURCE = b.LS_DATA_SOURCE
は、私が使用しているgrepのですが、あなたは結果に見ることができるようにそれがにISN各ORA-01555行とそのSQL文全体の内容をキャプチャしません。
grep -Pzo 'ORA-01555.*\n(^.*[0-9]{2}:[0-9]{2}:[0-9]{2}.*)\n.*(?!.*[0-9]{2}:[0-9]{2}.*\n).+' alert.log
ORA-01555 caused by SQL statement below (SQL ID: 1sfgms7z66zrs, SCN: 0x0401.1e45bbc4):
Sat Oct 21 12:11:48 2017
CREATE INDEX AAD_SAA_ADB_RESULTS_AUD_GTI1 ON AAD_PS_SAA_ADB_RESULTS_AUD_GT (
ORA-01555 caused by SQL statement below (SQL ID: 9ad5awvfvsfd9, Query Duration=6444 sec, SCN: 0x0401.1e53de65):
Sat Oct 21 12:21:11 2017
SELECT a.EMPLID, a.TEST_ID, a.TEST_COMPONENT, a.SCORE
それを釘付け!ありがとうctac。 –