KVM: Unterschied zwischen den Versionen

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen
 
(84 dazwischenliegende Versionen von 2 Benutzern werden nicht angezeigt)
Zeile 1: Zeile 1:
 +
=Grundlagen=
 +
*[[QEMU,KVM,libvirt]]
 +
*[[KVM Grundlagen]]
 +
=Dokumentation=
 +
*https://libvirt.org/docs.html
 
=Installation=
 
=Installation=
 
*[[KVM Installation]]
 
*[[KVM Installation]]
 +
=Virtual Machine Manager=
 +
*[[Virtual Machine Manager]]
  
=[http://docs.fedoraproject.org/de-DE/Fedora/12/html/Virtualization_Guide/sect-Virtualization_Guide-Installing_the_virtualization_packages-Installing_KVM_packages_on_an_existing_Fedora_system.html Fedora KVM]=
+
=Virsh=
=[[Spice]]=
+
*[[Virsh]]
=Handling=
 
This command outputs the guest's XML configuration file to standard out (stdout).
 
You can save the data by piping the output to a file. An example of piping the output to a file called guest.xml:
 
  
virsh dumpxml GuestID > guest.xml
 
  
 +
=Virt=
 +
*[[virt-clone]]
 +
*[[virt-viewer]]
 +
*[[virt-top]]
 +
*[[libguestfs-tools]]
  
 +
=Examples=
 +
*[[Konvertierung eines VirtualBox Images und anbinden an eine Virtuelle Maschnine]]
  
* [[Domain-Administration]]
+
=Cluster=
 +
*[[virsh-cluster]]
 +
*[[Libvirt PCS]]
  
= Migration zu neuem Host =
+
=Welche Produkte nutzen KVM=
virsh migrate --live <GuestName> <DestinationURL>
+
*[[Welche Produkte nutzen KVM]]
 +
=Qemu Agent=
 +
*[[Qemu Agent]]
 +
*[[Virtio Treiber]]
  
Beispiel:
+
=Linux handling=
# virsh migrate --live galactica qemu+ssh://test2.example.com/system
+
*[[Linux bridge-utils]]
 +
*[[Libvirt Openvswitch]]
 +
*[[linux vlan]]
 +
*[[macvlan]]
 +
*[[LVM]]
  
=Autostart =
+
=KVM Images=
virsh autostart <domain>
+
*[[KVM Images]]
virsh autostart <domain> --disable
+
=Libivirt=
 +
*[[Libvirt Directories]]
 +
*[[Libvirt TLS]]
 +
*[[Libvirt SSH]]
 +
*[[Libvirt Client]]
  
=An/Aus=
 
Connecten auf Hypervisor
 
virsh -c qemu+ssh://''SERVER''/system
 
In Konsole eingeben
 
  
Zum starten:
+
=Tools=
start ''VM''
+
*[[qemu-img]]
Zum virtuellen Stecker rausziehn:
+
=Nested Virtualiziation=
destroy ''VM''
+
*[[How to enable nested virtualization in KVM]]
Nach Installation von '''acpid''' auf ''VM''
+
*[[Proxmox in KVM]]
 +
*[[KVM Nested Client]]
  
Normales herunterfahren:
+
=KVM Lösungen=
shutdown ''VM''
+
*[[Ganeti]]
 +
*[[Proxmox]]
 +
*[[Ovirt]]
 +
*[[Foreman]]
 +
=KVM loging und debuging=
 +
*[[KVM loging und debugging]]
  
=Configure a Serial Console in the Guest=
+
=Xming=
==Enable on the VM==
+
*[[Xming]]
 
+
=CGroups=
cat /etc/init/ttyS0.conf
+
*[[cgroups]]
 
+
*https://libvirt.org/cgroups.html
# ttyS0 - getty
+
*https://www.berrange.com/posts/2009/12/03/using-cgroups-with-libvirt-and-lxckvm-guests-in-fedora-12/
#
+
=FAQ=
# This service maintains a getty on ttyS0 from the point the system is
+
*http://wiki.libvirt.org/page/FAQ
# started until it is shut down again.
 
 
start on stopped rc RUNLEVEL=[2345]
 
stop on runlevel [!2345]  
 
 
respawn
 
exec /sbin/getty -L 115200 ttyS0 xterm
 
 
 
Run the following command to initiate the Serial Console (or restart the VM):
 
 
 
sudo start ttyS0
 
 
 
==Connect on Host to VM==
 
 
 
console VM
 
00:50:56:00:31:f9
 
 
 
=Virtuelle MACAdresse vergeben=
 
 
 
gaius=KVM server
 
 
 
virsh console XXXXXXX
 
VM:    cp /etc/udev/rules./70-persistent.net(cd).rules 70-persistent.net(cd).rules.orig
 
VM:    herunterfahren...
 
gaius:  vi /etc/libvirt/qemu/XXXXXX.xml
 
 
 
-> MAC eintragen
 
 
 
gaius:    virsh define XXXXXXXX
 
gaius:    virsh start XXXXXXXX
 
 
 
-> TESTEN
 
 
 
=Images umwandeln=
 
*http://qemu-buch.de/de/index.php/QEMU-KVM-Buch/_Speichermedien/_Konvertieren_von_Image-Dateien
 
 
 
 
 
===img zu qcow2===
 
qemu-img convert -f raw -O qcow2 input.img output.qcow2
 
 
 
===qcow2 zu raw===
 
qemu-img convert -f qcow2 -O raw input.img output.raw
 
===raw zu vmdk===
 
qemu-img convert -f raw -O vmdk input.img output.raw
 
 
 
===qcow2 zu vmdk===
 
qemu-img convert -f qcow2 -O vmdk input.img output.raw
 
 
 
===4 unterstützten VirtBox-Typen:===
 
 
 
- .vdi      [ VirtualBox Disk Image ]
 
 
 
- .vmdk    [ Virtual Machine Disk ]
 
 
 
- .vhd      [ Virtual Hard Disk ]
 
 
 
- .hhd      [ Parallels Hard Disk ]
 
 
 
 
 
das ist falsch .... wer hat es geschrieben?
 
 
 
'''umwandeln VirtB. zu KVM'''
 
 
 
qemu-img convert "source".vmdk -O qcow2 "target".qemu
 
qemu-img convert "source".hhd -O qcow2 "target".qemu
 
qemu-img convert "source".vhd -O qcow2 "target".qemu
 
qemu-img convert "source".vdi -O qcow2 "target".qemu
 
 
 
'''RAW (for VirtualBox)'''
 
 
 
qemu-img convert "source".vmdk -O raw "target".img
 
 
 
'''umwandeln VirtB. zu VirtB. (vdi-vmdk)'''
 
 
VBoxManage clonehd "source".vdi "target".vmdk --format VMDK
 
 
 
==LVM in VMDK umwandeln==
 
lvcreate -L592M -s -n myvolume /dev/myvg/myvolume_snapshot
 
qemu-img convert /dev/myvg/myvolume_snapshot -O vmdk myvolume.vmdk
 
 
 
 
 
= RAW Image mounten =
 
 
 
Ein Raw Image ist ein einfaches Abbild einer Festplatte. Daher lässt es sich auch relativ leicht und ohne größere Umwege einhängen.
 
 
 
<pre>
 
losetup /dev/loop0 foo.img
 
kpartx -av /dev/loop0
 
mount /dev/mapper/loop0p1 /mnt
 
[arbeiten durchführen...]
 
unmount /mnt
 
kpartx -dv /dev/loop0
 
losetup -d /dev/loop0
 
</pre>
 
 
 
== QCOW2 Image mounten ==
 
 
 
Ein dynamisches QCOW2 Image kann im System nicht mehr einfach so gemounted werden. Dafür kann man einen Umweg über NBD (Network Block Device) nehmen. Damit wird das gewünschte Image als Network Block Device gestartet und eingehängt.
 
 
 
<pre>
 
modprobe nbd max_part=8
 
qemu-nbd --connect=/dev/nbd0 disk.img
 
mount /dev/nbd0p1 /mnt
 
</pre>
 
 
 
disconnecten
 
qemu-nbd --d /dev/nbd0
 
== Snapshot==
 
*http://kashyapc.wordpress.com/2013/01/22/live-backup-with-external-disk-snapshots-and-libvirts-blockpull/
 
 
 
== Weitere Infos ==
 
 
 
* http://blog.loftninjas.org/2008/10/27/mounting-kvm-qcow2-qemu-disk-images/
 
* http://doku.corvent.ch/doku.php/linux/kvm
 
  
 
= Links =
 
= Links =
 +
*https://libvirt.org/
 +
*https://www.linux-kvm.org/page/Main_Page
 +
*https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Virtualization_Administration_Guide/index.html
  
* http://qemu-buch.de/d/Speichermedien/_Konvertieren_von_Image-Dateien
+
=Misc=
* http://equivocation.org/node/107
+
*https://wiki.libvirt.org/page/UbuntuKVMWalkthrough
* http://blog.dustinkirkland.com/2008/10/mounting-kvm-disk-image.html
+
*http://rabexc.org/posts/how-to-get-started-with-libvirt-on
 
+
*http://blog.loftninjas.org/2008/10/27/mounting-kvm-qcow2-qemu-disk-images/
 
+
*http://doku.corvent.ch/doku.php/linux/kvm
==snapshot==
+
*http://qemu-buch.de/d/Speichermedien/_Konvertieren_von_Image-Dateien
http://kashyapc.wordpress.com/2013/01/22/live-backup-with-external-disk-snapshots-and-libvirts-blockpull/
+
*http://equivocation.org/node/107
Huang Wenlong 2011-09-26 03:14:09 EDT
+
*http://blog.dustinkirkland.com/2008/10/mounting-kvm-disk-image.html
 
+
*http://wiki.centos.org/HowTos/KVM
Verify it with libvirt-0.9.4-13.el6.x86_64
+
*https://help.ubuntu.com/community/KVM/Access
 
+
*http://blog.programster.org/kvm-cheatsheet
 
 
1. define a persistent domain named "snap"with qcow2 disks
 
2. create a snapshot for domain snap
 
# virsh snapshot-create snap
 
3.
 
virsh # snapshot-list snap
 
Name                Creation Time            State
 
------------------------------------------------------------
 
1317020538          2011-09-26 15:02:18 +0800 shutoff
 
 
 
4.virsh # undefine snap
 
error: Failed to undefine domain snap
 
error: Requested operation is not valid: cannot delete inactive domain with 1 snapshots
 
 
 
5. virsh undefine --snapshots-metadata snap
 
Domain snap has been undefined
 
 
 
4. check snapshot metadata (no metadata)
 
# ls /var/lib/libvirt/qemu/snapshot/snap
 
5. define a new domain with the same name, but different UUID
 
6. check snapshot for domain test:
 
# virsh snapshot-list snap
 
Name                Creation Time            State
 
---------------------------------------------------------
 
 
 
https://bugzilla.redhat.com/show_bug.cgi?id=735457
 
 
 
=Links=
 
==qemu-monitor==
 
http://blog.vmsplice.net/2011/03/how-to-access-qemu-monitor-through.html
 
 
 
= Links =
 
* http://wiki.centos.org/HowTos/KVM
 
* https://help.ubuntu.com/community/KVM/Access
 

Aktuelle Version vom 4. Dezember 2023, 12:01 Uhr

Grundlagen

Dokumentation

Installation

Virtual Machine Manager

Virsh


Virt

Examples

Cluster

Welche Produkte nutzen KVM

Qemu Agent

Linux handling

KVM Images

Libivirt


Tools

Nested Virtualiziation

KVM Lösungen

KVM loging und debuging

Xming

CGroups

FAQ

Links

Misc