Operating System - HP-UX
1833329 Members
3805 Online
110051 Solutions
New Discussion

How to script to round robin LV onto separate disks ?

 
SOLVED
Go to solution
Sammy_2
Super Advisor

How to script to round robin LV onto separate disks ?

Got 3 disks in a VG. Need to add LV's to this VG but 1st lv on disk1(c8t0d0), 2nd on disk2(c8t0d1), 3rd on disk3(c8t0d3), and 4th back on disk1,... on and on.
How do I do that.?

LV's- /dev/vgprod/app1 200mb
/dev/vgprod/app2 1000mb
/dev/vgprod/app3 6000mb
...
(about 50 lvs)
good judgement comes from experience and experience comes from bad judgement.
6 REPLIES 6
Alan Meyer_4
Respected Contributor
Solution

Re: How to script to round robin LV onto separate disks ?

First since it seems that your LV's are not all the same size, create a data file(LV.dat) corresponding the LV with the size required... ie...

app1 200
app2 1000
app3 6000
app4 500
app5 600
app6 700

then create the following script to read in the sizes and create the VG's

#! /bin/ksh

DSKDEV[1]="/dev/dsk/c8t0d0"
DSKDEV[2]="/dev/dsk/c8t0d1"
DSKDEV[3]="/dev/dsk/c8t0d3"

CURDSK=1

cat LV.dat |awk '{print $1, $2}' |while read LV SIZE ;do
lvcreate -n $LV vgprod
lvextend -L $SIZE /dev/vgprod/$LV ${DSKDEV[$CURDSK]}
newfs -F vxfs /dev/vgprod/r$LV

(( CURDSK = CURDSK + 1 ))
[ $CURDSK -eq 4 ] && CURDSK=1
done


You may also want to add lines to echo the proper lines to the fstab file in the loop as well as create the mount points too.

Also, be sure that the 3 disks have enough space on them to contain the space configuration you've laid out in LV.dat.

-Alan

" I may not be certified, but I am certifiable... "
Sammy_2
Super Advisor

Re: How to script to round robin LV onto separate disks ?

Good One Allen. Seems like the logic you have will work. I will give it a shot as it will save me enormous time. I dont need newfs since these are ops raw devices on a shared drives.

Thanks a bunch.Allen 10pt answer
good judgement comes from experience and experience comes from bad judgement.
Devender Khatana
Honored Contributor

Re: How to script to round robin LV onto separate disks ?

Hi,

Although above steps are perfect for what you are trying to achive but it will be better for performance that you put these LV's stripped across all disks. This can be achived by using -D option in lvcreate.

HTH,
Devender
Impossible itself mentions "I m possible"
Sammy_2
Super Advisor

Re: How to script to round robin LV onto separate disks ?

Devender,
These are actually SAN EMC disks and so I assume striping is done at the h/w level. I dont have to do it. I just want to put lvs in 3 separate disks for DBA's satisfaction.
Thanks
good judgement comes from experience and experience comes from bad judgement.
TwoProc
Honored Contributor

Re: How to script to round robin LV onto separate disks ?

Sammy, don't forget to stripe across your alternate paths too! I see that you're putting the whole rotation on the same controller.
We are the people our parents warned us about --Jimmy Buffett
Sammy_2
Super Advisor

Re: How to script to round robin LV onto separate disks ?

Alen,
your solution is a time saver script. Will save that script for further use. THANKS.
It works.
good judgement comes from experience and experience comes from bad judgement.