Saturday, March 19, 2011
Install 11g IDM
Install SOA 11.1.1.2
Install SOA patchset 11.1.1.3
Install IAM 11.1.1.3(OAM and OIM components etc)
Install IDM 11.1.1.2 (OVD,OID and ODSM components)
Install IDM 11.1.1.3 patchset (OVD,OID and ODSM components)
Friday, May 8, 2009
Database Monitor Script
MAILLIST="test@gmail.com"
if [ "$1" ]
then DBNAME=$1
else echo "\nOracle SID has not been entered."
exit 16
fi
sqlplus -silent <<> /tmp/$$.1 &
a/a@${DBNAME}
exit;
EOF
Pid=$!
sleep 2
if [[ `ps -ef grep -w "$Pid"` != "" ]] ; then
kill -9 $Pid
fi
egrep 'ORA-121ORA-01034' /tmp/$$.1 > /dev/null
if [[ $? = 0 ]]
then
echo " ${DBNAME} is not accessible - db is down"
mailx -s " ${DBNAME} is not accessible - db is down" ${MAILLIST} < /tmp/$$.1 else grep -e 'ORA-01017' -e 'ORA-01033' /tmp/$$.1 > /dev/null
if [[ $? = 0 ]]
then
echo " ${DBNAME} is accessible - db is up and running"
exit 16
else
echo " ${DBNAME} is not accessible - db is down"
mailx -s " ${DBNAME} is not accessible - db is down" ${MAILLIST} < /tmp/$$.1 fi fi rm /tmp/$$.1 exit
SQLPLUS edit and format tips
set long 500 longchunksize 500
list - print all rows
change - c /old/new
del - del 4 will delete 4th line
input - input order by 2 will append line as last line
APPEND - Adds specified text to the end of the current line in the buffer
#############Col and Report format################
ttitle - center 'Redo Log Summary' skip 2
col group# format 999 heading 'Group'
col member format a45 heading 'Member' justify c
col status format a10 heading 'Status' justify c
col archived format a10 heading 'Archived'
col fsize format 99 heading 'Size(MB)'
Thursday, December 11, 2008
Unix command examples
man get manual page on a UNIX command
example: man uniq
cut extract columns of data
example: cut -f -3,5,7-9 -d ' ' infile1 > outfile1
example: ls -l | awk '{print $8}' | cut -d '.'. -f -2
-f 2,4-6 field
-c 35-44 character
-d ':' delimiter (default is a tab)
sort sort lines of a file (Warning: default delimiter is white space/character transition)
example: sort -nr infile1 more
Linux example: ls -l | sort -nr +4 -5
Linux example: df -k '/b01/oradata/' | sort -nr +1 -2
-n numeric sort
-r reverse sort
-k 3,5 start key
wc count lines, words, and characters in a file
example: wc -l infile1
-l count lines
-w count words
-c count characters
paste reattach columns of data
example: paste infile1 infile2 > outfile2
cat concatenate files together
example: cat infile1 infile2 > outfile2
-n number lines
-vet show non-printing characters (good
for finding problems)
uniq remove duplicate lines (normally from a sorted file)
example: sort infile1 uniq -c > outfile2
-c show count of lines
-d only show duplicate lines
join perform a relational join on two files
example: join -1 1 -2 3 infile1 infile2 > outfile1
-1 FIELD join field of infile1
-2 FIELD join field of infile2
cmp compare two files
example: cmp infile1 infile2
diff or diff3 compare 2 or 3 files - show differences
example: diff infile1 infile2 more
example: diff3 infile1 infile2 infile3 > outfile1
head extract lines from a file counting from the beginning
example: head -100 infile1 > outfile1
tail extract lines from a file counting from the end
example: tail +2 infile1 > outfile1
-n count from end of file (n is an integer)
+n count from beginning of file (n is an integer)
dos2unix convert dos-based characters to UNIX format (the file is
overwritten).
example: dos2unix infile1
tr translate characters - example shows replacement of spaces
with newline character
example: tr " " "[\012*]" <> outfile
grep extract lines from a file based on search strings and
regular expressions
example: grep 'Basin1' infile1 > outfile2
example: grep -E '15:2015:01' infile1 more
sed search and replace parts of a file based on regular
expressions
example: sed -e 's/450/45/g' infile1 > outfile3
Regular Expressions
Regular expressions can be used with many programs including ls, grep, sed,
vi, emacs, perl, etc. Be aware that each program has variations on usage.
ls examples:
ls Data*.txt
ls Data4[5-9].ps list ps files beginning with Data numbered 45-49
sed examples: (these are the regex part of the sed command only)
s/450/45/g search for '450' replace with '45' everywhere
s/99/-9999\.00/g search for all '99' replace with '-9999.00'
s/Basin[0-9]//g remove the word Basin followed by a single digit
s/^12/12XX/ search for '12' at the beginning of a line,
insert XX
s/Basin$// remove the word Basin if it is at the end of
the line.
s/^Basin$// remove the word Basin if it is the only word on
the line.
s/[cC]/100/g search for 'c' or 'C' replace with 100
45,$s/\([0-9][0-9]\)\.\([0-9][0-9]\)/\2\.\1/g
on lines 45 to the end of file, search for two digits
followed by a '.' followed by two digits. replace
with the digit pairs reversed.
2,$s/,\([^,]*\),/,\"\1\",/
on all lines except the first, search for a comma,
followed by any text, followed by a comma. replace
the found text surrounded by double quotes.
s/\([0-9][0-9]\):\([0-9][0-9]\):\([0-9][0-9][0-9][0-9]\)/Year = \3, Month = \2, Day = \1/
search for 2 digits, followed by a colon, followed by 2 digits,
followed by a colon, followed by 4 digits. replace with
text plus values in a different order.
Pipes, standard input, standard output:
Standard output, ">", places the results of a command into the file named
after the ">". A new file will be written (an old file with the same name
will be removed). In order to append to an existing file use ">>".
Pipes allow you to connect multiple commands together to form a data stream.
For example, to count the number of times the string "Nile" occurs in the
3rd column of a file run this:
cut -f 3 infile1 sort uniq -c grep 'Nile'
or do this:
cut -f 3 infile1 grep 'Nile' wc -l
From a global STN Attributes data set (tab delimited):
- extract all North American basins draining into the Atlantic Ocean
- select only columns 2,3,4,5,11,12,13, and 17
- replace all missing data values (either -99 or -999) with -9999.0
- remove duplicate lines
- sort by the first column
- number all lines sequentially
- save to a new file
grep 'North America' STNAttributes.txt grep 'Atlantic Ocean' \
cut -f 2-5,11-13,17 sed -e 's/-99\-999/-9999\.0/g' \
sort uniq cat -n > NewSTNAttributes.txt
Wednesday, November 19, 2008
FIND command examples...
To use the find command, at the Unix prompt, enter:
find . -name "pattern" -print
Replace "pattern" with a filename or matching expression, such as “*.txt”. (Leave the double quotes in.)
Options:
The general form of the command is:
find (starting directory) (matching criteria and actions)
The find command will begin looking in the starting directory you specify and proceed to search through all accessible subdirectories. You may specify more than one starting directory for searching.
You have several options for matching criteria:
-atime n File was accessed n days ago
-mtime n File was modified n days ago
-size +nM File is larger than n Mbytes
-type c Specifies file type: f=plain text, d=directory
-name nam The filename is nam
-user usr The file's owner is usr
-group grp The file's group owner is grp
-perm p The file's access mode is p (where p is an integer)
You can use + (plus) and - (minus) modifiers with the atime, mtime, and size criteria to increase their usefulness, for example:
-mtime +7 Matches files modified more than seven days ago
-atime -2 Matches files accessed less than two days ago
-size +100M Matches files larger than 100 MB
By default, multiple options are joined by "and". You may specify "or" with the -o flag and the use of grouped parentheses. To match all files modified more than 7 days ago and accessed more than 30 days ago, use:
\( -mtime +7 -o -atime +30 \)
You may specify "not" with an exclamation point. To match all files ending in .txt except the file notme.txt, use:
\! -name notme.txt -name \*.txt
You can specify the following actions for the list of files that the find command locates:
-print Display pathnames of matching files.
-exec cmd Execute command cmd on a file.
-ok cmd Prompt before executing the command cmd on a file.
Executed commands must end with \; (a backslash and semi-colon) and may use {} (curly braces) as a placeholder for each file that the find command locates. For example, for a long listing of each file found, use:
-exec ls -l {} \;
Matching criteria and actions may appear in any order and are evaluated from left to right.
Full examples
- To find and report all C language source code files starting at the current directory, enter:
$find . -name \*.c -print
- To report all files starting in the directories /mydir1 and /mydr2 larger than 2 Mbytes and that have not been accessed in over 30 days, enter:
$find /mydir1 /mydir2 -size +2M -atime +30 -print
- To remove (with prompting) all files starting in the /mydir directory that have not been accessed in over 100 days, enter:
$find /mydir -atime +100 -ok rm {} \;
- To show a long listing starting in /mydir of files not modified in over 20 days or not accessed in over 40 days, enter:
$find /mydir \(-mtime +20 -o -atime +40\) -exec ls -l {} \;
- To list and remove all regular files named core starting in the directory /prog that are larger than 500KB, enter:
$find /prog -type f -size +500K -print -name core -exec rm {} \;
- To search foo file in whole systemby, specifying the root directory (/) to search. If you don't run this command as root, find will display a error message for each directory on which you don't have read permission. This can be a lot of messages, and the matching files that are found may scroll right off your screen. A good way to deal with this problem is to redirect the error messages so you don't have to see them at all:
$find / -name foo 2>/dev/null
Thursday, November 13, 2008
Debug plsql procedure/function in TOAD when executed by external application
Debug plsql procedure/function in TOAD when executed by external application
Step Over: Execute one line of code at a time but does not go into any called procedures or functions.
Trace Into: Execute one line of code at a time and does go to any called procedure or functions and executing its code one line at a time as well.
Trace Out: Returns the execution to calling routine and stopping on next line of code after call statement.
Breakpoint: Stop execution at the line with breakpoint
Add Watch: Watches allow to the contents of specific variables.
For tutorials on google:
Toad for Oracle Tutorials - debug
Step 0:
grant DEBUG CONNECT SESSION to system;
revoke DEBUG CONNECT SESSION from system;
Step 1:
Anonymous Block
-- run this in your client session
-- first block gets the debug session ready
DECLARE
id VARCHAR2(255);
BEGIN
id := DBMS_DEBUG.INITIALIZE('TOAD_EXAMPLE');
DBMS_DEBUG.DEBUG_ON;
END;
/
Step 2:
--this fires off your stored pl/sql object so it can be debugged.
BEGIN
KARAM.LOOP_INSERT;
DBMS_DEBUG.DEBUG_OFF;
END;
/
Step 3:
Now attach session in TOAD
Thursday, August 28, 2008
check and set stty setting
UNIX$ stty -a
speed 38400 baud; line = 0;
rows = 45; columns = 126
min = 1; time = 1;
intr = ^C; quit = ^\; erase = ^H; kill = ^U
eof = ^D; eol = ^@; eol2 = ^@; swtch = ^@
stop = ^S; start = ^Q; susp = ^Z; dsusp = ^Y
werase = ^W; lnext = ^V
-parenb -parodd cs8 -cstopb hupcl cread -clocal -loblk -crts
-ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl -iuclc
ixon -ixany -ixoff imaxbel -rtsxoff -ctsxon -ienqak
isig icanon -iexten -xcase echo echoe echok -echonl -noflsh
echoctl -echoprt echoke -flusho -pendin
opost -olcuc onlcr -ocrnl -onocr -onlret -ofill -ofdel -tostop tab3
LINUX$ stty -a
speed 38400 baud; rows 45; columns 126; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol =; eol2 = ; swtch = ; start = ^Q; stop = ^S;
susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke
LINUX$ stty erase ^h