Cómo transferir el contenedor OpenVZ 6 al servidor KVM sin dolor de cabeza

Todos los que necesitaban transferir un contenedor OpenVZ a un servidor con virtualización KVM completa al menos una vez en su vida encontraron algunos problemas:


  • La mayor parte de la información está obsoleta y era relevante para el ciclo EOL OS antiguo.
  • Siempre se proporciona información diferente para diferentes sistemas operativos, y los posibles errores nunca se consideran durante la migración.
  • A veces tiene que lidiar con configuraciones que no quieren funcionar después de la migración

Cuando transfiere 1 servidor, siempre puede arreglar algo sobre la marcha, y cuando transfiere un clúster completo.


En este artículo, intentaré explicar cómo migrar un contenedor OpenVZ a KVM correctamente con un tiempo de inactividad mínimo y una solución rápida a todos los problemas.


Un pequeño programa educativo: ¿qué es OpenVZ y qué es KVM?


No profundizaremos en la terminología, sino en términos generales:


OpenVZ es virtualización a nivel de sistema operativo, incluso puede implementarlo en el microondas, ya que no hay necesidad de instrucciones de CPU y tecnologías de virtualización en la máquina host.


KVM es una virtualización completa que utiliza toda la potencia de la CPU y es capaz de virtualizar cualquier cosa, lo que sea, cortar longitud y amplitud.


, - 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