Showing posts with label vgdisplay. Show all posts
Showing posts with label vgdisplay. Show all posts

12/27/2017

Logical Volume Manager (LVM). Part 4 Use case

Continue to describe LVM from the practical point of view.
The previous parts are available here:

Logical Volume Manager (LVM). Part 1.Basics
Logical Volume Manager (LVM). Part 2 Commands
Logical Volume Manager (LVM). Part 3 Commands

Another typical situation is when you need to arrange access to a file system Volume Group from
different servers. The disks are 
physicallylocatedin the disk array, for example, in network SAN
(Storage Area Network) and multiple servers have access to those drives. 
This configuration is
required for the Organization of the work of the failover cluster on the basis of the MC/ServiceGuard
.

The sequence is as follows:

  1. Create the Volume Group (c) Logical Volumes and file systems with mount points on the
    same server. 
    Name it the source (host1).
  2. Unmount file systems and deactivate the Volume Group on the source server:
    • umount /data
    • vgchange -a n/dev/vg01  
  3. Create a special mapping file Volume Group on the source server and copy it to the new
    server. 
    Lets name it target  (host2).
    • vgexport -p -s -m /vg01.map/dev/vg01 pay attention to the-p option
      (mode, when the export Volume Group vg01 is not deleted on the source server),
    • rcp /vg01.map host2:/vg01.map
  4. On the destination server to prepare disks presented with disk array, which were included
    in the Volume Group vg01 on the source server, create a directory and a file for Volume
    Group vg01:
    • the ioscan -fnC disk - in case when devices were not created, to create use the
       command: insf-C disk , nothing to do else with the disks then.
    • mkdir /dev/vg01
    • mknod /dev/vg01/group c 64 0x010000 -to search for free junior rooms use the
       command: ls-al /*/group
  5. Import to the target server using the mapping file that you obtained in step 3:
    • vgimport-s-m/vg01.map/dev/vg01 -team itself finds the disks and add them to a new
       Volume Group; the failover command to verify that you can use the command:
      strings /etc/lvmtab
  6. You can now activate the Volume Group on the target server, save the configuration to
    restore, create a mount point, mount the file system and, if necessary, prescribe automatic
     mounts in/etc/fstab:
    • vgchange -a y /dev/vg01 
    • vgcfgbackup /dev/vg01
    • mkdir /data 
    • mount /dev/vg01/lvol1/data
    • vi /etc/fstab
By this method the Volume Groups can be migrated from one server to another. In this case it
is necessary to remove them after the migration on the source server with the following command:
  • vgexport /dev/vg01

Logical Volume Manager (LVM). Part 3 Commands

Command to gather information about file systems, the structure of the LVM, etc.:
  •  bdf -list of mounted file systems.
  •  ls -ltra /*/group  -cool command to view control files of all Volume Groups on the server.
     
    Is often useful when finding free minor-rooms for the new Volume Group.
  •  lvdisplay -v/dev/vg01/lvol1 -information about Logical Volume, you can try lvol1 general case:
  •  cat /etc/fstab -a list of all the file systems that are mounted at startup OS
  •  vgdisplay -v information about all Volume Groups
  •  vgdisplay-v vg01 -  information about the specific group.
  •  lvdisplay -v/dev/vg01/lv * -information about all Logical Volume from a Volume Group vg01.
  • pvdisplay -v /dev/dsk/c1t1d2 -information on the Physical Volume.
Expansion Volume Group (adding disk) Logical Volume:
  1.  pvcreate -f /dev/rdsk/c1t1d2 -to prepare a disk for connecting to LVM,
  2.  vgextend vg01 /dev/dsk/c1t1d2 -add to an existing Volume Group vg01 new drive.
  3.  lvextend -L /dev/vg01/lvol1 48000 -extend Logical Volume size to 48000 lvol1 MB.
Extend filesystem on lvol1 (prior to this event, though the drive (Logical Volume) and became more,
 but the file system will not be able to use it):

  • umount /data -unmount file system
  • extendfs -F vxfs/dev/vg01/rlvol1 -extend the file system on any space
  • mount /data -mount extended file system
  • bdf -check out the new size.
Reducing of the file system and Logical Volumes is very rare operation, because prior to this,
you must delete the data by making a backup, and after you reduce the file system and Logical Volume commands newfs and lvreduce command
.

Commands to delete Logical Volume:

  1.  umount /data -unmount file system
  2.  lvremove -f /dev/vg01/lvol1 -remove a Logical Volume with option "force" (in spite of
     the existence of the file system and data)
  3.  vi /etc/fstab -edit the list of mounted file systems in Windows is restarted,
  4.  vgdisplay -v vg01 -verify that Logical Volume.
Remove a physical disk from a Volume Group:
  1.  pvmove/dev/dsk/c1t1d2 /dev/dsk/c1t2d1 -move data from disk c1t1d2 on another
     disk in the Volume Group (if you do not specify a second disk, the command will place itself
     on the remaining disks in the Volume Group, of course, subject to the availability of places on them),
  2.  pvdisplay -v /dev/dsk/c1t1d2 -check that there is no data on the disk (a single physical
     extent-PE)
  3.  vgreduce vg01 /dev/dsk/c1t1d2 -remove the disk from the Volume Group vg01,
  4.  vgdisplay -v vg01 -check changes.
Removing a Volume Group:
  1.  lvremove -f /dev/vg01/lvol1 -remove all Logical Volumes,
  2.  vgreduce vg01/dev/dsk/c1t1d2 -remove all but one of the disks
  3.  vgremove vg01 -Delete Volume Group vg01,
  4.  rm-irf/dev/vg01 - force remove of a directory vg01.
You can remove a single command: 
 vgexport/dev/vg01 - remove everything about anything without asking. :)

Activation and deactivation of the Volume Group:

  •  vgchange-a n vg01 -deactivates the Volume Group vg01, removing it from the LVM kernel
     tables,
  •  vgchange-a y vg01 -activates the Volume Group vg01, making possible the mounting of
     file systems (automatic activation is performed when Windows is restarted)
  •  vgchange-a r vg01 -activate Volume Group vg01 in read-only mode.
Command sequences are correct for the file systems HFS, JFS. There is an additional option,
which can be purchased at the HP Online JFS. 
There's "cool things"  like reducing - extending
the file system without unmount etc. The main command - 
fsadm.

Popular Posts