How to transfer OpenVZ 6 container to KVM server without headache

Everyone who needed to transfer an OpenVZ container to a server with full KVM virtualization at least once in their life encountered some problems:


  • Most of the information is banal outdated and was relevant for the long-past EOL OS cycle
  • Different information is always provided for different operating systems, and possible errors are never considered during migration.
  • Sometimes you have to deal with configurations that do not want to work after migration

When you transfer 1 server, you can always fix something on the go, and when you transfer an entire cluster?


In this article I will try to tell how to migrate OpenVZ container to KVM correctly with minimal downtime and quick solution to all problems.


A small educational program: what is OpenVZ and what is KVM?


We will not delve into the terminology, but in general terms:


OpenVZ is virtualization at the operating system level, you can even deploy it on the microwave, since there is no need for CPU instructions and virtualization technologies on the host machine.


KVM is a full-fledged virtualization that uses all the power of the CPU and is able to virtualize anything, whatever, cut length and breadth.


, - OpenVZ , KVM — , KVM .


?


, OpenVZ: CentOS (6 7 ), Ubuntu (14, 16 18 LTS), Debian 7.


, OpenVZ - LAMP, - . , ISPmanager, VestaCP ( , ). .


IP- , IP, , VM .


, :


  • OpenVZ, - -, ///
  • KVM, - -, . , .


, , :


KVM_NODE — - KVM
VZ_NODE — - OpenVZ
CTID — OpenVZ
VM — KVM


.


1


- , VM KVM_NODE.
! VM , CTID. , CTID Ubuntu 14, VM Ubuntu 14. , — .


VM, CTID VM ( — , , , ).


CentOS :


# yum clean all
# yum update -y

Ubuntu, Debian:


# apt-get update
# apt-get upgrade

2


CTID, VZ_NODE VM rsync:


CentOS:


# yum install rsync -y

Debian, Ubuntu:


# apt-get install rsync -y

, .


3


CTID VZ_NODE


vzctl stop CTID

CTID:


vzctl mount CTID

/vz/root/CTID


mount --bind /dev dev && mount --bind /sys sys && mount --bind /proc proc && chroot .

/root/exclude.txt — ,


/boot
/proc
/sys
/tmp
/dev
/var/lock
/etc/fstab
/etc/mtab
/etc/resolv.conf
/etc/conf.d/net
/etc/network/interfaces
/etc/networks
/etc/sysconfig/network*
/etc/sysconfig/hwconf
/etc/sysconfig/ip6tables-config
/etc/sysconfig/kernel
/etc/hostname
/etc/HOSTNAME
/etc/hosts
/etc/modprobe*
/etc/modules
/net
/lib/modules
/etc/rc.conf
/usr/share/nova-agent*
/usr/sbin/nova-agent*
/etc/init.d/nova-agent*
/etc/ips
/etc/ipaddrpool
/etc/ips.dnsmaster
/etc/resolv.conf
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/network-scripts/ifcfg-ens3

KVM_NODE VM, .


. !


4


,


rsync --exclude-from="/root/exclude.txt" --numeric-ids -avpogtStlHz --progress -e "ssh -T -o Compression=no -x" / root@KVM_NODE:/

rsync , , — , , ( - cipher, ), .


rsync, - chroot ( ctrl+d)


umount dev && umount proc && umount sys && cd .. && vzctl umount CTID

5


, VM OpenVZ.
Systemd , , , VNC


mv /etc/systemd/system/getty.target.wants/getty\@tty2.service /etc/systemd/system/getty.target.wants/getty\@tty1.service

CentOS 6 CentOS 7 :


yum install kernel-$(uname -r)

, .


CentOS 7 PolkitD, :


getent group polkitd >/dev/null && echo -e "\e[1;32mpolkitd group already exists\e[0m" || { groupadd -r polkitd && echo -e "\e[1;33mAdded missing polkitd group\e[0m" || echo -e "\e[1;31mAdding polkitd group FAILED\e[0m"; }

getent passwd polkitd >/dev/null 
&& echo -e "\e[1;32mpolkitd user already exists\e[0m" || { useradd -r -g polkitd -d / -s /sbin/nologin -c "User for polkitd" polkitd && echo -e "\e[1;33mAdded missing polkitd user\e[0m" || echo -e "\e[1;31mAdding polkitd user FAILED\e[0m"; }

rpm -Va polkit\* && echo -e "\e[1;32mpolkit* rpm verification passed\e[0m" || { echo -e "\e[1;33mResetting polkit* rpm user/group ownership & perms\e[0m"; rpm --setugids polkit polkit-pkla-compat; rpm --setperms polkit polkit-pkla-compat; }

, mod_fcgid Apache, , , mod_fcgid, 500:


chmod +s `which suexec` && apachectl restart

, Ubuntu, Debian .


looping too fast. throttling execution a little

, , .


Debian 9 :



dbus-uuidgen


/usr/local/lib/libdbus-1.so.3: version `LIBDBUS_PRIVATE_1.10.8′ not found

LIBDBUS


ls -la /lib/x86_64-linux-gnu | grep dbus
libdbus-1.so.3 -> libdbus-1.so.3.14.15 
libdbus-1.so.3.14.15 <--  
libdbus-1.so.3.14.16

,


cd /lib/x86_64-linux-gnu
rm -rf libdbus-1.so.3
ln -s libdbus-1.so.3.14.15  libdbus-1.so.3

— .


throttling execution a little Ubuntu Debian .



bash -x /var/lib/dpkg/info/dbus.postinst configure

Ubuntu 14, Debian 7 :


adduser --system --home /nonexistent --no-create-home --disabled-password --group messagebus

rm -rf /etc/init.d/modules_dep.sh 

? messagebus, Debian/Ubuntu modules_dep, OpenVZ .


6


VM, VNC — . , , — .


, ! :)


All Articles