Home Our Concept Services Products Shopping Cart Payment Options FAQ Privacy About Us Contact Us
 
Sitemap
You are here: Home > Tips and Tricks > Useful UNIX commands for DBA's

UNIX Commands for Database Administrators

This personal notepad of a DBA shared with others contains some useful UNIX commands for DBA's who don't use those commands on a daily base. Professional UNIX-administrator will not find here anything what they not know.

What Solaris ® HPUX ® AIX ®

Kernel Parameter Config

/etc/system

kmtune .
System messages /var/adm/messages /var/adm/system
/var/log
syslog
.
Diagnose prtdiag
top -S 20
glance /m nmon
Memory prstat -u <user> -s size ps -e -o'vsz pid ruser args' |sort -nr nmon m

:1,$s/string1/string2/g

vi search and replace

mv x.txt x.txt `date '+txt.%y_%m_%d'`

add a timestamp to a file.

Use a loop to execute tkprof for many trace files

After tracing database sessions you find .trc files in the user dump destination.
The following UNIX-command executes "tkprof" for all trace files in this directory and adds the extension ".txt" to output files.
for p_file in `ls *.trc`; 
         do  tkprof $p_file $p_file.txt explain=<username>/<password>; 
done

Warning: If you have many trace file (.trc) in this directory, the execution of the loop for all can cause high server load and might cause this filesystem to run full.

Advise: Check how many trace files you have and replase the "ls *.trc" with a more selective condition!

Loop that sleeps 5 seconds

while true
 do
  date
  echo 'Hallo'
  sleep 5
done

Memory

Display Process Memory in MB and sort

ps -efl |awk '{print "MB " $10*8/1024 " " $16}' |sort -n -k 2,2

Note: This command assumes that "ps -efl" displays the memory consumption in 8 KB pages.
Note: On Solaris the Shared Memory (e.g. Oracle SGA) is included. To see the real memory consumption the shared memory needs to be substracted.

/opt/RMCmem/bin/prtmem

Where is my memory? - Excellent answer from Sunmanagers Mailinglist

Check "Question 1 - Where is all my Memory?" in http://www.sunmanagers.org/archives/1997/att-1736/01-kernel.txt

Cleanup of IPC segments

Reference to another website: http://ocpdba.net/oracle/ipcs_cleanup.html

Searching core files and empty files

How to find core files

Searching just for the name "core" might find files which are not real "core" files created by core-dumps but unfortunately use this name.

Real files from core dumps can be identified by the file argument using the "xargs" command:

$ find . -type f -name core |xargs file
./scripts/core: ELF 32-bit MSB core file SPARC Version 1, from 'oraweb'

The example above is not the final solution, it just shows the working principle.
To display just the filename we need to "cut" the first field (-f1) and remove the delimiter ":" (-d:)

find . -type f -name core |xargs file | grep "core file" |cut -f1 -d:
Example output:
./scripts/core

Searching empty files

find . -size 0c

moving empty files to other directory

find . -size 0c -exec mv{} /destination_directory \;&

TitleDescription

prstat

Alternative on Solaris if "top" is not installed.

glance

On HP-UX, shows much more than "top"
Alarm thresholds are defined in /var/opt/perf/alarmdef

psrinfo

Displays list of all CPU's and the status (online or offline) (Solaris)

uname -a

Displays hostname and server type

prtdiag

Displays Hardware-Information (Memory, CPU's, ....)
in directory

/usr/platform/<your server type>/sbin/prtdiag

"your server type" is displayed by "uname -a", e.g.
/usr/platform/SUNW,Sun-Fire-880/sbin/prtdiag

cd /var/adm
ls -l messages*

This files contain error-messages and warnings from operating system and hardware. In case that Oracle error messsages indicate an operating system or hardware problem, you might find more information here.

kill -23 <pid>
kill -25 <pid>

kill -STOP <pid>
kill -CONT <pid>(continue)

Finding Files

find . -mtime +10 -exec ls -l {} \;

Find all files older than 10 days and execute a command. You might need to try it with and without the "+"sign.

find . -size 0c
find . -size 0c -exec mv{} /dest_dir \;&

Find / move empty files

find . -type f -name core |xargs file 
          | grep "core file" |cut -f1 -d
        

Find core files

/var/samba/log/smbd.log
	smbstatus

samba logfile
Status of samba daemon

scp

scp <file_to_copy> user@host:dirctory/file

__

__

__

__

__

__

__

__

Config Files ....

Filename and LockationDescription

/var/opt/perf/alarmdef

Defines limits for e.g. disk-IO and Network cards (e.g. 100 MBit or 1GBit); this limites are used by Glance ® to display "warnings" and "alarms".

That means, that the warning "Network bottleneck" might be misleading, as your server has a Gigabit Network Card, but the alarm threshold is still defined for old 100 MBit Cards.)

-

Copyright © 2005-2009 Mercury Consulting Limited.