KVM: Unterschied zwischen den Versionen

Aus xinux.net
Zur Navigation springen Zur Suche springen
 
(145 dazwischenliegende Versionen von 9 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
 
  
==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
 
==Vergeben der CAP_NET_ADMIN Fähigkeit==
 
setcap cap_net_admin=ei /usr/bin/qemu-system-x86_64
 
setcap cap_net_admin=ei /usr/bin/qemu-system-i386
 
  
==Erlauben der Beerchtigung für den Adminuser==
 
echo cap_net_admin  xinux >> /etc/security/capability.conf
 
  
==Netzwerk mit Bridgefunktion==
+
=Virt=
auto lo
+
*[[virt-clone]]
iface lo inet loopback
+
*[[virt-viewer]]
+
*[[virt-top]]
auto eth0
+
*[[libguestfs-tools]]
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 0
 
        bridge_maxwait 0
 
  
Damit libvirt-bin automatisch start muss man in der Datei /etc/default/libvirt-bin die Option start_libvirtd auf "yes" setzen.
+
=Examples=
vi /etc/default/libvirt-bin
+
*[[Konvertierung eines VirtualBox Images und anbinden an eine Virtuelle Maschnine]]
start_libvirtd="yes"
 
  
=Domain-Installation=
+
=Cluster=
 +
*[[virsh-cluster]]
 +
*[[Libvirt PCS]]
  
 +
=Welche Produkte nutzen KVM=
 +
*[[Welche Produkte nutzen KVM]]
 +
=Qemu Agent=
 +
*[[Qemu Agent]]
 +
*[[Virtio Treiber]]
  
virt-install --connect qemu:///system --name orion --ram 1024 --disk path=/dev/data/orion \
+
=Linux handling=
--cdrom /isos/ubuntu-10.04-server-amd64.iso --vnc --noautoconsole  --os-type linux --accelerate --network=bridge:br0
+
*[[Linux bridge-utils]]
 +
*[[Libvirt Openvswitch]]
 +
*[[linux vlan]]
 +
*[[macvlan]]
 +
*[[LVM]]
  
{|border=1
+
=KVM Images=
|name
+
*[[KVM Images]]
|Name der Domain
+
=Libivirt=
|-
+
*[[Libvirt Directories]]
|disk
+
*[[Libvirt TLS]]
|Diese Images werden in die Domain eingebunden. Es können mehrere Disks eingebunden werden, sowie weitere Optionen getrennt mit Leerzeichen gemacht werden.
+
*[[Libvirt SSH]]
|-
+
*[[Libvirt Client]]
|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.
 
|}
 
  
=Domain-Administration=
 
{| border=1 cellpadding="2"
 
| Kommando
 
| Bedeutung
 
|-
 
| help
 
| Hilfe ausgeben
 
|-
 
| attach-device
 
| Gerät aus einer XML-Datei anhängen
 
|-
 
| attach-disk
 
| Plattengerät anhängen
 
|-
 
| attach-interface
 
| Netzwerkschnittstelle verbinden
 
|-
 
| autostart
 
| Eine Domain automatisch starten
 
|-
 
| capabilities
 
| Fähigkeiten
 
|-
 
| cd
 
| change the current directory
 
|-
 
| connect
 
| (Wieder)verbinden mit Hypervisor
 
|-
 
| console
 
| Verbindung mit der Gast-Konsole
 
|-
 
| cpu-baseline
 
| compute baseline CPU
 
|-
 
| cpu-compare
 
| compare host CPU with a CPU described by an XML file
 
|-
 
| create
 
| Eine Domain aus einer XML-Datei erstellen
 
|-
 
| start
 
| Eine (zuvor definierte) inaktive Domain starten
 
|-
 
| destroy
 
| Domain löschen
 
|-
 
| detach-device
 
| Gerät von einer XML-Datei lösen
 
|-
 
| detach-disk
 
| Plattengerät abtrennen
 
|-
 
| detach-interface
 
| Netzwerkschnittstelle abhängen
 
|-
 
| define
 
| Definiere (aber starte keine) Domain aus einer XML-Datei
 
|-
 
| domid
 
| Einen Domain-Namen oder -UUID in Domain-ID konvertieren
 
|-
 
| domuuid
 
| Einen Domain-Namen oder -ID in Domain-UUID konvertieren
 
|-
 
| dominfo
 
| Domain-Informationen
 
|-
 
| domjobinfo
 
| domain job information
 
|-
 
| domjobabort
 
| abort active domain job
 
|-
 
| domname
 
| Eine Domain-ID oder UUID in Domain-Namen konvertieren
 
|-
 
| domstate
 
| Domain-Status
 
|-
 
| domblkstat
 
| Geräteblockstatistiken für eine Domain abrufen
 
|-
 
| domifstat
 
| Statistiken der Netzwerkschnittstelle für eine Domain abrufen
 
|-
 
| dommemstat
 
| get memory statistics for a domain
 
|-
 
| domblkinfo
 
| domain block device size information
 
|-
 
| domxml-from-native
 
| Convert native config to domain XML
 
|-
 
| domxml-to-native
 
| Convert domain XML to native config
 
|-
 
| dumpxml
 
| Domain-Informationen in XML
 
|-
 
| edit
 
| edit XML configuration for a domain
 
|-
 
| find-storage-pool-sources
 
| discover potential storage pool sources
 
|-
 
| find-storage-pool-sources-as
 
| find potential storage pool sources
 
|-
 
| freecell
 
| NUMA freier Speicher
 
|-
 
| hostname
 
| Hypervisor-Hostname ausgeben
 
|-
 
| list
 
| Domains auflisten
 
|-
 
| migrate
 
| Domain auf anderen Host migrieren
 
|-
 
| migrate-setmaxdowntime
 
| set maximum tolerable downtime
 
|-
 
| net-autostart
 
| Ein Netzwerk automatisch starten
 
|-
 
| net-create
 
| Netzwerk aus einer XML-Datei erstellen
 
|-
 
| net-define
 
| Definiere (aber starte kein) Netzwerk aus einer XML-Datei
 
|-
 
| net-destroy
 
| Netzwerk löschen
 
|-
 
| net-dumpxml
 
| Netzwerk-Informationen in XML
 
|-
 
| net-edit
 
| edit XML configuration for a network
 
|-
 
| net-list
 
| Netzwerke auflisten
 
|-
 
| net-name
 
| Eine Netzwerk-UUID in einen Netzwerk-Namen konvertieren
 
|-
 
| net-start
 
| Ein (zuvor definiertes) inaktives Netzwerk starten
 
|-
 
| net-undefine
 
| Ein inaktives Netzwerk undefinieren
 
|-
 
| net-uuid
 
| Einen Netzwerk-Namen in eine Netzwerk-UUID konvertieren
 
|-
 
| iface-list
 
| list physical host interfaces
 
|-
 
| iface-name
 
| convert an interface MAC address to interface name
 
|-
 
| iface-mac
 
| convert an interface name to interface MAC address
 
|-
 
| iface-dumpxml
 
| interface information in XML
 
|-
 
| iface-define
 
| define (but don't start) a physical host interface from an XML file
 
|-
 
| iface-undefine
 
| undefine a physical host interface (remove it from configuration)
 
|-
 
| iface-edit
 
| edit XML configuration for a physical host interface
 
|-
 
| iface-start
 
| start a physical host interface (enable it / "if-up")
 
|-
 
| iface-destroy
 
| destroy a physical host interface (disable it / "if-down")
 
|-
 
| managedsave
 
| managed save of a domain state
 
|-
 
| nodeinfo
 
| Knoteninformation
 
|-
 
| nodedev-list
 
| enumerate devices on this host
 
|-
 
| nodedev-dumpxml
 
| node device details in XML
 
|-
 
| nodedev-dettach
 
| dettach node device from its device driver
 
|-
 
| nodedev-reattach
 
| reattach node device to its device driver
 
|-
 
| nodedev-reset
 
| reset node device
 
|-
 
| nodedev-create
 
| create a device defined by an XML file on the node
 
|-
 
| nodedev-destroy
 
| destroy a device on the node
 
|-
 
| nwfilter-define
 
| define or update a network filter from an XML file
 
|-
 
| nwfilter-undefine
 
| undefine a network filter
 
|-
 
| nwfilter-dumpxml
 
| network filter information in XML
 
|-
 
| nwfilter-list
 
| list network filters
 
|-
 
| nwfilter-edit
 
| edit XML configuration for a network filter
 
|-
 
| pool-autostart
 
| autostart a pool
 
|-
 
| pool-build
 
| baue einen Pool
 
|-
 
| pool-create
 
| create a pool from an XML file
 
|-
 
| pool-create-as
 
| create a pool from a set of args
 
|-
 
| pool-define
 
| define (but don't start) a pool from an XML file
 
|-
 
| pool-define-as
 
| define a pool from a set of args
 
|-
 
| pool-destroy
 
| Zerstören eines Pools
 
|-
 
| pool-delete
 
| Pool löschen
 
|-
 
| pool-dumpxml
 
| Pool-Informationen in XML
 
|-
 
| pool-edit
 
| edit XML configuration for a storage pool
 
|-
 
| pool-info
 
| storage pool information
 
|-
 
| pool-list
 
| Poolliste
 
|-
 
| pool-name
 
| Konvertieren einer pool-UUID in einen Pool-Namen
 
|-
 
| pool-refresh
 
| Einen Pool aktualisieren
 
|-
 
| pool-start
 
| start a (previously defined) inactive pool
 
|-
 
| pool-undefine
 
| undefine an inactive pool
 
|-
 
| pool-uuid
 
| convert a pool name to pool UUID
 
|-
 
| secret-define
 
| define or modify a secret from an XML file
 
|-
 
| secret-dumpxml
 
| secret attributes in XML
 
|-
 
| secret-set-value
 
| set a secret value
 
|-
 
| secret-get-value
 
| Output a secret value
 
|-
 
| secret-undefine
 
| undefine a secret
 
|-
 
| secret-list
 
| list secrets
 
|-
 
| pwd
 
| print the current directory
 
|-
 
| quit
 
| Dieses interaktive Terminal beenden
 
|-
 
| exit
 
| Dieses interaktive Terminal beenden
 
|-
 
| reboot
 
| Domain neu starten
 
|-
 
| restore
 
| Eine Domain aus einem gespeicherten Status in einer Datei wiederherstellen
 
|-
 
| resume
 
| Domain fortsetzen
 
|-
 
| save
 
| Einen Domainstatus in einer Datei speichern
 
|-
 
| schedinfo
 
| Scheduler-Parameter anzeigen/setzen
 
|-
 
| dump
 
| Den Kern einer Domain zu Analysezwecken in eine Datei dumpen
 
|-
 
| shutdown
 
| Kontrolliertes Stillegen einer Domain
 
|-
 
| setmem
 
| Speicherzuweisung ändern
 
|-
 
| setmaxmem
 
| Maximale Speichergrenze ändern
 
|-
 
| setvcpus
 
| Anzahl der virtuellen CPUs ändern
 
|-
 
| suspend
 
| Eine Domain anhalten
 
|-
 
| ttyconsole
 
| TTY-Konsole
 
|-
 
| undefine
 
| Eine inaktive Domain undefinieren
 
|-
 
| update-device
 
| update device from an XML file
 
|-
 
| uri
 
| Kanonisierte URI des Hypervisors ausgeben
 
|-
 
| vol-create
 
| create a vol from an XML file
 
|-
 
| vol-create-from
 
| create a vol, using another volume as input
 
|-
 
| vol-create-as
 
| create a volume from a set of args
 
|-
 
| vol-clone
 
| clone a volume.
 
|-
 
| vol-delete
 
| Löschen eines Datenträgers
 
|-
 
| vol-wipe
 
| wipe a vol
 
|-
 
| vol-dumpxml
 
| vol information in XML
 
|-
 
| vol-info
 
| storage vol information
 
|-
 
| vol-list
 
| list vols
 
|-
 
| vol-pool
 
| returns the storage pool for a given volume key or path
 
|-
 
| vol-path
 
| returns the volume path for a given volume name or key
 
|-
 
| vol-name
 
| returns the volume name for a given volume key or path
 
|-
 
| vol-key
 
| returns the volume key for a given volume name or path
 
|-
 
| vcpuinfo
 
| Domain vcpu-Information
 
|-
 
| vcpupin
 
| Domain vcpu-Affinität kontrollieren
 
|-
 
| version
 
| Version anzeigen
 
|-
 
| vncdisplay
 
| VNC-Anzeige
 
|-
 
| snapshot-create
 
| Create a snapshot
 
|-
 
| snapshot-current
 
| Get the current snapshot
 
|-
 
| snapshot-delete
 
| Delete a domain snapshot
 
|-
 
| snapshot-dumpxml
 
| Dump XML for a domain snapshot
 
|-
 
| snapshot-list
 
| List snapshots for a domain
 
|-
 
| snapshot-revert
 
| Revert a domain to a snapshot
 
|}
 
  
= Migration zu neuem Host =
+
=Tools=
virsh migrate --live <GuestName> <DestinationURL>
+
*[[qemu-img]]
 +
=Nested Virtualiziation=
 +
*[[How to enable nested virtualization in KVM]]
 +
*[[Proxmox in KVM]]
 +
*[[KVM Nested Client]]
  
Beispiel:
+
=KVM Lösungen=
# virsh migrate --live galactica qemu+ssh://test2.example.com/system
+
*[[Ganeti]]
 +
*[[Proxmox]]
 +
*[[Ovirt]]
 +
*[[Foreman]]
 +
=KVM loging und debuging=
 +
*[[KVM loging und debugging]]
  
=Autostart =
+
=Xming=
virsh atutostart <domain>
+
*[[Xming]]
virsh atutostart <domain> --disable
+
=CGroups=
=An/Aus=
+
*[[cgroups]]
Connecten auf Hypervisor
+
*https://libvirt.org/cgroups.html
virsh -c qemu+ssh://''SERVER''/system
+
*https://www.berrange.com/posts/2009/12/03/using-cgroups-with-libvirt-and-lxckvm-guests-in-fedora-12/
In Konsole eingeben
+
=FAQ=
 +
*http://wiki.libvirt.org/page/FAQ
  
Zum starten:
+
= Links =
start ''VM''
+
*https://libvirt.org/
Zum virtuellen Stecker rausziehn:
+
*https://www.linux-kvm.org/page/Main_Page
destroy ''VM''
+
*https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Virtualization_Administration_Guide/index.html
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
+
=Misc=
 
+
*https://wiki.libvirt.org/page/UbuntuKVMWalkthrough
==Connect on Host to VM==
+
*http://rabexc.org/posts/how-to-get-started-with-libvirt-on
 
+
*http://blog.loftninjas.org/2008/10/27/mounting-kvm-qcow2-qemu-disk-images/
console VM
+
*http://doku.corvent.ch/doku.php/linux/kvm
 
+
*http://qemu-buch.de/d/Speichermedien/_Konvertieren_von_Image-Dateien
= Links =
+
*http://equivocation.org/node/107
* http://wiki.centos.org/HowTos/KVM
+
*http://blog.dustinkirkland.com/2008/10/mounting-kvm-disk-image.html
* https://help.ubuntu.com/community/KVM/Access
+
*http://wiki.centos.org/HowTos/KVM
 +
*https://help.ubuntu.com/community/KVM/Access
 +
*http://blog.programster.org/kvm-cheatsheet

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