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
Create a Linux Swap File
Viewed 727 times since Fri, Jun 8, 2018
ZPOOL: Detach a submirror from a mirrored zpool
Viewed 806 times since Sun, Jun 3, 2018
Jak znaleźć najszybszy publiczny serwer DNS w Polsce?
Viewed 1224 times since Mon, May 21, 2018
Linux 16 Useful Bandwidth Monitoring Tools to Analyze Network Usage in Linux
Viewed 168 times since Mon, Sep 21, 2020
Tip: SSD and Linux. Enable TRIM and check if it works
Viewed 635 times since Fri, May 15, 2020
How setting the TZ environment variable avoids thousands of system calls
Viewed 1487 times since Mon, May 21, 2018
RHCS6: Show/Add GFS2/GFS journals
Viewed 983 times since Sun, Jun 3, 2018
How to recover error - Audit error: dispatch err (pipe full) event lost
Viewed 6105 times since Tue, Aug 6, 2019
watchdog How to restart a process out of crontab on a Linux/Unix
Viewed 2118 times since Tue, Jul 31, 2018
OEL 7 – How to disable IPv6 on Oracle Linux 7
Viewed 4455 times since Fri, Aug 3, 2018