This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
технология_kvm [2024/07/17 11:05] val [Создание, регистрация и запуск VM] |
технология_kvm [2026/10/23 16:32] (current) val [Использование Ceph RBD в качестве диска] |
||
|---|---|---|---|
| Line 12: | Line 12: | ||
| * !!! 4GB RAM в хост систему (однажды хватило 2:) | * !!! 4GB RAM в хост систему (однажды хватило 2:) | ||
| + | * [[Технология VirtualBox#Вложенная виртуализация]] в VirtualBox | ||
| <code> | <code> | ||
| # egrep -c '(vmx|svm)' /proc/cpuinfo | # egrep -c '(vmx|svm)' /proc/cpuinfo | ||
| + | # apt update | ||
| # time apt install qemu-kvm libvirt-daemon libvirt-clients bridge-utils virt-manager #qemu | # time apt install qemu-kvm libvirt-daemon libvirt-clients bridge-utils virt-manager #qemu | ||
| real 4m27.401s | real 4m27.401s | ||
| Line 34: | Line 36: | ||
| node1# virsh list --all | node1# virsh list --all | ||
| - | node1# virsh vncdisplay winxp1 | + | node1# virsh vncdisplay winxp |
| :0 | :0 | ||
| </code> | </code> | ||
| Line 63: | Line 65: | ||
| --noautoconsole --hvm --boot hd --network bridge=br0,model=rtl8139 \ | --noautoconsole --hvm --boot hd --network bridge=br0,model=rtl8139 \ | ||
| --print-xml | tee /disk3/winxp1.xml | --print-xml | tee /disk3/winxp1.xml | ||
| - | |||
| - | node1# virsh define /disk3/winxp1.xml | ||
| - | node1# virsh edit winxp1 | ||
| - | node1# virsh start winxp1 | ||
| - | node1# virsh undefine winxp1 | ||
| - | |||
| - | или, запуск без регистрации VM в KVM | ||
| node1# virsh create /disk3/winxp1.xml | node1# virsh create /disk3/winxp1.xml | ||
| Line 76: | Line 71: | ||
| node1# virsh vncdisplay winxp1 | node1# virsh vncdisplay winxp1 | ||
| + | |||
| + | node1# ###tail /var/log/libvirt/qemu/winxp1.log | ||
| + | |||
| + | node1# ###virsh shutdown winxp1 | ||
| </code> | </code> | ||
| * [[Сервис VNC]] | * [[Сервис VNC]] | ||
| + | |||
| + | === Если падает в BSOD === | ||
| + | <code> | ||
| + | node1# cat /disk3/winxp1.xml | ||
| + | </code><code> | ||
| + | <domain type="qemu"> | ||
| + | ... | ||
| + | <cpu mode="custom"/> | ||
| + | ... | ||
| + | </code> | ||
| + | |||
| + | ===== Использование Ceph RBD в качестве диска ===== | ||
| + | |||
| + | * [[Решение Ceph]] | ||
| + | * [[#Создание конфигурации VM из образа]] | ||
| + | |||
| + | <code> | ||
| + | node1# qemu-img convert -f qcow2 -O raw /disk3/winxp1.qcow2 rbd:test-pool1/rbd1:mon_host=node3 | ||
| + | |||
| + | node1# cat /disk3/winxp1.xml | ||
| + | </code><code> | ||
| + | ... | ||
| + | <disk type="network" device="disk"> | ||
| + | <driver name="qemu" type="raw"/> | ||
| + | <source protocol="rbd" name="test-pool1/rbd1"> | ||
| + | <host name="node3" port="3300"/> | ||
| + | <host name="node4" port="3300"/> | ||
| + | <host name="node5" port="3300"/> | ||
| + | </source> | ||
| + | <target dev="hda" bus="ide"/> | ||
| + | </disk> | ||
| + | ... | ||
| + | </code><code> | ||
| + | nodeN# ss -ntp | grep 3300 | ||
| + | </code> | ||
| ===== Миграция VM ===== | ===== Миграция VM ===== | ||
| Line 86: | Line 120: | ||
| node1# virsh migrate --live winxp1 qemu+ssh://node2/system | node1# virsh migrate --live winxp1 qemu+ssh://node2/system | ||
| + | node1# ssh node2 virsh list | ||
| + | или | ||
| node1# virsh -c qemu+ssh://node2/system list | node1# virsh -c qemu+ssh://node2/system list | ||
| node1# virsh -c qemu+ssh://node2/system shutdown winxp1 | node1# virsh -c qemu+ssh://node2/system shutdown winxp1 | ||
| + | или | ||
| + | node1# virsh -c qemu+ssh://node2/system destroy winxp1 | ||
| </code> | </code> | ||
| Line 99: | Line 137: | ||
| crm(live/node1)configure# primitive pr_vm_winxp1 ocf:heartbeat:VirtualDomain params config=/disk3/winxp1.xml migration_transport=ssh meta allow-migrate=true | crm(live/node1)configure# primitive pr_vm_winxp1 ocf:heartbeat:VirtualDomain params config=/disk3/winxp1.xml migration_transport=ssh meta allow-migrate=true | ||
| + | </code> | ||
| + | * Может понадобиться | ||
| + | <code> | ||
| + | crm resource stop pr_vm_winxp1 | ||
| + | crm resource unmanage pr_vm_winxp1 | ||
| + | |||
| + | virsh destroy winxp1 | ||
| + | |||
| + | crm resource cleanup pr_vm_winxp1 | ||
| + | crm resource manage pr_vm_winxp1 | ||
| + | |||
| + | crm resource start pr_vm_winxp1 | ||
| + | |||
| + | crm resource move pr_vm_winxp1 node1 | ||
| </code> | </code> | ||
| Line 113: | Line 165: | ||
| # qemu-img info --output json /root/noble-server-cloudimg-amd64.img | # qemu-img info --output json /root/noble-server-cloudimg-amd64.img | ||
| + | # qemu-img info --output json /root/debian-12-generic-amd64.qcow2 | ||
| # time apt install libguestfs-tools | # time apt install libguestfs-tools | ||
| Line 383: | Line 436: | ||
| virsh -c lxc+ssh://node1/ | virsh -c lxc+ssh://node1/ | ||
| + | ====== | ||
| + | |||
| + | <features> | ||
| + | <acpi/> | ||
| + | <apic/> | ||
| + | <pae/> | ||
| + | <kvm> | ||
| + | <hidden state='on'/> | ||
| + | </kvm> | ||
| + | </features> | ||
| + | ... | ||
| + | <cpu mode='custom' match='exact' check='none'> | ||
| + | <model fallback='allow'>kvm64</model> | ||
| + | </cpu> | ||
| + | ... | ||
| + | <cpu mode='custom' match='exact' check='none'> | ||
| + | <model fallback='allow'>kvm64</model> | ||
| + | </cpu> | ||
| + | ... | ||
| + | <os> | ||
| + | <type arch='x86_64' machine='pc'>hvm</type> | ||
| + | ... | ||
| </code> | </code> | ||