Tuesday, February 2, 2010

HMC command line

HMC command line

Getting console access using IBM HMC v6 Command Line


To get a console access through a remote connection, first ssh to the HMC
root@crnimx01# ssh hmc3 -l hscroot
Then type vtmenu. It will retrieve all the physical servers connected and that can be managed by the HMC.
hscroot@localhost:~> vtmenu
Retrieving name of managed system(s) . . . Server-9117-570-SN103CBBB 2-Server-9117-570-SN103CABB Server-9117-570-SN069D5BF Server-9119-595-SN8211572
———————————————————-
Managed Systems:
———————————————————-
1) Server-9117-570-SN103CBBB
2) 2-Server-9117-570-SN103CABB
3) Server-9117-570-SN069D5BF
4) Server-9119-595-SN8211572
Enter Number of Managed System. (q to quit): 1
You choose one of the managed servers and then it will show all LPARs available on that physical server.
———————————————————-
Partitions On Managed System:  Server-9117-570-SN103CBBB
OS/400 Partitions not listed
———————————————————-
1)    LPAR1                                   Running
2)    LPAR2                                   Running
3)    LPAR3                                   Running
After you selected which LPAR you will control, you will be shown the login screen
Open in progress..
Open Completed.
AIX Version 5
Copyright IBM Corporation, 1982, 2008.
Console login:
To exit you type tilde, space, tilde, space, dot.
~ ~ .

Using Line Commands on the HMC

Occasionally it’s quicker to SSH into the HMC to execute commands. 
The HMC is actually a Linux system with a restricted command set. 
Common actions that may be performed at the command line include: opening and controlling vterms, listing dynamic IP addresses, getting details of an LPAR or system’s configuration, rebooting the HMC or an LPAR and powering a system on or off.

vterm Operations—One useful command to know is the 

vtmenu command—which provides a list of managed systems you can work with. 
You can then select the system and the LPAR to open the vterm to. 
To escape a terminal session selected in this way type in "~.

mkvterm command can be used to open a vterm to an LPAR. 
The command below will open a vterm to the LPAR that allows a user to then login once they receive the login prompt.
~> mkvterm -m p6-520-8203-E4A-06A8A94 -p p6vios1

Instead of -p p6vios1 you could use -id 3, where 3 is the LPAR ID. To exit the vterm you will need to type in "~~." or to use rmvterm.

rmvterm -m p6-520-8203-E4A-06A8A94 -p p6vios1

Rebooting the HMC—It’s possible to reboot the HMC using a line command. 
From the HMC login type in 

hmcshutdown -r -t now

Controlling an LPAR via the HMC Command Line If there are issues with the Web-browser interface it’s still possible to shutdown, activate or reboot an LPAR from the HMC command line. It’s also possible to power a managed server off or on. The following commands would shutdown and reboot the LPAR that is partition ID 3 (or that is named p6l1) on the managed system that is listed below. 
It’s an immediate shutdown as the command specifies -immed.

chsysstate -r lpar -m p6-520-8203-E4A-06A8A94  -o shutdown --immed --restart --id 3
chsysstate -r lpar -m p6-520-8203-E4A-06A8A94  -o shutdown --immed --restart -n p6lpar1

If an LPAR is already shutdown then it is possible to activate the LPAR as follows:

chsysstate -r lpar -m p6-520-8203-E4A-06A8A94 -r lpar -o on -n p6lpar1 -f default -b normal 

Above, the -f default would use the profile called default and the -b could be normal or sms, depending on whether this is a normal reboot or a boot into sms mode. 
It’s also possible to replace the -n p6lpar1 with the LPAR ID by using -id 3. Finally the whole machine can be powered on using the following:

chsysstate -m managedsystemname -o on -r sys

Commands to get Configuration Information

There are additional commands that will provide configuration information if it needs to be gathered in a hurry. 
The first of these will list the dynamic IP addresses served out by the HMC along with other network settings.

  • The lshmc -n command will list the hostname for the HMC, its domain information, the IP addresses for the public and private networks, the subnet mask, the gateway and nameserver plus additional network information, including the media access control (MAC) addresses of the network cards in the HMC.

  • The lssysconn command is used to list all of the known managed systems for the HMC along with certain attributes. Specifically, (see Figure 2) the serial number for the managed system, its connection status and the DHCP that it was assigned are all listed.

  • The lssyscfg command is used to get information about the attributes of managed systems. Typing in lssyscfg -r sys will cause all the attributes for all of the managed systems to be listed. The output can be limited to a specific system by using: lssyscfg -r sys -name=p6-520-8203-E4A-06A8A94

System Plans—System plans are a critical component of systems documentation and can be invaluable if it’s necessary to recover a server. 
The lssysplan command can be used to provide a list of the current sysplans on the HMC.

lssysplan
name=mar2509-plan.sysplan,description=System plan created from p6-520-8203-E4A-06A8A94,source=HMC V7R3.4.0.0,version=HMC 1.5,"date=Mar 25, 2009 10:20:03 PM"

In order to create a system plan the command would be:

mksysplan -f p6520-jaqui.sysplan -m p6-520-8203-E4A-06A8A94

System plans can be taken from the GUI as well, but if there are problems with that method then the command-line version usually works. 
If you’re taking advantage of file-backed optical, then sometimes this causes problems for the system plan. 
Modifying the command to still probe the other LPARs but to not probe the virtual I/O servers will usually get around this. 
You can do this with the following command:

