Thursday, 24 October 2013

All-IN-ONE: Linux User Administration

Linux User Administration:


As a Linux Administrator its very important job to monitor and administering users on Linux server.Security plays vital role in any organization , so user administration is very critical."The similarities of sysadmins and drug dealers: both measure stuff in Ks, and both have users." (Old, tired computer joke.)

Going forward i am  going to explain different types user accounts,how to create new user accounts, how to modify the properties of those accounts, and how to remove the accounts.There are some differences in-terms of commands used in different Linux flavors but these commands will work mostly.

What is shell account ?

A Shell account is just like a bank account  which is created on Linux  server,which gives access to a shell via a command line  interface protocol such as telnet or ssh.There is more than to user account than just a name.An account is all the files, resources, and information belonging to one user.

Before moving to learn about types of shell accounts we need to know few terms .

Whenever you are trying to add a shell account (user) you add an entry to "/etc/passwd" file.This is an essential file  used during the login. This file consists of seven colon-separated fields(:), specified all on one line.

Eg:
surya:x:501:105:Surya_Unix_Admin:/home/surya:/bin/bash
ram:!:202:100:Ram_App_User:/home/ram:/bin/bash


The fields are: user login name(shell account), password, UID, GID, comment (gecos) field, user's home directory & user's default shell

1)  Username: It is used when user logs in. It should be between 1 and 32 characters in  length.Each name  must be unique

2)  Password: An 'x' character indicates that encrypted password is stored in /etc/shadow file.

3)  User ID (UID): Each user must be assigned a user ID (UID). UID 0 (zero) is reserved for root and UIDs. 1-99 are reserved for other predefined accounts. Further UID 100-999 are reserved by system for  administrative and system accounts/groups.
   
4)  Group ID (GID): The primary group ID (stored in /etc/group file)

5)  User ID Info(Gecos): The comment field. It allow you to add extra information about the users   such as  user's  full name, phone number etc. This  field use by finger command.
   
6)  Home directory: The absolute path to the directory the user will be in when they log in. If this directory does not exists then users directory  becomes /.
   
7) Command/shell: The absolute path of a command or shell (/bin/bash). Typically, this is a shell. Please   note that it does not have to be a shell.

Note: Your encrypted password is not stored in /etc/passwd file. It is stored in /etc/shadow file.

Type of Linux user accounts:


There are three basic types of user accounts.

1) Administrative (root) Account

2) Regular Account

3) Service Account

Administrative Account:  

Its root ,we often see people calling it as "super user" which is created automatically  when you install Linux operating system.

A special kind of user account which holds all kind’s of permissions to do any alteration to a programs or services of Linux. Especially this kind of  user account is used for  system administration. He can control and limit the access of other User’s. As  all the powers is vested for Root User, care has to be taken before performing each and every modifications, if anything goes wrong, no option left other than crash of  Kernel. It is so sensitive with unlimited accessibility.Take care while logged in as Root :-).

Regular Account: 

Regular user accounts have privileges to perform standard tasks on a Linux computer such as running word processors, databases, and Web browsers.They can store files in their own home directories. Since regular users do not normally have administrative privileges, they cannot accidentally delete critical operating system configuration files.

Service Account:

Services such as Apache, Squid, mail, games, and printing have their own individual service accounts. These accounts exist to allow each of these services to interact with your computer.


Exploring UID:

Every Users got their own identity and authenticity. When someone say Identity of the User, UID (User identifier) comes into picture.  UID  is a unique identity, simply a number given to the user.Valid UID ranges are from 0 to 65534.

Every kind of User type as discussed above are given a particular range of UID’s.

Root User got the UID ‘0‘ . {As root user is prime and supreme authoritative, so he got the UID ” 0 “, This can be altered in the configuration file, which we come across later}

UID for System User lies with in the range of 1 to 499. {Don’t come to a conclusion that Linux OS can only provide 500 System Users. It’s just a default range provided by the OS, it can be altered and can add system users greater than 500 but less than a saturation value which depends on a type Linux OS}.

UID for Normal User lies with in the range of > 500 <6000.
UID for Network User lies with in the range of  >6000.

User Administration-Live:

1) Creating User Account:  

   "useradd" : This command is used to create a new user with default values.
 
$useradd   {username}

   where the options can be,

  -U = User id
  -g = group ID (primary)
  -G = group ID (secondary)
  -c = comment
  -d = directory
  -s  = shell
  -f  = inactive days
  -e = expire date (YYYY MM DD)
 
    # useradd surya

   # passwd surya
   Changing password for user surya.
   New UNIX password:
   Retype new UNIX password:
   passwd: all authentication tokens updated successfully.

# grep surya /etc/passwd
surya:x:500:500::/home/surya:/bin/bash

# grep surya /etc/group
surya:x:500:
[Note: default useradd command created surya as username and group

To view the default options give the following command with the option-D.
$ useradd -D
GROUP=1001
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/sh
SKEL=/etc/skel
CREATE_MAIL_SPOOL=no

  • GROUP: This is the only option which will not be taken as default. Because if you don’t specify -n option a group with same name as the user will be created and the user will be added to that group. To avoid that and to make the user as the member of the default group you need to give the option -n. 
  • HOME: This is the default path prefix for the home directory. Now the home directory will be created as /home/USERNAME.
  • INACTIVE: -1 by default disables the feature of disabling the account once the user password has expired. To change this behavior you need to give a positive number which means if the password gets expired after the given number of days the user account will be disabled.
  • EXPIRE: The date on which the user account will be disabled.
  • SHELL: Users login shell.
  • SKEL: Contents of the skel directory will be copied to the users home directory.
  • CREATE_MAIL_SPOOL: According to the value creates or does not create the mail spool.

2) Modify user accounts ( UserName/Lock/Un-Lock):

usermod : This command is used to modify the user accounts. Only the administrator can use this command. It's syntax is,
$ usermod   {username} 

where the options can be,    

-l = to change the user name
-L = to lock the user account
-U = to unlock the user account

3) Changing Password of a User:

passwd:This command is used to generate the passwords for users account.
$ passwd < user-name>
To disable a password,
$ passwd -d  {username}

4) Remove/Delete  a User:

userdel : This command is used to delete a user account.
$userdel    {user-name}

This will remove the user. But if you want to remove their home folder and all their files.
$userdel -r   {user-name}

Miscellaneous Commands:

5) Change user password expiry information:

chage: This command is used to change the password expiry information.
$ chage {user-name}

6) change the shell of a User:

chsh: Changes a user's login shell.

Valid shells are defined in the usw stanza of the /etc/security/login.cfg file. The default list of valid shells is: /usr/bin/ksh, /usr/bin/sh, /usr/bin/bsh, /usr/bin/csh but your system manager may have defined more.

