Sunday, September 13, 2009

Compress Files

To compress and uncompress the files in unix you can use the following commands.

1. Compress and uncompress
2. gzip and gunzip
3. bzip2 and bunzip2

Compress and uncompress

The output file has the extension as .Z

Example:

$ compress -v test.txt
test.txt: Compression: 59.74% This file is replaced with test.txt.Z

To compress file to another directory
$ compress -c proddmp.dmp > /data_back/proddmp.dmp.Z

$ uncompress test.txt.Z
$

To uncompress to another directory
$ uncompress -c proddmp.dmp.Z > /oradump/proddmp.dmp

gzip and gunzip

The output file has the extension as .gz

Example:

$ gzip test.txt
test.txt.gz

$ gunzip test.txt.gz

note: You can use gzip -d instead of gunzip. Both are same.

To view the compressed text file without decompressing use gzcat or gzmore if available in the platform.

$ gzcat test.txt.gz
$ gzmore test.txt.gz

To compress the folder

$ gzip -r /oracle/test
$ gunzip -r /oracle/test

bzip2 and bunzip2

The output file has the extension .bz2 The usage of bzip2 and bunzip2 is similar to gzip and gunzip.

Thanks

Tuesday, May 19, 2009

svmon

The svmon command captures a snapshot of virtual memory, so it is useful for determining which processes, user programs, and segments are consuming the most real, virtual, and paging space memory.

To display the total real memory pages that are in use and free and the paging space pages that are in use and free.

# svmon -G

To display the processes using the most real memory

# svmon -Pu -t x |grep -p Pid|grep '^.*[0-9]'

where x is the top x no. of processes.

To display the processes using the most paging space

# svmon -gP -t x |grep -p Pid|grep '^.*[0-9]'

In the O/P the pgsp indicates the number of 4kb pages reserved or used in the paging space by this process. Inuse column indicates the total real memory pages used.

To find out the most utilized segments

# svmon –S –t 10

With the -S option, svmon sorts segments by memory usage and displays the
statistics for the top memory-usage segments.

The different segments are

1. Persistent - Used to manipulate JFS files and directories
2. Working - Used to implement data areas of processes and shared memory.
3. Client - Used to implement some virtual file systems such as CD ROM etc.
4. Mapping - Used to implement the mapping of files in memory.
5. Real memory map – Used to access I/O space from virtual address space.

Thanks

lslv, lspv, lsvg

Some important commands

To display all the disks installed on an AIX machine

$ lsdev -Cc disk

To see what volume groups the disks belong to

$ lspv

This lists all the physical disks available on the system with their pvids assigned to it with the Volume Group name associated with this disk. "None" if NOT part of LVM.

To list information about the disks that belongs to the volume group.

$ lsvg -p

To list which logical volumes occupy the volume group

$ lsvg –l

To list all available volume groups

$ lsvg

Logical Volume Commands

To list all logical volumes under a volume group

$ lslv -l

To list the Logical Volume details with partition size , characteristics of volume and mirror copies.

$ lslv

To list the Physical Volume where the LV is located.

$ lslv -l

Note: vgname - volume group name and lv - logical volume

Thanks

iostat (Disk Utilization Report)

iostat (Disk Utilization Report)

To display report for all the disks

$ iostat -d 10 10

To display for only a subset of disks

$ iostat -d hdisk0 hdisk1 hdisk2 10 10

Important column
  • If %tm_act (% of the time the disk was active) is greater than 70, then indicates a IO bottleneck.
  • kb_read indicates the amount of data read from the drive.
  • kb_wrtn indicates the amount of data written to the drive.
  • tps indicates the no. of transfers requested per second to the drive. A transfer is an IO request to that drive.

Thanks

iostat

The iostat tool is used to detect the IO bottleneck.

Syntax

$ iostat [options] [drives] [interval] [count]

where
options - d, s (d - disk utilization report, s - system throughput report)

vmstat

Vmstat reports statistics about processes, Virtual memory, paging activity, faults, CPU activity and disk transfers.

Syntax:

$ vmstat [interval] [count]

