-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
961 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,3 +44,4 @@ bin/* | |
*.old.* | ||
test*.* | ||
|
||
*.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
= CollectDeadlockTraces.sh | ||
Norman Dunbar <[email protected]> | ||
:revnumber: v1.0 | ||
:revdate: March 6 2019 | ||
|
||
|
||
*What is it?* | ||
|
||
CollectDeadlockTraces.sh is a script to run under a bash shell to: | ||
|
||
|
||
*What does it do?* | ||
|
||
* Locate the alert.log for the current Oracle database environment; | ||
* Scan it for deadlocks - ORA-00060 - and obtain the created trace file's name; | ||
* List any trace files which are not found in the diagnostics area; | ||
* Extract a list of deadlock trace files which still exist; | ||
* Tar them all together; | ||
* Compress the resulting tar file with gzip. | ||
|
||
|
||
*How do I run it?* | ||
|
||
Just execute it. You might need to allow execution by: | ||
|
||
chmod ug+x collectDeadlockTraces.sh | ||
|
||
Now you can execute it! | ||
|
||
|
||
*Give me an example* | ||
|
||
A test run looks remarkably like the following, for a system that suffered badly from deadlocks caused by using bitmap indexes on an OLTP system, Sigh! | ||
|
||
[source] | ||
---- | ||
$ ./collectDeadlockTraces.sh | ||
|
||
DIAG currently set to /u01/app/oracle/diag/rdbms/xxxxxxxx/xxxxxxxx | ||
|
||
Checking alert log... | ||
MISSING: /u01/app/oracle/diag/rdbms/xxxxxxxx/xxxxxxxx/trace/xxxxxxxx_ora_10158780.trc | ||
... | ||
... | ||
MISSING: /u01/app/oracle/diag/rdbms/xxxxxxxx/xxxxxxxx/trace/xxxxxxxx_ora_9175774.trc | ||
|
||
Collecting ... | ||
-rw-r----- 1 oracle asmadmin 1694112 Mar 2 06:05 /u01/app/oracle/diag/rdbms/xxxxxxxx/xxxxxxxx/trace/xxxxxxxx_ora_14025328.trc | ||
-rw-r----- 1 oracle asmadmin 1515803 Mar 2 06:05 /u01/app/oracle/diag/rdbms/xxxxxxxx/xxxxxxxx/trace/xxxxxxxx_ora_15860432.trc | ||
... | ||
... | ||
-rw-r----- 1 oracle asmadmin 1897975 Feb 11 10:55 /u01/app/oracle/diag/rdbms/xxxxxxxx/xxxxxxxx/trace/xxxxxxxx_ora_7602800.trc | ||
-rw-r----- 1 oracle asmadmin 1147204 Feb 27 09:34 /u01/app/oracle/diag/rdbms/xxxxxxxx/xxxxxxxx/trace/xxxxxxxx_ora_9437892.trc | ||
|
||
Tarring (and feathering) the files... | ||
|
||
Zipping xxxxxxxx_deadlocks.tar ... | ||
|
||
Finished: 'xxxxxxxx_deadlocks.tar.gz' is ready for collection. | ||
---- | ||
|
||
*OK, now what?* | ||
|
||
* Download the generated `xxxxxxxx_deadlocks.tar.gz` file; | ||
* Gunzip it (On Windows, https://www.7-zip.org/download.html[`7zip`] is useful for this); | ||
* Untar it (https://www.7-zip.org/download.html[`7zip`] again); | ||
* Run `DeadlockAnalysis` against the resulting pile of trace files; | ||
* Open the generated HTML files in your favourite browser, or use Internet Explorer, and examine why the deadlocks occurred. | ||
|
||
|
||
*What are all those Xs about?* | ||
|
||
They replace the `instance name` and `Oracle_SID` for the database I was testing this code on. It's a small way to protect the innocent and/or guilty and to avoid database names escaping into the wilds where miscreants _might_ wish to attack them. | ||
|
||
*Enjoy*. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
#!/bin/bash | ||
#------------------------------------------------------------------------- | ||
# A script to scan the PNET01P1 alert log for deadlock entries, from there | ||
# to extract a list of trace file names for said deadlocks. Then, for the | ||
# trace files that still exist, to collect them together in a tar.gz file | ||
# for subsequent SFTPing for further processing. | ||
#------------------------------------------------------------------------- | ||
# You will need to ensure that DIAG is correctly set, either in the shell | ||
# or in this code, to point at where the 'alert' and 'trace' directories | ||
# for the database live, within the diagnostics area. | ||
# | ||
# DIAG=/u01/app/oracle/diag/rdbms/ORACLE_INSTANCE/$ORACLE_SID | ||
#------------------------------------------------------------------------- | ||
# Execution is easy: | ||
# | ||
# 1. Create a working directory. | ||
# 2. Change into it. | ||
# 3. Execute this code. | ||
# 4. Pick up the file $ORACLE_SID_deadlocks.tar.gz. | ||
#------------------------------------------------------------------------- | ||
# History: | ||
# | ||
# 18/09/2018 NDunbar Created. | ||
# 06/03/2019 NDunbar Modified to attempt to create DIAG, and validate it | ||
# to be sure we are in the right location. | ||
#------------------------------------------------------------------------- | ||
|
||
|
||
# Variables. | ||
TRACELIST=CollectedTraceFiles.txt | ||
TARFILE=${ORACLE_SID}_deadlocks.tar | ||
ZIPFILE="$TARFILE".gz | ||
|
||
# Test DIAG exists | ||
if [ ! -v DIAG ] | ||
then | ||
# Try to creat DIAG. | ||
DIAG=${ORACLE_BASE}/diag/rdbms/${ORACLE_SID}/${ORACLE_SID} | ||
fi | ||
|
||
echo DIAG currently set to ${DIAG} | ||
|
||
# Is DIAG a directory? | ||
if [ ! -d ${DIAG} ] | ||
then | ||
echo ${DIAG} is not a directory. | ||
exit 1 | ||
fi | ||
|
||
# Is it the correct directory? | ||
if [ ! -d ${DIAG}/trace ] | ||
then | ||
echo ${DIAG} is not an Oracle diagnostic directory. | ||
exit 1 | ||
fi | ||
|
||
# Wipe out any existing data. | ||
> "$TRACELIST" | ||
rm "$ZIPFILE" >/dev/null 2>&1 | ||
|
||
|
||
# Scan the alert log for unique deadlock trace file names | ||
echo " " | ||
echo Checking alert log... | ||
|
||
grep "^ORA-00060:" ${DIAG}/trace/alert_${ORACLE_SID}.log |\ | ||
awk -F"." '{print $2}' |\ | ||
awk -F" " '{print $5 ".trc"}' |\ | ||
sort -u |\ | ||
while read traceFile | ||
do | ||
if [ -f "$traceFile" ] | ||
then | ||
echo $traceFile >> "${TRACELIST}" | ||
else | ||
echo MISSING: "$traceFile" | ||
fi | ||
done | ||
|
||
|
||
# We have a list of existing trace files, collect them together. | ||
echo " " | ||
echo "Collecting ..." | ||
|
||
cat "${TRACELIST}" |\ | ||
while IFS='' read -r tracefile || [[ -n "$tracefile" ]] | ||
do | ||
ls -l "$tracefile" | ||
chmod o+r "$tracefile" | ||
cp "$tracefile" /tmp/ | ||
chmod o-r "$tracefile" | ||
done | ||
|
||
# Create the tar file and gzip it. | ||
echo " " | ||
echo Tarring \(and feathering\) the files... | ||
|
||
BACK_THERE=`pwd` | ||
cd /tmp | ||
tar -cf "${BACK_THERE}"/"${TARFILE}" ./${ORACLE_SID}*.trc | ||
rm /tmp/${ORACLE_SID}*.trc | ||
cd "${BACK_THERE}" | ||
|
||
echo " " | ||
echo Zipping "${TARFILE}" ... | ||
gzip -9 "${TARFILE}" | ||
|
||
|
||
# Finished. | ||
echo " " | ||
echo Finished: \'"${ZIPFILE}"\' is ready for collection. | ||
echo " " | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.