RHCS6: Mirror/unmirror a GFS2 volume

RHCS: Mirror/unmirror a GFS2 volume

# Tested on RHEL 6


# Mirroring
# ------------------------------------------------------------------------------------------

# Given a simple gfs2 logical volume (note that type is 'linear' and all extents are
# currently on a single physical volume):

lvdisplay -m /dev/gfstestvg/gfstestlv01
  --- Logical volume ---
  LV Path                /dev/gfstestvg/gfstestlv01
  LV Name                gfstestlv01
  VG Name                gfstestvg
  LV UUID                Ih02E9-62kI-JmLz-HSSJ-3fhn-t0wd-r73UxX
  LV Write Access        read/write
  LV Creation host, time myserver, 2014-10-09 15:24:28 +0200
  LV Status              available
  # open                 0
  LV Size                512.00 MiB
  Current LE             128
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:7

  --- Segments ---
  Logical extent 0 to 127:
    Type                linear
    Physical volume     /dev/shared/sdd   <--- Current physical volume
    Physical extents    0 to 127


# It makes no sense mirroring disk on current physical volume so we have to look for a
# PV belonging to current volume group with enough free space to allocate extents.
# If needed, add a new physical volume to the volume group

pvs
  PV              VG        Fmt  Attr PSize  PFree
  /dev/sda2       rootvg    lvm2 a--  15.50g 3.50g
  /dev/shared/sdc gfsvg     lvm2 a--   6.00g    0
  /dev/shared/sdd gfstestvg lvm2 a--   2.00g 1.50g    <--- current physical volume
  /dev/shared/sde gfstestvg lvm2 a--   2.00g 2.00g    <--- pv with free extents
  /dev/shared/sdf           lvm2 a--   1.00g 1.00g


# Let's mirror (one copy) our volume

lvconvert -m1 gfstestvg/gfstestlv01 /dev/shared/sde
  Shared cluster mirrors are not available.


# Ooops, something went wrong!

# In fact, we need cmirrord daemon to be running in order to mirror and make work correctly
# any gfs2 mirrored volume. It tracks mirror log information on a cluster and relies on
# 'cman' which must be running for cmirrord to function ('clvmd' is also required).
# Install it if needed, "yum install cmirror"


# We start 'cmirrord', then, and enable the automatic start at boot time:

service cmirrord start
   Starting cmirrord:                             [  OK  ]

chkconfig cmirrord on


# Then, we are ready for mirroring operation:

lvconvert -m1 gfstestvg/gfstestlv01 /dev/shared/sde
  gfstestvg/gfstestlv01: Converted: 3.1%
  gfstestvg/gfstestlv01: Converted: 5.1%
[...]
  gfstestvg/gfstestlv01: Converted: 97.3%
  gfstestvg/gfstestlv01: Converted: 100.0%


# Our mirrored volume

lvs
  LV          VG        Attr      LSize Pool Origin Data%  Move Log              Cpy%Sync Convert
  gfstestlv01 gfstestvg mwi-a-m-- 512.00m                       gfstestlv01_mlog   100.00     <----
  lv_depot    gfsvg     -wi-ao--- 6.00g
  lv_home     rootvg    -wi-ao--- 1.00g
  lv_opt      rootvg    -wi-ao--- 1.00g
  lv_root     rootvg    -wi-ao--- 1.00g
  lv_swap     rootvg    -wi-ao--- 2.00g
  lv_tmp      rootvg    -wi-ao--- 2.00g
  lv_usr      rootvg    -wi-ao--- 4.00g
  lv_var      rootvg    -wi-ao--- 1.00g


lvdisplay -m /dev/gfstestvg/gfstestlv01
[...]

  --- Segments ---
  Logical extent 0 to 127:
    Type                mirror
    Mirrors             2
    Mirror size         128
    Mirror log volume   gfstestlv01_mlog
    Mirror region size  512.00 KiB
    Mirror original:
      Logical volume    gfstestlv01_mimage_0
      Logical extents   0 to 127
    Mirror destinations:
      Logical volume    gfstestlv01_mimage_1
      Logical extents   0 to 127