Analysing the report
  • The value of r should not be more than the number of CPUs consistently.
  • If the value in b is high and sy is high then there is a possibility of paging or thrashing.
  • A high fr:sr ratio (1-(fr/sr))*100 indicates performance bottleneck.
  • If cy is greater than 0, then there is a severe memory shortage. Increase the RAM.
  • If cs is too high then it indicates a performance problem. Tune time slices with schedo.
  • If us + sy is greater than 80, it is CPU bound.
  • If wa is high when id is not 0, tune I/O.

Thanks

Monday, May 18, 2009

Topas

The topas command is a performance analysis tool. It displays statistics such as CPU use, events and queues, memory, paging, network, disk performance.

$ topas –P –i 60

The o/p displays the top processes with the interval of 60 seconds. Get the process id and find the sessions in oracle.

Thanks

SAR (Context Switch)

To monitor the context switching activity

# sar -wP ALL 10 5

Context switching happens when a multi-process OS suspends running one process or thread and starts another. Context switching occurs during any of the following,
  • A time slice expires.
  • A process exits
  • A process puts itself to sleep or in a stopped state.
  • A real-time priority process becomes ready to run.

Thanks

SAR (Paging)

To monitor paging activity

# sar -r 10 5

The o/p has the following columns

Slots - No. of free pages (4kb pagesize) available. (672979 *4*1024) kb.
Cycle/s- No. of page replacement cycles per second.
Fault/s - No. of page faults per second.
Odio/s - No. of non-paging disk I/O per second.

Thanks

SAR (System Buffer Usage)

To monitor the system's buffer activity (not Oracle's buffer cache).

# sar -b 10 5

It provides the number of transfers per second between system buffers and block devices.

Bread/s, bwrit/s -No. of physical I/O. Gives overall write activity on server.
Lread/s, lwrit/s -No. of reads and writes from and to system’s buffer cache.
Pread/s, pwrit/s -No. of I/O on raw devices.
%rcache, %wcache-Buffer cache hit ratio for read and write requests. (100* (lread –bread)/lread )

Inference
  • %rcache > 90% indicates the potential for bad disk I/O.
  • %wcache < 70% indicates the potential for bad disk I/O.

Thanks

SAR (IO)

To monitor the disk usage

# sar -d 10 5

The o/p has the following columns

%busy- The portion of time the device was busy servicing a transfer request.
avque - The average number of requests in queue.
r+w/s- Number of read and write requests per second.
Kbs/s - The number of Kbytes transferred per second.
avwait- The average time each request waits in the queue before it is serviced.
avserv- The average time taken for servicing a request.

Inference

  • %busy > 50 on a device indicates contention.
  • Avwait should not be greater than avserv
  • A high %busy and high avque indicates a big I/O bottleneck.

Thanks

SAR (Cpu) Individual

To monitor one CPU at a time.

# sar -P 2 10 5

The o/p displays the result for the 3rd CPU, 10 seconds apart, 5 times.

# sar -P 0,3 10 5

The o/p displays the result for the 1st and 4th CPU, 10 seconds apart, 5 times.

# sar -P ALL 10 5

The o/p displays the result for all the CPU, 10 seconds apart, 5 times.

Thanks

SAR (Cpu)

To monitor CPU usage

# sar -u 10 5

The o/p has the following columns.

%usr - Percent of CPU running in user mode (executing user code).
%sys - Percent of CPU running in system mode (executing OS code).
%wio - Percent of CPU running idle with a process waiting for block I/O.
%idle - Percent of CPU that is idle.

Inference
  • A low %idle indicates CPU intensive job.
  • A high %wio indicates a disk contention.
  • A high %sys (>20) indicates a bottleneck. May be due to swapping or paging.
  • A high %usr indicates applications not tuned properly or over utilization of CPU.

Thanks

ps (IO)

To display processes in order of I/O (PGIN)

$ ps avx |head -1 ; ps avx | grep -v PID | sort -rn +4 | head -10

PGIN represents the number of page ins caused by page faults. Because all AIX I/O is classified as page faults, this value represents the measure of all I/O volume.

Thanks

ps (Memory)

To display processes in order of real memory (RSS) use

$ ps avx | head -1 ; ps avx | grep -v PID | sort -rn +6 | head -10

The RSS value is the size of working segment and code segment combined together in memory in 1 KB units.

To display top 10 Memory Consuming Process (SZ)

$ ps -ealf | head -1 ; ps -ealf | sort -rn +9 | head -10

