WPAR tiny digest

Update : Migrate Versioned WPARs from AIX 5  to 7 is now possible with AIX 7 TL3

Here is a nice video presentation by Nigel Griffiths : http://www.youtube.com/watch?v=0boDGqHy2YU

First you need to backup your WPAR, then stop it, then launch the migwpar command (after putting AIX 7 TL3 lpp_source in some directory) :

 # savewpar -f /tmp/wpar1.backup wpar1
 # stopwpar  wpar1
 # migwpar -d [Path_to_your_AIX7_install_filesets_location] -C wpar1 

Intro

No fancy things here, it’s just a memo to keep track of the commands, to check and use them later if I have to :)

Feel free to dig in !

WPAR definition from the Redbook :

« A WPAR is a software-created, virtualized OS environment within a single AIX V6 image. Each workload partition is a secure and isolated environment for the application it hosts. The application in a WPAR thinks that it is being executed in its own dedicated AIX instance. »

Requirements :

I. Basic WPAR commands

1. System WPAR Creation

« The system WPAR provides a complete virtualized OS environment to host multiple processes, services, and applications. »

To create a system WPAR, you just need a wpar name , optionally a hostname (the hostname will be the same as the wpar name, if the -h option is not specified) :

# mkwpar -n wpar1
mkwpar: Creating file systems...
 /
 /home
 /opt
 /proc
 /tmp
 /usr
 /var
Mounting all workload partition file systems.
x ./usr
x ./lib
(blah blah blah, untar and filesets installation output for about 3-4 minutes...)

[...]
rsct.core.gui 3.1.2.0 ROOT COMMIT SUCCESS
rsct.opt.storagerm 3.1.2.0 ROOT COMMIT SUCCESS
syncroot: Processing root part installation status.
syncroot: Installp root packages are currently synchronized.
syncroot: Synchronizing RPM root files.
syncroot: Checking space requirements.
+---------- Space statistics (in 512 byte-blocks) ----------+
File system: /wpars/wpar1/var, Free: 500464, Required: 165, Deficit: 0.
syncroot: Installing RPM file: /var/toto.rpm
syncroot: RPM root packages are currently synchronized.
syncroot: Root part is currently synchronized.
syncroot: Returns Status = SUCCESS
Workload partition wpar1 created successfully.
mkwpar: 0960-390 To start the workload partition, execute the following as root: startwpar [-v] wpar1

2. Application WPAR creation

« An application WPAR is used to isolate an individual service or application. It provides a runtime environment for executing either a single application or a group of related applications. It does not contain running AIX services or daemons normally present in a complete instance of AIX. »

I don’t see so much use for this type of WPAR though… except for some testing purposes, I guess.

Let’s try a simple application wpar, which will run the lsvg command (you need to specifiy the full path of the command) :

 # wparexec /usr/sbin/lsvg
Starting workload partition 'lsvg'.
Mounting all workload partition file systems.
Loading workload partition.
rootvg
testvg
Shutting down all workload partition processes.

3. Starting the wpar

# lswpar
Name State Type Hostname Directory RootVG WPAR
-----------------------------------------------------------------------
wpar1 D S wpar1 /wpars/wpar1 no 

The Wpar is in defined state (D), which is normal because we juste created it.

Talking about the states, here is a nice figure from the redbook which explains all the system (I’m not covering the application ones) WPAR state transitions :

Let’s start the wpar with startwpar command (or use the -s option with mkwpar)

# startwpar wpar1
Starting workload partition 'wpar1'.
Mounting all workload partition file systems.
Loading workload partition.
Exporting workload partition devices.
Exporting workload partition kernel extensions.
Starting workload partition subsystem 'cor_wpar1'.
0513-059 The cor_wpar1 Subsystem has been started. Subsystem PID is 7536718.
Verifying workload partition startup.
#

4. WPAR access from the global environment

use the clogin command :

# clogin wpar1 -l root

*******************************************************************************
* *
* *
* Welcome to AIX Version 7.1! *
* *
* *
* Please see the README file in /usr/lpp/bos for information pertinent to *
* this release of the AIX Operating System. *
* *
* *
*******************************************************************************

