How to take backup of GFS2 in Redhat ?

As we know that in case of clustered file system its not possible to take the snapshots. To take the snapshot we have to mount them exclusively. To show how to do that

I have created two node Redhat cluster and mounted one GFS2 file system on mount point /mygfs2 on both nodes.

My Test Lab OS : Redhat 6.2 64 bit

[root@Node1 mygfs2]# clustat -l
Cluster Status for Shiv @ Tue Sep 30 03:08:18 2014
Member Status: Quorate

Member Name                             ID   Status
—— —-                             —- ——
192.168.56.10                               1 Online, Local
192.168.56.11                               2 Online

[root@Node1 ~]# df -h /mygfs2/
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/gfs_vg1-gfs_lv1
700M  281M  420M  41% /mygfs2

[root@Node2 ~]# df -h /mygfs2/
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/gfs_vg1-gfs_lv1
700M  281M  420M  41% /mygfs2

Step 1 : I have unmounted the GFS2 file system on both cluster nodes.

[root@Node1 ~]# umount /mygfs2
[root@Node1 ~]#

[root@Node2 ~]# umount /mygfs2
[root@Node2 ~]#

[root@Node1 ~]# lvs gfs_vg1/gfs_lv1
LV      VG      Attr   LSize   Origin Snap%  Move Log Copy%  Convert
gfs_lv1 gfs_vg1 -wi-a- 700.00m

[root@Node2 ~]# lvs gfs_vg1/gfs_lv1
LV      VG      Attr   LSize   Origin Snap%  Move Log Copy%  Convert
gfs_lv1 gfs_vg1 -wi-a- 700.00m

Step 2 : Deactivate the logical volume on both nodes using below commands.

[root@Node1 ~]# lvchange -an gfs_vg1/gfs_lv1

[root@Node1 ~]# lvs gfs_vg1/gfs_lv1
LV      VG      Attr   LSize   Origin Snap%  Move Log Copy%  Convert
gfs_lv1 gfs_vg1 -wi— 700.00m

[root@Node2 ~]# lvchange -an gfs_vg1/gfs_lv1

[root@Node2 ~]# lvs gfs_vg1/gfs_lv1
LV      VG      Attr   LSize   Origin Snap%  Move Log Copy%  Convert
gfs_lv1 gfs_vg1 -wi— 700.00m

Step 3 : Changed the logical volume to exclusive single node by using below command. This needs to be done only on one node.

[root@Node1 ~]# lvchange -aey gfs_vg1/gfs_lv1

[root@Node1 ~]# lvs gfs_vg1/gfs_lv1
LV      VG      Attr   LSize   Origin Snap%  Move Log Copy%  Convert
gfs_lv1 gfs_vg1 -wi-a- 700.00m

Step 4 : Created the snapshot volume from that volume. Snapshot volume is named as “snap” and it is of size 100MB.

[root@Node1 ~]# lvcreate –size 100M –snapshot –name snap /dev/gfs_vg
Logical volume “snap” created

[root@Node1 ~]# lvs
LV      VG       Attr   LSize   Origin  Snap%  Move Log Copy%  Conver
gfs_lv1 gfs_vg1  owi-a- 700.00m
snap    gfs_vg1  swi-a- 100.00m gfs_lv1   0.00

Step 5 : I mounted the snapshot volume on one temporary mountpoint to access the data inside it.

[root@Node1 ~]# mount -o lockproto=lock_nolock /dev/gfs_vg1/snap /mnt

[root@Node1 ~]# df -h /mnt
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/gfs_vg1-snap
700M  281M  420M  41% /mnt

Step 6 : After that I tried to mount the original file system I was getting error this was becuase my snap was still mounted. I unmounted my snap volume and tried to mount the original volume again after changing the volume to cluster mode.

[root@Node1 ~]# lvchange -aen gfs_vg1/gfs_lv1
LV gfs_vg1/gfs_lv1 has open snapshot snap: not deactivating

[root@Node1 ~]# umount /mnt

[root@Node1 ~]# lvchange -aen gfs_vg1/gfs_lv1
[root@Node1 ~]#

[root@Node1 ~]# lvchange -aey gfs_vg1/gfs_lv1

Step 7 : I removed the snap volume otherwise if you start using original volume and snap volume reaches 100% value then it will create trouble.

[root@Node1 ~]# lvremove /dev/gfs_vg1/snap
Do you really want to remove active logical volume snap? [y/n]: y
Logical volume “snap” successfully removed

References :

How to backup GFS2 file system ?
https://access.redhat.com/solutions/307333
https://access.redhat.com/solutions/19283
How to change cluster Logical volume to non-clustered ?
https://access.redhat.com/solutions/3618
Why backup using rsync is very slow in GFS2 ?
https://access.redhat.com/solutions

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s