KVM: Unterschied zwischen den Versionen

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen
 
(117 dazwischenliegende Versionen von 7 Benutzern werden nicht angezeigt)
Zeile 1: Zeile 1:
 +
=Grundlagen=
 +
*[[QEMU,KVM,libvirt]]
 +
*[[KVM Grundlagen]]
 +
=Dokumentation=
 +
*https://libvirt.org/docs.html
 
=Installation=
 
=Installation=
−
==Vorbereitung==
+
*[[KVM Installation]]
−
Testen ob VT Unterstützung der CPU vorhanden ist
+
=Virtual Machine Manager=
−
egrep -c '(vmx|svm)' /proc/cpuinfo
+
*[[Virtual Machine Manager]]
−
0 bedeutet keine Unterstützung
 
−
1 (oder mehr) Unterstützung vorhanden
 
−
==Basis Pakete==
 
−
  apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils virtinst
 
−
  apt-get install ssh-askpass
 
  
−
==Verifizieren der Installation==
+
=Virsh=
−
virsh -c qemu:///system list
+
*[[Virsh]]
−
Id Name                Status
 
−
----------------------------------
 
−
==Installation des Virtmanagers(GUI)==
 
−
apt-get install virt-manager
 
−
==Installation des Linux capabilities tools==
 
−
apt-get install libcap2-bin
 
−
==Netzwerk mit Bridgefunktion==
 
−
auto lo
 
−
iface lo inet loopback
 
−
 
−
auto eth0
 
−
iface eth0 inet manual
 
−
 
−
auto br0
 
−
iface br0 inet static
 
−
        address 192.168.240.101
 
−
        netmask 255.255.240.0
 
−
        gateway 192.168.240.100
 
−
        bridge_ports eth0
 
−
        bridge_stp off
 
−
        bridge_fd 1
 
−
        bridge_maxwait 12
 
  
−
Damit libvirt-bin automatisch start muss man in der Datei /etc/default/libvirt-bin die Option start_libvirtd auf "yes" setzen.
 
−
vi /etc/default/libvirt-bin
 
−
start_libvirtd="yes"
 
  
−
=Domain-Installation=
+
=Virt=
 +
*[[virt-clone]]
 +
*[[virt-viewer]]
 +
*[[virt-top]]
 +
*[[libguestfs-tools]]
  
 +
=Examples=
 +
*[[Konvertierung eines VirtualBox Images und anbinden an eine Virtuelle Maschnine]]
  
−
virt-install --connect qemu:///system --name orion --ram 1024 --disk path=/dev/data/orion \
+
=Cluster=
−
--cdrom /isos/ubuntu-10.04-server-amd64.iso --vnc --noautoconsole  --os-type linux --accelerate --network=bridge:br0
+
*[[virsh-cluster]]
 +
*[[Libvirt PCS]]
  
−
{|border=1
+
=Welche Produkte nutzen KVM=
−
|name
+
*[[Welche Produkte nutzen KVM]]
−
|Name der Domain
+
=Qemu Agent=
−
|-
+
*[[Qemu Agent]]
−
|disk
+
*[[Virtio Treiber]]
−
|Diese Images werden in die Domain eingebunden. Es können mehrere Disks eingebunden werden, sowie weitere Optionen getrennt mit Leerzeichen gemacht werden.
 
−
|-
 
−
|ram
 
−
|Zu Verfügung stehender Arbeitspeicher der Domain
 
−
|-
 
−
|os-type
 
−
|linux, windows, solaris etc.
 
−
|-
 
−
|os-variant
 
−
|ubuntukarmic, winxp etc.
 
−
|-
 
−
|hvm
 
−
|Gebraucht full virtualization.
 
−
|-
 
−
|accelerate
 
−
|Benutze kvm oder KQEMU, wenn vorhanden.
 
−
|-
 
−
|import
 
−
|Die Installation ist bereits im Disk-Image enthalten.
 
−
|-
 
−
|vnc
 
−
|Aktiviert VNC-Display und öffnete einen beliebigen Port >5000, falls nicht --vncport angegeben ist.
 
−
|-
 
−
|vncport
 
−
|Setzt den Port für VNC fest.
 
−
|}
 
  
−
=Handling=
+
=Linux handling=
−
This command outputs the guest's XML configuration file to standard out (stdout).
+
*[[Linux bridge-utils]]
−
You can save the data by piping the output to a file. An example of piping the output to a file called guest.xml:
+
*[[Libvirt Openvswitch]]
 +