# hostname
wpar1
# ifconfig -a
lo0: flags=e08084b,c0
 inet 127.0.0.1 netmask 0xff000000 broadcast 127.255.255.255
 inet6 ::1%1/0
 tcp_sendspace 131072 tcp_recvspace 131072 rfc1323 1

Here we can see that if we don’t specify an ip address during the mkwpar part, we can only login from the global environment using the clogin [wparname] command. The wpar is completely isolated from the network.

5. Wpar-related commands from the global environment

Verbose output about wpars (including network, resources, FS…) :

# lswpar -L
=================================================================
wpar1 - Active
=================================================================
GENERAL
Type: S
RootVG WPAR: no
Owner: root
Hostname: wpar1
WPAR-Specific Routing: no
Virtual IP WPAR:
Directory: /wpars/wpar1
Start/Stop Script:
Auto Start: no
Private /usr: no
Checkpointable: no
Application:

OStype: 0
UUID: 15c74fb3-6663-4a62-bf65-9c930948560d

NETWORK
Interface Address(6) Mask/Prefix Broadcast
-----------------------------------------------------------------

USER-SPECIFIED ROUTES
Type Destination Gateway Interface
-----------------------------------------------------------------

FILE SYSTEMS
Mount Point Device Vfs Nodename Options
-----------------------------------------------------------------
/wpars/wpar1 /dev/fslv17 jfs2
/wpars/wpar1/home /dev/fslv18 jfs2
/wpars/wpar1/opt /opt namefs ro
/wpars/wpar1/proc /proc namefs rw
/wpars/wpar1/tmp /dev/fslv19 jfs2
/wpars/wpar1/usr /usr namefs ro
/wpars/wpar1/var /dev/fslv20 jfs2

RESOURCE CONTROLS
Active: yes
Resource Set:
CPU Shares: unlimited
CPU Limits: 0%-100%,100%
Memory Shares: unlimited
Memory Limits: 0%-100%,100%
Per-Process Virtual Memory Limit: unlimited
Total Virtual Memory Limit: unlimited
Total Processes: unlimited
Total Threads: unlimited
Total PTYs: unlimited

–> use the -@ argument to apply the command to your wpar(s) ;

here is the full list to all the enhanced AIX commands for WPARS : http://pic.dhe.ibm.com/infocenter/aix/v6r1/index.jsp?topic=%2Fcom.ibm.aix.wpar%2Fwpar-commands.htm


# ps -aef@ wpar1

WPAR UID PID PPID C STIME TTY TIME CMD
 wpar1 0 3211324 8257756 0 13:31:45 - 0:00 /usr/lib/errdemon
 wpar1 0 3407916 4522198 0 13:32:45 - 0:00 /usr/sbin/sshd
 wpar1 0 4522198 8257756 0 13:32:35 - 0:00 /usr/sbin/srcmstr
 wpar1 0 4653118 8257756 0 13:32:43 - 0:00 /usr/sbin/cron
 wpar1 0 5832864 4522198 0 13:32:42 - 0:00 /usr/sbin/rpc.lockd -d 0
 wpar1 0 6553774 4522198 0 13:32:43 - 0:00 /usr/sbin/clcomd -d
 wpar1 0 7077896 4522198 0 13:32:41 - 0:00 /usr/sbin/inetd
 wpar1 0 7405606 4522198 0 13:32:43 - 0:00 /usr/sbin/writesrv
 wpar1 0 7798974 4522198 0 13:32:41 - 0:00 /usr/sbin/portmap
 wpar1 0 8257756 2228232 0 13:31:39 - 0:00 /etc/init
 wpar1 0 9371902 4522198 0 13:32:41 - 0:00 /usr/sbin/syslogd
 wpar1 0 9699504 4522198 0 13:32:43 - 0:00 /usr/sbin/qdaemon
 wpar1 0 10289176 4522198 0 13:32:41 - 0:00 /usr/sbin/biod 6
 wpar1 0 10354942 4522198 0 13:32:41 - 0:00 sendmail: accepting connections
 wpar1 0 10485932 4522198 0 13:32:45 - 0:00 /usr/sbin/clconfd
 wpar1 0 10813548 4522198 0 13:32:45 - 0:00 /usr/sbin/rsct/bin/rmcd -a IBM.LPCommands -r

