In this section, we're going to do some work with XP 256 disks. We want to create ten volume groups with five primary disks and five alternate disks per volume group. Let's take a look at the file that contains the physical disks to be used for the primary and alternate paths on the XP 256. The XP 256 is an advanced storage device that has in it the capability to fail over to an alternate controller, should the primary controller fail. The same set of disks are connected to the primary and alternate controllers, but the disks are given two different sets of device files. One set is for the disks when connected to the primary controller and the second set is for the same disks when connected to the alternate controller. This is the same concept that you may have come across if you are a ServiceGuard user. There are a set of disks connected through two different paths, so you must define the disks with different names depending on whether they are connected through the primary or alternate path. The following is a listing of the file pri, containing the primary disks in groups of five: c9t0d0 c9t0d1 c9t0d2 c8t0d0 c8t0d1 c7t0d0 c7t0d1 c7t0d2 c10t0d0 c10t0d1 c9t0d3 c9t0d4 c9t0d5 c8t0d3 c8t0d4 c7t0d3 c7t0d4 c7t0d5 c10t0d3 c10t0d4 c9t0d6 c9t0d7 c9t1d0 c8t0d6 c8t0d7 c7t0d6 c7t0d7 c7t1d0 c10t0d6 c10t0d7 c9t1d1 c9t1d2 c9t1d3 c8t1d1 c8t1d2 c7t1d1 c7t1d2 c7t1d3 c10t1d1 c10t1d2 c9t1d4 c9t1d5 c9t1d6 c8t1d4 c8t1d5 c7t1d4 c7t1d5 c7t1d6 c10t1d4 c10t1d5 Notice that in this listing, the disks have been grouped in fives. Each group of five disks will constitute a volume group. There are a total of 10 groups of five disks that will be placed in volume groups vgu01 through vgu10. There will also be an alternate group of five disks. The alternate disks will be used in the event of a disk controller failover as described earlier. The following is a listing of the file alt, which contains a list of alternate disks in groups of five: c8t8d0 c8t8d1 c8t8d2 c9t8d0 c9t8d1 c10t8d0 c10t8d1 c10t8d2 c7t8d0 c7t8d1 c8t8d3 c8t8d4 c8t8d5 c9t8d3 c9t8d4 c10t8d3 c10t8d4 c10t8d5 c7t8d3 c7t8d4 c8t8d6 c8t8d7 c8t9d0 c9t8d6 c9t8d7 c10t8d6 c10t8d7 c10t9d0 c7t8d6 c7t8d7 c8t9d1 c8t9d2 c8t9d3 c9t9d1 c9t9d2 c10t9d1 c10t9d2 c10t9d3 c7t9d1 c7t9d2 c8t9d4 c8t9d5 c8t9d6 c9t9d4 c9t9d5 c10t9d4 c10t9d5 c10t9d6 c7t9d4 c7t9d5 There are a total of 10 groups of alternate disks shown in this listing that will also be part of volume groups vgu01 through vgu10. Using these primary and alternate disks that have been set up on the XP 256, we'll set up the appropriate volumes on the host system. In this example, the host system is a V-Class system. Let's now cover the steps to create one of these volume groups. First, we'll create a physical volume for each of the disks in the volume group with the pvcreate command. Next, we'll create a directory for the volume group with mkdir, then we'll create a device special file for the volume group within the directory with mknod. This will set up the directory and special file required for the first of the 10 volume groups. Then we'll create the volume group in which the five primary disks will be contained using vgcreate. We'll specify the first disk when we create the volume group and then include the other disks in the volume group with vgextend. Then we extend the volume group with vgextend to include the five alternate disks. The final step is to create a single logical volume for the entire volume group. You might want to create several logical volumes within a volume group, but in our example, we need only one logical volume that consumes the entire capacity of the volume group, which is 8755 physical extents. The following procedure is the list of manual steps to create the first volume group: # pvcreate /dev/rdsk/c9t0d0 # run for each of the 5 pri disks # mkdir /dev/vgu01 # make dir for first vol group # mknod /dev/vgu01/group -c 64 0x01000 # create special file with major and minor numbers shown # vgcreate /dev/vgu01 /dev/dsk/c9t0d0 # Place first disk in volume group # vgextend /dev/vgu01 /dev/dsk/c9t0d1 # extend volume with remaining four primary disks disks # vgextend /dev/vgu01 /dev/dsk/c8t8d0 # extend volume group to include five alternte disks # lvcreate -l 8755 /dev/vgu01 # creates lvol1 (lvol1 by default) that consumes all 8755 extents We completed the procedure for only one disk, and there are nine additional disks in this volume group. In addition, there are another nine volume groups for which this procedure must be completed. That is a total of an additional 99 disks for which various commands must be run. There is a lot of room for error with that much typing involved so this is an ideal process to automate. -- Read this only if you wish to see how to automate the procedure -- Since there area primary set of disks and an alternate set of disks we'll write a short program to automate each procedure. The following program performs all of the steps required to create a physical volume for each disk, create a volume group, and include the primary disks in it: #!/bin/ksh set -x ;set tracing on vgnum=$1 ;first item on each line is the volume group no. shift ;shift to get to first disk for i in $* ;run pvcreate for every disk name in first line do pvcreate /dev/rdsk/$i done reada ;pause program to view what has been run mkdir /dev/vgu$vgnum ;mkdir for volume group mknod /dev/vgu$vgnum/group c 0x$(vgnum)0000 ;mknod for volume group vgcreate /dev/vgu$vgnum /dev/dsk/$1 ;vgcreate 1st disk in vg shift ;shift over to second disk for i in $* ;extend volume group to include remaining four disks do vgextend /dev/vgu$vgnum /dev/dsk/$i done lvcreate -l 8755 /dev/vgu$vgnum ;create single log vol for entire vg I use set -x in this file to turn on execution tracing. I always do this when first debugging a shell program so I can see that the lines in the shell program as they are executed. The line being executed will appear with a "+" in front of it, followed by what you would normally see when the program is run. The read a is a way of pausing the program to wait for input so I can review what has been run to that point of the program. In order for this program to run, we must slightly modify the file containing the primary disk devices and add the volume group number to the beginning of each line. In addition, I decided to call the program from the file that has the primary disks in it and operate on one line of disks at a time. The following listing shows the updated file containing the name of the shell program in the previous listing (vg.sh), followed by the volume group number and then the list of five primary disks names for each volume group: #vg.sh 01 c9t0d0 c9t0d1 c9t0d2 c8t0d0 c8t0d1 #read a #vg.sh 02 c7t0d0 c7t0d1 c7t0d2 c10t0d0 c10t0d1 #read a #vg.sh 03 c9t0d3 c9t0d4 c9t0d5 c8t0d3 c8t0d4 #read a #vg.sh 04 c7t0d3 c7t0d4 c7t0d5 c10t0d3 c10t0d4 #read a #vg.sh 05 c9t0d6 c9t0d7 c9t1d0 c8t0d6 c8t0d7 #read a #vg.sh 06 c7t0d6 c7t0d7 c7t1d0 c10t0d6 c10t0d7 #read a #vg.sh 07 c9t1d1 c9t1d2 c9t1d3 c8t1d1 c8t1d2 #read a #vg.sh 08 c7t1d1 c7t1d2 c7t1d3 c10t1d1 c10t1d2 #read a #vg.sh 09 c9t1d4 c9t1d5 c9t1d6 c8t1d4 c8t1d5 #read a #vg.sh 10 c7t1d4 c7t1d5 c7t1d6 c10t1d4 c10t1d5 The read a between lines of this file will pause and wait for you to enter a Return before the next line will be executed. I did this in case I decided to run several lines and I wanted to check the results between the execution of lines. We can now uncomment the first line of the file and type the file name pri, which will call vg.sh and run the program (you must give appropriate permissions to the files and make sure both vg.sh and pri are executable.) I like to run such files one line at a time and check the volume groups as they are created. The script is written to run one line at a time but is easily modifiable to run all ten lines. We need to do much less work with the alternate disk names. The physical volumes have already been created, and the volume group and single logical volume have already been set up in vg.sh. We'll create another script called vga.sh, "a" for alternate), in which we'll extend the volume group to include the alternate name for each disk. This script is shown in the listing below: #!/bin/ksh set -x ;set tracing on vgnum=$1 ;first item on each line is the volume group number shift ;shift to get to first disk for i in $* ;extend vol group to include all five disks on line vgextend /dev/vgu$vgnum /dev/dsk/$i done This script performs only the task of extending the volume group vgnum to include all five disks that appear on the line. Much like the file pri, the file alt will call the script vga.alt, as shown in the following listing: #vga.sh 01 c8t8d0 c8t8d1 c8t8d2 c9t8d0 c9t8d1 #vga.sh 02 c10t8d0 c10t8d1 c10t8d2 c7t8d0 c7t8d1 #vga.sh 03 c8t8d3 c8t8d4 c8t8d5 c9t8d3 c9t8d4 #vga.sh 04 c10t8d3 c10t8d4 c10t8d5 c7t8d3 c7t8d4 #vga.sh 05 c8t8d6 c8t8d7 c8t9d0 c9t8d6 c9t8d7 #vga.sh 06 c10t8d6 c10t8d7 c10t9d0 c7t8d6 c7t8d7 #vga.sh 07 c8t9d1 c8t9d2 c8t9d3 c9t9d1 c9t9d2 #vga.sh 08 c10t9d1 c10t9d2 c10t9d3 c7t9d1 c7t9d2 #vga.sh 09 c8t9d4 c8t9d5 c8t9d6 c9t9d4 c9t9d5 #vga.sh 10 c10t9d4 c10t9d5 c10t9d6 c7t9d4 c7t9d5 You would uncomment the line for which you wanted to run the script. Again, you could run all ten lines, but I like to check what has taken place after each line has been run. You could add read a between the lines of this file if you wanted to run several lines and have a pause between them to check the results. These two scripts automate a lot of typing. There are 100 disks for which commands must be run as well as other Logical Volume Manager commands. This is the type of HP-UX system administration task that is ideally suited to shell programming. ----------- End of Automated Procedure ----------- I completed the steps that had to be run for the additional disks to complete the work, such as the vgcreate for the additional four disks and the vgextend for the additional nine disk devices. I included only the first disk in the examples so you could see the initial step that had to be run. We don't have to set up any RAID levels within the primary or alternate volume because this is being done internally to the XP 256. The following vgdisplay listing shows the disks we set up for volume group vgu01 with both the group of five primary and alternate disks: # vgdisplay /dev/vgu01 -v VG Name /dev/vgu01 VG Write Access read/write VG Status available Max LV 255 Cur LV 1 Open LV 1 Max PV 16 Cur PV 5 Act PV 5 Max PE per PV 1751 VGDA 10 PE Size (Mbytes) 4 Total PE 8755 Alloc PE 8755 Free PE 0 Total PVG 0 Total Spare PVs 0 Total Spare PVs in use 0 --- Logical volumes --- LV Name /dev/vgu01/lvol1 LV Status available/syncd LV Size (Mbytes) 35020 Current LE 8755 Allocated PE 8755 Used PV 5 --- Physical volumes --- PV Name /dev/dsk/c9t0d0 PV Name /dev/dsk/c8t8d0Alternate Link PV Status available Total PE 1751 Free PE 0 PV Name /dev/dsk/c9t0d1 PV Name /dev/dsk/c8t8d1Alternate Link PV Status available Total PE 1751 Free PE 0 PV Name /dev/dsk/c9t0d2 PV Name /dev/dsk/c8t8d2Alternate Link PV Status available Total PE 1751 Free PE 0 PV Name /dev/dsk/c8t0d0 PV Name /dev/dsk/c9t8d0Alternate Link PV Status available Total PE 1751 Free PE 0 PV Name /dev/dsk/c8t0d1 PV Name /dev/dsk/c9t8d1Alternate Link PV Status available Total PE 1751 Free PE 0 There are some points of interest to cover in this vgdisplay. The first is that there is a primary and an alternate path to the same disk because we defined them earlier. For instance, the first disk in the volume group has a primary pathname of c9t0d0 and an alternate pathname of c8t8d0. Next, both the volume group vgu01 and the only logical volume in it, lvol1, consist of a total of 8755 PE or physical extents (the size of the volume group is PE x PE size, or 8755 x 4MB in our case). We should also check one logical volume on vgu01, called lvol1.We can check the parameters of this logical volume with the lvdisplay command as shown in the following example: # lvdisplay -v /dev/vgu01/l* --- Logical volumes --- LV Name /dev/vgu01/lvol1 VG Name /dev/vgu01 LV Permission read/write LV Status available/syncd Mirror copies 0 Consistency Recovery MWC Schedule parallel LV Size (Mbytes) 35020 Current LE 8755 Allocated PE 8755 Stripes 0 Stripe Size (Kbytes) 0 Bad block on Allocation strict IO Timeout (Seconds) default --- Distribution of logical volume --- PV Name LE on PV PE on PV /dev/dsk/c9t0d0 1751 1751 /dev/dsk/c9t0d1 1751 1751 /dev/dsk/c9t0d2 1751 1751 /dev/dsk/c8t0d0 1751 1751 /dev/dsk/c8t0d1 1751 1751 --- Logical extents --- LE PV1 PE1 Status 1 00000 /dev/dsk/c9t0d0 00000 current 00001 /dev/dsk/c9t0d0 00001 current 00002 /dev/dsk/c9t0d0 00002 current 00003 /dev/dsk/c9t0d0 00003 current 00004 /dev/dsk/c9t0d0 00004 current 00005 /dev/dsk/c9t0d0 00005 current 00006 /dev/dsk/c9t0d0 00006 current 00007 /dev/dsk/c9t0d0 00007 current 00008 /dev/dsk/c9t0d0 00008 current 00009 /dev/dsk/c9t0d0 00009 current 00010 /dev/dsk/c9t0d0 00010 current 00011 /dev/dsk/c9t0d0 00011 current 00012 /dev/dsk/c9t0d0 00012 current 00013 /dev/dsk/c9t0d0 00013 current 00014 /dev/dsk/c9t0d0 00014 current 00015 /dev/dsk/c9t0d0 00015 current 00016 /dev/dsk/c9t0d0 00016 current 00017 /dev/dsk/c9t0d0 00017 current 00018 /dev/dsk/c9t0d0 00018 current 00019 /dev/dsk/c9t0d0 00019 current 00020 /dev/dsk/c9t0d0 00020 current 00021 /dev/dsk/c9t0d0 00021 current 00022 /dev/dsk/c9t0d0 00022 current 00023 /dev/dsk/c9t0d0 00023 current 00024 /dev/dsk/c9t0d0 00024 current 00025 /dev/dsk/c9t0d0 00025 current 00026 /dev/dsk/c9t0d0 00026 current 00027 /dev/dsk/c9t0d0 00027 current 00028 /dev/dsk/c9t0d0 00028 current 00029 /dev/dsk/c9t0d0 00029 current 00030 /dev/dsk/c9t0d0 00030 current 00031 /dev/dsk/c9t0d0 00031 current 00032 /dev/dsk/c9t0d0 00032 current . . . 08733 /dev/dsk/c8t0d1 01729 current 08734 /dev/dsk/c8t0d1 01730 current 08735 /dev/dsk/c8t0d1 01731 current 08736 /dev/dsk/c8t0d1 01732 current 08737 /dev/dsk/c8t0d1 01733 current 08738 /dev/dsk/c8t0d1 01734 current 08739 /dev/dsk/c8t0d1 01735 current 08740 /dev/dsk/c8t0d1 01736 current 08741 /dev/dsk/c8t0d1 01737 current 08742 /dev/dsk/c8t0d1 01738 current 08743 /dev/dsk/c8t0d1 01739 current 08744 /dev/dsk/c8t0d1 01740 current 08745 /dev/dsk/c8t0d1 01741 current 08747 /dev/dsk/c8t0d1 01743 current 08746 /dev/dsk/c8t0d1 01742 current 08748 /dev/dsk/c8t0d1 01744 current 08749 /dev/dsk/c8t0d1 01745 current 08750 /dev/dsk/c8t0d1 01746 current 08751 /dev/dsk/c8t0d1 01747 current 08752 /dev/dsk/c8t0d1 01748 current 08753 /dev/dsk/c8t0d1 01749 current 08754 /dev/dsk/c8t0d1 01750 current This listing has been abbreviated where the three dots are shown. Only the beginning of the first disk and end of the last disk are shown. The lvdisplay does indeed show the five primary disks of which the logical volume is comprised. The final step is to place a file system on the logical volume we set up in vgu00. This is a task for which SAM is ideally suited. Figure 9-2 shows the SAM screen shot of the logical volumes we created. There is one logical volume created for each of the ten volume groups. Figure 9-2. lvol1 on vgu01 through vgu10 lvol1 appears for volume groups vgu01 through vgu10. We want a file system on each of the logical volumes for the application we are running. Although we could issue the appropriate commands at the command line, we'll use SAM for this task. Figure 9-3 shows the SAM screen used to add a file system to one of the logical volumes: Figure 9-3. Adding a File System to lvol1 on vgu01 We have selected lvol1 on vgu01 to add a file system as shown in this figure. Next, we want to modify the defaults for the logical volume as shown in Figure 9-4: Figure 9-4. Modify Filesystem Defaults We want to be sure to Allow Large Files in this screen because we'll be running a database application that creates many large files. If we were to create a filesystem without large files, we could use the fsadm command to convert to large files if we're running Online JFS. We want to mount this file system now and at the time of system boot so an entry gets made in /etc/ fstab for us. Figure 9-5 shows the result of having created the ten filesystems on the ten logical volumes: Figure 9-5. Ten VxFS File Systems on Ten Logical Volumes Using SAM, we created ten VxFS filesystems on all ten lvol1s. We had to create all ten individually in SAM, so this may have been a good candidate for automating with a shell program. SAM automatically adds these entries to /etc/fstab because we specified them to be mounted both now and at the time of system boot, as shown in the following listing: # System /etc/fstab file. Static information about the file systems # See fstab(4) and sam(1M) for further details on configuring devices. /dev/vg00/lvol3 / vxfs delaylog 0 1 /dev/vg00/lvol1 /stand hfs defaults 0 1 /dev/vg00/lvol4 /opt vxfs delaylog 0 2 /dev/vg00/lvol5 /tmp vxfs delaylog 0 2 /dev/vg00/lvol6 /usr vxfs delaylog 0 2 /dev/vg00/lvol7 /var vxfs delaylog 0 2 /dev/vg00/lvol8 /home vxfs delaylog 0 2 /dev/vg00/lvol9 ... swap pri=0 0 0 /dev/vgapp/lvol1 /app vxfs rw,suid,largefiles,delaylog,datainlog 0 2 /dev/vgu01/lvol1 /u01 vxfs rw,suid,largefiles,delaylog,datainlog 0 2 /dev/vgu02/lvol1 /u02 vxfs rw,suid,largefiles,delaylog,datainlog 0 2 /dev/vgu03/lvol1 /u03 vxfs rw,suid,largefiles,delaylog,datainlog 0 2 /dev/vgu04/lvol1 /u04 vxfs rw,suid,largefiles,delaylog,datainlog 0 2 /dev/vgu05/lvol1 /u05 vxfs rw,suid,largefiles,delaylog,datainlog 0 2 /dev/vgu06/lvol1 /u06 vxfs rw,suid,largefiles,delaylog,datainlog 0 2 /dev/vgu07/lvol1 /u07 vxfs rw,suid,largefiles,delaylog,datainlog 0 2 /dev/vgu08/lvol1 /u08 vxfs rw,suid,largefiles,delaylog,datainlog 0 2 /dev/vgu09/lvol1 /u09 vxfs rw,suid,largefiles,delaylog,datainlog 0 2 /dev/vgu10/lvol1 /u10 vxfs rw,suid,largefiles,delaylog,datainlog 0 2 This listing shows our ten logical volumes with the parameters we set up such as VxFS and support for large files as the last ten entries. There is no reason why we could not have run the filesystem-related commands such as newfs and fsadm at the command line as we did with the volume-related commands earlier. Since most people use SAM for these procedures, I thought it would be best illustrated using SAM. The next section provides tips on various procedures you may want to perform using logical volume manager. These are procedures I have used many times, and they may help you when you need to perform similar tasks. |