or

$ ps aux | head -1; ps aux | sort -rn +4 | head -10

The SZ represents the virtual size in kilobytes of the data section of the process. This number is equal to the number of working-segment pages of the process that have been touched (that is, the number of paging-space slots that have been allocated)times four. File pages are excluded. If some working-segment pages are currently paged out, this number is larger than the amount of real memory being used.


To display top 10 Memory Consuming Process (%MEM)

$ ps aux | head -1 ; ps aux | sort -rn +3 | head -10

Thanks

Tuesday, May 5, 2009

ps (Cpu)

To display top 10 CPU consuming process

$ ps aux | head -1; ps aux | sort -rn +2 | head -10

To display process in order of CPU time

$ ps avx | head -1 ; ps avx | grep -v PID | sort -rn +3 | head -10

This is the total accumulated CPU time for the life of the process and not the clock time.

To display processes in order of being penalized

$ ps -eakl | head -1 ; ps -eakl | sort -rn +5 | head -10

Penalized process are awarded less CPU time. Use nice to increase the priority.

To display processes in order of priority

$ ps -eakl | sort -n +6 | head -10

The lower value in the PRI column has the high priority.

To display processes in order of nice value

$ ps -eakl | head -1; ps -eakl | sort -rn +7 | head -10

By running the above commands you will get the process ids of the top resource consuming sessions. Use the pids in the following SQL statements to get the session details.

SQL> Select * From v$session s, v$process p
Where s.paddr = p.addr
and p.spid in ('pid', ‘pid’);


Thanks

renice

The renice command is used to change the nice value of one or more processes that are running on a system. The renice command can also change the nice values of a specific process group.

Syntax

# renice [-n Increment] [-g -p -u] ID

Where ID – When p option is used it represents PID. When g option is used it represents process group ID. When u option is used it indicates user id.

To increase the priority of ps command, decrease the nice value

# renice –n -10 –p 52904

To decrease the priority of ps command, increase the nice value

# renice –n 10 –p 52904

Thanks

nice

The nice command enables to adjust the priority of a command.

Syntax

# nice [-increment] command [Arguments]

To increase the priority of ps command, decrease the nice value.

# nice --10 ps

To decrease the priority of ps command, increase the nice value.

# nice -10 ps

Note1: By default a foreground process has a nice value of 20.
Note2: By default a background process has a nice value of 24.
Note3: Non Root users can only degrade the priority of their own commands.

Thanks

mpstat (Solaris)

The mpstat command reports per processor statistics. Each row of the table represents the activity of one processor. Pay close attention to the smtx measurement. Smtx measures the no. of times the CPU failed to obtain a mutex (Mutual Exclusion Lock). Mutex stalls waste CPU time and degrade multiprocessor scaling.

# mpstat

If the smtx value is greater than 200, then the system is heading towards a CPU bottleneck.

Thanks

uptime

The uptime command produces a single line of output that shows the current time, how long the system has been running since it was booted up, how many user sessions are currently open and the load averages.

$ uptime

The load averages are the average numbers of processes (run queue) that were active during the past one, five and fifteen minutes.

Thanks

ipcs

The ipcs command shows the size of each shared memory segment for the SGA. If there is not enough memory for the entire SGA to fit in a contiguous piece of memory, the SGA will be built in non-contiguous memory segments. In the event of an instance crash, there is possibility that the memory will not be released.

# ipcs -b

It is usually preferable to have the entire SGA fit into a single shared memory segment because of the overhead that can be required to track more than one segment and the time required to switch back and forth between those segments.

If the SGA doesn't fit into a single contiguous piece of memory, consider decreasing the size of SGA.

Thanks

Monday, May 4, 2009

Size of Real Memory

To find the amount of RAM in your machine,

AIX

# lsattr -El sys0 -a realmem

Also, the first line of vmstat report shows the no. of CPUs and Memory installed.

Thanks.

Swap Space Usage

To report information on Swap Space usage use the following command,

AIX

$ lsps -a

Solaris

$ swap -l

HP

$ swapinfo -m

Linux

$ swapon -s

Thanks

Followers

Powered By Blogger
 

RAC Database Administration. Copyright 2008 All Rights Reserved Revolution Two Church theme by Brian Gardner Converted into Blogger Template by Bloganol dot com