We can even concatenate the output of all the wpars active , like with vmstat :

# vmstat -@ ALL 2

System configuration: lcpu=4 mem=1024MB drives=0 ent=0.50 wpar=3 mmode=shared mpsz=6.00GB

wpar kthr memory page faults cpu
----- ----- ----------- ------------------------ ------------ -----------------------
 r b avm fre re pi po fr sr cy in sy cs us sy id wa pc rc
System 1 0 192416 51225 0 0 0 0 0 0 22 238 297 0 4 96 0 0.02 4.3
Global 1 0 - - 0 0 0 0 0 0 - - 290 4 96 - - 0.02 3.7
wpar1  0 0 - - 0 0 0 0 0 0 - - 1 40 60 - - 0.00 0.0
wpar2 0 0 - - 0 0 0 0 0 0 - - 2 43 57 - - 0.000 0.0
wpar3 0 0 - - 0 0 0 0 0 0 - - 1 43 57 - - 0.00 0.0
------------------------------------------------------

6. Create a filesystem into the WPAR

We have to create a filesystem from the global environment (the hosting LPAR), it isn’t possible to do this directly from the WPAR (change or delete FS as well), let’s create a 1GB FS :

# clogin wpar1
*******************************************************************************
* *
* *
* Welcome to AIX Version 7.1! *
* *
* *
* Please see the README file in /usr/lpp/bos for information pertinent to *
* this release of the AIX Operating System. *
* *
* *
******************************************************************************

wpar1# lsvg
0516-318 lsvg: No volume groups found.

wpar1# exit

# mklv -t jfs2 -y testwpar_lv wparvg 4
# crfs -v jfs2 -d testwpar_lv  -m /wpars/infviomon1/app/list/lpar2rrd -u wpar1 -A yes -a logname=INLINE

Or , a bit quicker:

# crfs -v jfs2 -g datavg -m /wpars/wpar1/testFS -u wpar1 -a logname=INLINE -a size=1G

File system created successfully.
1040148 kilobytes total disk space.
New File System size is 2097152
# mount /wpars/wpar1/testFS

# clogin wpar1
*******************************************************************************
* *
* *
* Welcome to AIX Version 7.1! *
* *
* *
* Please see the README file in /usr/lpp/bos for information pertinent to *
* this release of the AIX Operating System. *
* *
* *
*******************************************************************************
Last login: Wed Oct 31 15:32:06 2012 on /dev/Global from lpar

# df
Filesystem 512-blocks Free %Used Iused %Iused Mounted on
Global 524288 375680 29% 4425 10% /
Global 524288 519424 1% 5 1% /home
Global 1572864 1066096 33% 8376 7% /opt
Global - - - - - /proc
Global 524288 518960 2% 9 1% /tmp
Global 6291456 383512 94% 54757 53% /usr
Global 524288 489704 7% 363 1% /var
Global 2097152 2079792 1% 4 1% /testFS

7. View the allocation of resources WPAR

# lswpar -R wpar1
=================================================================
wpar1 - Active
=================================================================
Active: yes
Resource Set:
CPU Shares: unlimited
CPU Limits: 0%-100%,100%
Memory Shares: unlimited
Memory Limits: 0%-100%,100%
Per-Process Virtual Memory Limit: unlimited
Total Virtual Memory Limit: unlimited
Total Processes: unlimited
Total Threads: unlimited
Total PTYs: unlimited
Total Large Pages: unlimited
Max Message Queue IDs: 100%
Max Semaphore IDs: 100%
Max Shared Memory IDs: 100%
Max Pinned Memory: 100%

8. WPAR backup, restore and clone

  • From the WPAR :
