Using a post-migration script with nimadmI’ve received a couple of requests for an example of using a post migration script with nimadm. What follows is a simple example of using such a resource with NIM. If you are not familiar with the nimadm tool then perhaps you’d like to start first by reading my article on using nimadm to migrate to AIX 6.1.
The nimadm utility can perform both pre and post migration tasks. This is accomplished by running NIM scripts either before or after a migration. The tool accepts the following flags for pre and post migration script resources:
-a PreMigrationScript Specifies the pre-migration NIM script resource. -z PostMigrationScript Specifies the post-migration NIM script resource.
pre-migration This script resource that is run on the NIM master, but in the environment of the client's alt_inst file system that is mounted on the master (this is done by using the chroot command). This script is run before the migration begins.
post-migration This script resource is similar to the pre-migration script, but it is executed after the migration is complete.
We are going to focus on post-migration only, although the configuration is the same for both.
In this example I need to uninstall and install a 3rd party device fileset for a storage device. I need to perform this task as part of the migration process. To protect the innocent, I have not named the storage vendor in this post. But I will say that it was not IBM storage we are dealing with in this case.
Before we start, first we collect all the necessary device filesets that provide support for this type of storage on AIX. We place them into a local directory on my NIM master. Along with the software, I also place a copy of my NIM script in the same directory on the NIM master. The script name is XYZpost.ksh.
root@nim1 : /usr/local/XYZ # ls -ltr total 544 -r-xr-xr-x 1 root system 51200 Mar 11 2011 MPIO_1001I -r-xr-xr-x 1 root system 51200 Mar 11 2011 MPIO_1002U -r-xr-xr-x 1 root system 51200 Mar 11 2011 MPIO_1003U -r-xr-xr-x 1 root system 51200 Mar 11 2011 MPIO_1004U -r-xr-xr-x 1 root system 51200 May 18 16:39 MPIO_1005U -r-xr-xr-x 1 root system 715 May 24 16:57 XYZpost.ksh -rw-r--r-- 1 root system 2310 May 25 14:57 .toc
The contents of my script are simple. This script will de-install the old device fileset and then immediately install the latest version of the VendorXYZ’s device fileset. The script will then change the attributes for the vendor’s storage to more appropriate default values.
#!/usr/bin/ksh
echo “Uninstalling XYZ fileset: devi installp -u devi echo Return code is: $? echo echo “Installing XYZ ODM fileset: devi cd /usr/local/XYZ/ installp -aXd . devi echo Return code is: $? ## echo “Changing default ODM (PdAt) attributes for VendorXYZ storage.” ## set -x odmget -q uniq ## odmchange -o PdAt -q uniq ## odmget -q uniq ## odmchange -o PdAt -q uniq ## odmget -q uniq ## odmchange -o PdAt -q uniq ## set +x cd /
At this point I copy the same directory and all of its contents to the NIM client.
root@nim1 : /usr/local # scp –pr XYZ
lpar …etc…
lparaix01 : /usr/local/XYZ # ls -ltr total 0 -r-xr-xr-x 1 root system 51200 Mar 11 2011 MPIO_1001I -r-xr-xr-x 1 root system 51200 Mar 11 2011 MPIO_1002U -r-xr-xr-x 1 root system 51200 Mar 11 2011 MPIO_1003U -r-xr-xr-x 1 root system 51200 Mar 11 2011 MPIO_1004U -r-xr-xr-x 1 root system 51200 May 18 16:39 MPIO_1005U -r-xr-xr-x 1 root system 715 May 24 16:57 XYZpost.ksh -rw-r--r-- 1 root system 2310 May 25 14:57 .toc
Make sure that any scripts you write for use with nimadm start with an appropriate ‘hashbang’ to announce it is a shell script and the shell that must be used to execute it e.g. #!/usr/bin/ksh. If you forget to do this nimadm will fail to execute your script and will report an error message similar to the following:
+--- Executing nimadm phase 7. +--- Executing user chroot script
/usr /lpa
The next step is to define the script as a NIM resource so that nimadm can call the resource during the migration process. I’ve decided to call this new NIM resource, XYZPOST.
This is easily achieved using smit nim_mkres:
root@nim1 : / # smit nim_mkres
| script = an executable file which is executed on a client |
Define a Resource
Type or select values in entry fields. Press Enter AFTER making all desired changes.
*
Resource Nam *
Resource Typ * Server of Reso * Location of Reso
We can confirm that the NIM script resource is now available using the lsnim command.
root@nim1 : / # lsnim -t script XYZPOST resources script
root@nim1 : / # lsnim -l XYZPOST XYZPOST: class = resources type = script Rstate = ready for use prev_state = unavailable for use location
= /usr alloc_count = 0 server
= mast
Now that the script is in place, and defined to NIM, we are ready to test it. We will migrate the system from AIX 5.3 to AIX 6.1 using nimadm. Once the migration phase is complete (phases 1 to 6), the post-migration script will be executed in the NIM clients nimadm (chroot) environment on the NIM master. Once this is finished the NIM clients data is synced back to the NIM clients alternate disk and the boot image is created. The migration process is then complete.
We add the –z flag to our nimadm command line options to specify the post migration resource.
In normal operation we would simply let nimadm run all phases in sequence with the following command.
root@nim1 : / # nimadm -j nimadmvg -c lparaix01 -s spotaix610605 -l lpp_sourceaix610605 -d hdisk2 -z XYZPOST -Y
In our case we would like to test the post-migration script phase as a separate step.
We will start by running only the first 6 phases. We will stop at the completion of phase 6 and run phase 7 (post-migration script) manually, before moving on to phases 8 through 12.
You’ll observe that we have specified the –z option with the name of the NIM script resource and the –P flag with phases 1 to 6 only.
root@nim1 : / # nimadm -j nimadmvg -c lparaix01 -s spotaix610605 -l lpp_sourceaix610605 -d hdisk2 -z XYZPOST -P1,2,3,4,5,6 -Y Initializing the NIM master. Initializing NIM client lparaix01. Verifying alt_disk_migration eligibility. Initializing
log: /var Starting Alternate Disk Migration.
+--- Executing nimadm phase 1. +--- Cloning altinst_rootvg on client, Phase 1. Client alt_disk_install command: alt_disk_copy -j -M 6.1 -P1 -d "hdisk2" Calling mkszfile to create new /image.data file. ...etc... Filesets processed: 1 of 2 (Total time: 3 secs).
installp: COMMITTING software for: X11.
Finished processing all filesets. (Total time: 4 secs). ...etc... inst inst inst inst inst Known Recommended Maintenance Levels ---- Restoring device ODM database.
root@nim1 : / #
Phase 6 has completed successfully. The NIM clients rootvg data has been migrated from AIX 5.3 to 6.1 on the NIM master. The data has not yet been synced back to the NIM client.
At this stage we can now run phase 7 separately and ensure that it performs the required task. We expect it will de-install the device fileset, install the latest version and change the ODM default attributes for the device type. Again, you’ll notice that we specify the –P flag for phase 7 only.
Let’s test it.
root@nim1 : / # nimadm -j nimadmvg -c lparaix01 -s spotaix610605 -l lpp_sourceaix610605 -d hdisk2 -z XYZPOST -P7 -Y Initializing the NIM master. Initializing NIM client lparaix01. Initializing
log: /var Starting Alternate Disk Migration.
+--- Executing nimadm phase 7. +--- Executing
user chroot script /usr Uninstalling XYZ
ODM fileset: devi +--- Pre-deinstall Verification... +--- Verifying selections...done Verifying requisites...done Results...
FILESET STATISTICS ------------------ 1 Selected to be deinstalled, of which: 1 Passed pre-deinstall verification ---- 1 Total to be deinstalled
SUCCESSES --------- Filesets listed in this section passed pre-deinstall verification and will be removed.
Selected Filesets ----------------- devi
<< End of Success Section >>
+--- +---
installp: DEINSTALLING software for: devi
...etc... Installation Summary ---- Nam ---- devi Return code is: 0
Installing XYZ
ODM fileset: devi +--- Pre-installation Verification... +--- Verifying selections...done Verifying requisites...done Results...
FILESET STATISTICS ------------------ 1 Selected to be installed, of which: 1 Passed pre-installation verification ---- 1 Total to be installed
SUCCESSES --------- Filesets listed in this section passed pre-installation verification and will be installed.
Selected Filesets ----------------- devi
<< End of Success Section >>
+--- +---
installp: APPLYING software for: devi
.
. . . . << Copyright notice for devi ...etc... Installation Summary ---- Nam ---- devi Return code is: 0
Changing default ODM (PdAt) attributes for VendorXYZ storage
+
odmget
-q uniq + sed s/deflt = "2"/deflt = "32"/g +
1> /usr +
odmchange
-o PdAt -q uniq +
odmget
-q uniq + sed s/deflt = "single_path"/deflt = "no_reserve"/g +
1> /usr +
odmchange
-o PdAt -q uniq +
odmget
-q uniq + sed s/deflt = "fail_over"/deflt = "round_robin"/g +
1> /usr +
odmchange
-o PdAt -q uniq
root@nim1 : / #
Great news! Our script has worked as expected. The old fileset was de-installed, the new fileset was installed and the PdAt default attributes were changed successfully.
Note:
You can also review the post migration script output at a later
date if you wish. All nimadm
activities are logged, on the NIM master, to /var
With regard to nimadm
log files, please be aware that if you choose to run nimadm in phases (as I’ve shown in this example) that each run will
generate a new log file. So in my
case, when I ran phases 1 to 6, this created a log file named
lpar
Now we can complete the rest of the migration and execute the remaining phases, 8 through 12.
root@nim1 : / # nimadm -j nimadmvg -c lparaix01 -s spotaix610605 -l lpp_sourceaix610605 -d hdisk2 -z XYZPOST -P8,9,10,11,12 -Y Initializing the NIM master. Initializing NIM client lparaix01. Initializing
log: /var Starting Alternate Disk Migration.
+--- Executing nimadm phase 8. +--- Creating client boot image. bosboot: Boot image is 46989 512 byte blocks. Writing boot image to client's alternate boot disk hdisk2.
+--- Executing nimadm phase 9. +--- Adjusting client file system sizes ... Adjusting size for / Adjusting size for /admin Adjusting size for /home Adjusting size for /opt Adjusting size for /tmp Adjusting size for /usr Expanding /alt_inst/usr client filesystem. Filesystem size changed to 4325376 Adjusting size for /usr/local Adjusting size for /usr/local/chksys Adjusting size for /var Adjusting size for /var/log Adjusting size for /var/log/audit Adjusting size for /var/tsm/log Syncing cache data to client ...
+--- Executing nimadm phase 10. +--- Unmounting client mounts on the NIM master. forced
unmount of /lpa forced
unmount of /lpa forced
unmount of /lpa forced
unmount of /lpa forced
unmount of /lpa forced
unmount of /lpa forced
unmount of /lpa forced
unmount of /lpa forced
unmount of /lpa forced
unmount of /lpa Removing nimadm cache file systems. Removing
cache file system /lpa Removing
cache file system /lpa Removing
cache file system /lpa Removing
cache file system /lpa Removing
cache file system /lpa Removing
cache file system /lpa Removing
cache file system /lpa Removing
cache file system /lpa Removing
cache file system /lpa Removing
cache file system /lpa
+--- Executing nimadm phase 11. +--- Cloning altinst_rootvg on client, Phase 3. Client alt_disk_install command: alt_disk_copy -j -M 6.1 -P3 -d "hdisk2" ## Phase 3 ################### Verifying altinst_rootvg... Modifying ODM on cloned disk. forced
unmount of /alt forced unmount of /alt_inst/var/log forced unmount of /alt_inst/var forced unmount of /alt_inst/usr/local forced unmount of /alt_inst/usr forced unmount of /alt_inst/tmp forced unmount of /alt_inst/opt forced unmount of /alt_inst/home forced unmount of /alt_inst/admin forced unmount of /alt_inst Changing logical volume names in volume group descriptor area. Fixing LV control blocks... Fixing file system superblocks... Bootlist is set to the boot disk: hdisk2 blv=hd5
+--- Executing nimadm phase 12. +--- Cleaning up alt_disk_migration on the NIM master. Cleaning up alt_disk_migration on client lparaix01. root@nim1 : / #
Our nimadm operation is finished. The NIM client is rebooted. We verify it is now running AIX 6.1. And the correct version of the vendor’s device fileset is installed.
lparaix01 : / # oslevel -s 6100-06-05-1115
lparaix01
: / # lslpp -l devi File ---- Path: /usr/lib/objrepos devi
lparaix01 : / # lsdev -Cc disk hdisk1 Available 20-T1-01 VendorXYZ MPIO Disk hdisk2 Available 20-T1-01 VendorXYZ MPIO Disk hdisk3 Available 20-T1-01 VendorXYZ MPIO Disk hdisk4 Available 20-T1-01 VendorXYZ MPIO Disk
And there you have it, an example of using a post migration script with nimadm.
nimadm Command http |
Thanks Brian and Kris for your comments. Appreciated!