In this manual we will install OpenVZ on top of ZFS on CentOS 6. More documentation about ZVOL: http://zfsonlinux.org/example-zvol.html
Check ZFS loading:
Installing OpenVZ
At first you should install OpenVZ kernel and userspace using this guide http://openvz.org/Quick_installation:
wget -P /etc/yum.repos.d/ http://ftp.openvz.org/openvz.repoAt second please reboot to OpenVZ kernel and _after_ this install OpenZFS packages:
rpm --import http://ftp.openvz.org/RPM-GPG-Key-OpenVZ
yum install vzkernel vzctl vzquota ploop
shutdown -r now
yum remove kernelZFS kernel modules will be installed using DKMS and will be recompiled for new kernels automatically.
yum install -y vzkernel-devel
rpm -ihv http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
yum localinstall -y --nogpgcheck http://archive.zfsonlinux.org/epel/zfs-release$(rpm -E %dist).noarch.rpm
yum update -y
yum install zfs -y
Check ZFS loading:
zpool statusCreate ZFS pool with name vzpool (don't use name "vz" because it already used by OpenVZ's /vz partition):
no pools available
zpool create -f vzpool mirror /dev/sdc /dev/sdd
Integrate ZFS with OpenVZ
Create OpenVZ container with simfs layout model:
vzctl create 101 --layout simfs --name zfs.ru --ostemplate debian-7.0-x86_64Create ZFS zvol for 10G:
zfs create -V 10G vzpool/ct101We can use sparse allocation and specify block size. But it's _VERY DANGEROUS_, please read documentation after doing something!
The reservation is kept equal to the volume’s logical size to prevent unexpected behavior for consumers. Without the reservation, the volume could run out of space, resulting in undefined behavior or data corruption, depending on how the volume is used. These effects can also occur when the volume size is changed while it is in use (particularly when shrinking the size). Extreme care should be used when adjusting the volume size. Though not recommended, a "sparse volume" (also known as "thin provisioning") can be created by specifying the -s option to the zfs create -V command, or by changing the reservation after the volume has been created. A "sparse volume" is a volume where the reservation is less then the volume size. Consequently, writes to a sparse volume can fail with ENOSPC when the pool is low on space. For a sparse volume, changes to volsize are not reflected in the reservation.Create GPT partition table on created zvol:
-b blocksize
Equivalent to -o volblocksize=blocksize. If this option is specified in conjunction with -o volblock-size, the resulting behavior is undefined.
parted -s /dev/vzpool/ct101 mklabel gptCreate one partition for whole disk:
parted /dev/vzpool/ct101 "mkpart primary 1 -1"Create ext4 filesystem on zvol:
mkfs -t ext4 -j -b4096 -Elazy_itable_init,resize=4294967295 -Jsize=128 /dev/vzpool/ct101-part1And move container to this filesystem:
mkdir /mnt/101Remove old container body:
mount /dev/vzpool/ct101-part1 /mnt/101
cp -a /vz/private/101/* /mnt/101/
umount /mnt/101
sync
rm -rf /vz/private/101/And replace it by mounted ZFS zvol:
mkdir /vz/private/101Mount container:
mount /dev/vzpool/ct101-part1 /vz/private/101
vzctl mount 101Check files in /vz/root/101:
LANG=C ls -al /vz/root/101/Start container:
total 92K
drwxr-xr-x 23 root root 4.0K Jun 27 02:38 .
drwx------ 3 root root 4.0K Jul 2 12:35 ..
drwxr-xr-x 2 root root 4.0K Jun 27 02:38 bin
drwxr-xr-x 2 root root 4.0K Jun 27 02:37 boot
drwxr-xr-x 2 root root 4.0K Jun 27 02:36 dev
drwxr-xr-x 81 root root 4.0K Jul 2 12:35 etc
-rw-r--r-- 1 root root 0 Jun 27 02:36 fastboot
drwxr-xr-x 2 root root 4.0K Jun 27 02:37 home
drwxr-xr-x 11 root root 4.0K Jun 27 02:37 lib
drwxr-xr-x 2 root root 4.0K Jun 27 02:37 lib64
drwx------ 2 root root 4.0K Jun 27 02:36 lost+found
drwxr-xr-x 2 root root 4.0K Jun 27 02:37 media
drwxr-xr-x 2 root root 4.0K Jun 27 02:37 mnt
drwxr-xr-x 2 root root 4.0K Jun 27 02:37 opt
dr-xr-xr-x 2 root root 4.0K Jun 27 02:36 proc
drwx------ 2 root root 4.0K Jun 27 02:37 root
drwxr-xr-x 2 root root 4.0K Jun 27 02:38 run
drwxr-xr-x 2 root root 4.0K Jun 27 02:37 sbin
drwxr-xr-x 2 root root 4.0K Jun 27 02:37 selinux
drwxr-xr-x 2 root root 4.0K Jun 27 02:37 srv
drwxr-xr-x 2 root root 4.0K Jun 27 02:36 sys
drwxrwxrwt 2 root root 4.0K Jun 27 02:38 tmp
drwxr-xr-x 10 root root 4.0K Jun 27 02:38 usr
drwxr-xr-x 12 root root 4.0K Jun 27 02:38 var
vzctl start 101Inside container filesystem show as simfs not an ZFS:
Starting container...
Container is unmounted
Container is mounted
Setting CPU units: 1000
Container start in progress...
cat /proc/mountsIf you need any help/questions, you can write to me: pavel.odintsov at gmail dot com.
/dev/simfs / simfs rw,relatime 0 0
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
none /dev devtmpfs rw,nosuid,noexec,relatime,mode=755 0 0
none /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
none /proc/sys/fs/binfmt_misc binfmt_misc rw,nosuid,nodev,noexec,relatime 0 0
none /run tmpfs rw,nosuid,noexec,relatime,size=26216k,mode=755 0 0
none /run/lock tmpfs rw,nosuid,nodev,noexec,relatime,size=5120k 0 0
none /run/shm tmpfs rw,nosuid,nodev,noexec,relatime,size=157280k 0 0
none /run/user tmpfs rw,nosuid,nodev,noexec,relatime,size=102400k,mode=755 0 0
No comments :
Post a Comment
Note: only a member of this blog may post a comment.