Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Tuesday, July 2, 2013

Form process is not getting cleared and occupying /tmp space

LSOF:

lsof is a command meaning "list open files", which is used in many Unix-like systems to report a list of all open files and the processes that opened them. This open source utility was developed and supported by Victor A. Abell, the retired Associate Director of the Purdue University Computing Center. It works in and supports several Unix flavors.

Open files in the system include disk files, pipes, network sockets and devices opened by all processes. One use for this command is when a disk cannot be unmounted because (unspecified) files are in use. The listing of open files can be consulted (suitably filtered if necessary) to identify the process that is using the files.


# lsof /var
COMMAND     PID     USER   FD   TYPE DEVICE SIZE/OFF   NODE NAME
syslogd     350     root    5w  VREG  222,5        0 440818 /var/adm/messages
syslogd     350     root    6w  VREG  222,5   339098   6248 /var/log/syslog
cron        353     root  cwd   VDIR  222,5      512 254550 /var -- atjobs


To view the port associated with a daemon:

# lsof -i -n -P | grep sendmail
sendmail  31649    root    4u  IPv4 521738       TCP *:25 (LISTEN)

From the above one can see that "sendmail" is listening on its standard port of "25".
-i Lists IP sockets.
-n Do not resolve hostnames (no DNS).
-P Do not resolve port names (list port number instead of its name).
One can also list Unix Sockets by using lsof -U.

The /tmp directory keeps filling up but the space reported with user space tools ("du" for example) is next to nothing.

According to the standard system tools:


Digging deeper with "lsof" we see the following:


[root@mail tmp]# lsof | grep "/tmp"
bash       1970    root  cwd       DIR        9,3       4096          2 /tmp
screen    13507   jgray    3r     FIFO        9,3                 15747 /tmp/uscreens/S-jgray/13507.pts-0.mail
perl      19932  zimbra    1w      REG        9,3      71523         18 /tmp/logswatch.out (deleted)
perl      19932  zimbra    2w      REG        9,3      71523         18 /tmp/logswatch.out (deleted)
zmlogger  19937  zimbra    1w      REG        9,3      71523         18 /tmp/logswatch.out (deleted)
zmlogger  19937  zimbra    2w      REG        9,3      71523         18 /tmp/logswatch.out (deleted)
zmlogger  19937  zimbra    4w      REG        9,3 1884374605         26 /tmp/zmlogger.out (deleted)
mysqld_sa 21321  zimbra    1w      REG        9,3         70         15 /tmp/zmcontrol.out.20738 (deleted)
mysqld_sa 21321  zimbra    2w      REG        9,3         70         15 /tmp/zmcontrol.out.20738 (deleted)
logswatch 21391  zimbra    1w      REG        9,3         82         19 /tmp/logswatch.out
logswatch 21391  zimbra    2w      REG        9,3         82         19 /tmp/logswatch.out
mysqld    21402  zimbra    5u      REG        9,3          0         20 /tmp/ibD4jO0l (deleted)
mysqld    21402  zimbra    6u      REG        9,3          0         21 /tmp/ibzy1fOB (deleted)
mysqld    21402  zimbra    7u      REG        9,3          0         22 /tmp/ibXukIBR (deleted)
mysqld    21402  zimbra    8u      REG        9,3          0         23 /tmp/ibJj1dq7 (deleted)
mysqld    21402  zimbra   12u      REG        9,3          0         25 /tmp/iblBE0Vn (deleted)
perl      21423  zimbra    1w      REG        9,3         82         19 /tmp/logswatch.out
perl      21423  zimbra    2w      REG        9,3         82         19 /tmp/logswatch.out


Regards,
Jaagadish.

Sunday, November 25, 2012

Ulimit OS Command


