Saturday, January 29, 2011

Restore a file from mksysb tape in AIX

cd /tmp
rmt -f /dev/rmt0 rewind
restore -s4 -xvqf /dev/rmt0.1 ./var/spool/cron/crontabs/sksupp1

the file will be restored in /tmp/var/spool/cron/crontabs/sksupp1

Basic TCP/IP Network Troubleshooting in AIX

Basic TCP/IP Network Troubleshooting
************************************

To see default network interface card:

   netstat -rn |egrep '(Destination|default)'


To troubleshoot name resolution:

   Check the services:

   - DNS (bind)
   - NIS (yp)
   - local (/etc/hosts)

   The above list is the default order, but
   the default can be overridden by
   /etc/irs.conf, which can be overridden by
   /etc/netsvc.conf, which can be overridden
   by the NSORDER environment variable.


To troubleshoot a server that fails to return a ping:

   The server might not be down, but its routing table
   might have errors. Someone must walk up to the
   server, login, and use netstat to determine whether
   the server can see your client's subnet.
 

To troubleshoot network services:

   Check /etc/inetd.conf to determine your service
   is not commented out. Also, try HUP'ing the
   inetd daemon:

   refresh -s inetd



How can I find out what command is respawning too rapidly and filling up my wtmp file?

A common situation is that the init process is repeatedly attempting to start a failing process. The init man page describes what happens when init finds an entry is being respawned:


If the init command finds that it is continuously running an entry in
the /etc/inittab file (more than five times in 225 seconds), it assumes
that an error in the entry command string exists. It then prints an
error message to the console and logs an error in the system error log.
After the message is sent, the entry does not run for 60 seconds. If
the error continues to occur, the command will respawn the entry only
five times every 240 seconds. The init command continues to assume an
error occurred until the command does not respond five times in the
interval, or until it receives a signal from a user. The init command
logs an error for only the first occurrence of the error.


To find out what is being respawned use the steps below.


1. Check the console or console logs
Check on the console to see if init is writing an error message similar to the one below:

0 Thu Jan 22 10:16:27 EST 2009
INIT: Command is respawning too rapidly. Check for possible errors.
id:  xvfb "/usr/bin/X11/X -force -vfb -x abx -x dbe -x GLX :1 &"


Or search through the console log using the alog command:

# alog -t console -o | more


2. Check errpt

Next there may be an entry in the errpt output with the label "INIT_RAPID" like below:

LABEL: INIT_RAPID
IDENTIFIER: 3A30359F

Date/Time:       Wed Jan 28 10:14:17 2009
Sequence Number: 1789
Machine Id:      00CC2F914C00
Node Id:         libgng
Class:           S
Type:            TEMP
Resource Name:   init

Description
SOFTWARE PROGRAM ERROR

Probable Causes
SOFTWARE PROGRAM

User Causes
PERFORMANCE DEGRADED

Recommended Actions
REVIEW DETAILED DATA

Detail Data
SOFTWARE ERROR CODE
Command is respawning too rapidly. Check for possible errors.
COMMAND
id:  xvfb "/usr/bin/X11/X -force -vfb -x abx -x dbe -x GLX :1 &"

Both messages clearly identify the failing command that is being run out of the /etc/inittab file.


3. Check the wtmp file

If the warning messages are not noticed on the system console or in errpt, the next indication of he problem may be that the /var file system is filling up. This is a result of init creating an entry in /var/adm/wtmp file during each attempt to start the problem process. See below for a procedure to format the wtmp file in readable characters for diagnosis.

This technique makes use of the fwtmp utility which is part of the bos.acct fileset.

# lslpp -w /usr/sbin/acct/fwtmp
File                                    Fileset               Type
------------------------------------------------------------------
/usr/sbin/acct/fwtmp                    bos.acct              File


What's In The wtmp File

The actual content of the wtmp is not viewable, as the wtmp entries are written as binary structures (see /usr/include/utmp.h for the format). The fwtmp utility can be used to extract the contents into a human readable format.

