Você está na página 1de 10

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: devices.fcp.disk.VendorXYZ.mpio.rte.”
installp -u devices.fcp.disk.VendorXYZ.mpio.rte
echo Return code is: $?

1
echo echo “Installing XYZ ODM fileset: devices.fcp.disk.VendorXYZ.mpio.rte.”
cd /usr/local/XYZ/
installp -aXd . devices.fcp.disk.VendorXYZ.mpio.rte
echo Return code is: $?
##
echo “Changing default ODM (PdAt) attributes for VendorXYZ storage.”
##
set -x
odmget -q uniquetype="disk/fcp/xyzmpio and attribute=queue_depth" PdAt |sed s/deflt\
=\ \"2\"/deflt\ =\ \"32\"/g >/usr/local/XYZ/chg_pdat_qd
##
odmchange -o PdAt -q uniquetype="disk/fcp/xyzmpio and attribute=queue_depth" /usr/local/
XYZ/chg_pdat_qd
##
odmget -q uniquetype="disk/fcp/xyzmpio and attribute=reserve_policy" PdAt |sed s/deflt\
=\ \"single_path\"/deflt\ =\ \"no_reserve\"/g >/usr/local/XYZ/chg_pdat_rp
##
odmchange -o PdAt -q uniquetype="disk/fcp/xyzmpio and attribute=reserve_policy" /usr/local/
XYZ/chg_pdat_rp
##
odmget -q uniquetype="PCM/friend/VendorXYZ and attribute=algorithm" PdAt |sed s/deflt\
=\ \"fail_over\"/deflt\ =\ \"round_robin\"/g> /usr/local/XYZ/chg_pdat_al
##
odmchange -o PdAt -q uniquetype="PCM/friend/VendorXYZ and attribute=algorithm" /usr/
local/XYZ/chg_pdat_al
##
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 lparaix01:/usr/local/
…etc…

lparaix01 : /usr/local/XYZ # ls -ltr


-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

2
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/local/XYZ/XYZpost.ksh.
/lparaix01_alt/alt_inst/tmp/.alt_mig_chroot_script.11731036: Cannot run a file that does not have
a valid format.

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.
[Entry Fields]
* Resource Name [XYZPOST]
* Resource Type script
* Server of Resource [master] +
* Location of Resource [/usr/local/XYZ/XYZpost.ksh] /

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/local/XYZ/XYZpost.ksh
alloc_count = 0
server = master

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

3
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/adm/ras/alt_mig/lparaix01_alt_mig.log
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.compat.lib.X11R6_motif 6.1.6.15

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


...etc...
install_all_updates: Checking for recommended maintenance level 6100-06.
install_all_updates: Executing /usr/bin/oslevel -rf, Result = 6100-06
install_all_updates: Verification completed.
install_all_updates: Log file is /var/adm/ras/install_all_updates.log
install_all_updates: Result = SUCCESS

4
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/adm/ras/alt_mig/lparaix01_alt_mig.log
Starting Alternate Disk Migration.

+-----------------------------------------------------------------------------+
Executing nimadm phase 7.
+-----------------------------------------------------------------------------+
Executing user chroot script /usr/local/XYZ/XYZpost.ksh.
Uninstalling XYZ ODM fileset: devices.fcp.disk.VendorXYZ.mpio.rte
+-----------------------------------------------------------------------------+
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.

5
Selected Filesets
-----------------
devices.fcp.disk.VendorXYZ.mpio.rte 1.2.0.0 # AIX MPIO Support for VendorXYZ Disk

<< End of Success Section >>

+-----------------------------------------------------------------------------+
Deinstalling Software...
+-----------------------------------------------------------------------------+

installp: DEINSTALLING software for:


devices.fcp.disk.VendorXYZ.mpio.rte 1.2.0.0

...etc...
Installation Summary
--------------------
Name Level Part Event Result
-------------------------------------------------------------------------------
devices.fcp.disk.VendorXYZ.mpio 1.2.0.0 USR DEINSTALL SUCCESS
Return code is: 0

Installing XYZ ODM fileset: devices.fcp.disk.VendorXYZ.mpio.rte


+-----------------------------------------------------------------------------+
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
-----------------
devices.fcp.disk.VendorXYZ.mpio.rte 1.4.0.0 # AIX MPIO Support for VendorXYZ Disk

6
<< End of Success Section >>

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

