1863043 Members
1203 Online
110446 Solutions
New Discussion

script help please

 
SOLVED
Go to solution
John Meissner
Esteemed Contributor

script help please

posted in the wrong place ... posting here to imporve visability
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x5f235bd3782dd711abdc0090277a778c,00.html
All paths lead to destiny
37 REPLIES 37
John Poff
Honored Contributor
Solution

Re: script help please

Hi John,

I've done something similar to what you are trying. I wrote a script 'build_vg_conf' that will write a simple configuration file which describes a volume group and the logical volumes in it. These config files are used by a second script, 'recreate_vg', which will create the volume groups and logical volumes. The 'recreate_vg' script can go search for your EMC disks, or you can pass it a list of PVs in a file. We've used this script a couple of times in disaster recovery drills and it seems to work. Feel free to take it and hack it up for your needs, or just copy the useful parts of it as needed. It does many of the same things you are trying to do in your script, such as finding a valid list of EMC disks, figuring out the next available minor number to use for creating VGs, etc.

Have fun!

JP
John Poff
Honored Contributor

Re: script help please

Here is the 'build_vg_conf' script. We usually put it in cron and run it once a day. The config files are small and we just leave them in our root home directory, and they get picked up for free by our Ignite backups.

Here is a sample config file:

PESIZE 4
TOTALPE 6471
LV /dev/vg_app/lvol1 /u01/app/oracle 2000
LV /dev/vg_app/lvol2 /u01/app/applmgr 4000


See, I figured out that all I really needed to recreate a volume group was the name, the PE size, and the number of PEs. The number of PVs in the old VG doesn't really matter because you might not have the same size PVs on the new system, and as long as the PE size is the same it doesn't really matter. The 'recreate_vg' script will look at this config file, figure out how big the VG needs to be in PEs, and start pvcreating PVs and throwing them into the new VG until it has enough PEs. Then it is a simple matter to create the LVs based on the LV entries in the config file.

Fun stuff!

JP
John Poff
Honored Contributor

Re: script help please

Oops. Here is the 'build_vg_conf' script. I forgot to attach it to the last post.

JP
John Meissner
Esteemed Contributor

Re: script help please

Great - Thanks for the script! I'll take a look and see if it works for my needs - at the very least I'll be able to redirect my approach from here.
All paths lead to destiny
John Meissner
Esteemed Contributor

Re: script help please

John - just out of curiousity - when you execute the 2nd script do you need to pass it any options? I ran it and came up with a few errors. and it doesn't look like it completed it's task. just checking. I definately will be using most of what you wrote to recover my vg's but so far the script doesn't work "as is". Any suggestions?
All paths lead to destiny
John Poff
Honored Contributor

Re: script help please

Hi John,

Which script gave you the errors, and what errors did you get? If it is the 'recreate_vg' script, I'm not surprised as I usually just run it [and refine it] while we are doing a disaster recovery drill, which means it only gets worked on when I am very sleep deprived and full of caffeine. [Not too far from my normal condition!].

JP
John Meissner
Esteemed Contributor

Re: script help please

John - yeah it was the recreate script. It had a few useage errors....

/usr/sbin/vgcreate -p 128 -s $VG
Usage: vgcreate
[-f]
[-A Autobackup]
[-x Extensibility]
[-e MaxPhysicalExtents]
etc.....

I can probably send you the entire file with all the output if you really want. I saved it to a file but it's too big to attach here.

I know what you mean about sleep deprived... our DR tests are the same way. Fortunately I work for Mars Inc (M&M candies) so I usually have a sugar rush going for me... plus one of our companies makes coffee so We bring a brewer with us to the test site. Still .... If I can get this working then it'll cut the build time down to almost nothing... and then we can go to out and have some fun :)
....and thanks for the quick response too.
All paths lead to destiny
John Poff
Honored Contributor

Re: script help please

Ok. The 'recreate_vg' script expects to find the *.config files for the volume groups that are created by the 'build_vg_conf' script. Did you run 'build_vg_conf' first to give it some .config files to work with?

JP
John Poff
Honored Contributor

Re: script help please

And you're welcome. My boss thinks I am busy working. Too busy to go help roll some new equipment from the other end of the building to the computer room. :)

JP
John Meissner
Esteemed Contributor

Re: script help please

Yes - the config files that the 1st script generated were in the same directory as the recreate script. in this case there were 2 files since the server I was creating had 2 vg's besides vg00.
All paths lead to destiny
John Meissner
Esteemed Contributor

Re: script help please

you get extra points for making your boss thing you're busy :)
All paths lead to destiny
John Meissner
Esteemed Contributor

