Useful Unix commands for DBAs Here are some useful Unix/Linux commands which you will find handy in your day-to-day life as an Oracle DBA. Most of these commands are just query commands and will not change / alter anything on the operating system. Commands whch can change / alter anything at operating system level are denoted with sign. However please use due diligence in using these commands. Please also note that the output may differ depending on the version and flavor of Unix that you are using. Do give your feedback, suggestions and contribution to improve this page.
Memory Display total RAM (Memory) on the server Tru64 Unix uerf –r 300 | grep –i mem Solaris prtconf | grep –i mem Linux free HP-UX swapinfo –tm AIX lsdev –C | grep mem lsattr –El
$ lsdev -C | grep mem Output on AIX mem0
Available 00-00
Memory
$ lsattr -El mem0 size 1536 Total amount of physical memory in Mbytes False goodsize 1536 Amount of usable physical memory in Mbytes False Go top
Display paging utilization lsps –a (provides a snapshot of the current utilization of each of the paging spaces on a system) Output on AIX Page Space Physical Volume Volume Group Size %Used Active Auto Type paging01 hdisk4 dbvg2 2560MB 9 yes yes lv hd6 hdisk0 rootvg 512MB 42 yes yes lv lsps -s (provides a summary of the total active paging space and its current utilization) Output on AIX Total Paging Space Percent Used 4096MB 1% Go top
Display memory utilization on Linux To read memory usage in Linux, please use "free" command. As you said, you may noticed that most the memory had been used, here is the example, # free Output on Linux total used free shared buffers cached Mem: 26871344 15263128 11608216 0 374036 13635804 -/+ buffers/cache: 1253288 25618056 Swap: 54524600 0 54524600 "cached" memory basically are free to be used. The Linux philosophy is keeping resource idle/wasted as little as it can. Keeping the cache means that if something needs the same data again. You will notice the cached is very little during the system just rebooted, but it keeps growing if you leave it running for days. If you want to know the memory used, please read the second line. The -/+ buffers/cache line shows how much memory is used and free from the perspective of the applications. So, for this example, we still have 25GB memory free to be used. The bottom line is as far as swap is not being used (third line from the example), memory usage isn't impacting system performance. Refer to URL for more information. http://www.redhat.com/advice/tips/meminfo.html Go top
Which process is using memory at O/S (AIX) The following command displays the memory usage statistics for the top ten processes. If you do not specify a number, it will display all the processes currently running in this system. # svmon -Pau 10 Output on AIX Pid 4783 2750 15706 17172 21150 17764 2910 19334 13664 17520
1174
Command Inuse Pin Pgspace 15012 4781 X 4353 1178 5544 dtwm 3257 1174 4003 dtsession 2986 1174 3827 dtterm 2941 1174 3697 aixterm 2862 1174 3644 dtterm 2813 1174 3705 dtterm 2813 1174 3704 dtterm 2804 1174 3706 aixterm 2801 1174 3619
Pid: 15012 Command: maker4X.exe Segid Type Description
Inuse
1572 pers /dev/hd3:62 142 pers /dev/hd3:51
0 0
Pin Pgspace Address Range 0 0
0 0..-1 0 0..-1
maker4X.exe
1bde pers /dev/hd3:50 0 0 0 0..-1 2c1 pers /dev/hd3:49 1 0 0 0..7 9ab pers /dev/hd2:53289 1 0 0 0..0 404 work kernel extension 27 27 0 0..24580 1d9b work lib data 39 0 23 0..607 909 work shared library text 864 0 7 0..65535 5a3 work sreg[4] 9 0 12 0..32768 1096 work sreg[3] 32 0 32 0..32783 1b9d work private 1057 1 1219 0..1306 : 65307..65535 1af8 clnt 961 0 0 0..1716 0 work kernel 1792 1146 3488 0..32767 : 32768..65535 Pid 15012 is the process ID that has the highest memory usage. The Command indicates the command name, in this case maker4X.exe. The Inuse column (total number of pages in real memory from segments that are used by the process) shows 4783 pages (each page is 4 KB). The Pin column (total number of pages pinned from segments that are used by the process) shows 1174 pages. The Pgspace column (total number of paging-space pages that are used by the process) shows 4781 pages. Go top
Displaying Allocated RAM Memory Segments in Unix ipcs –pmb (Inter process control system) $ ipcs -pmb Output on AIX IPC status from /dev/mem as of Fri Aug 2 15:20:20 WAUST 2002 T ID KEY MODE OWNER GROUP SEGSZ CPID LPID Shared Memory: m 131072 0x58000932 --rw-rw-rw- root system 134217728 6990 47580 m 1 0x0d003187 --rw-rw-rw- root system 1440 11872 27654 m 131074 0xffffffff --rw------- root system 104857600 45198 45198 m 2621443 0x05c17710 --rw-r----- crpor11i oradba 368291840 25196 29384 m 1310724 0x50942e5c --rw-r----- devor11i oradba 405147648 25450 46580 Go top
Identify all held RAM memory segments & release the RAM memory from Unix ipcs –pmb (To check for held memory) Output on AIX IPC status from /dev/mem as of Fri Aug 2 14:27:14 WAUST 2002 T ID KEY MODE OWNER GROUP SEGSZ CPID LPID Shared Memory: m 131072 0x58000932 --rw-rw-rw- root system 134217728 6990 47580 m 1 0x0d003187 --rw-rw-rw- root system 1440 11872 7812 m 131074 0xffffffff --rw------- root system 104857600 45198 45198 m 2621443 0x05c17710 --rw-r----- crpor11i oradba 368291840 25196 39296 m 1310724 0x50942e5c --rw-r----- devor11i oradba 405147648 25450 39290
ipcrm –m 1310724 (To release the memory) Go top
CPU Displaying the No. of CPU processors in UNIX AIX lsdev –C | grep Process | wc –l HP-UX ioscan –C processor | grep processor | wc –l Solaris psrinfo –v | grep “Status of Processor” | wc –l Linux cat /proc/cpuinfo | grep processor | wc –l
Display top CPU Consumers with ps $ ps –ef | sort +7 | tail Output on AIX devor11i 30420 1 0 02:36:10 devor11i 33088 1 0 02:36:10 devor11i 41300 1 0 02:36:06 devor11i 48032 1 2 13:46:19 crpor11i 18498 7812 2 14:12:49 crpap11i 31850 1 0 06:17:06 devap11i 32832 1 0 02:35:31 crpor11i 48448 7812 1 14:12:49 crpor11i 39190 7812 0 14:12:49 root 15182 9030 0 13:24:19
- 0:05 oracleDEV (LOCAL=NO) - 0:06 oracleDEV (LOCAL=NO) - 0:01 oracleDEV (LOCAL=NO) - 0:02 oracleDEV (LOCAL=NO) pts/0 0:00 ps -ef - 0:00 rwmts60 name=REP60_CRP - 0:00 rwmts60 name=REP60_DEV pts/0 0:00 sort +7 pts/0 0:00 tail - 0:00 telnetd -a
ps auxgw | sort +2 | tail The third column of this listing (%CPU) shows the percentage of CPU used. Output on AIX USER
PID %CPU %MEM SZ RSS TTY STAT STIME TIME COMMAND
crpor11i 42412 0.1 1.0 29420 16164 - A 06:15:58 0:30 ora_qmn0_CRP devor11i 48032 0.1 1.0 30252 16036 - A 13:46:19 0:03 oracleDEV (LOCAL =NO) crpor11i 27526 0.1 1.0 30372 17336 - A 12:53:46 0:10 oracleCRP (DESCR IPTION=(LOCAL=no)(ADDRESS=(PROTOCOL=BEQ))) root 2888 0.2 0.0 164 36 -A Jul 20 73:42 /usr/sbin/syncd 60 crpor11i 34816 0.3 1.0 31916 18888 - A 13:43:29 0:12 oracleCRP (DESCR IPTION=(LOCAL=no)(ADDRESS=(PROTOCOL=BEQ))) root 45198 0.3 7.0 175204 103064 -A Jul 24 67:10 dsmserv quiet crpor11i 43620 0.4 1.0 32264 19236 - A 13:58:23 0:08 oracleCRP (DESCR IPTION=(LOCAL=no)(ADDRESS=(PROTOCOL=BEQ))) root 774 47.1 0.0 12 7492 -A Jul 20 17411:25 kproc root 516 48.0 0.0 12 7492 -A Jul 20 17723:26 kproc
ps augxww | grep “RSS| “ | head Output on AIX USER PID %CPU %MEM SZ RSS TTY STAT STIME TIME COMMAND root 516 48.0 0.0 12 7492 -A Jul 20 17725:33 kproc root 774 47.1 0.0 12 7492 -A Jul 20 17413:32 kproc crpor11i 46568 1.9 1.0 29768 16728 - A 14:16:18 0:02 oracleCRP (DESCR IPTION=(LOCAL=no)(ADDRESS=(PROTOCOL=BEQ))) crpor11i 43620 0.4 1.0 32264 19236 - A 13:58:23 0:08 oracleCRP (DESCR IPTION=(LOCAL=no)(ADDRESS=(PROTOCOL=BEQ))) crpor11i 34816 0.3 1.0 31924 18896 - A 13:43:29 0:14 oracleCRP (DESCR IPTION=(LOCAL=no)(ADDRESS=(PROTOCOL=BEQ))) root 45198 0.3 7.0 175204 103012 -A Jul 24 67:10 dsmserv quiet root 2888 0.2 0.0 164 36 -A Jul 20 73:42 /usr/sbin/syncd 60 root 47586 0.1 0.0 1296 212 - A Jul 24 26:07 dtgreet crpor11i 27526 0.1 1.0 30372 17336 - A 12:53:46 0:10 oracleCRP (DESCR IPTION=(LOCAL=no)(ADDRESS=(PROTOCOL=BEQ))) Go top
To display processes consuming CPU% & elapsed time ps -aef -o ruser,pid,pcpu,args,etime, Output on AIX app_prd 6504490 app_prd 6512660 app_prd 6516842 app_prd 6520950 app_prd 6533186 app_prd 6541388 app_prd 6557804 app_prd 6562028 app_prd 6570158 app_prd 6574202 app_prd 6582450 app_prd 6586452
0.1 f60runm webfile=5,13090,ebspap1_9000_ebspr 04:05:37 0.0 f60runm webfile=5,14982,ebspap1_9000_ebspr 01:18 0.0 f60runm webfile=5,14058,ebspap1_9000_ebspr 02:11:32 0.0 f60runm webfile=5,13662,ebspap1_9000_ebspr 02:50:33 0.2 f60runm webfile=5,14771,ebspap1_9000_ebspr 30:17 0.0 f60runm webfile=5,14886,ebspap1_9000_ebspr 15:33 0.6 f60runm webfile=5,14865,ebspap1_9000_ebspr 18:29 0.0 /a01/app/app_prd/product/ebsprdiAS/Apache/ 2-13:42:42 0.1 f60runm webfile=5,12980,ebspap1_9000_ebspr 04:38:38 0.0 d2ls60 9100 9200 2-13:42:30 0.0 /a01/app/app_prd/product/ebsprdiAS/Apache/ 2-13:42:39 0.1 f60runm webfile=5,14453,ebspap1_9000_ebspr 01:17:47 Go top
Monitoring CPU Run-Queue with sar command sar -qu 5 5 (ATT) Output on AIX 10:58:02 %usr 10:58:07 0
runq-sz %sys 2
%runocc
swpq-sz %wio 2.8 4
%swpocc %idle 100 94
Note: The CPU is spending most (94%) of its time in idle mode. This CPU is not being heavily used at all. Generally it is alright to have a CPU that is 0% idle as long as the RUN-QUEUE is not too large. In this case the run queue is 100% occupied (there is always a process waiting to be run) and there are an average of 2.8 processes waiting to be run in the RUN-QUEUE. You want to keep the RUN-QUEUE under 5-6 for a single CPU machine. If the run queue gets any larger that those values you will see some performance degradation. Two solutions to this are: Obtain Use
a
faster more
processor CPU's.
Avoid overloading your CPU. Response time on your machine will suffer if it is overloaded. Try to keep the run queue 100% occupied and have less that 6 processes waiting to be run for one CPU. This changes as you add more CPU's or a faster CPU. You may also want to avoid the CPU spending most of its time (more than 50%) in system mode. This may indicate that you are spending too much time in kernel mode servicing interrupts, swapping processes etc. Go top
Disk To list the disks/tapes on the Server To list the tapes on your system $ lsdev -C -c tape Output on AIX rmt0 Available 40-60-00-0,0 SCSI 4mm Tape Drive smc0 Available 21-08-00-5,0 IBM 3581 Tape Medium Changer rmt1 Available 21-08-00-6,0 IBM 3580 Ultrium Tape Drive To list the disks on your system $ lsdev -C -c disk hdisk0 Available 40-60-00-4,0 16 Bit LVD SCSI Disk Drive hdisk1 Available 40-60-00-8,0 16 Bit LVD SCSI Disk Drive hdisk2 Available 11-08-00-0,0 SCSI Disk Array RAID 5 hdisk3 Available 11-08-00-1,0 SCSI Disk Array RAID 5 hdisk4 Available 14-08-L SSA Logical Disk Drive hdisk5 Available 31-08-L SSA Logical Disk Drive hdisk6 Available 31-08-L SSA Logical Disk Drive hdisk7 Available 14-08-L SSA Logical Disk Drive hdisk8 Available 14-08-L SSA Logical Disk Drive Go top
Viewing UNIX volume groups $ lsvg –o -o
Lists only the active volume groups (those that are varied on). An active volume group is one that
is available for use. Output on AIX appvg1 rootvg lsvg –l For details on a specific volumne group, you can use lsvg –l, passing the volume group name as a parameter $ lsvg -l rootvg Output on AIX rootvg: LV NAME hd5 hd6 hd8 hd4 hd2 hd9var hd3 hd1 pridumplv softwarelv scriptslv
TYPE LPs PPs PVs LV STATE MOUNT POINT boot 1 2 2 closed/syncd N/A paging 16 32 2 open/syncd N/A jfslog 1 2 2 open/syncd N/A jfs 5 10 2 open/syncd / jfs 42 84 2 open/syncd /usr jfs 3 6 2 open/syncd /var jfs 36 72 2 open/syncd /tmp jfs 3 6 2 open/syncd /home sysdump 5 5 1 open/syncd N/A jfs 8 8 1 closed/syncd /software jfs 8 8 1 open/syncd /scripts
lsvg –o | xargs lsvg –l The xargs UNIX command is used to pass the complete output of the first command (lsvg –o in this case) one at a time to the lsvg –l command. $ lsvg -o | xargs lsvg -l Output on AIX appvg1: LV NAME orastagelv loglv00 crpr11ilv prdap11i paging00 testbkup rootvg: LV NAME hd5 hd6 hd8 hd4 hd2 hd9var
TYPE LPs PPs PVs LV STATE MOUNT POINT jfs 122 122 1 open/syncd /orastage jfslog 1 1 1 open/syncd N/A jfs 160 160 1 open/syncd /crpr11i jfs 120 120 1 open/syncd /prdap11i paging 20 20 1 open/syncd N/A jfs 120 120 1 closed/syncd /testbkup TYPE LPs PPs PVs LV STATE boot 1 2 2 closed/syncd N/A paging 16 32 2 open/syncd N/A jfslog 1 2 2 open/syncd N/A jfs 5 10 2 open/syncd / jfs 42 84 2 open/syncd /usr jfs 3 6 2 open/syncd /var
MOUNT POINT
hd3 hd1 pridumplv softwarelv scriptslv
jfs jfs
36 72 2 open/syncd /tmp 3 6 2 open/syncd /home sysdump 5 5 1 open/syncd N/A jfs 8 8 1 closed/syncd /software jfs 8 8 1 open/syncd /scripts Go top
Display Unix Mount Points df –k A UNIX mount point is the UNIX location of disk storage. As a Oracle DBA you should know the mapping between your physical disks, logical volumes and mount points. $ df -k Output on AIX Filesystem 1024-blocks Free %Used Iused %Iused Mounted on /dev/hd4 163840 138700 16% 1376 2% / /dev/hd2 1376256 144952 90% 31234 10% /usr /dev/hd9var 98304 89588 9% 457 2% /var /dev/hd3 1179648 968404 18% 468 1% /tmp /dev/hd1 98304 72612 27% 256 2% /home /dev/orastagelv 15990784 3335864 80% 21256 1% /orastage /dev/crpr11ilv 20971520 10737752 49% 85411 2% /crpr11i /dev/scriptslv 262144 105352 60% 90 1% /scripts /dev/prdap11i 15728640 5718636 64% 84626 3% /prdap11i
Show mount points for a Disk $ lspv Output on AIX hdisk0 hdisk1 hdisk2 hdisk3 hdisk4 hdisk5
000780ffaac20aee rootvg 000780ffdb900f40 rootvg 000780ffdde9b3e7 dbvg1 000780dfddf63eb8 appvg1 000780dff8276946 dbvg2 none None
lspv –l <device> You can use the physical volume command lspv to display disk mount points in IBM AIX. $ lspv -l hdisk0 Output on AIX hdisk0: LV NAME hd5 hd6 pridumplv
LPs PPs DISTRIBUTION 1 1 01..00..00..00..00 N/A 16 16 00..16..00..00..00 N/A 5 5 00..05..00..00..00 N/A
MOUNT POINT
scriptslv hd8 hd4 hd2 hd9var hd3 hd1
8 1 5 42 3 36 3
8 1 5 42 3 36 3
00..08..00..00..00 00..00..01..00..00 00..00..05..00..00 00..00..42..00..00 00..00..03..00..00 00..00..36..00..00 00..00..03..00..00
/scripts N/A / /usr /var /tmp /home Go top
Miscellenous To see the Server Configuration $ prtconf Output on AIX System Model: IBM,7026-6H1 Processor Type: PowerPC_RS64-IV Number Of Processors: 4 Memory Size: 6144MB Good Memory Size: 6144MB Firmware Version: IBM,M2P030828_condor_ Console Login: enable Auto Restart: true Full Core: true Network Information Host Name: dbsrv IP Address: 137.40.1.100 Sub Netmask: 255.255.254.0 Gateway: 137.40.1.1 Name Server: 137.40.1.50 Domain Name: asagarwal.com Paging Space Information Total Paging Space: 4096MB Percent Used: 1%
Displaying Server Kernel Values (AIX) $ lsdev –C This command will display all of the attached components including disk, memory, CPUs, buses and other hardware components. Output on AIX sys0 Available 00-00 sysplanar0 Available 00-00
System Object System Planar
pci0 Available 00-fff7f09000 PCI Bus pci1 Available 00-fff7f0a000 PCI Bus pci2 Available 00-fff7f08000 PCI Bus isa0 Available 10-80 ISA Bus sa0 Available 01-S1 Standard I/O Serial Port sa1 Available 01-S2 Standard I/O Serial Port sa2 Available 01-S3 Standard I/O Serial Port sa3 Available 01-S4 Standard I/O Serial Port siokma0 Available 01-K1 Keyboard/Mouse Adapter fda0 Available 01-D1 Standard I/O Diskette Adapter pci3 Available 10-58 PCI Bus scsi0 Available 11-08 Wide/Fast-20 SCSI I/O Controller pci4 Available 10-5a PCI Bus pci5 Available 10-5c PCI Bus pci6 Available 10-5e PCI Bus pci7 Available 20-58 PCI Bus ssa0 Available 21-08 IBM SSA 160 SerialRAID Adapter (14109100) pci8 Available 20-5a PCI Bus mg20 Available 24-08 GXT130P Graphics Adapter pci9 Available 20-5b PCI Bus pci10 Available 20-5c PCI Bus pci11 Available 20-5e PCI Bus ………………. ………………. ………………. Go top
To see the base values for the server in AIX $ lsattr –El sys0 This is useful for displaying UNIX kernel variables that are used by Oracle such as maxuproc and maxbuf Output on AIX keylock normal State of system keylock at boot time False maxbuf 20 Maximum number of pages in block I/O BUFFER CACHE True maxmbuf 0 Maximum Kbytes of real memory allowed for MBUFS True maxuproc 128 Maximum number of PROCESSES allowed per user True autorestart false Automatically REBOOT system after a crash True iostat false Continuously maintain DISK I/O history True realmem 1572864 Amount of usable physical memory in Kbytes False conslogin enable System Console Login False fwversion IBM,M2P011204 Firmware version and revision levels False maxpout 0 HIGH water mark for pending write I/Os per file True minpout 0 LOW water mark for pending write I/Os per file True fullcore false Enable full CORE dump True Go top
Displaying System Log Messages $ errpt –a | more Output on AIX ---------------------------------------------------------LABEL: CORE_DUMP IDENTIFIER: C60BB505 Date/Time: Thu Aug 1 23:40:47 Sequence Number: 13368 Machine Id: 000780DF4C00 Node Id: db11i Class: S Type: PERM Resource Name: SYSPROC Description SOFTWARE PROGRAM ABNORMALLY TERMINATED Probable Causes SOFTWARE PROGRAM User Causes USER GENERATED SIGNAL Recommended Actions CORRECT THEN RETRY Go top
How to Tell if OS is a 32-Bit or 64-Bit AIX lslpp -l bos.64bit Fileset Level State Description ---------------------------------------------------------------------------Path: /usr/lib/objrepos bos.64bit 4.3.3.79 APPLIED Base Operating System 64 bit Runtime Path: /etc/objrepos bos.64bit 4.3.3.79 APPLIED Runtime
Base Operating System 64 bit
You will also need to check if the hardware is 32/64 bit enabled. You can do this by issuing 'bootinfo -y' as the unix root user. # bootinfo -y 64 Example of 32-bit AIX OS lslpp -l bos.64bit
lslpp: Fileset bos.64bit not installed. HP-UX getconf KERNEL_BITS 64 Linux – RedHat # uname -i i386 # uname -i X86_64 Go top
To check the OS Version AIX oslevel –r HP-UX / Linux uname –a
To see the previous logons and logoffs last The last command is generally used to display, in reverse chronological order, all previous logins and logoffs recorded in the /var/adm/wtmp file. oracle oracle oracle ashish root root root ashish ashish root ashish
pts/0 pts/0 pts/0 pts/1 ftp ftp ftp pts/1 pts/0 ftp pts/1
10.81.1.92 10.81.1.92 10.81.1.92 10.81.1.110 137.40.68.207 cch70 10.81.1.110 10.81.1.110 10.81.1.110 10.81.1.110 10.81.1.110
Jun 23 13:43 still logged in. Jun 16 10:37 - 10:51 (00:13) Jun 15 08:34 - 09:09 (00:35) Jun 14 11:24 - 11:24 (00:00) Jun 14 10:53 - 10:54 (00:00) Jun 14 10:33 - 10:35 (00:01) Jun 14 10:29 - 10:30 (00:01) Jun 14 10:24 - 11:24 (01:00) Jun 14 10:24 - 10:24 (00:00) Jun 14 10:21 - 10:23 (00:02) Apr 20 09:57 - 09:57 (00:00)
Some Examples The last command can also be used to determine when the system was last shut down. The syntax of the command follows: # last shutdown If you want to find out when the user root logged on and off from the console, enter the command: # last root console Go top
To see When the Server was started uptime 01:57PM up 2 days, 22:40, 1 user, load average: 1.11, 0.57, 0.40
To shutdown the Server shutdown –Fr This command will shutdown and Fast Restart the Server. At times, it may be necessary to properly close down all the applications and other user processes without issuing a kill command to end the processes. You can achieve this by adding your desired commands and actions to a file named /etc/rc.shutdown. The /etc/rc.shutdown file is checked each time a shutdown command is issued. If the file exists, it will be run; otherwise, the system will perform a regular shutdown depending on the flags that are used to bring the system down. /etc/rc.shutdown must be set as executable before it can called by the /usr/sbin/shutdown script. Go top
To kill all the oracle process from OS ps –ef | grep “ora_” | grep –v grep | awk ‘{print $2}’ | -exec kill –9 {} \ ;
Show number of active Oracle dedicated Connection Users ps –ef | grep $ORACLE_SID | grep –v grep | grep –v ora_ | wc -l Remarks: If you are not using multithreaded server this command will give you an accurate count of the number of Oracle connections on the Unix Server
Killing Stubborn Unix Tasks cat /dev/null > /dev/ttyname kill –9 Remarks: This command is indispensable when killing stubborn UNIX tasks. Go top
vmstat r (run queue)
Pi (page in)
Us (user CPU) Sy (system
the run queue value shows the number of tasks executing and waiting for cpu resources. When this number exceeds the number of CPUs on the server, a CPU bottleneck exists, and some tasks are waiting for execution. a page in operation occurs when the server is experiencing a shortage of RAM memory. While all virtual memory server will page out to the swap disk, page in operations show that the server has exceeded the available RAM storage. Any nonzero value for pi indicates excessive activity as RAM memory contents are read in from the swap disk this is the amount of CPU that is servicing the user tasks this is the percentage of CPU being used to service system tasks.
CPU) Id (idle)
this is the percentage of CPU that is idle this shows the percentage of CPU that is waiting on external operations such as disk I/O
Wa (wait) Output on AIX
kthr memory page faults cpu ----- ----------- ------------------------ ------------ ----------r b avm fre re pi po fr sr cy in sy cs us sy id wa 0 1 286902 1063 0 0 0 32 90 0 146 1059 180 3 1 87 8 0 2 287086 257 0 54 0 0 0 0 400 995 758 11 2 52 35 0 3 287086 137 0 0 0 0 0 0 343 807 240 10 0 66 23 0 2 287086 120 0 0 0 0 0 0 261 854 107 2 0 96 2 0 2 287086 124 0 1 0 1 4 0 223 484 66 1 1 97 2 Go top
sar utility on Unix The sar utility is short for System Activity Reporter. Usage : sar 2 5 sar –b sar –u sar –w sar –d
Monitor Unix buffer Activity Monitor CPU Usage RAM Memory Switching & Swapping Activity Monitor disk usage
# sar -u 5 5 Output on AIX AIX dbsrv 3 4 000106DF4C00 17:05:35 17:05:40 17:05:45 17:05:50 17:05:55 17:06:00
%usr 23 23 22 33 34
Average
27
09/21/02
%sys 22 18 17 35 42
%wio %idle 1 54 0 59 0 60 0 32 0 24
27
0
46
# sar -b 3 5 sar –b command reports buffer activity which equates to disk I/O and is especially helpful if you suspsect that your database is I/O bound. Output on AIX AIX dbsrv 3 4 000106DF4C00
09/21/02
17:06:49 bread/s lread/s %rcache bwrit/s lwrit/s %wcache pread/s pwrit/s 17:06:52 0 0 0 0 0 0 0 0 17:06:55 0 0 0 0 0 0 0 0 17:06:58 0 0 0 0 0 0 0 0
17:07:01 17:07:04
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
Average
0
0
0
0
0
0
0
0
Bread/s Lread/s
Number of Physical Reads from disk per second
# sar -w 3 5 Output on AIX AIX dbsrv 3 4 000106DF4C00
09/21/02
17:07:27 cswch/s 17:07:30 16308 17:07:33 18440 17:07:36 18760 17:07:39 16757 17:07:42 13467 Average
16746
# sar -d 3 5 Output on AIX AIX dbsrv 3 4 000106DF4C00 17:07:57
device
17:08:00
09/21/02
%busy avque 0 0.0 0.0 0 0.0 0 0.0 0 0.0 0
0
0 0 0 0
0 0.0 0.0 0 0.0 0 0.0 0 0.0 0
0
0 0 0 0
0 0.0 0.0 0 0.0 0 0.0 0 0.0 0
0
0 0 0 0
0
0 0 0 0
0 0.0 0.0 0 0.0 0 0.0 0 0.0 0 0 0.0 0.0 0 0.0 0
0
0 0
17:08:03
17:08:06
17:08:09
17:08:12
r+w/s blks/s avwait avserv
0 0 0 0
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0 0 0 0
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0 0 0 0
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0 0 0 0
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0 0
0 0.0 0.0 0.0 0.0 0.0 0.0
0 0 Average 0 0 0 0
0.0 0.0
0 0
0 0.0 0.0 0 0.0 0 0.0 0 0.0 0
0 0 0 0 0 0 0
0.0 0.0
0.0 0.0
0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 Go top
Determining the type of the file file or file * e.g. $file sqlnet.log sqlnet.log: ASCII text
Searching for a particular Text in the directory and sub-directories under that find . -name "*" -exec grep -il <search_string> {} \; | tee
Find all files except owned by a specific user Will list the file names containing the search string. find . ! -user oracle9i -print ‘ ! ‘ negates the expression. The other example will list all the files not owned by user oracle9i.
Find files having some specific permission find . –name *.* -perm 664 -print
Searching for links in all the folders under the directory and output to a text file to create a script to change the links. find . -type l -print -exec ls -trl {} \; | grep -i uat | awk '{ print $11, $9 }' | tee change_link.sh Go top
Taking TAR Backup on Internal (Default) Tape Drive Tested on AIX mt -f /dev/rmt1 rewind cd / tar -cvf /dev/rmt0 ./prodr11i ./prod_dat ./prod_idx ./prod_msc To view the list of files backed up tar –tvf /dev/rmt0
Taking TAR Backup on Disk Tested on SunOS 5.9 tar cpf u01_oradata_absolute.tar /u01/oradata/PRODDB* The tar file u01_oradata_absolute.tar will be created in the present directory. CAUTION: The above command will store the absolute path in the tar file and will restore to the same location while extracting. If you do not want to extract the files to the same location, take the tar backup with relative file name. E.g. cd /u01/ tar cpf /backup/u01_oradata_relative.tar ./oradata/PRODDB* Go top
Extracting file from TAR backup tar xpf u01_oradata_absolute.tar CAUTION: The above command will extract the files to its original location if the files were tarred using the absolute path. E.g. if the TAR file include the file backed up from /vaporub/u04/oradata/, using the absolute path, the extract command will restore the files to /vaporub/u04/oradata/ thereby overwriting the original contents. To check whether the tar backup was taken using the absolute path or relative path using the the following command. Tar backup taken with absolute path tar tvf u01_oradata_absolute.tar -rwxr-x--- 500/501 -rwxr-x--- 500/501 -rw-r----- 500/501 -rwxr-x--- 500/501
0 Jul 4 21:56 2007 /u01/oradata/PRODDB/system.dbf 0 Jul 4 21:58 2007 /u01/oradata/PRODDB/undotbs.dbf 0 Jul 4 21:58 2007 /u01/oradata/PRODDB/users.dbf 0 Jul 4 21:58 2007 /u01/oradata/PRODDB/index.dbf
Tar backup taken with relative path. Notice that the path is starting with dot ( '.' ) tar tvf u01_oradata_relative.tar -rwxr-x--- 500/501 -rwxr-x--- 500/501 -rw-r----- 500/501 -rwxr-x--- 500/501
0 Jul 4 21:56 2007 ./oradata/PRODDB/system.dbf 0 Jul 4 21:58 2007 ./oradata/PRODDB/undotbs.dbf 0 Jul 4 21:58 2007 ./oradata/PRODDB/users.dbf 0 Jul 4 21:58 2007 ./oradata/PRODDB/index.dbf
To extract to a directory other than where the tar file is located, navigate to that directory and then issue the tar xvf command. E.g. cd /restore tar xvf /backup/u01_oradata_relative.tar Go top
Take a compressed tar backup of file or directory /usr/bin/tar cpf - <source_dir> | compress - > <destination_file> e.g. /usr/bin/tar cpf - ./u01/stage/rapidinstall | compress - > /backup/rapidinstall.Z
Copy the file and compress it at the same time cat <source_file> | compress - > <desintation>.Z e.g. cat ./u01/stage/rapidinstall | compress - > /tmp/stage_rapidinstall.Z Go top
Sending Mails from Unix Sending a file as the body of the mail For AIX mail –s “Meeting today at 1100 Hrs” [email protected] < mailmsg.file For HP-UX mailx –s “Meeting today at 1100 Hrs” [email protected] < mailmsg.file The above command will send the contents of the file mailmsg.file to [email protected] with the subject line as “Meeting today at 1100 Hrs”. Sending file as attachment uuencode ashish.test ashish.test | mail [email protected] You can’t specify the subject with mail. Using mailx instead of mail will send the file as body of the mail and not as an attachment. Go top
Installing, upgrading, removing, querying package using rpm in redhat To install a package (i=install v=verbose h=show hash marks) :rpm -ivh <package_name> To uninstall (erase) a package rpm -e <package_name> To upgrade a package rpm -Uvh <package_name> To test a package to see how it would install (without installing, also checks dependencies) rpm -Uvh --test <package_name> To query whether a package has been installed or not rpm -qa | grep <package_name>
To Open or block ports on RedHat Linux /usr/sbin/lokkit Go top
vi editor commands Movement Commands l or SPACEBAR or -> Moves right one character h or CTRL-H or BACKSPACE or <moves left one character j or CTRL-J or CTRL-N or down arrow move down one line k or CTRL-P or up arrow move up one line 0 beginning of line $ End of Line + or Enter Beginning of next line Beg of Previous line w Move to next word or punctuation mark W Move to next word e Move to end of current word or punctuation E Move to end of current word b move back to beginning of word or punct B move back begning of word ) start of next sentence ( start of current sentence } start of next paragraph { start of current paragraph ]] start of next section [[ start of current section CTRL-F Move forward one full screen CTRL-D Move forward one half screen CTRL-B Move back one full screen CTRL-U Move back one half screen G Move to end of file CTRL-F move ahead full screens CTRL-B move back full screens Modifying Text rn rn Rstring ESC
replace current char with ‘n’ replace characters with ‘n’ replaces current characters with ‘string until ESC is pressed
cwstringESC change the current word by replacing. The change continues until ESC is pressed. Vi puts $ over the last character of the work do be changed. c$stringESC cw 3c$ Deleting Text
will change from current cursor position to end of line. will change next words will change next three lines
x x dw dw d$ D d$ d) d} d]] dd dd dENTER dG
deletes current character deletes characgters delete from cursor to end of the word delete words delete to the end of line deletes to end of line (Same as d$) deletes till end of n lines ahead deletes to beg of next line deletes to beg of next paragraph deletes to be of next section deletes current line deletes n lines deletes 2 lines Deletes from Cursor to End of File
Undoing changes and deletions u U p current line) P current line) :e!
undo most recent change or deletion undo all changes made ina line since you last moved to that line put the contents to of the buffer to the right of the cursor (immediately below the put the contents of the buffer to the left of the cursor (immediately above the undo all the changes made since last time you save the file
Searching for text /<string> /ENTER ?<string> n
seach forward for the specified string continue searching search backup for the specified string continue searching in the same direction
Copying and moving text yw yw y$ y) y} y]] yy or Y Y p P
yanks (copies) a word yanks words yanks to the end of line yanks to the end of sentence yanks to the end of paragraph yanks to the end of section yanks the current line yanks lines paste to the right of the cursor paste to the left of the cursor Go top
Home | Profile Snapshot | Services | Training & Workshops | Resources for DBAs | My Blog | Social Responsibility | Contact Me Bookmarks Memory CPU
Disk Miscellenous vi editor