OpenVZ Forum


Home » General » Support » I find a Copy On Write Solution for openVZ
I find a Copy On Write Solution for openVZ [message #6800] Fri, 22 September 2006 18:07 Go to next message
themoonseeker is currently offline  themoonseeker
Messages: 12
Registered: September 2006
Junior Member
Hi,

Finally, after many tests i have found a Copy On Write solution for openVZ. Let me show you :

1 : install lvm

apt-get install lvm2

2 : create a LVM physical volume

pvcreate /dev/hde8

3 : Create a LVM group

vgcreate openvz /dev/hde8

4 : Create a volume and format it in ext3

lvcreate -L200M -n vps-core openvz
mkfs -t ext3 /dev/openvz/vps-core

5 : Create VPS 201 area and mount the logical volume

mkdir -p /mnt/201/root /mnt/201/private
mount /dev/openvz/vps-core /mnt/201

6 : Populate the 201 area

cd /var/lib/vz/template/cache/
wget http://download.openvz.org/template/precreated/debian-3.1-i3 86-minimal.tar.gz
cd /mnt/201/private/
tar zxvf /var/lib/vz/template/cache/debian-3.1-i386-minimal.tar.gz /mnt/201/private/

7 : Unmount the logical volume (for a snapshot)

umount /mnt/201/

8 : Create the 201 config file

echo "# Copyright (C) 2000-2006 SWsoft. All rights reserved.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#

ONBOOT="no"

# UBC parameters (in form of barrier:limit)
# Primary parameters
AVNUMPROC="15:15"
NUMPROC="40:40"
NUMTCPSOCK="40:40"
NUMOTHERSOCK="40:40"
VMGUARPAGES="1725:2147483647"
# Secondary parameters
KMEMSIZE="1740800:1847296"
TCPSNDBUF="159744:262144"
TCPRCVBUF="159744:262144"
OTHERSOCKBUF="61440:163840"
DGRAMRCVBUF="32768:32768"
OOMGUARPAGES="1725:2147483647"
# Auxiliary parameters
LOCKEDPAGES="4:4"
SHMPAGES="1152:1152"
PRIVVMPAGES="7680:8448"
NUMFILE="512:512"
NUMFLOCK="50:60"
NUMPTY="4:4"
NUMSIGINFO="256:256"
DCACHESIZE="196608:202752"

PHYSPAGES="0:2147483647"
NUMIPTENT="16:16"

# Disk quota parameters (in form of softlimit:hardlimit)
DISKSPACE="512000:512000"
DISKINODES="80000:88000"
QUOTATIME="0"

# CPU fair sheduler parameter
CPUUNITS="250"

VE_ROOT="/mnt/201/root"
VE_PRIVATE="/mnt/201/private"
OSTEMPLATE="debian-3.1-i386-minimal" >> /etc/vz/conf/201.conf

9 : create the 202 conf file

cp /etc/vz/conf/201.conf /etc/vz/conf/202.conf

vi /etc/vz/conf/202.conf

replace :

VE_ROOT="/mnt/201/root"
VE_PRIVATE="/mnt/201/private"

with this

VE_ROOT="/mnt/202/root"
VE_PRIVATE="/mnt/202/private"

10 : Create the snapshot

lvcreate -s -L100M -n vps202 /dev/openvz/vps-core

11 : Mount the 201 core

mount /dev/openvz/vps-core /mnt/201

12 : Mount the 202 copy on write

mkdir -p /mnt/202
mount /dev/openvz/vps202 /mnt/202/

13 : And finally start the two vps

vzctl start 201
vzctl start 202

Now let me show the memory saved :

themoonseeker:/# lvs
LV VG Attr LSize Origin Snap% Move Log Copy%
vps-core openvz owi-a- 200.00M
vps202 openvz swi-ao 100.00M vps-core 0.95

I'd like to use this solution for a virtual network editor.

What do you think about this solution? especially about stability and performance?

Thanks! Smile
Re: I find a Copy On Write Solution for openVZ [message #6840 is a reply to message #6800] Mon, 25 September 2006 08:29 Go to previous messageGo to next message
themoonseeker is currently offline  themoonseeker
Messages: 12
Registered: September 2006
Junior Member
Any notices or suggestions!?!?
Re: I find a Copy On Write Solution for openVZ [message #6844 is a reply to message #6840] Mon, 25 September 2006 10:02 Go to previous messageGo to next message
HaroldB is currently offline  HaroldB
Messages: 61
Registered: June 2006
Member
Hi, your solution seems pretty clean and simple. Are first level quotas handled OK? Since the VZFS is the major selling point/advantage of commercial VZ, I am not sure if the OVZ developers will be able to say this is a good idea. Laughing
Re: I find a Copy On Write Solution for openVZ [message #6851 is a reply to message #6800] Mon, 25 September 2006 12:50 Go to previous message
szocske is currently offline  szocske
Messages: 35
Registered: September 2006
Member
I must read up a lot on LVM to make sense of all this, but I have a question upfront: How are .so files and data mmapped from different VEs hadled? Does the kernel know when the processes from different VEs are accessing the same file?
Or is this only a measure to save disk space?

I don't care about quotas, so I'll definitely try this.

My ideal setup would be a master-slaves environment: one VE has everything mounted rw, the rest sees the same files but read only, except for /etc, /var and /home, which are separate for each.
Previous Topic: *SOLVED* veth
Next Topic: Oracle DB and VPS
Goto Forum:
  


Current Time: Thu Apr 18 19:20:50 GMT 2024

Total time taken to generate the page: 0.01692 seconds