Friday, November 18, 2011

HPUX LVM mirror


System Administration Guide for HP-UX 10.20
Part 4 - LVM Disk Mirroring

This note describes how to integrate a second disk into the system volume group and configure it as an alternative boot device, thereby providing LVM mirrored backup for the primary boot device.
Introduction
This note describes how to configure LVM mirroring of a system disk. In this particular example, the HP server is STSRV1, the primary boot device is SCSI=6 (/dev/dsk/c2t6d0) and the alternative mirrored boot device is SCSI=5 (/dev/dsk/c2t5d0). The following commands may be found in /sbin and /usr/sbin must be run as root.
Procedure - Create a System Mirror Disk
This procedure assumes that the HPUX-10.## Operating system and the HPUX LVM mirroring product has already been installed.

# ioscan -fnC disk                                         (identify mirror disk)
# pvcreate -Bf /dev/rdsk/c2t5d0                            (make a bootable physical volume)
# mkboot -l /dev/rdsk/c2t5d0                               (create LVM disk layout)
# mkboot -a "hpux -lq (;0)/stand/vmunix" /dev/rdsk/c2t5d0  (-lq = switch off quorum)
# vgextend /dev/vg00 /dev/dsk/c2t5d0


# for P in 1 2 3 4 5 6 7 8 9 10
> do
> lvextend -m 1 /dev/vg00/lvol$P /dev/dsk/c2t5d0
> sleep 1
> done
Following the mirroring procedure, it is now essential to setup the critical partitions concerning root, swap and boot. It is useful to confirm the partition layout using the commands bdf and lvlnboot.

# bdf -l
# lvlnboot –v
Following changes seen under HPUX-10.20, the / (root) partition will appear first in the listings as /dev/vg00/lvol3 and the /stand (boot) partition will probably be reported as "PV Name" and /dev/vg00/lvol1. The first command below is destructive, in that it removes the "PV Name" boot entry. It should therefore be reinserted using the lvlnboot -b command below. Exercise extreme care with the following commands.

# lvlnboot -r /dev/vg00/lvol3                      (prepare a root LVM logical volume)
# lvlnboot -s /dev/vg00/lvol2                      (prepare a swap LVM logical volume)
# lvlnboot -b /dev/vg00/lvol1                      (prepare a boot LVM logical volume)
# vgcfgbackup vg00
# lifls -C /dev/rdsk/c2t5d0                        (confirms as a boot device)



Disk Crash - D-Class Procedure (Fast Recovery - Hot-Swap Disk )
The example below assumes that the system disk (/dev/dsk/c0t5d0) has crashed and has been replaced by a hot-swap disk (ie. It is not necessary to halt or boot the server). The procedure would be just the same for the mirrored disk as follows :

# pvcreate -Bf /dev/rdsk/c0td50
# vgcfgrestore -n /dev/vg00 /dev/rdsk/c0td50
# vgchange -a y /dev/vg00
# pvcreate -Bf /dev/rdsk/c2t5d0                            (make a bootable physical volume)
# mkboot -l /dev/rdsk/c2t5d0                               (create LVM disk layout)
# mkboot -a "hpux -lq (;0)/stand/vmunix" /dev/rdsk/c2t5d0  (-lq = switch off quorum)
# vgsync /dev/vg00
[NB. It will only be necessary to run the mkboot commands above if it is a system disk replacement.]

When the synchronisation of the logical volumes is complete, reconfirm the following :

# lvlnboot -r /dev/vg00/lvol3                      (prepare a root LVM logical volume)
# lvlnboot -s /dev/vg00/lvol2                      (prepare a swap LVM logical volume)
# lvlnboot -b /dev/vg00/lvol1                      (prepare a boot LVM logical volume)
# vgcfgbackup vg00



Disk Crash - Night Procedure (Fast Recovery - No Disk Replacement)
The example below assumes that the system disk (/dev/dsk/c2t6d0) has crashed and has NOT been replaced. The procedure, however, would be just the same for a mirrored disk crash with the exception of the change in device name. Due to the quorum philosophy, in that half the disk space is now no longer available, it is necessary to boot up in single-user mode with the quorum argument unset as follows :
1.Escape from boot sequence
2. Choose mirrored disk (ie. P0 = /dev/dsk/c2td50)
3. Boot up in single user mode, without quorum, as follows :

... Select from menu : b P0 isl

ISL > hpux -is -lq (;0)/stand/vmunix


# init 4



Disk Crash - Day Procedure (Slow Recovery - Intrnal Disk Replacement)
The example below assumes that the system disk (/dev/dsk/c2t6d0) has crashed and been replaced. The procedure, however, would be just the same for a mirrored disk crash with the exception of the change in device name. Due to the quorum philosophy, in that half the disk space is now not available, it is necessary to boot up in single-user mode with the quorum argument unset as follows :
1. Escape from boot sequence
2. Choose mirrored disk (ie. P0 = /dev/dsk/c2td50)
3. Boot up in single user mode, without quorum, as follows :

... Select from menu : b p0 isl

ISL > hpux -is -lq (;0)/stand/vmunix


# PATH=$PATH:/sbin:/usr/sbin
# mount -a
# pvcreate -Bf /dev/rdsk/c2t6d0
# mkboot -l /dev/rdsk/c2t6d0
# mkboot -a "hpux (;0) /stand/vmunix" /dev/rdsk/c2t6d0
# vgcfgrestore -n /dev/vg00 /dev/rdsk/c2td60
# vgchange -a y /dev/vg00
# lvlnboot -r /dev/vg00/lvol3                      (prepare a root LVM logical volume)
# lvlnboot -s /dev/vg00/lvol2                      (prepare a swap LVM logical volume)
# lvlnboot -b /dev/vg00/lvol1                      (prepare a boot LVM logical volume)
# init 4

The machine will now boot up correctly and the disks will synchronize automatically. The replaced system disk will now mirror automatically from the original mirrored disk. There will be considerable disk activity at this time and the progress of the mirroring may be confirmed with :

# lvdisplay -v /dev/vg00/lvol1
This will probably show that the first volume is "current" and therefore successfully mirrored.

# lvdisplay -v /dev/vg00/lvol8
This will almost certainly show that the volume is "stale" and therefore not yet mirrored. When the disks are synchronized, reboot the machine, thereby ensuring that the future is secure and the original "primary boot path" is valid.

Procedure - Remove a Mirrored System DiskEssentially the reverse of the procedure above.


# for P in 1 2 3 4 5 6 7 8 9 10
> do
> lvreduce -m 0 /dev/vg00/lvol$P /dev/dsk/c2t5d0
> sleep 1
> done
# vgreduce /dev/vg00 /dev/dsk/c2t5d0

No comments:

UNIX: How to print column nicely using printf

[user@hostfwnms1-oam tmp]# cat b.sh printf "%-26s %-19s %-8s %-8s %-s %-s\n" HOSTNAME IP PING SNMPWALK 0-ok 1-fail for i in `cat n...