--------------------------------
netstat -a | 7777
to get system log messgaes in aix
---------------------------------
errpt
To kill vnc session without locking of port
-----------------------------------------------------
Vncserver –kill :0
Oratab locations in solaris
-----------------------------------
/var/opt/oracle
using alias for big command
============================
The following command assigns the new compound command to an alias named nuke_oracle :
alias nuke_oracle="ps -ef|grep 'ora_'|grep -v grep|grep $ORACLE_SID|awk '{ print $2 }'|xargs kill -9"
preferably place it in .bash_profile
Some good aliases for oracle users:
--------------------------------------------
alias alert='tail -100 $DBA/$ORACLE_SID/bdump/alert_$ORACLE_SID.log|more'
alias arch='cd $DBA/$ORACLE_SID/arch'
alias bdump='cd $DBA/$ORACLE_SID/bdump'
alias cdump='cd $DBA/$ORACLE_SID/cdump'
alias pfile='cd $DBA/$ORACLE_SID/pfile'
alias rm='rm -i'
alias sid='env|grep ORACLE_SID'
alias admin='cd $DBA/admin'
Any alias can be removed easily with the Unix unalias command. For example, to remove the pfile alias, you would enter the command
unalias pfile.
set the below command in .profile to change the look of the prompt when on linux
--------------------------------------------------------------------------------------------------
PS1=" `hostname`*\${ORACLE_SID}-\${PWD} >"
cd /u01/oradata/PROD
The prompt will be :-
corphp*PROD-/u01/oradata/PROD >
To run job in background
--------------------------------
nohup run_sql.ksh > logfile.lst 2>&1 &
watching logfile
-------------------
tail -f logfile.lst
Send some part of text /data through email
----------------------------------------------------
cat ~oracle/.sh_history|mailx -s "Secret DBA Activity Report" donald.burleson@remote-dba.net
mail ora-600 to email
---------------------------
dbalist='burleson@frontiernet.net\
Don@remote-dba.net'
cat alert_$ORACLE_SID.log|grep 0600|mailx -s\
"$ORACLE_SID alert log message detected" $dbalist
crontab -l
The five execution-time elements are defined, in the order in which they appear, as follows:
minute
The minute of the hour (0-59)
hour
The hour of the day (0-23)
monthday
The day of the month (1-31)
month
The month of the year (1-12)
weekday
The day of the week (0=Sunday, 1=Monday, . . . 6=Saturday)
For
Disk Management commands
==============================
Disks exist in Unix as physical volumes and are carved into physical partitions (PPs). These physical partitions are, in turn, assigned to logical volumes. A logical volume is a chunk of storage that consists of one or more physical partitions. The logical volumes are then mapped onto Unix mountpoints. Several logical volumes can be used in a mount point, and a collection of such logical volumes is referred to as a volume group. A Unix mount point is like a directory name, and is used by you, the Oracle DBA, when allocating Oracle data files
The following lsvg -o
command can be used to display a list of volume groups with Unix mount points:
Now that you can see the volume groups, you can drill-in using lsvg -l to see details for a specific volume group:
>lsvg -l >name from above command>
Sar commands:
==============
sar -u
Shows CPU activity
sar -w
Shows swapping activity
sar -b
Shows buffer activity
sar -u a b
a=interval between reading
b=number of readings
vmstat
========
execute vmstat 3 and get a line of output every three seconds:
>vmstat 3
The critical vmstat values that you need to know about are as follows:
r
The run queue. When this value exceeds the number of CPUs, the server is experiencing a CPU bottleneck. (You can get the number of CPUs by entering lsdev -C|grep Process|wc -l.)
pi
The page-in count. Non-zero values typically indicate that the server is short on memory and that RAM is being written to the swap disk. However, non-zero values can also occur when numerous programs are accessing memory for the first time. To find out which is the case, check the scan rate (sr) column. If both the page-in count and the scan rate are non-zero, then you are short on RAM.
sr
The scan rate. If you see the scan rate rising steadily, you know that the paging daemon is busy allocating memory pages.
For AIX and HP-UX, vmstat also provides the following CPU values. These values are expressed as percentages and will sum to 100:
us
User CPU percentage
sy
System CPU percentage
id
Idle CPU percentage
wa
Wait CPU percentage
When the sum of user and system CPU percentages (us + sy) approaches 100, then the CPUs are busy, but not necessarily overloaded. The run queue value can indicate a CPU overload, but only when the run queue exceeds the number of CPUs on the server.
When wait CPU percentages (the wa values) exceed 20, then 20% or more of the processing time is waiting for a resource, usually I/O. It is common to see high wait CPU percentages during backups and exports, but they can also indicate an I/O bottleneck.
STEPS TO AUTOMATE VMSTAT REPORTS IN ORACLE
===============================================
DROP TABLE MON_VMSTATS;
CREATE TABLE MON_VMSTATS
(
START_DATE DATE,
DURATION NUMBER,
SERVER_NAME VARCHAR2(20),
RUNQUE_WAITS NUMBER,
PAGE_IN NUMBER,
PAGE_OUT NUMBER,
USER_CPU NUMBER,
SYSTEM_CPU NUMBER,
IDLE_CPU NUMBER,
WAIT_CPU NUMBER
)
tablespace dba_perf
STORAGE (INITIAL 500K
NEXT 500K
PCTINCREASE 0)
;
get_vmstat.ksh
==============
#!/bin/ksh
# First, we must set the environment.
ORACLE_SID=BURLESON
export ORACLE_SID
ORACLE_HOME=`cat /etc/oratab|\
grep \^$ORACLE_SID:|cut -f2 -d':'`
export ORACLE_HOME
PATH=$ORACLE_HOME/bin:$PATH
export PATH
MON=`echo ~oracle/mon`
export MON
SERVER_NAME=`uname -a|awk '{print $2}'`
typeset -u SERVER_NAME
export SERVER_NAME
# Sample every five minutes (300 seconds).
SAMPLE_TIME=300
while true
do
vmstat ${SAMPLE_TIME} 2 > /tmp/msg$$
# This script is intended to run starting at
# 7:00 AM EST until midnight EST.
cat /tmp/msg$$|sed 1,4d | awk '{ \
printf("%s %s %s %s %s %s %s\n", $1, $6, $7,\
$14, $15, $16, $17) }' | while read RUNQUE\
PAGE_IN PAGE_OUT USER_CPU SYSTEM_CPU\
IDLE_CPU WAIT_CPU
do
$ORACLE_HOME/bin/sqlplus -s / <
sysdate,
$SAMPLE_TIME,
'$SERVER_NAME',
$RUNQUE,
$PAGE_IN,
$PAGE_OUT,
$USER_CPU,
$SYSTEM_CPU,
$IDLE_CPU,
$WAIT_CPU
);
EXIT
EOF
done
done
GETTING report
================
set pages 9999;
set feedback off;
set verify off;
column my_date heading 'date' format a20
column c2 heading runq format 999
column c3 heading pg_in format 999
column c4 heading pg_ot format 999
column c5 heading usr format 99
column c6 heading sys format 99
column c7 heading idl format 99
column c8 heading wt format 99
select
to_char(start_date,'day') my_date,
-- avg(runque_waits) c2
-- avg(page_in) c3,
-- avg(page_out) c4,
avg(user_cpu + system_cpu) c5,
-- avg(system_cpu) c6,
-- avg(idle_cpu) c7,
avg(wait_cpu) c8
from
mon_vmstats
group BY
to_char(start_date,'day')
;
the check_parms.ksh script requires two parameters: an Oracle SID and a numeric value that must be greater than 100. The if statements cause the script to terminate if the required parameters are not passed.
# Exit if no first parameter $1.
if [ -z "$1" ]
then
echo "Usage: check_parms.ksh
<#_days> (where value is > 100)"
exit 99
fi
# Exit if no second parameter $2.
if [ -z "$2" ]
then
echo "Usage: check_parms.ksh
<#_days> (where value is > 100)"
exit 99
fi
# Exit if parm is not greater than 100.
tmp=`expr $2` # Convert string to number.
if [ $tmp -lt 101 ]
then
echo
echo "Argument two is less than 100.\
Aborting Script."
echo
exit 99
fi
Script to check if oracle user is only the one executing the script
if [ `whoami` != 'oracle' ]
then
echo "Error: You must be oracle to execute."
exit 99
fi
script to validate if right oracle sid has been passed
TEMP=`cat /etc/oratab|grep \^$1:|\
cut -f1 -d':'|wc -l`
tmp=`expr TEMP` # Convert string to number.
if [ $tmp -ne 1 ]
then
echo "Your input $1 is not a valid ORACLE_SID."
exit 99
fi