Jeder, der mindestens einmal in seinem Leben einen OpenVZ-Container auf einen Server mit vollständiger KVM-Virtualisierung übertragen musste, hatte einige Probleme:
- Die meisten Informationen sind banal veraltet und waren für den längst vergangenen EOL-Betriebssystemzyklus relevant
- Für verschiedene Betriebssysteme werden immer unterschiedliche Informationen bereitgestellt, und mögliche Fehler werden bei der Migration niemals berücksichtigt.
- Manchmal müssen Sie sich mit Konfigurationen befassen, die nach der Migration nicht funktionieren möchten
Wenn Sie 1 Server übertragen, können Sie unterwegs immer etwas reparieren, und wenn Sie einen gesamten Cluster übertragen?
In diesem Artikel werde ich versuchen zu erklären, wie OpenVZ-Container mit minimaler Ausfallzeit und schneller Lösung für alle Probleme korrekt auf KVM migriert werden können.
Ein kleines Bildungsprogramm: Was ist OpenVZ und was ist KVM?
Wir werden uns nicht mit der Terminologie befassen, sondern allgemein:
OpenVZ ist eine Virtualisierung auf Betriebssystemebene. Sie können sie sogar in der Mikrowelle bereitstellen, da auf dem Host-Computer keine CPU-Anweisungen und Virtualisierungstechnologien erforderlich sind.
KVM ist eine vollwertige Virtualisierung, die die gesamte Leistung der CPU nutzt und in der Lage ist, alles zu virtualisieren, unabhängig von Länge und Breite.
, - 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 — . , , — .
, ! :)