# savewpar -f /tmp/wpar1.backup wpar1
Creating information file for workload partition wpar1.
Creating list of files to back up.
Backing up 2829 files
2829 of 2829 files (100%)
0512-038 savewpar: Backup Completed Successfully.

You can restore the wpar (or clone it to a new one) using the previously backed up file with restwpar :

# restwpar -f /tmp/wpar1.backup wpar1
  • From the NIM master:
First you need to create the nim client for your wpar (do not forget to specify the mgmt_profile1 attribute, which gives to NIM the « gateway » used to operate on the WPAR ):
 # nim -o define -t wpar -a platform=chrp -a if1="find_net wpar1 0" -k "64" -K "nimsh" -T'N/A' -S 'auto' -d 'auto' -n'wpar_net' -h 'wpar1' -a'0' -m -h 'wpar1' 
  # nim -o change -a mgmt_profile1="global_lpar wpar1" -a if1="find_net wpar1 0" wpar1
You can check the properties of your wpar nim client :
# lsnim -l wpar1
wpar1:
 class = machines
 type = wpar
 connect = nimsh
 current_master = nim_master
 platform = chrp
 if1 = wpar_net wpar1  0
 mgmt_profile1 = global_lpar wpar1
 Cstate = managed system defined but not yet created
 prev_state = ready for a NIM operation
 Mstate = currently running

Now that your wpar’s nim client is created, you can backup your wpar easily :

  # nim -o define -t savewpar -a verbose=yes -a server=master -a location=/export/nim/mksysb/WPAR1 -a source=wpar1 -a mk_image=yes WPAR1_savewpar

9. WPAR removal

First stop the wpar :

# stopwpar wpar1
Stopping workload partition 'wpar1'.
Stopping workload partition subsystem 'cor_wpar1'.
0513-044 The cor_wpar1 Subsystem was requested to stop.
stopwpar: 0960-261 Waiting up to 600 seconds for workload partition to halt.
Shutting down all workload partition processes.
Unmounting all workload partition file systems.

Now we can remove the wpar:

# rmwpar wpar1
rmwpar: Removing file system /wpars/wpar1/var.
rmlv: Logical volume fslv16 is removed.
rmwpar: Removing file system /wpars/wpar1/usr.
rmwpar: Removing file system /wpars/wpar1/tmp.
rmlv: Logical volume fslv15 is removed.
rmwpar: Removing file system /wpars/wpar1/proc.
rmwpar: Removing file system /wpars/wpar1/opt.
rmwpar: Removing file system /wpars/wpar1/home.
rmlv: Logical volume fslv14 is removed.
rmwpar: Removing file system /wpars/wpar1.
rmlv: Logical volume fslv13 is removed.

Now let’s clone wpar1 to a new wpar named « wpar2″ (do not forget to specify the hostname with -h argument, otherwise you’ll have 2 wpars with heir own name, but with the same hostname ):

# restwpar -n wpar2 -h wpar2 -d /wpars/wpar2 -f /tmp/wpar1.backup
New volume on /tmp/wpar1.backup:
 Cluster 51200 bytes (100 blocks).
 Volume number 1
 Date of backup: Mon Oct 29 17:13:32 2012
 Files backed up by name
 User root
x 2840 ./.savewpar_dir/wpar.spec
x 4644 ./.savewpar_dir/image.data
x 178241 ./.savewpar_dir/backup.data
 total size: 185725
 files restored: 3
**********************************************************************
Warning
mkwpar: 0960-105 general.hostname must be unique across all workload partitions.
 hostname = wpar1 also found in the following files:
 /etc/wpars/wpar1.cf

**********************************************************************
mkwpar: Creating file systems...
 /
ATTENTION: Logical volume 'fslv17' is not unique. Renaming to 'wlv0'.
Creating logical volume 'wlv0' specified in image.data
Creating file system '/' specified in image.data
 /home
ATTENTION: Logical volume 'fslv18' is not unique. Renaming to 'wlv1'.
Creating logical volume 'wlv1' specified in image.data
Creating file system '/home' specified in image.data
 /opt
 /proc
 /tmp