pvs --segments -o+lv_name,seg_start_pe,segtype
  PV              VG        Fmt  Attr PSize    PFree    Start SSize LV                     Start Type
[...]
  /dev/shared/sdd gfstestvg lvm2 a--     2.00g    1.50g     0   128 [gfstestlv01_mimage_0]     0 linear  <----
  /dev/shared/sdd gfstestvg lvm2 a--     2.00g    1.50g   128   383                            0 free
  /dev/shared/sde gfstestvg lvm2 a--     2.00g    1.49g     0   128 [gfstestlv01_mimage_1]     0 linear  <----
  /dev/shared/sde gfstestvg lvm2 a--     2.00g    1.49g   128     1 [gfstestlv01_mlog]         0 linear  <----
  /dev/shared/sde gfstestvg lvm2 a--     2.00g    1.49g   129   382                            0 free
  /dev/shared/sdf gfstestvg lvm2 a--  1020.00m 1020.00m     0   255                            0 free



# If we wanted to create a 3-side mirror (for example). We need two disks in our volume
# group with enough free space to allocate the mirror copies:

pvs
  PV              VG        Fmt  Attr PSize    PFree
  /dev/sda2       rootvg    lvm2 a--    15.50g    3.50g
  /dev/shared/sdc gfsvg     lvm2 a--     6.00g       0
  /dev/shared/sdd gfstestvg lvm2 a--     2.00g    1.50g
  /dev/shared/sde gfstestvg lvm2 a--     2.00g    2.00g  <----
  /dev/shared/sdf gfstestvg lvm2 a--  1020.00m 1020.00m  <----


# Let's mirror (two copies) our volume

lvconvert -m2 gfstestvg/gfstestlv01 /dev/shared/sde /dev/shared/sdf
  gfstestvg/gfstestlv01: Converted: 4.7%
  gfstestvg/gfstestlv01: Converted: 12.5%
[...]
  gfstestvg/gfstestlv01: Converted: 93.8%
  gfstestvg/gfstestlv01: Converted: 100.0%


# Check

lvdisplay -m /dev/gfstestvg/gfstestlv01
[...]

  --- Segments ---
  Logical extent 0 to 127:
    Type                mirror
    Mirrors             3
    Mirror size         128
    Mirror log volume   gfstestlv01_mlog
    Mirror region size  512.00 KiB
    Mirror original:
      Logical volume    gfstestlv01_mimage_0
      Logical extents   0 to 127
    Mirror destinations:
      Logical volume    gfstestlv01_mimage_1
      Logical extents   0 to 127
      Logical volume    gfstestlv01_mimage_2
      Logical extents   0 to 127


pvs --segments -o+lv_name,seg_start_pe,segtype
  PV              VG        Fmt  Attr PSize    PFree   Start SSize LV                     Start Type
[...]
  /dev/shared/sdd gfstestvg lvm2 a--     2.00g   1.50g     0   128 [gfstestlv01_mimage_0]     0 linear  <----
  /dev/shared/sdd gfstestvg lvm2 a--     2.00g   1.50g   128   383                            0 free
  /dev/shared/sde gfstestvg lvm2 a--     2.00g   1.50g     0   128 [gfstestlv01_mimage_1]     0 linear  <----
  /dev/shared/sde gfstestvg lvm2 a--     2.00g   1.50g   128   383                            0 free
  /dev/shared/sdf gfstestvg lvm2 a--  1020.00m 504.00m     0   128 [gfstestlv01_mimage_2]     0 linear  <----
  /dev/shared/sdf gfstestvg lvm2 a--  1020.00m 504.00m   128     1 [gfstestlv01_mlog]         0 linear  <----
  /dev/shared/sdf gfstestvg lvm2 a--  1020.00m 504.00m   129   126                            0 free




# Un-mirroring
# ------------------------------------------------------------------------------------------

