Topics: AIX, Backup & restore, NIM, System Admin
How to unconfigure items after mksysb recovery using NIM
There will be a situation where you want to test a mksysb recovery to a different host. The major issue with this is, that you bring up a server within the same network, that is a copy of an actual server that's already in your network. To avoid running into 2 exactly the same servers in your network, here's how you do this:
First make sure that you have a separate IP address available for the server to be recovered, for configuration on your test server. You definitely don't want to bring up a second server in your network with the same IP configuration.
Make sure you have a mksysb created of the server that you wish to recover onto another server. Then, create a simple script that disables all the items that you don't want to have running after the mksysb recovery, for example:
# cat /export/nim/cust_scripts/custom.ksh
#!/bin/ksh
# Save a copy of /etc/inittab
cp /etc/inittab /etc/inittab.org
# Remove unwanted entries from the inittab
rmitab hacmp 2>/dev/null
rmitab tsmsched 2>/dev/null
rmitab tsm 2>/dev/null
rmitab clinit 2>/dev/null
rmitab pst_clinit 2>/dev/null
rmitab qdaemon 2>/dev/null
rmitab sddsrv 2>/dev/null
rmitab nimclient 2>/dev/null
rmitab nimsh 2>/dev/null
rmitab naviagent 2>/dev/null
# Get rid of the crontabs
mkdir -p /var/spool/cron/crontabs.org
mv /var/spool/cron/crontabs/* /var/spool/cron/crontabs.org/
# Disable start scripts
chmod 000 /etc/rc.d/rc2.d/S01app
# copy inetd.conf
cp /etc/inetd.conf /etc/inetd.conf.org
# take out unwanted items
cat /etc/inetd.conf.org | grep -v bgssd > /etc/inetd.conf
# remove the hacmp cluster configuration
if [ -x /usr/es/sbin/cluster/utilities/clrmclstr ] ; then
/usr/es/sbin/cluster/utilities/clrmclstr
fi
# clear the error report
errclear 0
# clean out mail queue
rm /var/spool/mqueue/*
The next thing you need to do, is to configure this script as a 'script resource' in NIM. Run:
# smitty nim_mkresSelect 'script' and complete the form afterwards. For example, if you called it 'UnConfig_Script':
Then, when you are ready to perform the actual mksysb recovery using "smitty nim_bosinst", you can add this script resource on the following line:# lsnim -l UnConfig_Script UnConfig_Script: class = resources type = script comments = Rstate = ready for use prev_state = unavailable for use location = /export/nim/cust_scripts/custom.ksh alloc_count = 0 server = master
Customization SCRIPT to run after installation [UnConfig_Script]
Topics: AIX, Backup & restore, NIM, System Admin↑
Creating an image_data resource without preserving mirrors for use with NIM
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, for example: /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, for example: server1_image_data.
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/server1_image_data -a comments="image.data file with broken mirror for server1" server1_image_dataNOTE: "server1_image_data" is the name given to the 'image_data' resource.
Using smit on the NIM master:
# smit nim_mkresSelect 'image_data' as the Resource Type. Then complete the following screen:
Define a Resource
Type or select values in entry fields.
Press Enter AFTER making all desired changes.
[Entry Fields]
* Resource Name [server1_image_data]
* Resource Type image_data
* Server of Resource [master]
* Location of Resource [/export/nim/image_data/server1_image_data]
Comments []
Source for Replication []
Run the following command to make sure the 'image_data' resource was created:
# lsnim -t image_dataThe command will give output similar to the following:
Run the following command to get information about the 'image_data' resource:# lsnim -t image_data server1_image_data resources image_data
# lsnim -l server1_image_data server1_image_data: class = resources type = image_data Rstate = ready for use prev_state = unavailable for use location = /export/nim/image_data/server1_image_data alloc_count = 0 server = master
Create a new image.data file by running the following command:
Edit the image.data file to break the mirror, by running the following command:# cd / # mkszfile
# vi /image.dataWhat you are looking for are the "lv_data" stanzas. There will be one for every logical volume associated with rootvg.
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 bold:
lv_data: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.
VOLUME_GROUP= rootvg
LV_SOURCE_DISK_LIST= hdisk0 hdisk1
LV_IDENTIFIER= 00cead4a00004c0000000117b1e92c90.2
LOGICAL_VOLUME= hd6
VG_STAT= active/complete
TYPE= paging
MAX_LPS= 512
COPIES= 2
LPs= 124
STALE_PPs= 0
INTER_POLICY= minimum
INTRA_POLICY= middle
MOUNT_POINT=
MIRROR_WRITE_CONSISTENCY= off
LV_SEPARATE_PV= yes
PERMISSION= read/write
LV_STATE= opened/syncd
WRITE_VERIFY= off
PP_SIZE= 128
SCHED_POLICY= parallel
PP= 248
BB_POLICY= non-relocatable
RELOCATABLE= yes
UPPER_BOUND= 32
LABEL=
MAPFILE= /tmp/vgdata/rootvg/hd6.map
LV_MIN_LPS= 124
STRIPE_WIDTH=
STRIPE_SIZE=
SERIALIZE_IO= no
FS_TAG=
DEV_SUBTYP=
The following is an example of the same lv_data stanza after manually breaking the mirror. The lines that have been changed are marked bold. Edit each 'lv_data' stanza in the image.data file as shown below to break the mirrors.
lv_data: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.
VOLUME_GROUP= rootvg
LV_SOURCE_DISK_LIST= hdisk0
LV_IDENTIFIER= 00cead4a00004c0000000117b1e92c90.2
LOGICAL_VOLUME= hd6
VG_STAT= active/complete
TYPE= paging
MAX_LPS= 512
COPIES= 1
LPs= 124
STALE_PPs= 0
INTER_POLICY= minimum
INTRA_POLICY= middle
MOUNT_POINT=
MIRROR_WRITE_CONSISTENCY= off
LV_SEPARATE_PV= yes
PERMISSION= read/write
LV_STATE= opened/syncd
WRITE_VERIFY= off
PP_SIZE= 128
SCHED_POLICY= parallel
PP= 124
BB_POLICY= non-relocatable
RELOCATABLE= yes
UPPER_BOUND= 32
LABEL=
MAPFILE= /tmp/vgdata/rootvg/hd6.map
LV_MIN_LPS= 124
STRIPE_WIDTH=
STRIPE_SIZE=
SERIALIZE_IO= no
FS_TAG=
DEV_SUBTYP=
Save the edited image.data file. 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.
E.g.: 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 [/location] 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.
Note: If you don't want to edit the image.data file manually, here's a script that you can use to have it updated to a single disk for you, assuming your image_data file is called /image.data:
cat /image.data | while read LINE ; do
if [ "${LINE}" = "COPIES= 2" ] ; then
COPIESFLAG=1
echo "COPIES= 1"
else
if [ ${COPIESFLAG} -eq 1 ] ; then
PP=`echo ${LINE} | awk '{print $1}'`
if [ "${PP}" = "PP=" ] ; then
PPNUM=`echo ${LINE} | awk '{print $2}'`
((PPNUMNEW=$PPNUM/2))
echo "PP= ${PPNUMNEW}"
COPIESFLAG=0
else
echo "${LINE}"
fi
else
echo "${LINE}"
fi
fi
done > /image.data.1disk
Topics: AIX, Backup & restore, System Admin↑
How to restore an image.data file from an existing mksysb file
Change 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:
If you want to list the files in a mksysb image first, you can run the following command:# cd /tmp # restore -xqvf [/location/of/mksysb/file] ./image.data
# restore -Tqvf [/location/of/mksysb/file]
Restoring from tape:
First change the block size of the tape device to 512:
# chdev -l rmt0 -a block_size=512Check to make sure the block size of the tape drive has been changed:
# tctl -f /dev/rmt0 statusYou will receive output similar to this:
Change 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:rmt0 Available 09-08-00-0,0 LVD SCSI 4mm Tape Drive attribute value description user_settable block_size 512 BLOCK size (0=variable length) True compress yes Use data COMPRESSION True density_set_1 71 DENSITY setting #1 True density_set_2 38 DENSITY setting #2 True extfm yes Use EXTENDED file marks True mode yes Use DEVICE BUFFERS during writes True ret no RETENSION on tape change or reset True ret_error no RETURN error on tape change or reset True size_in_mb 36000 Size in Megabytes False
# cd /tmp # restore -s2 -xqvf /dev/rmt0.1 ./image.data
Topics: AIX, Backup & restore, Storage, System Admin↑
JFS2 snapshots
JFS2 filesystems allow you to create file system snapshots. Creating a snapshot is actually creating a new file system, with a copy of the metadata of the original file system (the snapped FS). The snapshot (like a photograph) remains
unchanged, so it's possible to backup the snapshot, while the original data can be used (and changed!) by applications. When data on the original file system changes, while a snapshot exists, the original data is copied to the snapshot to keep the snapshot in a consistant state. For these changes, you'll need temporary space, thus you need to create a snapshot of a specific size to allow updates while the snapshot exists. Usually 10% is enough. Database file systems are usually not a very good subject for creating snapshots, because all database files change constantly when the database is active, causing a lot of copying of data from the original to the snapshot file system.
In order to have a snapshot you have to:
- Create and mount a JFS2 file system (source FS). You can find it in SMIT as "enhanced" file system.
- Create a snapshot of a size big enough to hold the changes of the source FS by issuing smitty crsnap. Once you have created this snapshot as a logical device or logical volume, there's a read-only copy of the data in source FS. You have to mount this device in order to work with this data.
- Mount your snapshot device by issuing smitty mntsnap. You have to provide a directory name over which AIX will mount the snapshot. Once mounted, this device will be read-only.
# snapshot -o snapfrom=$FILESYSTEM -o size=${SNAPSIZE}MWhere $FILESYSTEM is the mount point of your file system and $SNAPSIZE is the amount of megabytes to reserve for the snapshot.
Check if a file system holds a snapshot:
# snapshot -q $FILESYSTEMWhen the snapshot runs full, it is automatically deleted. Therefore, create it large enough to hold all changed data of the source FS.
Mounting the snapshot:
Create a directory:
# mkdir -p /snapshot$FILESYSTEMFind the logical device of the snapshot:
# SNAPDEVICE=`snapshot -q $FILESYSTEM | grep -v ^Snapshots | grep -v ^Current | awk '{print $2}'`Mount the snapshot:
# mount -v jfs2 -o snapshot $SNAPDEVICE /snapshot$FILESYSTEMNow you can backup your data from the mountpoint you've just mounted.
When you're finished with the snapshot:
Unmount the snapshot filesystem:
# unmount /snapshot$FILESYSTEMRemove the snapshot:
# snapshot -d $SNAPDEVICERemove the mount point:
# rm -rf /snapshot$FILESYSTEMWhen you restore data from a snapshot, be aware that the backup of the snapshot is actually a different file system in your backup system, so you have to specify a restore destination to restore the data to.
If you wish to clone a system with a mksysb, then you can do so, but you do not want your cloned system to come up with the same TCP/IP information. Just issue rmtcpip before creating the mksysb, and you have a perfect image for cloning to another system. Be sure to issue this command at a terminal, as you will lose your network connection!
Topics: AIX, Backup & restore, System Admin↑
DVD-RAM Backup
You can use a DVD-RAM to create a system backup. To do so, enter:
# smitty mkdvdThis works in AIX 5.2 and above.
Sometimes, when you create an mksysb, you receive an error like this one:
/dev/ipldevice not foundDevice /dev/ipldevice is a hard link to the disk your system booted from. Mksysb tries to determine the size of the boot logical volume with the bosboot -qad /dev/ipldevice command. Via lslv -m hd5 you can see from which disk was booted (or via bootlist -m normal -o).
To resolve this problem: re-create the hard link yourself:
# ln /dev/bootdevice /dev/ipldeviceFor example:
ln /dev/rhdisk0 /dev/ipldeviceNote: Use "rhdisk" and not "hdisk".
Another way to solve this problem: reboot your system and the /dev/ipldevice will be created automatically for you (Your users may prefer the first solution...).
Topics: AIX, Backup & restore, System Admin↑
Restoring a mksysb of a mirrored rootvg to a non-mirrored rootvg
If you've created a mksysb of a mirrored rootvg and you wish to restore it to a system with only 1 disk in the rootvg, you can go about it as follows:
Create a new /image.data file, run:
# mkszfile -mChange the image.data file:
# vi /image.dataIn each lv_data stanza of this file, change the values of the COPIES= line by one-half (i.e. copies = 2, change to copies = 1). Also change the PPs to match the LPs as well.
Create a new mksysb, utilizing the /image.data file:
# mksysb /dev/rmt0(Do not use smit and do not run with the -i flag, both will generate a new image.data file).
Use this mksysb to restore your system on another box without mirroring.


