Monday, May 14, 2012

How to add device in LVM

My current setup is Raid5 with 2 Device. I decided to add a new disk so I need to configure Raid5 with 3 device. Below are the procedures that I did.

Record first your existing setup
[root@centosprod1 ~]# cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4]
md0 : active raid5 sdf1[2] sdg1[3]
      1043968 blocks super 1.2 level 5, 512k chunk, algorithm 2 [2/2] [UU]

unused devices: 
[root@centosprod1 ~]# mdadm --detail /dev/md0
/dev/md0:
        Version : 1.2
  Creation Time : Mon May  7 14:35:19 2012
     Raid Level : raid5
     Array Size : 1043968 (1019.67 MiB 1069.02 MB)
  Used Dev Size : 1043968 (1019.67 MiB 1069.02 MB)
   Raid Devices : 2
  Total Devices : 2
    Persistence : Superblock is persistent

    Update Time : Mon May 14 12:52:21 2012
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

         Layout : left-symmetric
     Chunk Size : 512K

           Name : centosprod1:0  (local to host centosprod1)
           UUID : f443db62:a4ff36fd:ab0706e4:d9e299cc
         Events : 104

    Number   Major   Minor   RaidDevice State
       3       8       97        0      active sync   /dev/sdg1
       2       8       81        1      active sync   /dev/sdf1
We will now add the new device /dev/sde1
[root@centosprod1 ~]# mdadm --add /dev/md0 /dev/sde1
mdadm: added /dev/sde1
[root@centosprod1 ~]# mdadm --detail /dev/md0
/dev/md0:
        Version : 1.2
  Creation Time : Mon May  7 14:35:19 2012
     Raid Level : raid5
     Array Size : 1043968 (1019.67 MiB 1069.02 MB)
  Used Dev Size : 1043968 (1019.67 MiB 1069.02 MB)
   Raid Devices : 2
  Total Devices : 3
    Persistence : Superblock is persistent

    Update Time : Mon May 14 13:02:13 2012
          State : clean
 Active Devices : 2
Working Devices : 3
 Failed Devices : 0
  Spare Devices : 1

         Layout : left-symmetric
     Chunk Size : 512K

           Name : centosprod1:0  (local to host centosprod1)
           UUID : f443db62:a4ff36fd:ab0706e4:d9e299cc
         Events : 105

    Number   Major   Minor   RaidDevice State
       3       8       97        0      active sync   /dev/sdg1
       2       8       81        1      active sync   /dev/sdf1

       4       8       65        -      spare   /dev/sde1
The disk has been added but you would notice that it is still spare. We will now set our raid array to have 3 devices
[root@centosprod1 ~]# mdadm --grow /dev/md0 --raid-devices=3
mdadm: Need to backup 1024K of critical section..
[root@centosprod1 ~]# mdadm --detail /dev/md0
/dev/md0:
        Version : 1.2
  Creation Time : Mon May  7 14:35:19 2012
     Raid Level : raid5
     Array Size : 1043968 (1019.67 MiB 1069.02 MB)
  Used Dev Size : 1043968 (1019.67 MiB 1069.02 MB)
   Raid Devices : 3
  Total Devices : 3
    Persistence : Superblock is persistent

    Update Time : Mon May 14 13:03:28 2012
          State : clean, reshaping
 Active Devices : 3
Working Devices : 3
 Failed Devices : 0
  Spare Devices : 0

         Layout : left-symmetric
     Chunk Size : 512K

 Reshape Status : 8% complete
  Delta Devices : 1, (2->3)

           Name : centosprod1:0  (local to host centosprod1)
           UUID : f443db62:a4ff36fd:ab0706e4:d9e299cc
         Events : 120

    Number   Major   Minor   RaidDevice State
       3       8       97        0      active sync   /dev/sdg1
       2       8       81        1      active sync   /dev/sdf1
       4       8       65        2      active sync   /dev/sde1
The new disk has successfully added.
[root@centosprod1 ~]# mdadm --detail /dev/md0
/dev/md0:
        Version : 1.2
  Creation Time : Mon May  7 14:35:19 2012
     Raid Level : raid5
     Array Size : 1043968 (1019.67 MiB 1069.02 MB)
  Used Dev Size : 1043968 (1019.67 MiB 1069.02 MB)
   Raid Devices : 3
  Total Devices : 3
    Persistence : Superblock is persistent

    Update Time : Mon May 14 13:10:00 2012
          State : clean, reshaping
 Active Devices : 3
Working Devices : 3
 Failed Devices : 0
  Spare Devices : 0

         Layout : left-symmetric
     Chunk Size : 512K

 Reshape Status : 63% complete
  Delta Devices : 1, (2->3)

           Name : centosprod1:0  (local to host centosprod1)
           UUID : f443db62:a4ff36fd:ab0706e4:d9e299cc
         Events : 157

    Number   Major   Minor   RaidDevice State
       3       8       97        0      active sync   /dev/sdg1
       2       8       81        1      active sync   /dev/sdf1
       4       8       65        2      active sync   /dev/sde1

No comments:

Post a Comment