Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss] LVM Re: A really interesting chain of functionality



On Mon, Sep 26, 2011 at 10:17 PM, Bill Bogstad <bogstad at pobox.com> wrote:

> On Mon, Sep 26, 2011 at 9:45 PM, Mark Woodward <markw at mohawksoft.com>
> wrote:
> > On 09/26/2011 07:17 PM, Edward Ned Harvey wrote:
> >>
> >> So, this all serves to rather emphasize my point, which is to say...
> >> (LVM) Create snapshot, mount it, monitor it with nagios or whatever,
> >> lvextend it, lvextend the filesystem, resize2fs, unmount and release
> >> snapshot...
> >> versus
> >> (ZFS, Netapp, Volume Shadow Services, etc.)  Do nothing, and don't worry
> >> about it.  It's all automatic and dynamic and just works.
> >
> > I don't think this is right. Running nagios on a snapshot would do
> nothing.
> > A snapshot is protected from change.
>
> This is neither true in the logical nor physical sense with LVM.   It
> was never true in a physical sense, in that the storage for the
> snapshot is slowly used up due to copy-on-write as applications write
> to the original copy of the filesystem.   It's not true in the logical
> sense because LVM snapshots have actually been read/write for quite a
> while.  A common usage pattern for this appears to be when you want
> multiple copies of essentially the same virtual machine image.
> You start with a single gold copy and then create writable snapshots
> for each virtual machine.
>
> Bill Bogstad
> _______________________________________________
> Discuss mailing list
> Discuss at blu.org
> http://lists.blu.org/mailman/listinfo/discuss
>

Correct, but from the way it's been desribed to me.  If you have a 500GB
drive, and only allocated 400GB, the 100GB becomes like a scratch space.
 When you take a snapshot, the 400GB volume is frozen and all changes (both
original and snapshot) go to the unallocated space.  If you run vgdisplay,
there will be a line that says "Free PE / Size".  If this get's to 0 while
you have a snapshot, the snapshot will release so all those changes can be
written back to the main volume.

You can also take as many snapshots as you want.  For example, in the past I
had a QA department that needed weekly refreshes of a MySQL database which
were over 750GB.  Copying and restoring would take too long and they
couldn't afford to be down that long.  They also needed a MySQL master-slave
setup, but at the time we couldn't give them more than a single server.  So
we bumped up the memory on the server, attached it to a 4TB volume on the
SAN.  Then we setup mysql in /var/lib/mysql (running on a separate IP and
port) mounted as a 1TB volume on the SAN drive (notice only 25% allocated).
 This copy of MySQL was a slave process of what was running in production,
so it's always up to date with the latest copy, but is a read-only copy.

Next to give QA a working master and slave with the most recent data, I
wrote a script that shuts down MySQL(prod-slave), snapshots /var/lib/mysql
to /var/lib/mysql-master and /var/lib/mysql-slave, then starts MySQL
(prod-slave) back up and starts replicating again.  Next a couple of cleanup
processes were run against the two snapshot folders so they wouldn't try to
replicate from production.  Starts mysql on QA-master and QA-slave, then
rans a few more commands to make the slave instance a slave of the master
instance.  Running my snapshot script took gave our QA department a fresh
snapshot of 750GB of data in about 1 minute.

The to keep track of the unused 75% of the volume since changes from all
three volumes were writing to it, I had a nagios process that monitored the
SAN drive's "Free PE / Size", so when it got to a certain threshold if QA
hadn't requested a refresh we told them it was about time.  If anyone's
interested I'll dig through my archive to see if I can find my script,
although I might have to clean them up a bit.

Matthew Shields
Owner
BeanTown Host - Web Hosting, Domain Names, Dedicated Servers, Colocation,
Managed Services
www.beantownhost.com
www.sysadminvalley.com
www.jeeprally.com
Like us on Facebook <http://www.facebook.com/beantownhost>
Follow us on Twitter <https://twitter.com/#!/beantownhost>



BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org