For example we redirect the the contents of the /var/adm/wtmp file:

# /usr/sbin/acct/fwtmp < /var/adm/wtmp--> /tmp/wtmp_readable

At quick cat of the /tmp/wtmp_readable file and we find that the
file mainly consists of the following entries:

xvfb   xvfb   5 319596 0000 0000 1078170250    Mon Mar  1 11:44:10 2004
      xvfb   8 319596 0000 0001 1078170250    Mon Mar  1 11:44:10 2004
xvfb   xvfb   5 319598 0000 0000 1078170250    Mon Mar  1 11:44:10 2004
      xvfb   8 319598 0000 0001 1078170250    Mon Mar  1 11:44:10 2004

The first numeric column shows us the ut_type of entry, as defined in the utmp.h header file. The interesting types in our case are:

#define INIT_PROCESS    5    /* Process spawned by "init" */
#define LOGIN_PROCESS   6    /* A "getty" process waiting for login */
#define USER_PROCESS    7    /* A user process */
#define DEAD_PROCESS    8

In this example the "xvfb" entry is being started by init (signified by the "5" in column 3) and in the next line it's dying (ut_type = 8)

A quick check of the inittab file we find our problem:

# grep xvfb /etc/inittab
xvfb:2:respawn:/usr/bin/X11/X -force -vfb -x abx -x dbe -x GLX :1 &

In this case, the xvfb entry was starting an X terminal server daemon.


SOLUTION
The solution would then to resolve the command problem or change the entry in inittab from respawn to off using the chitab utility:

# chitab xvfb:2:off:'/usr/bin/X11/X -force -vfb -x abx -x dbe -x GLX :1 &'

In this specific case the trailing "&" sign was removed from the X Server command and it started up normally

Commands to find memory utilisation of processes in AIX



To find memory usage, try these commands (may vary with version of UNIX):

# svmon -u | more
# svmon -P | more
# ps aux | more
# ipcs -ma | more

Command to find process which uses the most memory in AIX:

# svmon -P -t 1 (aix 4.3.3)
# svmon -Pau 1 (aix 4.3.2)

To find the memory utilisation of a certain proces:

# ps auwww [PID]

PID = process id

Example:

svmon -u ; svmon -P ; ps aux ; ipcs -ma

AIX 5.3 Commit Applied Software Updates failed

AIX 5.3 Commit Applied Software Updates failed
Problem:

Tried to commit applied Software Updates, failed with the following messages.


MISSING REQUISITES: The following filesets are requisites of one or more
of the selected filesets listed above. They are not currently installed
on the system. You should install these requisites to ensure that the
selected filesets function correctly. You MUST install these requisites
before committing the selected filesets.

bos.rte 6.1.0.0 # Base Level Fileset
devices.common.IBM.mpio.rte 5.2.0.50 # MPIO Disk Path Control Module
xlC.aix61.rte 9.0.0.1 # Fileset Update

<<>>

Solution:

Force install fileset devices.common.IBM.mpio.rte. (-F option below)

# installp -a -d . -F devices.common.IBM.mpio.rte

+-----------------------------------------------------------------------------+
Pre-installation Verification...
+-----------------------------------------------------------------------------+
Verifying selections...done
Verifying requisites...done
Results...

SUCCESSES
---------
Filesets listed in this section passed pre-installation verification
and will be installed.

Selected Filesets
-----------------
devices.common.IBM.mpio.rte 5.3.9.1 # MPIO Disk Path Control Module

<<>>

+-----------------------------------------------------------------------------+
BUILDDATE Verification ...
+-----------------------------------------------------------------------------+
Verifying build dates...done
FILESET STATISTICS
------------------
1 Selected to be installed, of which:
1 Passed pre-installation verification
----
1 Total to be installed

0503-409 installp: bosboot verification starting...
installp: bosboot verification completed