# Given a three side gfs2 logical volume (note that type is 'mirror' and extents are
# on three different physical volume, original + 2 mirror copies):

lvdisplay -m /dev/gfstestvg/gfstestlv01
  --- Logical volume ---
  LV Path                /dev/gfstestvg/gfstestlv01
  LV Name                gfstestlv01
  VG Name                gfstestvg
  LV UUID                L35bR5-1sCH-aiK5-joH4-h674-mIvx-xZ3lx5
  LV Write Access        read/write
  LV Creation host, time cientouno, 2014-10-09 15:26:49 +0200
  LV Status              available
  # open                 0
  LV Size                512.00 MiB
  Current LE             128
  Mirrored volumes       3
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:7

  --- Segments ---
  Logical extent 0 to 127:
    Type                mirror
    Mirrors             3
    Mirror size         128
    Mirror log volume   gfstestlv01_mlog
    Mirror region size  512.00 KiB
    Mirror original:
      Logical volume    gfstestlv01_mimage_0
      Logical extents   0 to 127
    Mirror destinations:
      Logical volume    gfstestlv01_mimage_1
      Logical extents   0 to 127
      Logical volume    gfstestlv01_mimage_2
      Logical extents   0 to 127

pvs --segments -o+lv_name,seg_start_pe,segtype
  PV              VG        Fmt  Attr PSize    PFree   Start SSize LV                     Start Type
[...]
  /dev/shared/sdd gfstestvg lvm2 a--     2.00g   1.50g     0   128 [gfstestlv01_mimage_0]     0 linear  <----
  /dev/shared/sdd gfstestvg lvm2 a--     2.00g   1.50g   128   383                            0 free
  /dev/shared/sde gfstestvg lvm2 a--     2.00g   1.50g     0   128 [gfstestlv01_mimage_1]     0 linear  <----
  /dev/shared/sde gfstestvg lvm2 a--     2.00g   1.50g   128   383                            0 free
  /dev/shared/sdf gfstestvg lvm2 a--  1020.00m 504.00m     0   128 [gfstestlv01_mimage_2]     0 linear  <----
  /dev/shared/sdf gfstestvg lvm2 a--  1020.00m 504.00m   128     1 [gfstestlv01_mlog]         0 linear  <----
  /dev/shared/sdf gfstestvg lvm2 a--  1020.00m 504.00m   129   126                            0 free


# Let's reduce one of the copies:

lvconvert -m1 gfstestvg/gfstestlv01 /dev/shared/sdf
  Logical volume gfstestlv01 converted.


# Check

lvdisplay -m /dev/gfstestvg/gfstestlv01
[...]

  --- Segments ---
  Logical extent 0 to 127:
    Type                mirror
    Mirrors             2
    Mirror size         128
    Mirror log volume   gfstestlv01_mlog
    Mirror region size  512.00 KiB
    Mirror original:
      Logical volume    gfstestlv01_mimage_0
      Logical extents   0 to 127
    Mirror destinations:
      Logical volume    gfstestlv01_mimage_1
      Logical extents   0 to 127


pvs
  PV              VG        Fmt  Attr PSize    PFree
  /dev/sda2       rootvg    lvm2 a--    15.50g    3.50g
  /dev/shared/sdc gfsvg     lvm2 a--     6.00g       0
  /dev/shared/sdd gfstestvg lvm2 a--     2.00g    1.50g
  /dev/shared/sde gfstestvg lvm2 a--     2.00g    1.50g
  /dev/shared/sdf gfstestvg lvm2 a--  1020.00m 1020.00m  <---- Reduced


