1834796 Members
2651 Online
110070 Solutions
New Discussion

vg active?

 
SOLVED
Go to solution

vg active?

hi,
is there anyother way than the vgdisplay output
( which displays an error ) to see if a vg is
active or not?
thx...
it's all a game
10 REPLIES 10
Sridhar Bhaskarla
Honored Contributor

Re: vg active?

Hi Atil,

Do a bdf and see if any of the logical volumes under this vg have been mounted.

If not, try to mount any of the logical volumes. It shouldn't say unable to open the logical volume if the vg is not activated

Or do a lvdisplay on any of the logical volumes in the volume group

-Sri
You may be disappointed if you fail, but you are doomed if you don't try

Re: vg active?

thx sridhar,
i am writing a script based on
"strings /etc/lvmtab" output,reading it line by
line and doing some operations, but because
some of vgs listed are not active( they are
defined because of a cluster membership ),
due to my vgdisplay output,some error conditions appear...to suppress those messages,
i simply wrote:
vgdisplay $line > /dev/null 2>&1
if [ $? -eq 0 ]
then

condition, just to check if it is activated...
but what works well in the command line without
any problems, causes the script to wait for a
5 minutes when used in...

any suggestions?

thx...
it's all a game
Stefan Farrelly
Honored Contributor

Re: vg active?


Try using the vgchange command instead. If you do a vgchange -a y it will report successfully changed if it was active or not. If you try a vgchange -a n and some part of the vg or one of its lvols is in use you will get a Device busy error - so you know it was active/in use.
Im from Palmerston North, New Zealand, but somehow ended up in London...
Sridhar Bhaskarla
Honored Contributor

Re: vg active?

Hi,

I would do like this.

vgdisplay -v > /tmp/vg.out 2>/dev/null

1. Get all the VGs that are active on the system.

grep "VG Name" /tmp/vg.out |awk '{print $3}'

2. Get the primary disks that are active

grep "PV Name" /tmp/vg.out |grep -v Alternate |awk '{print $3}'

3. Get the alternate disks

grep "PV Name" /tmp/vg.out |grep Alternate |awk '{print $3}'

4. Get the Lvols

grep "LV Name" /tmp/vg.out |awk '{print $3}'

5. Getting it straight redirecting errors to null

vgdisplay -v 2>/dev/null |grep "VG Name" |awk '{print $3}'

This may give you some idea

-Sri


You may be disappointed if you fail, but you are doomed if you don't try
Bill McNAMARA_1
Honored Contributor

Re: vg active?

vgchange -a y vgname

note it will say if already active, or otherwise activate it.. so you may want to disactivate after:

vgchange -a n vgname

Later,
Bill
It works for me (tm)
Stefan Farrelly
Honored Contributor

Re: vg active?


If a volume group is already active then Im afraid a vgchange -a y on it doesnt return an error (like already active) , it simply displays the same message (activated successfully) wether or not it was already active.

However, ive found a way to test for sure if a VG is active or not. Do the following command on one of the lvols in the VG;

adb 0x2000?2X | adb /dev//lvol1

If the VG is active this will return some data in 3 columns, if the VG is not active it will return an error; text address not found

Im from Palmerston North, New Zealand, but somehow ended up in London...
Bill Hassell
Honored Contributor
Solution

Re: vg active?

I'd be concerned about the errors being reported--things like "can't query physical volume...and so on" Thoss should be addressed as they will continue to cause big problems.

The strings /etc/lvmtab is a hack at best since this file is actually a binary file. Most of the time, it looks reasonable but occasionally strings will produce garbage characters that your script must accomodate. And lvmtab probably has entries that are incorrect, leading to the error messages you are receiving in vgdisplay.


Bill Hassell, sysadmin
Darrell Allen
Honored Contributor

Re: vg active?

Hi,

I'd be most concerned with why vgdisplay is hanging in a script. It shouldn't be, especially since you say it is working from command line without problem. I can run vgdisplay against an inactive VG in a script without problem. So, could this be a scripting issue?

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
Sanjay_6
Honored Contributor

Re: vg active?

Hi,

Try "vgdisplay -v /dev/vg_name"

Then for all the lv's listed under the VG, try,

lvdisplay -v /dev/vg_name/lv_name

Also for all the disks listed for that VG, try

pvdisplay -v /dev/dsk/cxtydz

Hope this helps.

Regds
Sanjay_6
Honored Contributor

Re: vg active?

Hi,

The VG should be active on the node to run vgdisplay on that Vg. For a cluster VG you can run the vgdisplay command on the node where the VG is active at that moment. If the vg is not active you can make it active on a cluster node with the cluster services running using,

vgchange -a e /dev/vg_name

then do a vgdisplay

to deactivate the Vg on the node,

vgchange -a n /dev/vg_name

If the cluster services are not running on the node and you want to activate a cluster vg on this node, make sure the vg is not active on any node, then do,

vgchange -c n /dev/vg_name

This will deactivate the cluster info from the vg,

then activate the vg using,

vgchange -a y /dev/vg_name

do a vgdisplay...

deactivate the VG,

vgchange -a n /dev/vg_name

put the VG back into cluster mode,

vgchange -c y /dev/vg_name

To activate the VG without quorum, use

vgchange -q n -a e /dev/vg_name

Hope this helps.

Regds