LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-12-2012, 05:55 AM   #1
devUnix
Member
 
Registered: Oct 2010
Posts: 606

Rep: Reputation: 59
Mirroring in LVM


I have got a book "RHEL 5 Administration Unleashed By Tammy Fox".

The author describes "Taking a Snapshot of a Logical Volume". I was once asked in an interview: "How do we do mirroring of an Logical Volume?", and I was not sure of it.

Is Mirroring of an LV is the same thing as Taking a Snapshot of it? If not, then, how to?
 
Old 03-12-2012, 07:04 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Normally "mirroring" would refer to setting up a RAID 1 either through software or hardware, normally with interview questions I'd ask for a clarification as to whether they mean raid mirror or some kind of time based snapshot. If it's a time-based snapshot to a different/remote volume you could look at DIRVISH as an option.
 
Old 03-12-2012, 11:05 AM   #3
devUnix
Member
 
Registered: Oct 2010
Posts: 606

Original Poster
Rep: Reputation: 59
Quote:
Originally Posted by TenTenths View Post
Normally "mirroring" would refer to setting up a RAID 1 either through software or hardware, normally with interview questions I'd ask for a clarification as to whether they mean raid mirror or some kind of time based snapshot.
That's exactly what I asked him! But he said: "RAID Controller is not there on the system. We are not concerned about implementing RAID. We want mirroring out of LVM only. Is it possible or not?" I said: "Mirroring is RAID 1. That's it. Not sure how to achieve it using LVM". He was disappointed.

Last edited by devUnix; 03-12-2012 at 11:08 AM.
 
Old 03-12-2012, 11:10 AM   #4
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Quote:
Originally Posted by devUnix View Post
That's exactly what I asked him! But he said: "RAID Controller is not there on the system. We are not concerned about implementing RAID. We want mirroring out of LVM only. Is it possible or not?" I said: "Mirroring is RAID 1. That's it. Not sure how to achieve it using LVM". He was disappointed.
pretty much would have been my answer too, although you could have said that it may have been possible to implement a linux software RAID for mirroring but that hardware raid is much more reliable.
 
Old 03-12-2012, 05:20 PM   #5
devUnix
Member
 
Registered: Oct 2010
Posts: 606

Original Poster
Rep: Reputation: 59
I created a Logical Volume "/dev/myVolGrp00/scripts" and wrote some files in the mount point "/scripts" and created another snapshot LV "/dev/myVolGrp00/scripts-snapshot" for it and added some more files but I see nothing in the snapshot "":

Code:
[root@localhost ~]# lvdisplay
  --- Logical volume ---
  LV Name                /dev/myVolGrp00/scripts
  VG Name                myVolGrp00
  LV UUID                NPRoIf-QEx1-aSv1-PF4V-Lyc1-ibIY-9PRsS3
  LV Write Access        read/write
  LV snapshot status     source of
                         /dev/myVolGrp00/scripts-snapshot [active]
  LV Status              available
  # open                 1
  LV Size                8.00 MiB
  Current LE             2
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

  --- Logical volume ---
  LV Name                /dev/myVolGrp00/scripts-snapshot
  VG Name                myVolGrp00
  LV UUID                yv1h3Y-0mjm-uM2P-vu3b-qZWZ-W4ta-DsmYKX
  LV Write Access        read/write
  LV snapshot status     active destination for /dev/myVolGrp00/scripts
  LV Status              available
  # open                 0
  LV Size                8.00 MiB
  Current LE             2
  COW-table size         4.00 MiB
  COW-table LE           1
  Allocated to snapshot  0.29%
  Snapshot chunk size    4.00 KiB
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0


[root@localhost ~]# ls -ltr /snap-scripts/
total 12
drwx------. 2 root root 12288 Mar 13 03:38 lost+found
Of course, before mounting them I had formatted them, for example:

Code:
[root@localhost ~]# mke2fs -t ext4 /dev/myVolGrp00/scripts-snapshot
I have added them to "/etc/fstab":

Code:
/dev/myVolGrp00/scripts /scripts                ext4    defaults        1 2
/dev/myVolGrp00/scripts /snap-scripts           ext4    defaults        1 2

Note: I created the snapshot in this way:

Code:
[root@localhost ~]# lvcreate --size 4M -s --name scripts-snapshot /dev/myVolGrp00/scripts
  Logical volume "scripts-snapshot" created