The ulimit command sets or reports user process resource limits, as defined in the /etc/security/limits file. This file contains these default limits:
fsize = 2097151
core = 2097151
cpu = -1
data = 262144
rss = 65536
stack = 65536
nofiles = 2000
threads = -1
nproc = -1
These values are used as default settings when a new user is added to the system.Limits are categorized as either soft or hard. With the ulimit command, you can change your soft limits, up to the maximum set by the hard limits. You must have root user authority to change resource hard limits.
Many systems do not contain one or more of these limits. The limit for a specified resource is set when the Limit parameter is specified. The value of the Limit parameter can be a number in the unit specified with each resource, or the value unlimited. To set the specific ulimit to unlimited, use the word unlimited
Note: Setting the default limits in the /etc/security/limits file sets system wide limits, not just limits taken on by a user when that user is created.
The current resource limit is printed when you omit the Limit parameter. The soft limit is printed unless you specify the -H flag. When you specify more than one resource, the limit name and unit is printed before the value. If no option is given, the -f flag is assumed.
Since the ulimit command affects the current shell environment, it is provided as a shell regular built-in command. If this command is called in a separate command execution environment, it does not affect the file size limit of the caller's environment. This would be the case in the following examples:
nohup ulimit -f 10000
env ulimit 10000
Once a hard limit has been decreased by a process, it cannot be increased without root privilege, even to revert to the original limit.
For more information about user and system resource limits, refer to the getrlimit, setrlimit, or vlimit subroutine in AIX® Version 6.1 Technical Reference: Base Operating System and Extensions, Volume 1.

Flags

Item Description
-a Lists all of the current resource limits.
-c Specifies the size of core dumps, in number of 512-byte blocks.
-d Specifies the size of the data area, in number of K bytes.
-f Sets the file size limit in blocks when the Limit parameter is used, or reports the file size limit if no parameter is specified. The -f flag is the default.
-H Specifies that the hard limit for the given resource is set. If you have root user authority, you can increase the hard limit. Anyone can decrease it.
-m Specifies the size of physical memory, in number of K bytes.
-n Specifies the limit on the number of file descriptors a process may have.
-r Specifies the limit on the number of threads a process can have.
-s Specifies the stack size, in number of K bytes.
-S Specifies that the soft limit for the given resource is set. A soft limit can be increased up to the value of the hard limit. If neither the -H nor -S flags are specified, the limit applies to both.
-t Specifies the number of seconds to be used by each process.
-u Specifies the limit on the number of a process a user can create.

Example

ulimit -a     (Lists all of the current resource limits.)
ulimit -n 65536   (Specifies the limit on the number of file descriptors a process may have.)

Tuesday, June 19, 2012

IPCS (Inter-process communication)

Inter-process communication (IPC) is a set of methods for the exchange of data among multiple threads in one or more processes. Processes may be running on one or more computers connected by a network. IPC methods are divided into methods for message passing, synchronization, shared memory, and remote procedure calls (RPC). The method of IPC used may vary based on the bandwidth and latency of communication between the threads, and the type of data being communicated.

This technique allows the processes to communicate with each another.
Since each process has its own address space and unique user space, how does the process communicate each other?
The answer is Kernel, the heart of the Linux operating system that has access to the whole memory. So we can request the kernel to allocate the space which can be used to communicate between processes.

The process can also communicate by having a file accessible to both the processes. Processes can open, and read/write the file, which requires lot of I/O operation that consumes time.

Different Types of IPCS

There are various IPC’s which allows a process to communicate with another processes, either in the same computer or different computer in the same network.
  • Pipes – Provides a way for processes to communicate with each another by exchanging messages. Named pipes provide a way for processes running on different computer systems to communicate over the network.
  • Shared Memory – Processes can exchange values in the shared memory. One process will create a portion of memory which other process can access.
  • Message Queue – It is a structured and ordered list of memory segments where processes store or retrieve data.
  • Semaphores – Provides a synchronizing mechanism for processes that are accessing the same resource. No data is passed with a semaphore; it simply coordinates access to shared resources.

10 IPCS Command Example

ipcs is a UNIX / Linux command, which is used to list the information about the inter-process communication ipcs command provides a report on System V IPCS (Message queue, Semaphore, and Shared memory).

IPCS Example 1: List all the IPC facility

ipcs command with -a option lists all the IPC facilities which has read access for the current process. It provides details about message queue, semaphore and shared memory.

# ipcs -a

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status
0xc616cc44 1056800768 oracle    660        4096       0
0x0103f577 323158020  root      664        966        1
0x0000270f 325713925  root      666        1          2

------ Semaphore Arrays --------
key        semid      owner      perms      nsems
0x0103eefd 0          root      664        1
0x0103eefe 32769      root      664        1
0x4b0d4514 1094844418 oracle    660        204

------ Message Queues --------
key        msqid      owner      perms      used-bytes   messages
0x000005a4 32768      root       644        0            0
All the IPC facility has unique key and identifier, which is used to identify an IPC facility.

IPCS Example 2: List all the Message Queue

ipcs with option -q, lists only message queues for which the current process has read access.
$ ipcs -q

------ Message Queues --------
key        msqid      owner      perms      used-bytes   messages
0x000005a4 32768      root       644        0            0

IPCS Example 3. List all the Semaphores

ipcs -s option is used to list the accessible semaphores.
# ipcs -s

------ Semaphore Arrays --------
key        semid      owner      perms      nsems
0x0103eefd 0          root      664        1
0x0103eefe 32769      root      664        1
0x4b0d4514 1094844418 oracle    660        204

IPCS Example 4. List all the Shared Memory

ipcs -m option with ipcs command lists the shared memories.
# ipcs -m

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status
0xc616cc44 1056800768 oracle    660        4096       0
0x0103f577 323158020  root      664        966        1
0x0000270f 325713925  root      666        1          2

IPCS Example 5. Detailed information about an IPC facility

ipcs -i option provides detailed information about an ipc facility.
# ipcs -q -i 32768

Message Queue msqid=32768
uid=0   gid=0   cuid=0  cgid=0  mode=0644
cbytes=0        qbytes=65536    qnum=0  lspid=0 lrpid=0
send_time=Not set
rcv_time=Not set
change_time=Thu Aug  5 13:30:22 2010
Option -i with -q provides information about a particular message queue. Option -i with -s provides semaphore details. Option -i with -m provides details about a shared memory.

IPCS Example 6. Lists the Limits for IPC facility

ipcs -l option gives the system limits for each ipc facility.
# ipcs -m -l

------ Shared Memory Limits --------
max number of segments = 4096
max seg size (kbytes) = 67108864
max total shared memory (kbytes) = 17179869184
min seg size (bytes) = 1
The above command gives the limits for shared memory. -l can be combined with -q and -s to view the limits for message queue and semaphores respectively.
Single option -l gives the limits for all three IPC facilities.
# ipcs -l

IPCS Example 7. List Creator and Owner Details for IPC Facility

ipcs -c option lists creator userid and groupid and owner userid and group id. This option can be combined with -m, -s and -q to view the creator details for specific IPC facility.
# ipcs -m -c

------ Shared Memory Segment Creators/Owners --------
shmid      perms      cuid       cgid       uid        gid
1056800768 660        oracle     oinstall   oracle     oinstall
323158020  664        root       root       root       root
325713925  666        root       root       root       root

IPCS Example 8. Process ids that accessed IPC facility recently

ipcs -p option displays creator id, and process id which accessed the corresponding ipc facility very recently.
# ipcs -m -p

------ Shared Memory Creator/Last-op --------
shmid      owner      cpid       lpid
1056800768 oracle     16764      5389
323158020  root       2354       2354
325713925  root       20666      20668
-p also can be combined with -m,-s or -q.

IPCS Example 9. Last Accessed Time

ipcs -t option displays last operation time in each ipc facility. This option can also be combined with -m, -s or -q to print for specific type of ipc facility. For message queue, -t option displays last sent and receive time, for shared memory it displays last attached (portion of memory) and detached timestamp and for semaphore it displays last operation and changed time details.
# ipcs -s -t

------ Semaphore Operation/Change Times --------
semid    owner      last-op                    last-changed
0        root        Thu Aug  5 12:46:52 2010   Tue Jul 13 10:39:41 2010
32769    root        Thu Aug  5 11:59:10 2010   Tue Jul 13 10:39:41 2010
1094844418 oracle      Thu Aug  5 13:52:59 2010   Thu Aug  5 13:52:59 2010

IPCS Example 10. Status of current usage

ipcs with -u command displays current usage for all the IPC facility. This option can be combined with a specific option to display the status for a particular IPC facility.
# ipcs -u

------ Shared Memory Status --------
segments allocated 30
pages allocated 102
pages resident  77
pages swapped   0
Swap performance: 0 attempts     0 successes

------ Semaphore Status --------
used arrays = 49
allocated semaphores = 252

------ Messages: Status --------
allocated queues = 1
used headers = 0
used space = 0 bytes

Thursday, April 26, 2012

iostat statistics Monitoring tool

Name

iostat - Report Central Processing Unit (CPU) statistics and input/output statistics for devices, partitions and network filesystems (NFS).

Synopsis

iostat [ -c ] [ -d ] [ -N ] [ -n ] [ -h ] [ -k | -m ] [ -t ] [ -V ] [ -x ] [ -z ] [ device [...] | ALL ] [ -p [ device [,...] | ALL ] ] [ interval [ count ] ]

Description


The iostat command is used for monitoring system input/output device loading by observing the time the devices are active in relation to their average transfer rates. The iostat command generates reports that can be used to change system configuration to better balance the input/output load between physical disks.
The first report generated by the iostat command provides statistics concerning the time since the system was booted. Each subsequent report covers the time since the previous report. All statistics are reported each time the iostat command is run. The report consists of a CPU header row followed by a row of CPU statistics. On multiprocessor systems, CPU statistics are calculated system-wide as averages among all processors. A device header row is displayed followed by a line of statistics for each device that is configured. When option -n is used, an NFS header row is displayed followed by a line of statistics for each network filesystem that is mounted.
The interval parameter specifies the amount of time in seconds between each report. The first report contains statistics for the time since system startup (boot). Each subsequent report contains statistics collected during the interval since the previous report. The count parameter can be specified in conjunction with the interval parameter. If the count parameter is specified, the value of count determines the number of reports generated at interval seconds apart. If the interval parameter is specified without the count parameter, the iostat command generates reports continuously.

Reports

The iostat command generates three types of reports, the CPU Utilization report, the Device Utilization report and the Network Filesystem report.
CPU Utilization Report
The first report generated by the iostat command is the CPU Utilization Report. For multiprocessor systems, the CPU values are global averages among all processors. The report has the following format: %user
Show the percentage of CPU utilization that occurred while executing at the user level (application).
%nice
Show the percentage of CPU utilization that occurred while executing at the user level with nice priority.
%system
Show the percentage of CPU utilization that occurred while executing at the system level (kernel).
%iowait
Show the percentage of time that the CPU or CPUs were idle during which the system had an outstanding disk I/O request.
%steal
Show the percentage of time spent in involuntary wait by the virtual CPU or CPUs while the hypervisor was servicing another virtual processor.
%idle
Show the percentage of time that the CPU or CPUs were idle and the system did not have an outstanding disk I/O request.
Device Utilization Report
The second report generated by the iostat command is the Device Utilization Report. The device report provides statistics on a per physical device or partition basis. Block devices for which statistics are to be displayed may be entered on the command line. Partitions may also be entered on the command line providing that option -x is not used. If no device nor partition is entered, then statistics are displayed for every device used by the system, and providing that the kernel maintains statistics for it. If the ALL keyword is given on the command line, then statistics are displayed for every device defined by the system, including those that have never been used. The report may show the following fields, depending on the flags used: Device:
This column gives the device (or partition) name, which is displayed as hdiskn with 2.2 kernels, for the nth device. It is displayed as devm-n with 2.4 kernels, where m is the major number of the device, and n a distinctive number. With newer kernels, the device name as listed in the /dev directory is displayed.
tps
Indicate the number of transfers per second that were issued to the device. A transfer is an I/O request to the device. Multiple logical requests can be combined into a single I/O request to the device. A transfer is of indeterminate size.
Blk_read/s
Indicate the amount of data read from the device expressed in a number of blocks per second. Blocks are equivalent to sectors with kernels 2.4 and later and therefore have a size of 512 bytes. With older kernels, a block is of indeterminate size.
Blk_wrtn/s
Indicate the amount of data written to the device expressed in a number of blocks per second.
Blk_read
The total number of blocks read.
Blk_wrtn
The total number of blocks written.
kB_read/s
Indicate the amount of data read from the device expressed in kilobytes per second.
kB_wrtn/s
Indicate the amount of data written to the device expressed in kilobytes per second.
kB_read
The total number of kilobytes read.
kB_wrtn
The total number of kilobytes written.
MB_read/s
Indicate the amount of data read from the device expressed in megabytes per second.
MB_wrtn/s
Indicate the amount of data written to the device expressed in megabytes per second.
MB_read
The total number of megabytes read.
MB_wrtn
The total number of megabytes written.
rrqm/s
The number of read requests merged per second that were queued to the device.
wrqm/s
The number of write requests merged per second that were queued to the device.
r/s
The number of read requests that were issued to the device per second.
w/s
The number of write requests that were issued to the device per second.
rsec/s
The number of sectors read from the device per second.
wsec/s
The number of sectors written to the device per second.
rkB/s
The number of kilobytes read from the device per second.
wkB/s
The number of kilobytes written to the device per second.
rMB/s
The number of megabytes read from the device per second.
wMB/s
The number of megabytes written to the device per second.
avgrq-sz
The average size (in sectors) of the requests that were issued to the device.
avgqu-sz
The average queue length of the requests that were issued to the device.
await
The average time (in milliseconds) for I/O requests issued to the device to be served. This includes the time spent by the requests in queue and the time spent servicing them.
svctm
The average service time (in milliseconds) for I/O requests that were issued to the device. Warning! Do not trust this field any more. This field will be removed in a future sysstat version.
%util
Percentage of CPU time during which I/O requests were issued to the device (bandwidth utilization for the device). Device saturation occurs when this value is close to 100%.
Network Filesystem report
The Network Filesystem (NFS) report provides statistics for each mounted network filesystem. The report shows the following fields: Filesystem:
This columns shows the hostname of the NFS server followed by a colon and by the directory name where the network filesystem is mounted.
rBlk_nor/s
Indicate the number of blocks read by applications via the read(2) system call interface. A block has a size of 512 bytes.
wBlk_nor/s
Indicate the number of blocks written by applications via the write(2) system call interface.
rBlk_dir/s
Indicate the number of blocks read from files opened with the O_DIRECT flag.
wBlk_dir/s
Indicate the number of blocks written to files opened with the O_DIRECT flag.
rBlk_svr/s
Indicate the number of blocks read from the server by the NFS client via an NFS READ request.
wBlk_svr/s
Indicate the number of blocks written to the server by the NFS client via an NFS WRITE request.
rkB_nor/s
Indicate the number of kilobytes read by applications via the read(2) system call interface.
wkB_nor/s
Indicate the number of kilobytes written by applications via the write(2) system call interface.
rkB_dir/s
Indicate the number of kilobytes read from files opened with the O_DIRECT flag.
wkB_dir/s
Indicate the number of kilobytes written to files opened with the O_DIRECT flag.
rkB_svr/s
Indicate the number of kilobytes read from the server by the NFS client via an NFS READ request.
wkB_svr/s
Indicate the number of kilobytes written to the server by the NFS client via an NFS WRITE request.
rMB_nor/s
Indicate the number of megabytes read by applications via the read(2) system call interface.
wMB_nor/s
Indicate the number of megabytes written by applications via the write(2) system call interface.
rMB_dir/s
Indicate the number of megabytes read from files opened with the O_DIRECT flag.
wMB_dir/s
Indicate the number of megabytes written to files opened with the O_DIRECT flag.
rMB_svr/s
Indicate the number of megabytes read from the server by the NFS client via an NFS READ request.
wMB_svr/s
Indicate the number of megabytes written to the server by the NFS client via an NFS WRITE request.
ops/s
Indicate the number of operations that were issued to the filesystem per second.
rops/s
Indicate the number of 'read' operations that were issued to the filesystem per second.
wops/s
Indicate the number of 'write' operations that were issued to the filesystem per second.

Options

-c
Display the CPU utilization report.
-d
Display the device utilization report.
-h
Make the NFS report displayed by option -n easier to read by a human.
-k
Display statistics in kilobytes per second instead of blocks per second. Data displayed are valid only with kernels 2.4 and later.
-m
Display statistics in megabytes per second instead of blocks or kilobytes per second. Data displayed are valid only with kernels 2.4 and later.
-N
Display the registered device mapper names for any device mapper devices. Useful for viewing LVM2 statistics.
-n
Display the network filesystem (NFS) report. This option works only with kernel 2.6.17 and later.
-p [ { device [,...] | ALL } ]
The -p option displays statistics for block devices and all their partitions that are used by the system. If a device name is entered on the command line, then statistics for it and all its partitions are displayed. Last, the ALL keyword indicates that statistics have to be displayed for all the block devices and partitions defined by the system, including those that have never been used. Note that this option works only with post 2.5 kernels.
-t
Print the time for each report displayed. The timestamp format may depend on the value of the S_TIME_FORMAT environment variable (see below).
-V
Print version number then exit.
-x
Display extended statistics. This option works with post 2.5 kernels since it needs /proc/diskstats file or a mounted sysfs to get the statistics. This option may also work with older kernels (e.g. 2.4) only if extended statistics are available in /proc/partitions (the kernel needs to be patched for that).
-z
Tell iostat to omit output for any devices for which there was no activity during the sample period.

Environment

The iostat command takes into account the following environment variable:
S_TIME_FORMAT
If this variable exists and its value is ISO then the current locale will be ignored when printing the date in the report header. The iostat command will use the ISO 8601 format (YYYY-MM-DD) instead. The timestamp displayed with option -t will also be compliant with ISO 8601 format.

Examples

iostat
Display a single history since boot report for all CPU and Devices.
iostat -d 2
Display a continuous device report at two second intervals.
iostat -d 2 6
Display six reports at two second intervals for all devices.
iostat -x hda hdb 2 6
Display six reports of extended statistics at two second intervals for devices hda and hdb.
iostat -p sda 2 6
Display six reports at two second intervals for device sda and all its partitions (sda1, etc.)

Bugs

/proc filesystem must be mounted for iostat to work.
Extended statistics are available only with post 2.5 kernels.
The average service time (svctm field) value is meaningless, as I/O statistics are calculated at block level, and we don't know when the disk driver starts to process a request. For this reason, this field will be removed in a future sysstat version.

Files

/proc/stat contains system statistics.
/proc/uptime contains system uptime.
/proc/partitions contains disk statistics (for pre 2.5 kernels that have been patched).
/proc/diskstats contains disks statistics (for post 2.5 kernels).
/sys contains statistics for block devices (post 2.5 kernels).
/proc/self/mountstats contains statistics for network filesystems.

Saturday, January 22, 2011

Miscellaneous - Useful UNIX



  • Find/Zip/Move/Delete files older than x days


  • Delete the 500 oldest files


  • Find and grep


  • list all files opened by a process


  • ls -l sorted by size


  • cpio unzip syntax


  • man commands


  • pipes


  • Turn off auto indent and bracket matching in vi


  • Capture a control charater


  • Configure ksh environment


  • Show routing tables


  • Check all logs for ORA- errors

  • Find/Zip/Move/Delete files older than x days

    find ./ -name "*.ARC" -mtime +1 -exec ls -l {} \;
    
    find ./ -name "*.ARC" -mtime +1 -exec rm {} \;
    find ./ -name "*.ARC" -mtime +1 -exec gzip {} \;
    find ./ -name "*.arch" -mtime +1 -exec mv {} /u01/andy/;
    

    Delete the 500 oldest files

    rm -f `ls -tr|head -500`
    

    Find and grep

    find ./ -grep <what> {} \; -print 2>/dev/null
    
    Or...
    find ./ -exec grep -l "string" {} \;


    list all files opened by a process

    lsof -p <pid>

    ls -l sorted by size

    ls -l |sort -k 5
    

    du -sk *|sort -n

    cpio unzip syntax

    cpio -idmv < <filename>
    

    man commands

    man -k <what> -displays the chapters containing the specified
    man <chapter> <what> -shows the page
    

    pipes

    mknod <name> p
    


    Turn off auto indent and bracket matching in vi

    :set noai nosm
    


    Capture a control charater
    ctl-v then press the control key (eg. backspace)

    Configure ksh environment
    To display the current settings
    set -o
    


    To set HP/UX stylee...
    set -o vi
    set -o vi-esccomplete
    

    Show routing tables

    netstat -r


    Check all logs for ORA- errors

    grep ^ORA- *log |cut -f2 -d"-"|cut -f1 -d:|awk '{print "ORA-" $1}'|sort -u
    

    Saturday, September 18, 2010

    About Kernel Parameters

    Edit /etc/sysctl.conf to edit the kernel parameters required for Applications
    vi /etc/sysctl.conf
    # semaphores in kernel.sem: semmsl semmns semopm semmni
    kernel.sem = 256 32000 100 142
    kernel.shmmax = 2288490188
    kernel.shmmni = 4096
    kernel.shmall = 3279547
    fs.file-max = 327679
    net.ipv4.ip_local_port_range = 1024 65000
    kernel.msgmax = 8192
    kernel.msgmni = 2878
    kernel.msgmnb = 65535
    net.core.rmem_default = 262144
    net.core.rmem_max = 262144
    net.core.wmem_default = 262144
    net.core.wmem_max = 262144
    SHMMAX
    The SHMMAX parameter is used to define the maximum size (in bytes) for a
    shared memory segment and should be set large enough for the largest SGA size.
    If the SHMMAX is set incorrectly (too low), it is possible that the Oracle SGA
    (which is held in shared segments) may be limited in size. An inadequate
    SHMMAX setting would result in the following:
    ORA-27123: unable to attach to shared memory segment
    You can determine the value of SHMMAX by performing the following:
    # cat /proc/sys/kernel/shmmax
    33554432
    As you can see from the output above, the default value for SHMMAX is 32MB.
    This is often too small to configure the Oracle SGA. I generally set the SHMMAX
    parameter to 2GB.
    NOTE: With a 32-bit Linux operating system, the default maximum size of the SGA is 1.7GB.
    This is the reason I often set the SHMMAX parameter to 2GB since it requires a larger value for SHMMAX.
    On a 32-bit Linux operating system, without Physical Address Extension (PAE), the physical
    memory is divided into a 3GB user space and a 1GB kernel space. It is therefore possible to
    create a 2.7GB SGA, but you will need make several changes at the Linux operating system
    level by changing the mapped base. In the case of a 2.7GB SGA, you would want to set the
    SHMMAX parameter to 3GB.
    This is method I use most often.
    This method sets the SHMMAX on startup by inserting the
    following kernel parameter in the /etc/sysctl.conf startup file:
    # echo “kernel.shmmax=2147483648″ >> /etc/sysctl.conf
    •If you wanted to dynamically alter the value of SHMMAX without rebooting the machine, you
    can make this change directly to the /proc file system. This command can be made
    permanent by putting it into the /etc/rc.local startup file:
    # echo “2147483648″ > /proc/sys/kernel/shmmax
    •You can also use the sysctl command to change the value of SHMMAX:
    # sysctl -w kernel.shmmax=2147483648
    SHMMNI
    We now look at the SHMMNI parameters. This kernel parameter is used to set the
    maximum number of shared memory segments system wide. The default value for
    this parameter is 4096. This value is sufficient and typically does not need to be
    changed.
    You can determine the value of SHMMNI by performing the following:
    # cat /proc/sys/kernel/shmmni
    4096
    SHMALL
    Finally, we look at the SHMALL shared memory kernel parameter. This parameter
    controls the total amount of shared memory (in pages) that can be used at one
    time on the system. In short, the value of this parameter should always be at least:
    ceil(SHMMAX/PAGE_SIZE)
    The default size of SHMALL is 2097152 and can be queried using the following
    command:
    # cat /proc/sys/kernel/shmall
    2097152
    From the above output, the total amount of shared memory (in bytes) that can be
    used at one time on the system is:
    SM = (SHMALL * PAGE_SIZE)
    = 2097152 * 4096
    = 8,589,934,592 bytes
    The default setting for SHMALL should be adequate for our Oracle installation.
    NOTE: The page size in Red Hat Linux on the i386 platform is 4096 bytes. You can, however,
    use
    bigpages which supports the configuration of larger memory page sizes.
    fs.file-max
    ——————
    When configuring our Linux database server, it is critical to ensure that the maximum number
    of file handles is large enough. The setting for file handles designate the number of open files
    that you can have on the entire Linux system.
    Use the following command to determine the maximum number of file handles for the entire
    system:
    # cat /proc/sys/fs/file-max
    103062
    Oracle recommends that the file handles for the entire system be set to at least 65536. In
    most cases, the default for Red Hat Linux is 103062
    This is method I use most often. This method sets the maximum number of file handles
    (using the kernel parameter file-max) on startup by inserting the following kernel parameter in
    the /etc/sysctl.conf startup file:
    # echo “fs.file-max=65536″ >> /etc/sysctl.conf
    •If you wanted to dynamically alter the value of all semaphore kernel parameters without
    rebooting the machine, you can make this change directly to the /proc file system. This
    command can be made permanent by putting it into the /etc/rc.local startup file:
    # echo “65536″ > /proc/sys/fs/file-max
    NOTE: It is also possible to query the current usage of file handles using the following
    command:
    # cat /proc/sys/fs/file-nr
    1140 0 103062
    In the above example output, here is an explanation of the three values from the file-nr
    command:
    •Total number of allocated file handles.
    •Total number of file handles currently being used.
    •Maximum number of file handles that can be allocated. This is essentially the value of filemax
    - (see above).
    NOTE: If you need to increase the value in /proc/sys/fs/file-max, then make sure that the
    ulimit is set properly. Usually for 2.4.20 it is set to unlimited. Verify the ulimit setting my
    issuing the ulimit command:
    # ulimit
    unlimited
    net.ipv4.ip_local_port_range
    ————————————–
    The /proc/sys/net/ipv4/ip_local_port_range defines the local port range that is used by TCP
    and UDP traffic to choose the local port. You will see in the parameters of this file two
    numbers: The first number is the first local port allowed for TCP and UDP traffic on the server,
    the second is the last local port number. For high-usage systems you may change its default
    parameters to 32768-61000 -first-last.
    The default setup for the ip_local_port_range parameters under Red Hat Linux is: “1024
    4999″
    To change the values of ip_local_port_range, type the following command on your terminal:
    [root@deep] /# echo “32768 61000″ >/proc/sys/net/ipv4/ip_local_port_range
    You must restart your network for the change to take effect.
    [root@deep] /# /etc/rc.d/init.d/network restart
    kernel.msgmni
    ——————–
    msg queues I use message queue’s to pass messages around. I use the same queue to
    send and receive messages. This is actually very bad (now that I think about it), cause you
    might fill up the queue, and cause a deadlock (hmm, that appears to be happening!). anyway
    to increase the sizes put bigger sizes into
    /proc/sys/kernel/msgmax
    The max number of bytes per message (redhat 7.2 default = 8192)
    /proc/sys/kernel/msgmnb
    The total size of the queue. (redhat 7.2 default = 16384)
    /proc/sys/kernel/msgmni
    Number of messages. (redhat 7.2 default = 16)
    Basically these low numbers make message queues pretty useless in a high traffic
    application. Probably you can just up these numbers to be pretty large
    msgmax: ( default 2048 )
    The parameter “msgmax” is the maximum number of bytes that can be in
    any one message. msgsnd() will give the error EINVAL if a message is
    longer than this.
    msgmnb: ( default 4096 )
    The parameter “msgmnb” is the maximum number of message bytes that
    can be on any one queue at a given time. If a message would cause a
    queue to grow larger than this, that msgsnd() would either block
    until space was available, or would give the error EAGAIN if user
    specified non-blocking mode. For obvious reasons “msgmnb” must be at
    least as large as “msgmax”, however, it is probably good to set it to
    some integral number of “msgmax.” This way, a few messages of the
    maximum size could be queued at any time. However, making “msgmnb”
    too large compared to the total bytes available for messages (see
    below) may allow one queue to hog the message system.
    msgmni: ( default 50 )
    The parameter “msgmni” is the number of message queue ids available
    to the system. Each message queue requires one id. msgget() gives
    the error ENOSPC if all the ids have been used up.

    Saturday, September 11, 2010

    To Recover Root Password

    I am trying  to cover   the password file information and root password recovery . It is not the task of DBA but sometimes the knowledge of Unix administration task help us to do the activities in effective manner .
    Password file information of root :-
    Operating system Sun Solaris :-  /etc/passwd and /etc/shadow
    Operating system AIX :- /etc/passwd and /etc/passwd/security
    Operating System Linux :- /etc/passwd and /etc/shadow
    Operating System HP-UX :- /etc/passwd and /tcb/files/auth/r/root
    Being a DBA we need to have good idea about unix important files .
    Sun Solaris :-
    boot cdrom -s
    mkdir /tmp/a
    mount the cd using mount /dev/<Device>    /tmp/a
    vi /tmp/a/etc/shadow
    AIX
    boot from cdrom or tape installation/Mantienance
    start limited shell
    getrootfs hd1sk0
    vi /etc/security/passwd
    Linux
    If it LILO (Linux  Loader) its a bootstrap program  then we have  the follow the below steps :-
    lilo
    Control -x
    linux  s
    passwd root
    If it GRUB (Grans Unified Bootloader) then
    grub
    c
    kernel vmlinuz-2.4.9-13 single  ro root=/dev/hda8 initrd  /initrd-2.4.9-13.img boot
    passwd root
    HP-UX
    boot interact with ipl ? Y
    isl->hpux- iS
    passwd root
    Out of all the  above opertaing system steps , i personally tried  Linux (LILO) and it worked

    Red Hat Enterprise Linux Version history

    The various Red Hat Linux versions have little different Errata Support Policies
    • Red Hat Linux 6.2E (Zoot), 27 March 2000
    • Red Hat Enterprise Linux 2.1 AS (Pensacola), 2002-03-26[8]
    • Red Hat Enterprise Linux 2.1 ES (Panama), May 2003
    • Red Hat Enterprise Linux 3 (Taroon), 22 October 2003. Uses Linux 2.4.21 (Release notes also for updates)
      • Update 1, 2004-01-16
      • Update 2, 2004-05-18
      • Update 3, 2004-09-03
      • Update 4, 2004-12-21
      • Update 5, 2005-05-20
      • Update 6, 2005-09-28
      • Update 7, 2006-03-15
      • Update 8, 2006-07-20
      • Update 9, 2007-06-15
    • Red Hat Enterprise Linux 4 (Nahant), 2005-02-15. Uses Linux 2.6.9
    • Red Hat Enterprise Linux 5 (Tikanga), 2007-03-14. Uses Linux 2.6.18 (Release notes)