Re: script help please

I'm attaching one of the config files that the script created

All paths lead to destiny
John Poff
Honored Contributor

Re: script help please

John,

Go ahead and post your output as an attachment. I'd like to take a look at it. Also, if you can post the two .config files I'd like to see them as well.

JP
John Meissner
Esteemed Contributor

Re: script help please

ok - the one config file i attached to my above post. I'll attach the 2nd config file here
All paths lead to destiny
John Meissner
Esteemed Contributor

Re: script help please

 
All paths lead to destiny
John Poff
Honored Contributor

Re: script help please

It looks like there were a couple of problems. In your first .config file the lvol8 and lvol15 logical volumes didn't get entries for the mount points. Are those LVs mounted currently? The 'build_vg_conf' script just takes the output from the 'mount' command to try to figure out the LVs and mount points.

Also, it looks like the 'recreate_vg' may have picked up a bogus .config file. The 'build_vg.config' file looks like it might be the culprit.


The vgcreate commands for the vg043bin and vg043data VGs choked with a 'file too large' error. I'm not sure what that is all about. Probably the author of the script should have put in more error checking!

JP

John Poff
Honored Contributor

Re: script help please

I poked around and I found a document that explains the 'file too large' error for the vgcreate:

http://www2.itrc.hp.com/service/cki/docDisplay.do?docLocale=en_US&docId=200000065011234

When I last used this script, we had a huge VG with just over a hundred PVs in it. The 'vgcreate' line in the 'recreate_vg' script is hard coded to set the Max PVs for 128. I think that is causing problems for vgcreate. Try lowering the '-p 128' option to something more reasonable, like '-p 32' and give it another go. You'll also need to get rid of the bogus .config file and make sure there are mountpoint entries in the vg043bin.config file.

Time for more caffeine!

JP
John Meissner
Esteemed Contributor

Re: script help please

Yes - I see the entry in the 1st config file that is messed up. I'll just try removing that or manually entering the correct information into the fields. I'll let you know how it goes.

as for the max extents... i'll take a look at that too. I know that some of our servers have terabytes of diskspace.... will the hardcoded 128 effect this?
All paths lead to destiny
John Meissner
Esteemed Contributor

Re: script help please

 
All paths lead to destiny
John Meissner
Esteemed Contributor

Re: script help please

ok - I canged the 128 to 40... a more reasonable number...

and it seemed to get through more this time.... then it had some pvcreate errors... it basically looked like it was doing a:
"pvcreate -f "
with no disk specified at the end of the statement. also i noticed an error about the vg not being activated. I did a vgchange -y a $vgname
and I was able to do a vgdisplay which showed all the PV names associated with each VG - nothing is mounted and the script never specified any temporary fstab file at the end. any ideas where to go from here?
All paths lead to destiny
John Meissner
Esteemed Contributor

Re: script help please

One other bit of information that you may be interested in is that the server I'm wroking on is ServiceGurarded..... I doubt that should effect this but ....
just thought i'd mention it.
All paths lead to destiny
John Poff
Honored Contributor

Re: script help please

Hi John,

The pvcreate errors sound like another bug. It looks like it ran out of PVs? Let me take a look at the script.

The script won't activate the volume groups. I could add that in if you think it would be helpful. As for mounting the filesystems, the script doesn't mess with it. Our method of using the script was that we recovered the system using Ignite, and then ran this script. Since we had Ignited the box, we had a copy of our old /etc/fstab out there and after the script was done we just did a 'mount -a' to get all the filesystems mounted. I added the option to create a new /etc/fstab later to cover the case where we might not have Ignited the system and were just creating the VGs and LVs on a clean system from just the .config files. I'm not sure the fstab creation works; I'll take a look at that also.

The MC/SG environment shouldn't matter. We use it here also and the script seems perfectly capable of blowing up with or without MC/SG. :)

I'll look at the script and post a revised version later today. Thanks for your interest and your patience.

JP
John Meissner
Esteemed Contributor

Re: script help please

John - thanks for your patience and your help. I'll take a look at it and see if I can tweak anything as well. Although I must admit you're a little more advanced in scripting than I am. Still I'll see what I can do too.
All paths lead to destiny
John Meissner
Esteemed Contributor

Re: script help please

John - I found one thing on the following line:

/usr/sbin/lvcreate -l $LVSIZE -n $(basename $LVNAME) $VGNAME

I can't find any other reference to "basename" anywhere else in your script. I ran through this morning and everything worked except actually creating the lvol names withing the /dev/vgname. I think if/when I get this last piece fixed the script will work beautifully. Did you find anything the other day?
All paths lead to destiny