ATTENTION: Logical volume 'fslv19' is not unique. Renaming to 'wlv2'.
Creating logical volume 'wlv2' specified in image.data
Creating file system '/tmp' specified in image.data
 /usr
 /var
ATTENTION: Logical volume 'fslv20' is not unique. Renaming to 'wlv3'.
Creating logical volume 'wlv3' specified in image.data
Creating file system '/var' specified in image.data
[...]
x 21 ./unix
x 0 ./var
x 0 ./wpars
x 1 ./wpars/wpar1
Import of ACLs failed
Read-only file system
Import of PCL for file ./opt failed.
Read-only file system
x 0 ./opt
./opt: Read-only file system
x 0 ./proc
Import of ACLs failed
Read-only file system
Import of PCL for file ./usr failed.
Read-only file system
x 0 ./usr
./usr: Read-only file system
 total size: 83783143
 files restored: 5602
syncroot: Processing root part installation status.
syncroot: Installp root packages are currently synchronized.
syncroot: RPM root packages are currently synchronized.
syncroot: Root part is currently synchronized.
syncroot: Returns Status = SUCCESS
Workload partition wpar2 created successfully.
mkwpar: 0960-390 To start the workload partition, execute the following as root: startwpar [-v] wpar2

# lswpar
Name State Type Hostname Directory RootVG WPAR
--------------------------------------------------------
wpar1 A S wpar1 /wpars/wpar1 no
wpar2 D S wpar2 /wpars/wpar2 no

10. WPAR update

You can sync your wpar to the level of the global environment (like when you upgrade to the latest technology level, or install a new package)  with the following command (use -A to synchronize all the WPARs at once) from the global :

 #syncwpar wpar1
*******************************************************************************
syncwpar: Synchronizing workload partition 'wpar1' (1 of 1)
*******************************************************************************
syncwpar: COMMAND START, ARGS: wpar1
syncwpar: Executing "/usr/sbin/syncroot" in workload partition 'wpar1'
syncroot: Processing root part installation status.
syncroot: Synchronizing installp software.
+-----------------------------------------------------------------------------+
Pre-installation Verification...
+-----------------------------------------------------------------------------+
Verifying selections...done
Verifying requisites...done
Results...
SUCCESSES
---------

[...]

syncroot: Processing root part installation status.
syncroot: Installp root packages are currently synchronized.
syncroot: Root part is currently synchronized.
syncroot: Returns Status = SUCCESS
syncwpar: Workload partition 'wpar1' synchronized successfully
syncwpar: Return Status = SUCCESS

(or use the syncroot command from the wpar)

II. Advanced stuff

Resource control, WPAR relocation, WPAR load balancing, IBM systems Director plugin…

… Needs to be dug into, there will be more to come ! :)

Change the IP address of your WPAR

 # chwpar -N address=10.246.70.52 netmask=255.255.255.0 wpar1

Add an alias ip on your WPAR

 # chwpar -N address=10.246.70.52 netmask=255.255.255.0 -N address=10.240.122.95  netmask=255.255.255.0 wpar1

Remove a network / ip

 # chwpar -K -N address=10.246.70.52 wpar1

Add a specific routing for your WPAR

 # chwpar -i -I rtdest=default rtnetmask=255.255.255.0 rtgateway=10.240.122.254 rtinterface=en1 wpar1
en1 net default: gateway 10.240.122.254

Check it :

 # netstat -r -@ wpar1
Routing tables
WPAR       Destination        Gateway           Flags   Refs     Use  If   Exp  Groups

Route tree for Protocol Family 2 (Internet):
wpar1      default            10.240.122.254    UG        1      2776 en1      -      -
wpar1      10.240.122/24      wpar1             U         1         0 en1      -      -
wpar1      wpar1              loopback          UGHS      0         0 lo0      -      -
wpar1      10.240.122.255     wpar1             UHSb      0         0 en1      -      -
wpar1      10.246.70/24       10.246.70.52      U         0         0 en0      -      -
wpar1      10.246.70.52       loopback          UGHS      0         0 lo0      -      -
wpar1      10.246.70.255      10.246.70.52      UHSb      0         0 en0      -      -
wpar1      127/8              loopback          U         0         0 lo0      -      -

