**************To List Huge Files**************
du
-a .| sort -n -r | head -n 30
find
. -size +100000 -exec ls -ltr {} \;
find
<path>/ -type f -size 1000c -exec ls {} \:
*******List Files Based on Modified Time*******
find
<path> -type f -mtime +1 -exec ls -ltr {} \; -- To List files based
on modified time
find
<path> -type f -mtime +1 -exec rm -f {} \; --- To Remove files
based on modified time
find
. -mtime +2 -exec mv "{}" <path>/ \; --- To Move
Files based on modified time
*******To check top process
consuming more memory*******
ps
-e -orss,pid=,user=,args=, | sort -b -k1,1n | pr -TW$COLUMNS| tail -30
*******To check top 5 process
consuming more cpu***********
ps axo pcpu,comm,pid,ruser,time,etime,args | sort -nr | head -n 5
*******************To kill LIBR
process********************
ps
-ef | grep applmgr |awk '{print "kill -9 " $2 }'
*******************To kill LOCAL=NO
process**************
kill
-9 `ps -ef |grep LOCAL=NO | grep gcasq | awk '{print $2}'`
*******PORT CONFLICT *******
lsof -i TCP|grep <port#>
netsta -anp|grep <port#>
CHECKING OPERATING SYSTEM LEVEL
STATS
*************************************************
Solaris:
=========
$
/usr/sbin/prtconf |grep -i "Memory size"
$
swap -s
$
df -k
$
/usr/local/bin/top
$
vmstat 5 100
$
sar -u 2 100
$
iostat -D 2 100
$
mpstat 5 100
Prtconf
command will show how much Physical Memory
Swap
command will provide us with the usage of swap space including the RAM.
Df
command will indicate how much space is free in each mount point and also
provides
information about swap space(s).
Top
command wil provide the above information plus information about top CPU
consuming
processes, CPU usage in the system, etc.
Vmstat
will provide information about process run queue, memory usage,
paging
and swapping and CPU % usage in the server.
Iostat
provides IO usage by Disk, CPU % usage, etc. depending on the options
used.
*********************************************************
prstat
-a ---will give the processes running.
ps
-ef --- processes
ipcs
- report inter-process communication facilities status (semaphorees)
ipcs
-b -the last col gives the no of semaphores.
ipcrm
- remove a message queue, semaphore set, or shared
memory ID
sysresv
-- The chances in this sort of case is sometimes that the semaphores are not
cleared we can check that using "sysresv" to ensure whether
semaphores are cleared after database is brought down.
Mpstat
will provide CPU usage stats for a Solaris server with 1 or more CPUs.
===============================================================
Linux
$
dmesg | grep Memory
$
vmstat 5 100
$
/usr/bin/top
AIX:
$
/usr/sbin/lsattr -E -l sys0 -a realmem
$
/usr/sbin/lsps -s
$
vmstat 5 100
$
iostat 2 100
$
/usr/local/bin/top # May not be installed by default in the server
HP-Unix
11.0:
$
grep Physical /var/adm/syslog/syslog.log
$
df -k
$
sar -w 2 100
$
sar -u 2 100
$
/bin/top
$
vmstat -n 5 100
$
iostat 2 100
$
top
To
set backspace
stty
erase {backspace}
this
will set backspace.
To
change owner
chown
oracle:dba oracle
owner=oracle
group=dba directory=oracle
To
know CPU info
psrinfo
uname
-X
To
know Oracle Version(64 bit/32 bit):
go
to $RACLE_HOME/bin..
then
$file oracle or $file sqlplus
To
create/modify a file's date/timestamp:
touch
-m 01092200 dam
(create
a file with timestamp jan 09 22:00 hrs
To
copy a file with the same timestamp:
cp
-pr abcd abcd
To
set LD_library_path:
export
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib:.
To
change the os users settings:
conn
as root,
DEFAULT:oracle>cat
/etc/passwd|grep oracle
oracle:x:1001:200:Oracle
Client Software Owner:/export/home/oracle:/bin/ksh
+@users_dba_oracle:x:::::
vi
/etc/passwd
then
the shell from sh to ksh,change ora_home,etc..
oracle:x:1001:200:Oracle
Client Software Owner:/export/home/oracle:/bin/ksh
osuser:encripted
pwd:uid:gid:mail send id:home dir:default shell
To
find the contents of the Binary File
strings
-a exp_file.dmp|grep "CREATE USER"
strings
-a exp_file.dmp|grep "TABLE"
To
change the server settings(database level)
In
every Oracle Home ($ORACLE_HOME/sqlplus/admin) there is a glogin.sql which
takes care of the sql session settings for all dataabses in that particlar
home.
To
set these settings at the server level for all homes
go
to cd $SQLPATH
[gemsora6:/export/home/oracle/aps7/sql]
edev:oracle>ls
-ltr login*
-rwxr-xr-x
1 oracle dba 1016 Jan 17 04:06
login.sql_jan17
-rwxr-xr-x
1 oracle dba 1017 Jan 17 04:09
login.sql
Here
u have a login.sql file which takes care of these settings.
Make
whatever changes u want in this file and run the .profile again.
If
you login to the database now, you will have new session settings.
Grep
usage
grep
dbaodc `crontab -l|grep -v ^#|awk '{print $6}'`
grep
-i "keyword" *
list
all the lines in the files where keyword in present
grep
-il "odcebiz" */*/*
liosts
all the files which have odcebiz keyword in them
expr
export
a=5
devec2:oracle>b=`expr
$a - 1`
[oradb5d:/gemsora5/u01/app/oracle/admin/local/scripts]
devec2:oracle>echo
$b
4
[oradb5d:/gemsora5/u01/app/oracle/admin/local/scripts]
devec2:oracle>tail
-`expr $a - 1` res_con.sql
END;
/
exit
prstat
-a ---will give the processes running.
ps
-ef --- processes
ipcs
- report inter-process communication facilities status (semaphorees)
ipcs
-b == the last col gives the no of semaphores.
ipcrm
- remove a message queue, semaphore set, or shared
memory ID
sysresv
-- The chances in this sort of case is sometimes that the semaphores are not
cleared we can check that using "sysresv" to ensure whether
semaphores are cleared after database is brought down.
To
know the sum of bytes
ls
-ltr /preprod/u*/oradata/preprod/*.dbf|awk '{sum += $5} END {print
sum/1024/1024/1024}'
601.858
356
ls
-ltr /glprod/u*/oradata/glprod/*.dbf|awk '{sum += $5} END {print
sum/1024/1024/1024}'
2000.87
1473
To
remove some files from srvr date
find
* -mtime +3 -exec \rm {} \;
-------------------------------------------------
cat
nar|awk '{print "mv " $2 " /u92/oracle/itest2/bdump/."}'>kum.sh
to
know how many files copied from source to target.
o=0
while
test true
do
n=`ls -lt /preprod/u*/oradata/preprod/*.*|wc -l`
s=`ls -lt /preprod/u*/oradata/preprod/*.*|awk '{s+=$5}
END{print int(s/1024/1024)}'`
d=`expr ${s} - ${o}`
echo "$n--->${s}Mb--->${d}Mb"
o=${s}
sleep 60
done
while
test true
do
n=`ls -lt /preprod/u*/oradata/preprod/*.*|wc -l`
s=`ls -lt /preprod/u*/oradata/preprod/*.*|awk '{s+=$5}
END{print int(s/1024/1024)}'`
d=`expr ${s} - ${o}`
echo "$n--->${s}Mb--->${d}Mb"
o=${s}
sleep 60
done
---------------------------------------------------------------------------------
to
remove files on given date
ls
-lt |grep "Oct 8"|awk '{print "rm -rf "$9}'>t1.sh
chmod
777 t1.sh
df
-k .
./t1.sh
df
-k .
ls
-ltr|more
---------------------------------------------------------
CPU
utilization for the database wise:
/usr/ucb/ps
-auxwww|grep prdscv | grep -i "local=no"|awk '{s += $3} END {print
float(s)}'
----------------------------------------------------------------------------
cat
cr_database.sql|grep -v redo|grep -v tempx|grep ".dbf"|wc -l
-----------------------------------------------------------------
to
split the big file
split
-b 1024m devl1c1_ora_4758.trc /u92/oracle/devl1c1/TRACE/devl1c1_ora_4758_
To
see the cpu usage on servers.
while
true
do
Servers="srvr28a
srvr28b srvr28c"
for
node in `echo ${Servers}`
do
echo
$node---Utilization
rsh
${node} sar 1 1
done
sleep
60
done
To
change the owner ship for the dir or files
chown
root:other
chown
-R applmgr:dba applmgr
TAR GZIP
tar
-cvf - 12.1.0.2 |gzip -c > /<path>/12.1.0.2_*****.tar.gz
To
tar and untar the file or dir
tar
cpf - 11.2.0.3| ssh <hostname> "tar xpf - -C <path>"
cd
<path>
tar
-cf - fs1 |ssh <hostname> -l <userid> 'cd <path>; tar
-xf -' &
tar
-cf - fs2 |ssh <hostname> -l <userid> 'cd <path>; tar
-xf -' &
To
create dir
df
-k /mmdev2/u* |awk '{ print $6 }'|grep -v Mount|while read line
do
mkdir
-p $line/oradata/mmdev2
chown
-R oracle:dba $line/oradata
done
To
know the ORA-600 entries
lines=`grep
-n ORA-00600 alert_glprod3.log|grep 729|awk -F: '{print $1}'`
for
l in $lines
do
lno=$((
$l-1 ))
echo
$lno
tail
+$lno alert_glprod3.log|head -3
done
To
Remove the Files in Specific Date
ls
-ltr |grep "May "|awk '{print "rm -rf "$9}' >
sha.sh;chmod 755 sha.sh;sh sha.sh &
To
remove some files from srvr date
find
* -mtime +3 -exec \rm {} \;
-------------------------------------------------
cat
nar|awk '{print "mv " $2 "
/u92/oracle/itest2/bdump/."}'kum.sh
To
know how many files copied from source to target.
o=0
while
test true
do
n=`ls -lt /preprod/u*/oradata/preprod/*.*|wc -l`
s=`ls -lt /preprod/u*/oradata/preprod/*.*|awk '{s+=$5}
END{print int(s/1024/1024)}'`
d=`expr ${s} - ${o}`
echo "$n---${s}Mb---${d}Mb"
o=${s}
sleep 60
done
while
test true
do
n=`ls
-lt /glprod/u*/oradata/glprod//*.*|wc -l`
s=`ls
-lt /glprod//u*/oradata/glprod/*.*|awk '{s+=$5} END{print int(s/1024/1024)}'`
d=`expr
${s} - ${o}`
echo
"$n---${s}Mb---${d}Mb"
o=${s}
sleep
60
done
CPU
utilization for the database wise:
/usr/ucb/ps
-auxwww|grep prdscv | grep -i "local=no"|awk '{s += $3} END {print
float(s)}'
MAILS
FROM SERVER
mailx
-s 1.log -a 1.log mail@***.com < /dev/null
uuencode
purge.sh purge.sh|mailx -s "purge.sh" mail@**.com
To
remove files on given date
ls
-lt |grep "Apr 20"|awk '{print "rm -rf "$9}'t1.sh
chmod
777 t1.sh
df
-k .
./t1.sh
df
-k .
ls
-ltr|more
find
. -size 524288000c
GREP
DATA INTO A FILE
ls
-ltr|grep "Apr 19"|awk '{print "rm -rf "$9}'RM1.SH
+++++++++++++++++++++++++++++++++++++++++++++++++++++
ls
-lrt | sed -n '1,100p'|awk '{print "rm -rf " $9 }' -- first 20
ls
-lrt|egrep "Nov 18"| awk '{print "rm -rf " $9 }' >
oct.sh;chmod 755 oct.sh; sh oct.sh &
ls
-lrt|egrep "Nov 18"| awk '{print "gzip " $9 " &
"}'
ps
-ef|grep oracle$ORACLE_SID|grep LOCAL=NO|awk '{print "kill -9 " $2 }'
> kill.sh;chmod 755 kill.sh;sh kill.sh &
find
. -mtime +3 -type f -exec rm {} \;
ls
-lrt |grep "Jun 30" |awk '{print "gzip " $9 " &
" }' > Jun30.sh;chmod 755 Jun30.sh;sh Jun30.sh
Firing
"awk" command
ls
-l | grep 'Apr' | awk '{print $9}' | xargs -i rm {} &
ls
-l | grep 'Dec 17' | awk '{print $9}' | xargs -i rm {}
ls
-l |awk '{print "ln -sf "$11" " $9}'
For
log files newer than 5 days
find
/opt/app/logs/ -name *.log -mtime -5 -exec ls -tl {} \;
find
/opt/app/logs/ -name *.log -mtime -5 -exec rm -f {} \;
listing
directory
ls
-F | grep /
ls
-l | sort +0
TAPE
To bring the tape offline
mt
-f /dev/rmt/0 offline
TO SEARCH SERVER NAME IN ALL FILES
find . -type f | xargs grep -l "<servername"
No comments:
Post a Comment