pvs --segments -o+lv_name,seg_start_pe,segtype | grep gfstestvg
  /dev/shared/sdd gfstestvg lvm2 a--     2.00g    1.50g     0   128 [gfstestlv01_mimage_0]     0 linear
  /dev/shared/sdd gfstestvg lvm2 a--     2.00g    1.50g   128   383                            0 free
  /dev/shared/sde gfstestvg lvm2 a--     2.00g    1.50g     0   128 [gfstestlv01_mimage_1]     0 linear
  /dev/shared/sde gfstestvg lvm2 a--     2.00g    1.50g   128   383                            0 free
  /dev/shared/sdf gfstestvg lvm2 a--  1020.00m 1016.00m     0   128                            0 free
  /dev/shared/sdf gfstestvg lvm2 a--  1020.00m 1016.00m   128     1 [gfstestlv01_mlog]         0 linear
  /dev/shared/sdf gfstestvg lvm2 a--  1020.00m 1016.00m   129   126                            0 free


# And, finally, completely remove the mirror:

lvconvert -m0 gfstestvg/gfstestlv01 /dev/shared/sde
  Logical volume gfstestlv01 converted.


# Check

lvdisplay -m /dev/gfstestvg/gfstestlv01
  --- Logical volume ---
  LV Path                /dev/gfstestvg/gfstestlv01
  LV Name                gfstestlv01
  VG Name                gfstestvg
  LV UUID                L35bR5-1sCH-aiK5-joH4-h674-mIvx-xZ3lx5
  LV Write Access        read/write
  LV Creation host, time cientouno, 2014-10-09 15:26:49 +0200
  LV Status              available
  # open                 0
  LV Size                512.00 MiB
  Current LE             128
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:7

  --- Segments ---
  Logical extent 0 to 127:
    Type                linear
    Physical volume     /dev/shared/sdd
    Physical extents    0 to 127


pvs
  PV              VG        Fmt  Attr PSize    PFree
  /dev/sda2       rootvg    lvm2 a--    15.50g    3.50g
  /dev/shared/sdc gfsvg     lvm2 a--     6.00g       0
  /dev/shared/sdd gfstestvg lvm2 a--     2.00g    1.50g
  /dev/shared/sde gfstestvg lvm2 a--     2.00g    2.00g  <---- Reduced
  /dev/shared/sdf gfstestvg lvm2 a--  1020.00m 1020.00m


pvs --segments -o+lv_name,seg_start_pe,segtype | grep gfstestvg
  /dev/shared/sdd gfstestvg lvm2 a--     2.00g    1.50g     0   128 gfstestlv01     0 linear
  /dev/shared/sdd gfstestvg lvm2 a--     2.00g    1.50g   128   383                 0 free
  /dev/shared/sde gfstestvg lvm2 a--     2.00g    2.00g     0   511                 0 free
  /dev/shared/sdf gfstestvg lvm2 a--  1020.00m 1020.00m     0   255                 0 free
0 (0)
Article Rating (No Votes)
Rate this article
Attachments
There are no attachments for this article.
Comments
There are no comments for this article. Be the first to post a comment.
Full Name
Email Address
Security Code Security Code
Related Articles RSS Feed
logrotate - rotates, compresses, and mails system logs.
Viewed 905 times since Fri, Nov 30, 2018
debian How to check Debian CVE status using python script
Viewed 1402 times since Sun, Sep 23, 2018
CentOS / RHEL : Configure yum automatic updates with yum-cron service
Viewed 2713 times since Fri, Oct 26, 2018
LVM: Reduce an existing Volume Group by removing one of its disks
Viewed 1143 times since Sat, Jun 2, 2018
RHEL: Retrieve and generate a unique SCSI identifier
Viewed 1724 times since Sat, Jun 2, 2018
How to do a Filesystem Resize (ext3/ext4) on Redhat running on VMware
Viewed 9596 times since Wed, Jul 25, 2018
RHEL: Enabling standard ftp/telnet
Viewed 1729 times since Sun, May 27, 2018
Jak ustawić LVM, jak robić snapshoty oraz automatycznie powiększać LV, czyli małe howto
Viewed 3159 times since Sun, May 20, 2018
What Is /dev/shm And Its Practical Usage
Viewed 6043 times since Tue, Mar 12, 2019
How to maximise SSD performance with Linux
Viewed 5637 times since Fri, May 15, 2020