mksysplan -f p6520-jaqui.sysplan -m p6-520-8203-E4A-06A8A94--novios
lssysplan
now shows: name=p6520-jaqui.sysplan,description=,source=HMC V7R3.4.0.0,version=HMC 1.5,"date=Jun 7, 2009 8:31:34 PM"

Other options on the mksysplan include -noprobe--noinvscout and -nohwdisc

These are all explained clearly in the man pages for mksysplan on the HMC. 
Once the sysplan is created, it can then be viewed through the Web-browser interface or FTP’d to a desktop and viewed using the Systems Planning Tool. 
For more information on SPT, read “Using the Systems Planning Tool for Disaster Recovery.”


1. HMC Version

hscroot@hmc> lshmc -V Version: 3 Release: 3.2 HMC Build level 20040827.1
power4 HMCs could never show a version higher 3.x - HMC version 4.x and higher are only for power5 systems. Power 6 systems need HMCs version 7.x.

2. LPAR Status

That's how you get an overview of all systems controlled by your HMC:
power4:
hscroot@hmc> lslpars
power5:
hscroot@hmc> lssyscfg -r sys -F name:serial_num:state pserver1:656D24A:Operating pserver2:656FFFF:Operating
The format string 'lpar_id:name:serial_num:state' also tells you the serial number of the systems. You can omit the field 'serial_num' if you don't need to know.
However, for every system from the list above you get the LPAR overview as shown below:
hscroot@hmc> lssyscfg -m pserver -r lpar -F name:state
Example:
hscroot@hmc> lssyscfg -m pserver1 -r lpar -F name:state mylpar1:Running mylpar2:Running mylpar3:Not Activated
Don't know where to start? Find the managed system to an LPAR with a query:
hscroot@hmc> for m in $(lssyscfg -r sys -F name); do echo $m ; lssyscfg -r lpar -m $m -F name:state ; done

3. Reboot the HMC

power4 + power5:
hscroot@hmc> hmcshutdown -t now -r

4. Soft Reset of an LPAR

power4:
hscroot@hmc> chsysstate -m pserver -r lpar -n mylpar -o reset
power5:
hscroot@hmc> chsysstate -r lpar -m pserver -o shutdown -n mylpar

5. Soft Reset of a System Running in FullPartitionMode

power4:
hscroot@hmc> chsysstate -n pserver -r sys -o reset

6. Hard Reset of an LPAR

power4:
hscroot@hmc> chsysstate -m pserver -r lpar -n mylpar -o off
power5:
hscroot@hmc> chsysstate -r lpar -m pseries -o shutdown -n mylpar --immed

7. Hard Reset of a System Running in FullPartitionMode

power4:
hscroot@hmc> chsysstate -n pserver -r sys -o off

8. Virtual Console

That's how you get a connection to an LPAR's serial console:
power4 + power5:
hscroot@hmc> mkvterm -m pserver -p mylpar
If your system is running in FullSystemPartition-Mode you connect with a command like this:
power4:
hscroot@hmc> mkvterm -m pserver
You can escape from the console connection by typing ~~. (twice tilde followed by a dot)
If you cannot connect to the serial console and you get an error message instead:
All available virtual terminal sessions have been opened and are in use. To force a new open session, perform a Close Terminal Session operation which frees up the session.
there is still another active connection to this console. You can close this connection with:
power4 + power5:
hscroot@hmc> rmvterm -m pserver -p mylpar

9. Show Status and LED/LCD Display of an LPAR

power4:
hscroot@hmc> lssyscfg -r lpar -m pserver -n mylpar
power5:
hscroot@hmc> lssyscfg -r lpar -m pserver --filter ""lpar_names=mylpar"" hscroot@hmc> lsled -m pserver -r sa -t virtuallpar --filter ""lpar_names=mylpar""

10. Show Status and LED/LCD Display of a Systems Running in FullPartitionMode

power4:
hscroot@hmc> lssyscfg -r sys -n pserver

11. Activation of an LPAR

power4:
hscroot@hmc> chsysstate -r lpar -m pserver -o on [ -f myprofile ] -n mylpar
power5:
hscroot@hmc> chsysstate -r lpar -m pserver -o on -f myprofile -n mylpar

12. How to Power on a System Running in FullPartitionMode

power4:
hscroot@hmc> chsysstate -o on -r sys -n pserver -c full

13. Bring the key switch to position NORMAL

This might be necessary on some power5 HMCs when an LPAR does not properly boot after issuing the power on command above. You might see a message like this:
0514-440 cfgcon: failed to create log file: check path name, permissions, and available space
When seeing this you can only access diag mode or boot the LPAR in singleuser mode. This command sets the key switch back to normal position:
power5:
hscroot@hmc> chsysstate -r lpar -o chkey -k norm -n mylpar -m pserver

14. How to change the HMC password (of user hscroot)

power4 + power5:
hscroot@hmc> chhmcusr -u hscroot -t passwd Enter the new password: Retype the new password:

15. Overview LPAR IDs

power5:
hscroot@hmc> lssyscfg -r lpar -m pserver -F lpar_id:name:serial_num:state | sort -n 1:vioserver1:Running 2:vioserver2:Running 3:mylpar1:Not Activated 4:mylpar2:Running 5:mylpar3:Running 6:mylpar4:Running 7:mylpar5:Running 8:mylpar6:Running 9:mylpar7:Running 10:mylpar8:Not Activated