Páginas

Monday, 20 October 2014

LVM


LVM stands for Logical Volume Manager, it provides a method of allocating space on mass storage devices. Its main characteristic and strengtht is that it is more flexible than conventional partitioning schemes.
LVM is such a big subjetc that there is a redbook only for that. So, I will try to explain the main concepts and some of the most useful commands.


From top to bottom we are going to talk about Physical Volumes, Volume Groups, Logical Volumes and ODM.

Physical Volumes (PV)

They can be hard disks, hard disk partitions or LUNs from a external storage. They can start to be called PVs when they are given "format" with the following command.
The physical volume is partitioned into contiguous, equal sized units of space called physical partitions (PP). PP is the smallest unit of storage space allocated.

chdev -l hdiskx -a pv=yes 

This command creates an identifier that is called physical volume identifier (PVID) and it is written on the first block of the device and in the ODM.
PVID is a combination of the machine’s serial number (from the systems EPROMs) and the date the PVID was generated. It can be seen with different commands:

# lspv hdiskpower15 |grep -i pv
PV IDENTIFIER:      00cab1c214dc6ea1 VG IDENTIFIER     00cab1c200004c000000013388c518cd
PV STATE:           active

# lsattr -EHl hdiskpower15|grep pvid
pvid          00cab1c214dc6ea10000000000000000 Physical volume identifier False
pvid_takeover yes                              Takeover PVIDs from hdisks True

# lquerypv -H /dev/hdiskpower15
00cab1c214dc6ea10000000000000000

The first 128 sectors of a physical volume are reserved to store various types of information like the boot record (sector 0) , the mirror write consistency (MWC) record (sector 1) or  LVM record (sector 7) among others. Sector 128 is the first non reserved one, the volume group descriptor area and status area (VGDA / VGSA) record starts here. There is another reserved area at the end of the disk, and it is reserved as a relocation pool for bad blocks.



Volume Group (VG) 

It is a collection of physical volumes, this is the definition from Redbook. I would add that VG is composed by at least one PV and it is divided into different Logical Volumes.
When you install the system a VG is created (rootvg). You can create new VG with command mkvg, and using the extendvg command  you can add PV to a VG and can be removed using the reducevg command.


Depending on the maximum numbers of PVs and LVs that VGs can contain, they can be Normal (32 PVs),  Big (128 PVs) and Scalable (1024 PVs).
You can check this with command readvgda

# readvgda hdiskpower21 |grep type
.....    readvgda_type: smallvg

When a volume group is created, there are a number of operations that runs in the background. A Volume Group Identifier (VGID), VGSA and VGDA areas are created. And two files are created in /dev with the selected major number:
__vgnn where nn is the major number (Note: NFS uses the major number as part of the file handle)
vg_name

# ls -l /dev/*vg* |grep 38
crw-------    1 root     system       38,  0 Jun 03 08:21 /dev/__vg38
crw-rw----    1 root     system       38,  0 Jun 03 08:21 /dev/sapvg


VGID is and identifier as the PVID

VGSA contains the state of all allocated PPs on all of the PVs in the VG. It contains information about the VG factor and the Physical volume missing flag.


What is the factor? The factor determines the maximum number of PVs and PPs per PV that a VG can have.
By default, the number of physical partitions factor is set to 1, this means that one VG can have 1016 PPs per PV and 32 PVs as maximum.
This can be changed with the following command chvg -t factor





.
VGDA resides on the edge of the disk and it requires contiguous space in case of VGDA expansion. It contains information about the volume group, the logical volumes that reside in the volume group, and the physical volumes that make up the volume group.

The VGDA is updated by almost all the LVM commands related to a VG; for instance create or extend a logical volume, add a  new physical volume. This involves that the VGDA on all disks is updated.

VGDA is divided into the following:
  • list of logical volume entries.
  • list of physical volume entries.
  • volume group header.
  • volume group trailer.
Every physical volume has two VGDAs, if there is one PV in the VG, both copies og VGDA are used.
If there are two physical volumes, both copies are used in the first physical volume and just the first copy in the second physical volume.
If there are three or more physical volumes, only the first copy is used in each physical volume.