+-----------------------------------------------------------------------------+
Installing Software...
+-----------------------------------------------------------------------------+

installp: APPLYING software for:
devices.common.IBM.mpio.rte 5.3.9.1


. . . . . <<>> . . . . . . .
Licensed Materials - Property of IBM

5765G0300
Copyright International Business Machines Corp. 1995, 2008.

All rights reserved.
US Government Users Restricted Rights - Use, duplication or disclosure
restricted by GSA ADP Schedule Contract with IBM Corp.
. . . . . <<>>. . . .


Finished processing all filesets. (Total time: 20 secs).

0503-409 installp: bosboot verification starting...
installp: bosboot verification completed.
0503-408 installp: bosboot process starting...

bosboot: Boot image is 38319 512 byte blocks.
0503-292 This update will not fully take effect until after a
system reboot.

* * * A T T E N T I O N * * *
System boot image has been updated. You should reboot the
system as soon as possible to properly integrate the changes
and to avoid disruption of current functionality.

installp: bosboot process completed.
+-----------------------------------------------------------------------------+
Summaries:

+-----------------------------------------------------------------------------+

Installation Summary
--------------------
Name Level Part Event Result
-------------------------------------------------------------------------------
devices.common.IBM.mpio.rte 5.3.9.1 USR APPLY SUCCESS
devices.common.IBM.mpio.rte 5.3.9.1 ROOT APPLY SUCCESS


Now smit commit works file.

common EFS issues in AIX

Problem: Can't enable EFS on the system

# efsenable -a
/usr/lib/drivers/crypto/clickext: A file or directory in the path name does not exist.
Unable to load CLiC kernel extension. Please check your installation.

Solution:
Install CLiC filesets from AIX Expansion Pack CD

clic.rte
installp -l -d clic.rte
Fileset Name Level I/U Q Content
====================================================================
clic.rte.includes 4.3.0.0 I N usr
# CryptoLite for C Library Include File

clic.rte.kernext 4.3.0.0 I N usr,root
# CryptoLite for C Kernel

clic.rte.lib 4.3.0.0 I N usr
# CryptoLite for C Library


2) Problem: Can't view user's key:

$ efskeymgr -v
Problem initializing EFS framework.
Please check EFS is installed and enabled (see efsenable) on you system.
Error was: (EFS was not configured)

Solution:
Enable EFS on the system:
# efsenable -a
and give root's password when it asks for root's initial keystore.


3) Problem: Can't enable encryption inheritiance on a directory.
# efsmgr -E testdir
or
Can't enable encryption on a specific file
# efsmgr -e myfile

Problem initializing EFS framework.
Please check EFS is installed and enabled on you system.
Error was: (EFS was not configured)

Solution:
Make sure CLiC filesets are installed
Enable EFS on the system
Enable EFS and RBAC on the filesystem:

# chfs -a efs=yes /myfilesystem


4) Problem: Have enabled EFS on a filesystem but get error mounting:

# mount /efstest
The CLiC library (libclic.a) is not available. Install clic.rte and run 'efsenable -a'.

Solution:
Install CLiC filesets
Enable EFS on the system
Remount the filesystem



5) Problem: No encryption algorithms show up!
# efsenable -q
List of supported algorithms for keystores:
1
2
3

List of supported ciphers for files:
1
2
3
4
5
6

Solution:
Install CLiC filesets

# efsenable -q
List of supported algorithms for keystores:
1 RSA_1024
2 RSA_2048
3 RSA_4096

List of supported ciphers for files:
1 AES_128_CBC
2 AES_192_CBC
3 AES_256_CBC
4 AES_128_ECB
5 AES_192_ECB
6 AES_256_ECB

How do you completely remove data from a disk in AIX

To format a disk:


#diag
  --> Task Selection
         --> Format Media  (Select hdisk#)
                  --> Format and Certify Disk
OR

diag -cd hdisk<#> -T "format -s erase -a write -P 20202020,00000000,FFFFFFFF"