To change the shell to /usr/bin/ksh for ram, type:
 #chsh ram /usr/bin/ksh

7) Editing the default options used by useradd:

The following example shows how to change the default shell from /bin/bash to /bin/ksh during user creation.

Syntax: #useradd -D --shell={shell name}

# useradd -D
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
[Note: The default shell is /bin/bash]

# useradd -D -s /bin/ksh

# useradd -D
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/ksh
SKEL=/etc/skel
[Note: Now the default shell changed to /bin/ksh]

# useradd ram

# grep ram /etc/passwd
ram:x:512:512::/home/ram:/bin/ksh
[Note: New users are getting created with /bin/ksh]

# useradd -D -s /bin/bash
[Note: Set it back to /bin/bash, as the above is only for testing purpose]

8)  Linux adduser Command – Create Users Interactively:

These are the friendlier tools to the low level useradd. By default it chooses the Debian policy format for UID and GID. A very simple way of creating user in the command line interactively is using adduser command.

Syntax: # adduser {username}

# adduser pinky

Adding user `pinky' ...
Adding new group `pinky' (1009) ...
Adding new user `pinky' (1009) with group `pinky' ...
Creating home directory `/home/pinky' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for pinky
Enter the new value, or press ENTER for the default
    Full Name []: Peter Parker
    Room Number []:
    Work Phone []:
    Home Phone []:
    Other []:
    Is the information correct? [y/N] y

9) Linux newusers Command — Creating bulk users:

Sometimes you may want to to create multiple users at the same time.
Any method for bulk user creation can be very tedious and time consuming. Fortunately, Linux offers a way to upload users using newusers command. This can also be executed in batch mode as it cannot ask any input.

Syntax: # newusers   {filename}


This file format is same as the password file.
loginname:password:uid:gid:comment:home_dir:shell

#cat db-tema-users.txt
sony:HbZ600a9:1008:1000:Sony DBA:/home/sony:/bin/bash
navs:1enq733N:1009:1000:Navs DBA:/home/navs:/bin/csh
rohan:1y51Jr8K:1010:1000:Rohan DBA:/home/rohan:/bin/ksh

Create DBA team user ids at oneshot

# newusers db-tema-users.txt

I hope these are helpful to you,see you again with another article.

Friday, 18 October 2013

Backup and Restore the Virtual I/O Server

How to backup and restore the Virtual I/O Server

This document describes different methods to backup and restore the Virtual I/O Server.


Backing up the Virtual I/O Server

There are 4 different ways to backup/restore the Virtual I/O Server as illustrated in the following table.

Backup method
Restore method
To tape
From bootable tape
To DVD
From bootable DVD
To remote file system
From HMC using the NIMoL facility and installios
To remote file system
From an AIX NIM server

Backing up to a tape or DVD-RAM

To backup the Virtual I/O Server to a tape or a DVD-RAM, the following steps must be performed

  1. check the status and the name of the tape/DVD drive
lsdev | grep rmt (for tape)
lsdev | grep cd (for DVD)

  1. if it is Available, backup the Virtual I/O Server with the following command
backupios –tape rmt#
backupios –cd cd#

If the Virtual I/O Server backup image does not fit on one DVD, then the backupios command provides instructions for disk replacement and removal until all the volumes have been created. This command creates one or more bootable DVDs or tapes that you can use to restore the Virtual I/O Server.

Backing up the Virtual I/O Server to a remote file system by creating a nim_resources.tar file

The nim_resources.tar file contains all the necessary resources to restore the Virtual I/O Server,including the mksysb image, the bosinst.data file, the network boot image, and SPOT resource.

The NFS export should allow root access to the Virtual I/O Server, otherwise the backup will fail with permission errors.

To backup the Virtual I/O Server to a filesystem, the following steps must be performed

  1. Create a mount directory where the backup file will be written
mkdir /backup_dir
  1. Mount the exported remote directory on the directory created in step 1.
mount server:/exported_dir /backup_dir
  1. Backup the Virtual I/O Server with the following command
backupios –file /backup_dir

The above command creates a nim_resources.tar file that you can use to restore the Virtual I/O Server from the HMC.

Note:The ability to run the installios command from the NIM server against the nim_resources.tar file is enabled with APAR IY85192.

The backupios command empties the target_disk_data section of bosinst.data and sets RECOVER_DEVICES=Default. This allows the mksysb file generated by the command to be cloned to another logical partition. If you plan to use the nim_resources.tar image to install to a specific disk, then you need to repopulate the target_disk_data section of bosinst.data and replace this file in the nim_resources.tar. All other parts of the nim_resources.tar image must remain unchanged.

Procedure to modify the target_disk_data in the bosinst.data:

  1. Extract from the nim_resources.tar the bosinst.data
tar -xvf nim_resources.tar ./bosinst.data
  1. The following is an example of the target_disk_data stanza of the bosinst.data generated by backupios.
target_disk_data:
LOCATION =
SIZE_MB =
HDISKNAME =
  1. Fill the value of HDISKNAME with the name of the disk to which you want to restore to
  2. Put back the modified bosinst.data in the nim_resources.tar image
tar -uvf nim_resources.tar ./bosinst.data

If you don't remember on which disk your Virtual I/O Server was previously installed, you can also view the original bosinst.data and look at the target_disk_data stanza.

Use the following steps

  1. extract from the nim_resources.tar the bosinst.data
tar -xvf nim_resources.tar ./bosinst.data
  1. extract the mksysb from the nim_resources.tar
tar -xvf nim_resources.tar ./5300-00_mksysb
  1. extract the original bosinst.data
restore -xvf ./5300-00_mksysb ./var/adm/ras/bosinst.data
  1. view the original target_disk_data
grep -p target_disk_data ./var/adm/ras/bosinst.data
           The above command displays something like the following:

target_disk_data:                                    
PVID = 00c5951e63449cd9                          
PHYSICAL_LOCATION = U7879.001.DQDXYTF-P1-T14-L4-L0
CONNECTION = scsi1//5,0                          
LOCATION = 0A-08-00-5,0                          
SIZE_MB = 140000                                 
HDISKNAME = hdisk0  
  1. replace ONLY the target_disk_data stanza in the ./bosinst_data with the original one                            
  2. add the modified file to the nim_resources.tar
tar -uvf nim_resources.tar ./bosinst.data

Backing up the Virtual I/O Server to a remote file system by creating a mksysb image

You could also restore the Virtual I/O Server from a NIM server. One of the ways to restore from a NIM server is from the mksysb image of the Virtual I/O Server. If you plan to restore the Virtual I/O Server from a NIM server from a mksysb image, verify that the NIM server is at the latest release of AIX.

To backup the Virtual I/O Server to a filesystem the following steps must be performed

  1. Create a mount directory where the backup file will be written
mkdir /backup_dir
  1. Mount the exported remote directory on the just created directory
mount NIM_server:/exported_dir /backup_dir
  1. Backup the Virtual I/O Server with the following command
backupios –file /backup_dir/filename.mksysb -mksysb

Restoring the Virtual I/O Server

As there are 4 different ways to backup the Virtual I/O Server, so there are 4 ways to restore it.

Restoring from a tape or DVD

To restore the Virtual I/O Server from tape or DVD, follow these steps:

  1. specify the Virtual I/O Server partition to boot from the tape or DVD by using the bootlist command or by altering the bootlist in SMS menu.
  2. insert the tape/DVD into the drive.
  3. from the SMS menu, select to install from the tape/DVD drive.
  4. follow the installation steps according to the system prompts.

Restoring the Virtual I/O Server from a remote file system using a nim_resources.tar file

To restore the Virtual I/O Server from a nim_resources.tar image in a file system, perform the following steps:

  1. run the installios command without any flag from the HMC command line.
a)      Select the Managed System where you want to restore your Virtual I/O Server from the objects of type "managed system" found by installios command.
b)      Select the VIOS Partition where you want to restore your system from the objects of type "virtual I/O server partition" found
c)      Select the Profile from the objects of type "profile" found.
d)     Enter the source of the installation images [/dev/cdrom]: server:/exported_dir
e)      Enter the client's intended IP address: <IP address of the VIOS>
f)       Enter the client's intended subnet mask: <subnet of the VIOS>
g)      Enter the client's gateway: <default gateway of the VIOS>
h)      Enter the client's speed [100]: <network speed>
i)        Enter the client's duplex [full]: <network duplex>
j)        Would you like to configure the client's network after the installation [yes]/no?
k)      Select the Ethernet Adapter used for the installation from the objects of type "ethernet adapters" found.

  1. when the restoration is finished, open a virtual terminal connection (for example, using telnet) to the Virtual I/O Server that you restored. Some additional user input might be required.

Note: The ability to run the installios command from the NIM server against the nim_resources.tar file is enabled with APAR IY85192.

Restoring the Virtual I/O Server from a remote file system using a mksysb image

To restore the Virtual I/O Server from a mksysb image in a file system using NIM, complete the following tasks:

  1. define the mksysb file as a NIM object, by running the nim command.
nim -o define -t mksysb -a server=master –a location=/export/ios_backup/filename.mksysb objectname
objectname is the name by which NIM registers and recognizes the mksysb file.

  1. define a SPOT resource for the mksysb file by running the nim command.
nim -o define -t spot -a server=master -a location=/export/ios_backup/
SPOT -a source=objectname SPOTname
SPOTname is the name of the SPOT resource for the mksysb file.

  1. install the Virtual I/O Server from the mksysb file using the smit command.
smit nim_bosinst
The following entry fields must be filled:
“Installation type” => mksysb
“Mksysb” =>  the objectname chosen in step1
“Spot” => the SPOTname chosen in step2

  1. start the Virtual I/O Server logical partition.
a)      On the HMC, right-click the partition to open the menu.
b)      Click Activate. The Activate Partition menu opens with a selection of partition profiles. Be sure the correct profile is highlighted.
c)      Select the Open a terminal window or console session check box to open a virtual terminal (vterm) window.
d)     Click (Advanced...) to open the advanced options menu.
e)      For the Boot mode, select SMS.
f)       Click OK to close the advanced options menu.
g)      Click OK. A vterm window opens for the partition.
h)      In the vterm window, select Setup Remote IPL (Initial Program Load).
i)        Select the network adapter that will be used for the installation.
j)        Select IP Parameters.
k)      Enter the client IP address, server IP address, and gateway IP address. Optionally, you can enter the subnet mask. After you have entered these values, press Esc to return to the Network Parameters menu.
l)        Select Ping Test to ensure that the network parameters are properly configured. Press Esc twice to return to the Main Menu.
m)    From the Main Menu, select Boot Options.
n)      Select Install/Boot Device.
o)      Select Network.
p)      Select the network adapter whose remote IPL settings you previously configured.
q)      When prompted for Normal or Service mode, select Normal.
r)       When asked if you want to exit, select Yes.

Integrated Virtualization Manager (IVM) Consideration


If your Virtual I/O Server is managed by the IVM, prior to backup of your system, you need to backup your partition profile data for the management partition and its clients as IVM is integrated with Virtual I/O Server, but the LPARs profile is not saved with the backupios command.

There are two ways to perform this backup:

From the IVM Web Interface

1)      From the Service Management menu, click Backup/Restore
2)      Select the Partition Configuration Backup/Restore tab
3)      Click Generate a backup

From the Virtual I/O Server CLI

1)      Run the following command
bkprofdata -o backup

Both these ways generate a file named profile.bak with the information about the LPARs configuration. While using the Web Interface, the default path for the file is /home/padmin. But if you perform the backup from CLI, the default path will be /var/adm/lpm. This path can be changed using the –l flag. Only ONE file can be present on the system, so each time the bkprofdata is issued or the Generate a Backup button is pressed, the file is overwritten.

To restore the LPARs profile you can use either the GUI or the CLI

From the IVM Web Interface

1)      From the Service Management menu, click Backup/Restore
2)      Select the Partition Configuration Backup/Restore tab
3)      Click Restore Partition Configuration

From the Virtual I/O Server CLI

1)      Run the following command
rstprofdata –l 1 –f /home/padmin/profile.bak

It is not possible to restore a single partition profile. In order to restore LPARs profile, none of the LPARs profile included in the profile.bak must be defined in the IVM.

Troubleshooting

Error during information gathering

In the case where after you specify the System Managed and the profile,the HMC is not able to find a network adapter:
  1. Check if the profile has a physical network adapter assigned
  2. Check if there is an hardware conflict with other running partition
  3. Check if the status of the LPAR is not correct (must be Not Activated)

Error during NIMOL initialization

  1. nimol_config ERROR: error from command /bin/mount < remoteNFS> /mnt/nimol
mount:< remoteNFS>  failed, reason given by server: Permission denied
probably the remote FS is not correctly exported.
  1. nimol_config ERROR: Cannot find the resource SPOT in /mnt/nimol.
probably you have specified a NFS which doesn’t contain a valid nim_resources.tar or the nim_resources.tar is a valid file but it doesn’t have valid permission for “others”

Error during lpar_netboot

In the case where the LPAR fails to power on
  1. Check if there is an hardware conflict with other running partition
  2. Check if the status of the LPAR is not correct (must be Not Activated)
In the case of Bootp failure
If the NIMOL initialization was successful
  1. Check if there is a valid route between the HMC and the LPAR
  2. Check that you have insert valid information during the initial phase

Error during BOS install phase

Probably there is a problem with the disk used for the installation

  1. Open a Vterm and check if the system is asking to select a different disk
  2. power off the LPAR, modify the profile to use another storage unit and restart installation


Creating and Restoring a Mksysb Without Preserving Mirrors

Question

How do you create/restore a mksysb, either locally or using NIM, without preserving mirrors?

Answer

This document gives the procedures to be taken to create or restore a mksysb without preserving mirrors either on a standalone system or in a NIM environment. The procedures in this document are valid for AIX 5.x and 6.1

WARNING: This procedure is valid ONLY with a mksysb image and will not work with a Sysback 6000 system backup.
____________________________________________________________________________

Contents of the note:

-How to restore an image.data file from a tape
-How to restore an image.data file from an existing mksysb backup file
-How to edit an image.data file to break a mirror
-Creating a mksysb with an edited image.data file to tape or file
-Creating an 'image_data' resource without preserving mirrors for use with NIM
-Using the 'image_data' resource to restore a mksysb without preserving mirrors using NIM
____________________________________________________________________________

How to restore an image.data file from a tape 

1. Change the block size of the tape device to 512:
# chdev –l rmt0 –a block_size=512
2. Check to make sure the block size of the tape drive has been changed:
# tctl –f /dev/rmt0 status
*You will receive output similar to this:
rmt0 Available 10-60-00-1,0 4.0 GB 4mm Tape Drive
attribute value description user_settable

block_size 512 BLOCK size (0=variable length) True
compress yes Use data COMPRESSION True
mode yes Use DEVICE BUFFERS during writes True
ret_error no RETURN error on tape change or reset True

3. 'cd' to the /tmp directory (or a directory where you would like to store the /image.data file from the mksysb image) and restore the /image.data file from the tape:
# cd /tmp
# restore –s2 -xqvf /dev/rmt0.1 ./image.data
*The image.data file from the tape will be restored to the /tmp directory

____________________________________________________________________________

How to restore an image.data file from an existing mksysb backup file 


1. ‘cd’ to the /tmp directory (or a directory where you would like to store the /image.data file from the mksysb image) and restore the /image.data file from the mksysb:
# cd /tmp
# restore -xqvf
./image.data ***The image.data file from the mksysb image will be restored to the /tmp directory

____________________________________________________________________________

How to edit an image.data file to break a mirror 

1. Create a new image.data file by running the following command:
# cd /
# mkszfile
2. vi the image.data file to break the mirror, by running the following command:
# vi /image.data
3. What you are looking for are the “lv_data” stanzas. There will be one for every logical volume associated with rootvg.

4. The following is an example of an lv_data stanza from an image.data file of a mirrored rootvg. The lines that need changing are marked with an --->, will be bold, and a slightly larger font:
lv_data:
VOLUME_GROUP= rootvg
--> LV_SOURCE_DISK_LIST= hdisk0 hdisk1
LV_IDENTIFIER= 000693da00004c00000001203de2aa29.14
LOGICAL_VOLUME= fslv01
VG_STAT= active/complete
TYPE= jfs2
MAX_LPS= 512
---> COPIES= 2
LPs= 20
STALE_PPs= 0
INTER_POLICY= minimum
INTRA_POLICY= middle
MOUNT_POINT= /chris
MIRROR_WRITE_CONSISTENCY= on/ACTIVE
LV_SEPARATE_PV= yes
PERMISSION= read/write
LV_STATE= opened/syncd
WRITE_VERIFY= off
PP_SIZE= 256
SCHED_POLICY= parallel
--> PP= 40
BB_POLICY= relocatable
RELOCATABLE= yes
UPPER_BOUND= 32
LABEL= /chris
MAPFILE=
LV_MIN_LPS= 1
STRIPE_WIDTH=
STRIPE_SIZE=
SERIALIZE_IO= no
FS_TAG= vfs=jfs2:log=/dev/hd8:mount=true:options=rw:account=false
DEV_SUBTYP=
*** Note: There are two disks in the 'LV_SOURCE_DISK_LIST', THE 'COPIES' value reflects two copies, and the 'PP' value is double that of the 'LPs' value.

4. The following is an example of the same lv_data stanza after manually breaking the mirror. The lines that have been changed are marked with a --->, will be bold, and a slightly larger font. Edit each 'lv_data' stanza in the /image.data.mksysb file as shown below to break the mirrors:
lv_data:
VOLUME_GROUP= rootvg
---> LV_SOURCE_DISK_LIST= hdisk0
LV_IDENTIFIER= 000693da00004c00000001203de2aa29.14
LOGICAL_VOLUME= fslv01
VG_STAT= active/complete
TYPE= jfs2
MAX_LPS= 512
---> COPIES= 1
LPs= 20
STALE_PPs= 0
INTER_POLICY= minimum
INTRA_POLICY= middle
MOUNT_POINT= /chris
MIRROR_WRITE_CONSISTENCY= on/ACTIVE
LV_SEPARATE_PV= yes
PERMISSION= read/write
LV_STATE= opened/syncd
WRITE_VERIFY= off
PP_SIZE= 256
SCHED_POLICY= parallel
---> PP= 20
BB_POLICY= relocatable
RELOCATABLE= yes
UPPER_BOUND= 32
LABEL= /chris
MAPFILE=
LV_MIN_LPS= 1
STRIPE_WIDTH=
STRIPE_SIZE=
SERIALIZE_IO= no
FS_TAG= vfs=jfs2:log=/dev/hd8:mount=true:options=rw:account=false
DEV_SUBTYP=
*** Note: The 'LV_SOURCE_DISK_LIST' has been reduced to one disk, the 'COPIES' value has been changed to reflect one copy, and the 'PP' value has been changed so that it is equal to the 'LPs' value.

5. Save the edited /image.data file with the following command:
*Hit the "Esc" button to exit 'input' mode, then type the following:
:wq!
Press to save and exit the file 

***Aside from the values specified in the documentation above, no other values in the /image.data file should be edited ***

6. At this point you can use the edited image.data file to do one of the following:
You can now use your newly edited image.data file to create a new mksysb to file, tape, or DVD..
Example :
To file or tape : place the edited image.data file in the / (root) directory and rerun your mksysb command without using the “-i” flag. If running the backup through SMIT, make sure you set the option “Generate new /image.data file?” to 'no'. (By default it is set to 'yes')

To DVD : Use the -i flag and specify the
of the edited image.data file. If running through SMIT specify the edited image.data file location in the “User supplied image.data file” field.
Within NIM you would create an 'image_data' resource for use with NIM to restore a mksysb without preserving mirrors.

____________________________________________________________________________

Creating a mksysb with an edited image.data file to tape or file 

1. Create a new /image.data file with the following command:
# cd /
# mkszfile
2. Break the mirror in the /image.data file as shown in the steps above

3. Move the edited image.data file to the root (/) directory

# mv /tmp/edited.image.data /image.data

3. Use the mksysb command to create a new mksysb with the /image.data file that has the broken mirror.

From command line:
To tape:
# mksysb /dev/rmt0
To file:
# mksysb /location/of/mksysb/file
***NOTE: DO NOT use the '-i' or '-m' flags. These flags will create a new /image.data file based upon the systems current configuration. This means that the mirrors will still be in tact in the mksysb. All other mksysb flags can be used.

- OR -

Using smit:

Use smit to create a mksysb:
# smit mksysb Back Up the System

Type or select values in entry fields.
Press Enter AFTER making all desired changes.

[Entry Fields]
WARNING: Execution of the mksysb command will
result in the loss of all material
previously stored on the selected
output medium. This command backs
up only rootvg volume group.
* Backup DEVICE or FILE [/dev/rmt0] +/
Create MAP files? no +
EXCLUDE files? no +
List files as they are backed up? no +
Verify readability if tape device? no +
Generate new /image.data file? no + <--- nbsp="" p="">EXPAND /tmp if needed? no +
Disable software packing of backup? no +
Backup extended attributes? yes +
Number of BLOCKS to write in a single output [] #
(Leave blank to use a system default)
Location of existing mksysb image [] /
File system to use for temporary work space [] /
(If blank, /tmp will be used.)
Back up encrypted files? yes +
Back up DMAPI filesystem files? yes +
***NOTE: By default, the 'Generate new /image.data file?' selection is set to 'yes'. You must make sure to change this selection to 'no', as displayed in the example above.

____________________________________________________________________________

Creating an 'image_data' resource without preserving mirrors for use with NIM 

1. Transfer the /image.data file to the NIM master and store it in the location you desire. It is a good idea to place the file, or any NIM resource for that matter, in a descriptive manor.
Ex : /export/nim/image_data
This will ensure you can easily identify your "image_data" NIM resource file locations, should you have the need for multiple "image_data" resources.
Make sure your image.data filenames are descriptive also. A common way to name the file would be in relation to your clientname.
Ex : ClientA.imagedata

2. Run the nim command, or use smitty and the fast path ‘nim_mkres’ to define the file that you have edited using the steps above:

From command line on the NIM master:
# nim -o define -t image_data -a server=master -a location=/export/nim/image_data/ClientA.imagedata -a comments="image.data file with broken mirror for testlpar" mksysb_image_data
***NOTE: "mksysb_image_data" is the name I am giving the 'image_data' resource

Using smit on the NIM master:
# smit nim_mkres
--> select 'image_data' as the Resource Type
Define a Resource

Type or select values in entry fields.
Press Enter AFTER making all desired changes.

[Entry Fields]
* Resource Name [mksysb_image_data]
* Resource Type image_data
* Server of Resource [master] +
* Location of Resource [/export/nim/image_data/ClientA.imagedata /
NFS Client Security Method [] +
NFS Version Access [] +
Comments [image.data file with broken mirror for testlpar]
Source for Replication [] +
3. Run the following command to make sure the 'image_data' resource was created:
# lsnim -t image_data

**The command will give output similar to the following:
mksysb_image_data resources image_data
4. Run the following command to get information about the 'image_data' resource:
# lsnim -l mksysb_image_data

**The command will give output similar to the following:
mksysb_image_data:
class = resources
type = image_data
comments = image.data file with broken mirror for testlpar
Rstate = ready for use
prev_state = unavailable for use
location = /export/nim/image_data/ClientA.imagedata
alloc_count = 0
server = master
____________________________________________________________________________

Using the 'image_data' resource to restore a mksysb without preserving mirrors using NIM 

1. Specify using the 'image_data' resource when running the 'bosinst' command from the NIM master:
From command line on the NIM master:
# nim -o bos_inst -a source=mksysb -a lpp_source= -a spot= -a mksysb= -a image_data= mksysb_image_data -a accept_licenses=yes ClientB 

- OR -

Using smit on the NIM master:

# smit nim_bosinst
>select the client to install
>select 'mksysb' as the type of install
>select a SPOT at the same level as the mksysb you are installing
>select an lpp_source at the same level than the mksysb you are installing
*NOTE: It is recommended to use an lpp_source at the same AIX Technology Level, but if using an lpp_source at a higher level than the mksysb, the system will be updated to the level of the lpp_source during installation. This will only update Technology Levels
Example:
You are using an AIX 5300-08 mksysb, you cannot use a 6.x lpp_source
This will not migrate the Version of AIX you are running to a higher Version
Example:
You are using an AIX 5300-08 mksysb and allocate a 5300-09 lpp_source – this will update your target system to 5300-09

>See below for example:

Install the Base Operating System on Standalone Clients

Type or select values in entry fields.
Press Enter AFTER making all desired changes.
[TOP] [Entry Fields]
* Installation Target lucidbso
* Installation Type mksysb
* SPOT 5300_09_00_spot
LPP_SOURCE [5300_09_00_lpp] +
MKSYSB lucid_mksysb
BOSINST_DATA to use during installation [] +
IMAGE_DATA to use during installation [mksysb_image_data] + <--- nbsp="" p="">RESOLV_CONF to use for network configuration [] +
Customization SCRIPT to run after installation [] +
Customization FB Script to run at first reboot [] +
ACCEPT new license agreements? [yes] + <--- nbsp="" p="">Remain NIM client after install? [yes] +
Preserve NIM definitions for resources on [yes] +
this target?

FORCE PUSH the installation? [no] +

Initiate reboot and installation now? [no] +
-OR-
Set bootlist for installation at the [no] +
next reboot?

Wednesday, 16 October 2013

All-In-One TSM Client Commands

TSM (Tivoli Storage Manager)  is  a centralized, policy-based, enterprise class, data backup and recovery package from IBM Corporation.The software enables the user to insert objects not only via backup, but also through space management and archive tools. It also allows retrieval of the same data via similar restore, recall, and retrieve methods.

As  Unix Admins  we used to get lot of requests from the application teams for tsm backup restores.I would like to discuss about the the best 14 best use-full TSM client commands.

I will  go by the  a category wise  "Query,Backup & Restore".

Generally we use dsmc/dsm  for the  TSM client commands.

In this article we are going to discuss about the following contents with practice examples.

  1) Querying the server
    A. Querying your scheduled backup slot
    B. Querying what files are included / excluded for backup
    C.Querying what partitions have been backed up
    D.Querying what files have been backed up
   
 2) Backing Up data
    A. Backing your local filesystems
    B. Backing up selected files
   
 3) Restore Data
    A. Restore a file to its original directory
    B. Restore the most recent backup version of a file
    C. Display a list of active and inactive backup versions of files from which you can select versions to restore
    D. Restore with a directory including subdirectories
    E. Restore the  file under a new name and directory
    F. Restore all files in a directory  as of their current state
    G. Restore all files from a  directory that end with .xyz to the another directory
    H. Restore files specified in the text file to a different location

1) Querying the server

A. Querying your scheduled backup slot

To query your scheduled backup slot enter dsmc q sched (which is short for query schedule). The output should look similar to that below:
#dsmc q sched

    Schedule Name: WEEKLY_UM
      Description: UM weekly incremental backup
   Schedule Style: Classic
           Action: Incremental
          Options:
          Objects:
         Priority: 5
   Next Execution: 135 Hours and 25 Minutes
         Duration: 20 Minutes
           Period: 1 Week
      Day of Week: Thursday
           Expire: Never

B. Querying what files are included / excluded for backup

"q inclexcl" to list output similar to the following:
#dsmc q inclexcl
*** FILE INCLUDE/EXCLUDE ***
Mode Function  Pattern (match from top down)  Source File
---- --------- ------------------------------ -----------------
Excl Filespace /var/run                       /opt/tivoli/tsm/client/ba/bin/incl.excl
Excl Filespace /tmp                           /opt/tivoli/tsm/client/ba/bin/incl.excl
Excl Directory /.../.opera/.../cache4         /opt/tivoli/tsm/client/ba/bin/incl.excl
Excl Directory /.../.mozilla/.../Cache        /opt/tivoli/tsm/client/ba/bin/incl.excl
Excl Directory /.../.netscape/.../cache       /opt/tivoli/tsm/client/ba/bin/incl.excl
Excl Directory /var/tmp                       /opt/tivoli/tsm/client/ba/bin/incl.excl
Excl All       /.../dsmsched.log              /opt/tivoli/tsm/client/ba/bin/incl.excl
Excl All       /.../core                      /opt/tivoli/tsm/client/ba/bin/incl.excl
Excl All       /.../a.out                     /opt/tivoli/tsm/client/ba/bin/incl.excl

C.Querying what partitions have been backed up

"q fi" to list which partitions have been backed up:
** Unix/Linux  **

#dsmc q fi
  #     Last Incr Date      Type    File Space Name
---     --------------      ----    ---------------
  1   02-05-2013 02:13:13   UFS     /        
  2   25-07-2012 12:26:09   UFS     /export/home
  3   02-05-2013 02:13:26   UFS     /home    
  4   16-01-2013 11:26:37   UFS     /scratch  
  5   02-05-2013 02:13:54   UFS     /usr/local
  6   12-02-2013 02:52:41   UFS     /var    

** Netware **

  #     Last Incr Date      Type       File Space Name
---     --------------      ----       ---------------
  1   02-05-2013 00:23:46   NTW:LONG   Oracle_data\usr:
  2   02-07-2013 00:22:42   NDS        Oracle_data\bin:
  3   02-07-2013 00:25:33   NTW:LONG   Oracle_data\apps:
  4   02-07-2013 00:25:11   NTW:LONG   Oracle_data\usr:

D.Querying what files have been backed up

In order to query the files or directories that are backed-up earlier you can use "q ba".

The below example gives you only the directory information.
#dsmc q ba /home/oraadmin
   Size      Backup Date                Mgmt Class           A/I File
   ----      -----------                ----------           --- ----
   1024  B  15-10-2013 02:52:09          STANDARD             A  /home/oraadmin
 

If you just add a trailing * (star) as a wildcard in the above query, TSM will only return those files and directories backed up immediately below the directory path given in the query
#dsmc q ba /home/oraadm/*
   Size      Backup Date        Mgmt Class A/I File
   ----      -----------        ---------- --- ----
    512  12-09-2012 19:57:09    STANDARD    A  /home/oraadm/data1.dtf
  1,024  08-12-2012 02:46:53    STANDARD    A  /home/oraadm/data2.dtf
    512  12-09-2012 19:57:09    STANDARD    A  /home/oraadm/data3.dtf
    512  24-04-2002 00:22:56    STANDARD    A  /home/oraadm/data4.dtf

If you want to query all the current files and directories backed up under a directory and all its sub-directories you need to add the -subdir=yes option as below:

#dsmc q ba /home/oraadm/* -subdir=yes
   Size      Backup Date        Mgmt Class A/I File
   ----      -----------        ---------- --- ----
    512  12-09-2012 19:57:09    STANDARD    A  /home/oraadm/data1.dtf
  1,024  08-12-2012 02:46:53    STANDARD    A  /home/oraadm/data2.dtf
    512  12-09-2012 19:57:09    STANDARD    A  /home/oraadm/data3.dtf
    512  24-04-2002 00:22:56    STANDARD    A  /home/oraadm/data4.dtf
  1,024  12-09-2012 19:57:09    STANDARD    A  /home/oraadm/datasmart1/test
  1,024  12-09-2012 19:57:09    STANDARD    A  /home/oraadm/datasmart1/test/test2
 12,048  04-12-2012 02:01:29    STANDARD    A  /home/oraadm/datasmart2/tables
 50,326  30-04-2013 01:35:26    STANDARD    A  /home/oraadm/datasmart3/data_file1
 50,326  27-04-2013 00:28:15    STANDARD    A  /home/oraadm/datasmart3/data_file2
 11,013  24-04-2013 00:22:56    STANDARD    A  /home/oraadm/datasmart3/data_file3

2. Backing Up data

A. Backing your local filesystems

The syntax for this is "dsmc backup-type filesystem" , where backup-type is one of incremental or selective. 


Incremental BackupIt is one that backs up only the data that changed since the last backup — be it a full or incremental backup
Selective BackupA type of backup where only the user specified files and directories are backed up. A selective backup is commonly used for backing up files which change frequently or in situations where the space available to store backups is limited. Also called a partial backup.

I would always suggest you always go with incremental. The command is "dsmc incremental"  or "dsmc incr" Where "incr" is an abbreviation for incremental.

Perform an incremental backup of your client server.
#dsmc incr
Make this will omit the filesystems which were mention in the exclude file.
To incrementally back up specific file-systems enter:
#dsmc incr /  /usr  /usr/local  /home

To back up entire filesystem irrespective of whether files have changed since the last backup, use the selective command with a wild-card and -subdir=yes as below:
#dsmc sel /*  /usr/*   /home/*  -su=yes

B. Backing up selected files

For backing up selected files is similar to that for backing up filesystems. Be aware, however, that you cannot use wildcards in directory / folder names:
#dsmc incr /home/oradm/data*/* -su=yes
ANS1071E Invalid domain name entered: '/home/oradm/data*/*'

#dsmc sel /home/oradm/data*/* -su=yes
Selective Backup function invoked.
ANS1081E Invalid search file specification '/home/oradm/data*/*' entered

You can, however, enter several file specifications on the command line, as below:
#dsmc incr /home/surya/*  /usr/bin/* -su=yes

3) Restore Data

We use the "restore" command to restore  files

 A. Restore a file to its original directory

 Restore the /home/oraadm/data.txt  file to its original directory.

 #dsmc restore /home/oraadm/data.txt

 If you do not specify a destination, the files are restored to their original location.

B. Restore the most recent backup version of a file

Here is an example to restore  /home/oraadm/data.txt file, even if the backup is inactive.
#dsmc restore /home/oraadm/data.txt -latest

If the file you are restoring no longer resides on your client machine, and you have run an incremental backup since deleting the file, there is no active backup of the file on the server. In this case, use the latest option to restore the most recent backup version. Tivoli Storage Manager restores the latest backup version, whether it is active or inactive.

C. Display a list of active and inactive backup versions of files from which you can select versions to restore

#dsmc restore "/home/oraadmin/*"-pick -inactive

D. Restore with a directory including subdirectories

Restore the files in the /oradata1 directory and all of its sub-directories (-sub=yes)
#dsmc restore /oradata1/ -subdir=yes

When restoring a specific path and file, Tivoli Storage Manager recursively restores all sub-directories under that path, and any instances of the specified file that exist under any of those sub-directories.

E. Restore the  file under a new name and directory

In-order to restore the  /home/oraadm/data.txt   file under a new name and directory.

#dsmc restore /home/oraadm/data.txt /tmp/data-renamed.txt

F. Restore all files in a directory  as of their current state

Restore all files in the /usr/oradata/docs directory to their state as of 5:00 PM on October 16, 2013.
#dsmc restore -pitd=10/16/2013 -pitt=17:00:00 /usr/oradata/docs/

Use the pitdate option with the pittime option to establish a point in time for which you want to display or restore the latest version of your backups. Files that were backed up on or before the date and time you specified, and which were not deleted before the date and time you specified, are processed. Backup versions that you create after this date and time are ignored.

G. Restore all files from a  directory that end with .xyz to the another directory

Restore all files from the /usr/oradata/docs/ directory that end with .bak to the /usr/oradata/projects/ directory.

# dsmc restore "/usr/oradata/docs/*.bak" /usr/oradata/projects/

If the destination is a directory, specify the delimiter (/) as the last character of the destination. If you omit the delimiter and your specified source is a directory or a file spec with a wildcard, you will receive an error. If the projects directory does not exist, it is created.

H. Restore files specified in the text file to a different location

Restore files specified in the restorelist.txt file to a different location.
# dsmc restore -filelist=/tmp/restorelist.txt /usr/ora_backup/

The files (entries) listed in the filelist must adhere to the following rules:

  • Each entry must be a fully or partially qualified path to a file or directory or a relative path.
  • Each entry must be on a new line.
  • Do not use wildcard characters.
  • Each entry results in the processing of only one object (file or directory).
  • If the file name contains any spaces, enclose the file name with quotes.
  • The filelist can be an MBCS file or a Unicode file with all Unicode entries.
  • Tivoli Storage Manager ignores any entry that is not valid.

Wednesday, 2 October 2013

Hardware Management Console (HMC ) Explained


HMC (Hardware Management Console) is a technology created by IBM  Vendor to provide a standard utility (interface) for configuring and operating logical partitions (also known as an LPAR or virtualized systems) and managing the  SMP (Symmetric multiprocessing)  systems such as IBM System i/z/p and IBM Power Systems.

Basically HMC is customized Linux blended with Java and many other graphical components. As per wiki  "The HMC is a Linux kernel using Busybox to provide the base utilities and X Window using the Fluxbox window manager to provide graphical logins. The HMC also utilizes Java applications to provide additional functionality."

As AIX admins like me very much  fond of  HMC uses in day-today operations. HMC supports the system with features that enable a system administrator to manage configuration and operation of partitions in a system, as well as to monitor the system for hardware problems. It consists of a 32-bit Intel-based desktop PC with a DVD-RAM drive.

Connection of HMC with different managed systems is shown in below diagram.

What does the HMC do?

  •     Creates and maintains a multiple-partitioned environment
  •     Displays a virtual operating system session terminal for each partition
  •     Displays virtual operator panel values for each partition
  •     Detects, reports, and stores changes in hardware conditions
  •     Powers managed systems on and off
  •     Powers Logical partitions on and off 
  •     Booting systems in Maintenance mode and  doing dump reboots
  •     Acts as a service focal point for service representatives to determine an appropriate service                                                   strategy  and enable the Service Agent Call-Home capability
  •     Activates additional resources on demand ( we call it as CoD, capacity on demand)
  •     Perform DLAR Operations. 
  •     Perform  Firmware up-gradations on managed systems
  •     Remote  management of managed systems

HMC  Facts:

  • Single HMC can manage multiple physical frames frames ( managed systems)
  • You can't open more than one virtual console for a given lpar at a given  time.
  • If your HMC is down , nothing will happen to your managed systems and their lpars they will operate as usual but only thing we can't manage them if something happens
  • There wont be direct root login . By default we get hscroot. ( need to engage  IBM support to get the root password)

HMC Operating Modes:

You can operate  HMC in two modes.

  1. Command Line Interface ( CLI )
  2. Graphical Interface
Each methods has its own merits ,  graphical interface can you clear view , how you can operate the managed systems even with  minimal knowledge on HMC

Where as using CLI you can run the information very fastly using commands  and scripts.

Below figure show how graphical interface.






















 

HMC Version Evolution:

  • HMC V7, for POWER5, POWER6 and POWER7 models
    • HMC V7R7.2.0 (Initial support for Power 710, Power 720, Power 730, Power 740 and Power 795 models)
    • HMC V7R7.1.0 (Initial support for POWER7)
    • HMC V7R3.5.0 (released Oct. 30, 2009)
    • HMC V7R3.4.0
    • HMC V7R3.3.0
    • HMC V7R3.2.0
    • HMC V7R3.1.0 (Initial support for POWER6 models)
  • HMC V6
    • HMC V6R1.3
    • HMC V6R1.2
  • 5.2.1
  • 5.1.0
  • 4.5.0
  • 4.4.0
  • 4.3.1
  • 4.2.1
  • 4.2.0, for POWER5 models
  • 4.1.x
  • 3.x, for POWER4 models

 RMC (Resource Monitoring and Control) & Association with HMC:

RMC is a distributed framework and architecture that allows the HMC to communicate with a managed logical partition. for example "IBM.DMSRM" is deamon which needs to run on the lapr inorder do DLAPR operation on through HMC on the lpar.

Both daemons in LPARs and HMCs use external network  to communicate among themselves but not through server processor  means both have access to same external  network in order to work with RMC related commands.

In order for RMC to work, port 657 upd/tcp must be open in both directions between the HMC public interface and the lpar.

The RMC daemons are part of the Reliable, Scalable Cluster Technology (RSCT) and are controlled by the System Resource Controller (SRC). These daemons run in all LPARs and communicate with equivalent RMC daemons running on the HMC. The daemons start automatically when the operating system starts and synchronize with the HMC RMC daemons.

Note: Apart from rebooting, there is no way to stop and start the RMC daemons on the HMC!

Things to check at the HMC:

- checking the status of the managed nodes: /usr/sbin/rsct/bin/rmcdomainstatus -s ctrmc  (you must be root on the HMC)

- checking connection between HMC and LPAR:
hscroot@umhmc1:~> lspartition -dlpar
<#0> Partition:<2 data-blogger-escaped-10.10.50.18="" data-blogger-escaped-aix10.domain.com="">
       Active:<1>, OS:, DCaps:<0x4f9f>, CmdCaps:<0x1b data-blogger-escaped-0x1b="">, PinnedMem:<1452>
<#1> Partition:<4 data-blogger-escaped-10.10.50.71="" data-blogger-escaped-aix20.domain.com="">
       Active:<0>, OS:, DCaps:<0x0>, CmdCaps:<0x1b data-blogger-escaped-0x1b="">, PinnedMem:<656>

For correct DLPAR function:
- the partition must return with the correct IP of the lpar.
- the active value (Active:...) must be higher than zero,
- the decaps value (DCaps:...) must be higher 0x0

(The first line shows a DLPAR capable LPAR, the second line is anon-working LPAR)

----------------------------------------

Things to check at the LPAR:

- checking the status of the managed nodes: /usr/sbin/rsct/bin/rmcdomainstatus -s ctrmc

- Checking RMC status:

# lssrc -a | grep rsct
 ctrmc            rsct             8847376      active   <== it is a RMC subsystem
 IBM.DRM          rsct_rm          6684802      active   <== it is for executing the DLPAR command on the partition
 IBM.DMSRM        rsct_rm          7929940      active    <== it is for tracking statuses of partitions
 IBM.ServiceRM    rsct_rm          10223780     active
 IBM.CSMAgentRM   rsct_rm          4915254      active   <== it is for  handshaking between the partition and HMC
 ctcas            rsct                          inoperative    <== it is for security verification
 IBM.ERRM         rsct_rm                       inoperative
 IBM.AuditRM      rsct_rm                       inoperative
 IBM.LPRM         rsct_rm                       inoperative
 IBM.HostRM       rsct_rm                       inoperative    <==it is for obtaining OS information

You will see some active and some missing (The key for DLPAR is the IBM.DRM)
- Stopping and starting RMC without erasing configuration:

# /usr/sbin/rsct/bin/rmcctrl -z   <== it stops the daemons
# /usr/sbin/rsct/bin/rmcctrl -A   <== adds entry to /etc/inittab and it starts the daemons
# /usr/sbin/rsct/bin/rmcctrl -p   <== enables the daemons for remote client connections

(This is the correct method to stop and start RMC without erasing the configuration.)
Do not use stopsrc and startsrc for these daemons; use the rmcctrl commands instead!

- recfgct: deletes the RMC database, does a discovery, and recreates the RMC configuration

# /usr/sbin/rsct/install/bin/recfgct (Wait several minutes)
# lssrc -a | grep rsct

(If you see IBM.DRM active, then you have probably resolved the issue)

Getting  Information of LPARS & HMC either way:

Make a Note: In-order to work with these commands you should have rsct daemons running on the servers means make sure RMC communication between the HMC and LPAR is happening.

1) Getting HMC IP  information from LPAR:

If you get the information of which HMC/HMCs your lpar associate  managed system ( frame) connected by using "lsrsrc" command .

Command: finding the HMC IP address
 (lsrsrc IBM.ManagementServer (or lsrsrc IBM.MCP on AIX 7))
$ lsrsrc IBM.ManagementServer

Resource Persistent Attributes for IBM.ManagementServer
resource 1:
Name             = "192.168.1.2″
Hostname         = "192.168.1.2″
ManagerType      = "HMC"
LocalHostname    = "ldap1-en1″
ClusterTM        = "9078-160″
ClusterSNum      = ""
ActivePeerDomain = ""
NodeNameList     = {"lpar1"}
So in this case, the HMC IP address is 192.168.1.2.

2) Get Managed System & LPAR information :

Below script will give us full details about Frame & LPAR information and their allocated CPU & Memory.

Script to get Frame & LPAR information
for system in `lssyscfg -r sys -F "name,state" | sort | grep ",Operating" | sed 's/,Operating//'`; do 
  echo $system
  echo "    LPAR            CPU    VCPU   MEM    OS"
  for lpar in `lssyscfg -m $system -r lpar -F "name" | sort`; do
     default_prof=`lssyscfg -r lpar -m $system --filter "lpar_names=$lpar" -F default_profile`
     procs=`lssyscfg -r prof -m $system --filter "profile_names=$default_prof,lpar_names=$lpar" -F desired_proc_units`
     vcpu=`lssyscfg -r prof -m $system --filter "profile_names=$default_prof,lpar_names=$lpar" -F desired_procs`
     mem=`lssyscfg -r prof -m $system --filter "profile_names=$default_prof,lpar_names=$lpar" -F desired_mem`
     os=`lssyscfg -r lpar -m $system --filter "lpar_names=$lpar" -F os_version`
     printf "    %-15s %-6s %-6s %-6s %-30s\n" $lpar $procs $vcpu $mem "$os"
  done
done


Generally  people will think there is no way to run scripts in HMC,but we have a possibility for this  use "rnvi" command to make scrippt file i.e  "rnvi -f  hmcscriptfile".

To run the script, use the "source" command.   For example "source hmcscriptfile".   This will run the script in your current shell. 


Here  "hmcscriptfile" is the script name and run the script like below you will see the o/p as below.

How to run script & o/p
hscroot@umhmc1:~> source hmcscriptfile
p570_frame5_ms
    LPAR            CPU    VCPU   MEM    OS
    umlpar1         0.1    3      512    AIX 6.1 6100-07-05-1228       
    umlpar2         0.1    3      512    AIX 6.1 6100-07-05-1228       
    umlpar3         0.1    3      512    Unknown                       
    linux1          0.1    3      512    Unknown                       
    vio1            0.2    2      512    VIOS 2.2.1.4                  
    vio2            0.1    2      352    Unknown