I simply followed the System Admin book. It does not say anything about how snapshot is going show the files/directories as well as how to reduce the Logical Volume's size. I have successfully extended its size but reducing did not work with the "lvextend -r" command.

Last edited by devUnix; 03-12-2012 at 05:28 PM.
 
Old 03-13-2012, 01:12 AM   #6
devUnix
Member
 
Registered: Oct 2010
Posts: 606

Original Poster
Rep: Reputation: 59
I see the same files in the snapshot now:

Code:
[root@localhost ~]# ls -l /snap-scripts/
total 19
-rw-rw-r--. 1 hello hello     0 Mar 13 03:41 feel
...
I made no changes. I just started the machine (after some hours) and the snapshot looks okay.
 
Old 03-13-2012, 05:08 AM   #7
makyo
Member
 
Registered: Aug 2006
Location: Saint Paul, MN, USA
Distribution: {Free,Open}BSD, CentOS, Debian, Fedora, Solaris, SuSE
Posts: 735

Rep: Reputation: 76
Hi.

Mirroring and snapshots are two different features.

With LVM, one can set up mirrors:
Code:
       -m, --mirrors Mirrors
              Creates  a  mirrored  logical  volume  with Mirrors copies.  For
              example, specifying "-m 1" would result in a  mirror  with  two-
              sides; that is, a linear volume plus one copy.
-- excerpt from man 8 lvcreate
I have usually used LVM on top of RAID1, but using LVM mirrors might be one less piece of complexity.

For the snapshot:
Quote:
A full backup of a large data set may take a long time to complete. On multi-tasking or multi-user systems, there may be writes to that data while it is being backed up. This prevents the backup from being atomic and introduces a version skew that may result in data corruption. For example, if a user moves a file into a directory that has already been backed up, then that file would be completely missing on the backup media, since the backup operation had already taken place before the addition of the file. Version skew may also cause corruption with files which change their size or contents underfoot while being read.

To avoid downtime, high-availability systems may instead perform the backup on a snapshot—a read-only copy of the data set frozen at a point in time—and allow applications to continue writing to their data. Most snapshot implementations are efficient and can create snapshots in O(1). In other words, the time and I/O needed to create the snapshot does not increase with the size of the data set, whereas the same for a direct backup is proportional to the size of the data set. In some systems once the initial snapshot is taken of a data set, subsequent snapshots copy the changed data only, and use a system of pointers to reference the initial snapshot. This method of pointer-based snapshots consumes less disk capacity than if the data set was repeatedly cloned.

-- http://en.wikipedia.org/wiki/Snapshot_(computer_storage)
In LVM, the snapshots are done with copy-on-write http://en.wikipedia.org/wiki/Copy-on-write

I use snapshots indirectly by telling rsnapshot to use snapshots for data on LVM volumes. It creates the snapshot for the duration of the backup, then removes it.

Best wishes ... makyo

Last edited by makyo; 03-13-2012 at 05:10 AM.
 
1 members found this post helpful.
Old 03-14-2012, 01:24 PM   #8
devUnix
Member
 
Registered: Oct 2010
Posts: 606

Original Poster
Rep: Reputation: 59
Quote:
Originally Posted by makyo View Post
Hi.

Mirroring and snapshots are two different features.

With LVM, one can set up mirrors:
Code:
       -m, --mirrors Mirrors
              Creates  a  mirrored  logical  volume  with Mirrors copies.  For
              example, specifying "-m 1" would result in a  mirror  with  two-
              sides; that is, a linear volume plus one copy.
-- excerpt from man 8 lvcreate

Makyo:


Thanks for the command option!


Rated you for your contribution to the post and for adding interesting stuffs as well.

Have a nice time!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Existing LVM filesystem to software RAID 0 (mirroring) hellowe Linux - Server 8 11-25-2009 07:28 AM
LXer: LVM's Roots - Mirroring Your Boot Disk On HP-UX 10 Unix LXer Syndicated Linux News 0 10-30-2008 10:50 AM
LVM mirroring jkboys Linux - Newbie 0 07-08-2008 02:22 PM
LVM mirroring two volumes sebstar Linux - Server 4 02-17-2008 05:07 PM
LVM and lvextend mirroring smkamene Linux - Software 0 02-26-2005 08:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration