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
Linux - How to get Memory information
Viewed 1636 times since Fri, Jun 8, 2018
stunnel basics and pki standards
Viewed 9207 times since Fri, Sep 28, 2018
Tcpdump Examples Linux
Viewed 5579 times since Fri, Nov 16, 2018
RHCS: Install a two-node basic cluster
Viewed 9739 times since Sun, Jun 3, 2018
Używanie rsync poprzez Secure Shell
Viewed 40457 times since Thu, May 24, 2018
LVM: Create a new Logical Volume / Filesystem
Viewed 1857 times since Sat, Jun 2, 2018
RHEL7 slow ssh login
Viewed 4018 times since Tue, Aug 6, 2019
ZPOOL: Detach a submirror from a mirrored zpool
Viewed 2314 times since Sun, Jun 3, 2018
RHEL7: Create and configure LUKS-encrypted partitions and logical volumes to prompt for password and mount a decrypted file system at boot.
Viewed 10859 times since Mon, Aug 6, 2018
SSH ProxyCommand example: Going through one host to reach another server
Viewed 12992 times since Tue, Aug 6, 2019