*[[linux vlan]]
 +
*[[macvlan]]
 +
*[[LVM]]
  
−
virsh dumpxml GuestID > guest.xml
+
=KVM Images=
 +
*[[KVM Images]]
 +
=Libivirt=
 +
*[[Libvirt Directories]]
 +
*[[Libvirt TLS]]
 +
*[[Libvirt SSH]]
 +
*[[Libvirt Client]]
  
  
 +
=Tools=
 +
*[[qemu-img]]
 +
=Nested Virtualiziation=
 +
*[[How to enable nested virtualization in KVM]]
 +
*[[Proxmox in KVM]]
 +
*[[KVM Nested Client]]
  
−
* [[Domain-Administration]]
+
=KVM Lösungen=
 +
*[[Ganeti]]
 +
*[[Proxmox]]
 +
*[[Ovirt]]
 +
*[[Foreman]]
 +
=KVM loging und debuging=
 +
*[[KVM loging und debugging]]
  
−
= Migration zu neuem Host =
+
=Xming=
−
virsh migrate --live <GuestName> <DestinationURL>
+
*[[Xming]]
−
 
+
=CGroups=
−
Beispiel:
+
*[[cgroups]]
−
# virsh migrate --live galactica qemu+ssh://test2.example.com/system
+
*https://libvirt.org/cgroups.html
−
 
+
*https://www.berrange.com/posts/2009/12/03/using-cgroups-with-libvirt-and-lxckvm-guests-in-fedora-12/
−
=Autostart =
+
=FAQ=
−
virsh atutostart <domain>
+
*http://wiki.libvirt.org/page/FAQ
−
virsh atutostart <domain> --disable
 
−
=An/Aus=
 
−
Connecten auf Hypervisor
 
−
virsh -c qemu+ssh://''SERVER''/system
 
−
In Konsole eingeben
 
−
 
 
−
Zum starten:
 
−
start ''VM''
 
−
Zum virtuellen Stecker rausziehn:
 
−
destroy ''VM''
 
−
Nach Installation von '''acpid''' auf ''VM''
 
−
 
 
−
Normales herunterfahren:
 
−
shutdown ''VM''
 
−
 
 
−
=Configure a Serial Console in the Guest=
 
−
==Enable on the VM==
 
−
 
 
−
cat /etc/init/ttyS0.conf
 
−
 
 
−
# ttyS0 - getty
 
−
#
 
−
# This service maintains a getty on ttyS0 from the point the system is
 
−
# 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
 
−
 
 
−
 
 
−
 
 
−
===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 ==
 
−
list
 
−
zerkling:~# virsh list
 
−
  Id    Name                          State
 
−
----------------------------------------------------
 
−
  13    nog                            running
 
−
  16    crass                          running
 
−
snapshot list
 
−
virsh snapshot-list crass
 
−
  Name                Creation Time            State
 
−
------------------------------------------------------------
 
−
show active image
 
−
grep "source file" /etc/libvirt/qemu/crass.xml
 
−
      source file='/b-one/kvm/crass.img'
 
−
make snapshot
 
−
virsh snapshot-create-as crass 1  "crass-1" --disk-only --atomic
 
−
show active image
 
−
grep "source file" /etc/libvirt/qemu/crass.xml
 
−
      source file='/b-one/kvm/crass.1'
 
−
blockpull image
 
−
virsh blockpull --wait --domain crass /b-one/kvm/crass.1
 
−
 
 
−
== 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