Logical Volume (LV) 

It is a portion of a physical volume or volumes viewed by the system as a single unit. Logical volumes can only exist within one volume group.
There are two elements to take into account:
  • The logical volume identifier (LVID) is the soft serial number, this number also represents the order in which the logical volume was created within the volume group.
  • The logical volume control block (LVCB), The LVCB holds important information, such as the creation date of the logical volume, information about mirrored copies and mount points.

Logical volumes are divided into logical partitions; these logical partitions are how logical volumes handle both the mapping to physical partitions on one or more physical volumes and multiple copies for mirroring. The command reorgvg which rearranges the physical partitions within the volume group, this means that the mapping between the logical partitions and the physical partitions is changed.



I will finish with a couple of remarks about the ODM and LVM
The information that is contained in the VGDA and LVCB is also stored on the system, this information is kept in the object data manager (ODM) and also there are some files in /etc which hold information.
That information in the ODM is stored in stanzas, under /etc/objrepos, /usr/lib/objrepos and /usr/share/lib/objrepos. You can find several files where that information is stored, CuAt,CuDv, PdAt, PdDv,...

You can query the information stored in those files with command odmget
odmget -q name=LV CuAt

If you are interested in this topic and want to go into detail about it, you can check the last link below in the references area.

There are commands which implies LVM modification, then a lock is put in the vg entry in the ODM.

The user can unlock the vg in two ways:
putlvodm -K <VGID>
varyonvg the volume group


References


LVM Redbook

Decoding PVID

VG Management

ODM

Thursday, 2 October 2014

HACMP Commands



I don't know why but PowerHA commands are not very well documented (in my humble opinion) or there is not much information about it, maybe because with smitty you can do everything and it is much more intuitive.

In this post, I will take a look at some commands, at least those from what you can display information from the cluster configuration.
Most of the commands are under /usr/es/sbin/cluster/utilities/ path so if I don't mention other path, the commmand will be inside that directory.


clRGinfo

gives you information on the location and state of one or more specified resource groups.  

clRGinfo - a very useful to track cluster events while they are happening
-----------------------------------------------------------------------------
  Group Name Type Resource Group Movement
-----------------------------------------------------------------------------
 m1_RG non-concurrent PRIMARY=":node1"
 m2_RG non-concurrent PRIMARY="node2:"

 m3_RG non-concurrent PRIMARY="node1:node2"

Explanation:
 The first RG (m1_RG) is being moved from offline to online in node1.
 The second RG (m2_RG)is being moved from node2 to offline.
 The third RG (m3_RG) is being moved from node1 to node2.


clRGinfo -s -p shows a lot of information about RG and its policy configuration.
    m2_RG:ONLINE:node2:non-concurrent:OHN:FNPN:NFB:ignore::: : :::

This means that m2_RG is online on node2 that starts on home node only (OHN), Fails over to next node configured (FNPN), Never Fails back (NFB) and ignore intersite policies (ignore).

If you want to know the explanation to all the different configuration policies, take a look at the first link


cltopinfo

displays cluster topology information. It is very useful to get a quick overview of how the cluster is configured.

Switches can be used to narrow the output. -c shows the clustername; -i shows all the interfaces configured.


clshowres

Shows resource group information for a cluster or a node.
clshowres -g m1_RG displays information about the RG such as Service Ip Label, Volume Groups, Application Servers.

clshowres-n node1


clshowsrv

gives you a view of the cluster subsystems.

clshowsrv -a
Subsystem         Group            PID          Status
clstrmgrES       cluster          8585226    active
clinfoES           cluster         14483554   active
clcomdES         clcomdES      6422536    active


clshowsrv -v gives you details about more HACMP subsystems



clstat

monitors cluster status. It is under the path /usr/es/sbin/cluster/

If you run it without options you get a graphical display with the status of the cluster. You can get a text display using clstat -o



clstat - HACMP Cluster Status Monitor
-------------------------------------
Cluster: CLUSTERPROD (1292631894)
Thu Oct 2 09:40:00 2014
State: UP Nodes: 4
SubState: STABLE



References

clRGinfo options

HACMP Commands