installp: APPLYING software for:


devices.fcp.disk.VendorXYZ.mpio.rte 1.4.0.0

. . . . . << Copyright notice for devices.fcp.disk.VendorXYZ.mpio >> . . . . . . .


...etc...
Installation Summary
--------------------
Name Level Part Event Result
-------------------------------------------------------------------------------
devices.fcp.disk.VendorXYZ.mpio 1.4.0.0 USR APPLY SUCCESS
Return code is: 0

Changing default ODM (PdAt) attributes for VendorXYZ storage

+ odmget -q uniquetype=disk/fcp/xyzmpio and attribute=queue_depth PdAt


+ sed s/deflt = "2"/deflt = "32"/g
+ 1> /usr/local/XYZ/chg_pdat_qd
+ odmchange -o PdAt -q uniquetype=disk/fcp/xyzmpio and attribute=queue_depth
/usr/local/XYZ/chg_pdat_qd
+ odmget -q uniquetype=disk/fcp/xyzmpio and attribute=reserve_policy PdAt
+ sed s/deflt = "single_path"/deflt = "no_reserve"/g
+ 1> /usr/local/XYZ/chg_pdat_rp
+ odmchange -o PdAt -q uniquetype=disk/fcp/xyzmpio and attribute=reserve_policy
/usr/local/XYZ/chg_pdat_rp
+ odmget -q uniquetype=PCM/friend/VendorXYZ and attribute=algorithm PdAt
+ sed s/deflt = "fail_over"/deflt = "round_robin"/g
+ 1> /usr/local/XYZ/chg_pdat_al
+ odmchange -o PdAt -q uniquetype=PCM/friend/VendorXYZ and attribute=algorithm
/usr/local/XYZ/chg_pdat_al

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/adm/ras/alt_mig/NIMclientname_alt_mig.log
(where NIMclientname is the name of the NIM client being migrated by nimadm).

7
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 lparaix01_alt_mig.log. When I ran phase 7, the original
log file was moved to lparaix01_alt_mig.log.prev. A new log file was created and used for phase 7.
Then when I ran phases 8 to 12, the phase 7 log file was moved to lparaix01_alt_mig.log.prev and
a new log file was used for phases 8-12. For this reason you may want to backup each log file to a
unique file name as you execute each phase group, so that you do not lose any of the information
logged to the .log or .log.prev files.

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/adm/ras/alt_mig/lparaix01_alt_mig.log
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 ...

8
+-----------------------------------------------------------------------------+
Executing nimadm phase 10.
+-----------------------------------------------------------------------------+
Unmounting client mounts on the NIM master.
forced unmount of /lparaix01_alt/alt_inst/var/log/audit
forced unmount of /lparaix01_alt/alt_inst/var/log
forced unmount of /lparaix01_alt/alt_inst/var
forced unmount of /lparaix01_alt/alt_inst/usr/local
forced unmount of /lparaix01_alt/alt_inst/usr
forced unmount of /lparaix01_alt/alt_inst/tmp
forced unmount of /lparaix01_alt/alt_inst/opt
forced unmount of /lparaix01_alt/alt_inst/home
forced unmount of /lparaix01_alt/alt_inst/admin
forced unmount of /lparaix01_alt/alt_inst
Removing nimadm cache file systems.
Removing cache file system /lparaix01_alt/alt_inst
Removing cache file system /lparaix01_alt/alt_inst/admin
Removing cache file system /lparaix01_alt/alt_inst/home
Removing cache file system /lparaix01_alt/alt_inst/opt
Removing cache file system /lparaix01_alt/alt_inst/tmp
Removing cache file system /lparaix01_alt/alt_inst/usr
Removing cache file system /lparaix01_alt/alt_inst/usr/local
Removing cache file system /lparaix01_alt/alt_inst/var
Removing cache file system /lparaix01_alt/alt_inst/var/log
Removing cache file system /lparaix01_alt/alt_inst/var/log/audit

+-----------------------------------------------------------------------------+
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_inst/var/log/audit
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

9
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 devices.fcp.disk.VendorXYZ.mpio.rte


Fileset Level State Description
----------------------------------------------------------------------------
Path: /usr/lib/objrepos
devices.fcp.disk.VendorXYZ.mpio.rte
1.4.0.0 COMMITTED AIX MPIO Support for VendorXYZ Disk

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.

10

Você também pode gostar