Route tree for Protocol Family 24 (Internet v6):

1. Resource Control

We can (using WLM in background) limit the WPAR’s access to many resources such as CPU, memory, max number of running processes… All of that with the chwpar -R option . For example, I want to limit wpar2′s resources to 33% of CPU , 50% of soft memory and 20 max running processes :

# chwpar -R shares_CPU=2 CPU=0%-33%,100% memory=0%-50%,100% totalProcesses=20 wpar2
# lswpar -R wpar2
=================================================================
wpar2 - Active
=================================================================
Active: yes
Resource Set:
CPU Shares: 2
CPU Limits: 0%-33%,100%
Memory Shares: unlimited
Memory Limits: 0%-50%,100%
Per-Process Virtual Memory Limit: unlimited
Total Virtual Memory Limit: unlimited
Total Processes: 20
Total Threads: unlimited
Total PTYs: unlimited
Total Large Pages: unlimited
Max Message Queue IDs: 100%
Max Semaphore IDs: 100%
Max Shared Memory IDs: 100%
Max Pinned Memory: 100%

We can use wlmstat to check the real utilization of each wpar from the global environment :

# wlmstat -@
CLASS CPU MEM DKIO
 wpar1 0.03 2.05 0.00
 wpar2 0.01 1.98 0.00
 TOTAL 0.04 4.03 0.00 

or in a more verbose way (apologies for the ugly formatting output on this blog, on your lpar it’ll look better ;) ) :

# wlmstat -@ -v
 CLASS tr i #pr CPU sha min smx hmx des rap urap pri MEM sha min smx hmx des rap urap npg DKIO sha min smx hmx des rap urap
 wpar1 0 0 15 0.02 -1 0.00 50.00 50.00 50.00 100 0 0 2.05 -1 0.00 100.00 100.00 98.00 95 203 3900 0.00 -1 0.00 100.00 100.00 100.00 100 0
wpar1.Default 0 0 15 100.00 -1 0.00 100.00 100.00 100.00 100 0 0 100.00 -1 0.00 100.00 100.00 100.00 95 203 3900 - -1 0.00 100.00 100.00 100.00 100 0
 wpar1.Shared 0 0 0 0.00 -1 0.00 100.00 100.00 100.00 100 0 0 0.00 -1 0.00 100.00 100.00 100.00 100 101 0 - -1 0.00 100.00 100.00 100.00 100 0
 wpar2 0 0 15 0.02 2 0.00 51.00 51.00 51.00 100 0 0 1.98 -1 0.00 50.00 100.00 50.00 92 326 3773 0.00 -1 0.00 100.00 100.00 100.00 100 0
wpar2.Default 0 0 15 100.00 -1 0.00 100.00 100.00 100.00 100 0 0 100.00 -1 0.00 100.00 100.00 100.00 92 326 3773 - -1 0.00 100.00 100.00 100.00 100 0
 wpar2.Shared 0 0 0 0.00 -1 0.00 100.00 100.00 100.00 100 0 0 0.00 -1 0.00 100.00 100.00 100.00 100 163 0 - -1 0.00 100.00 100.00 100.00 100 0

Links

AIX 6 workload partitions (WPAR) Frequently Asked Questions

http://pic.dhe.ibm.com/infocenter/aix/v6r1/index.jsp?topic=%2Fcom.ibm.aix.wpar%2Fwpar-commands.htm

Introduction to Workload Partition Management in IBM AIX Version 6.1

http://abderra.webspace.virginmedia.com/STUFF/cmds

http://www.torontoaix.com/wpar/create-wpar

https://www.ibm.com/developerworks/mydeveloperworks/blogs/aixpert/entry/workload_partition_wpar_answers305?lang=fr

https://www.ibm.com/developerworks/aix/library/au-wpar61aix/

Share

One thought on “WPAR tiny digest

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Vous pouvez utiliser ces balises et attributs HTML : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>