Änderungen

Zeile 1.259: Zeile 1.259:  
   | disabled
 
   | disabled
 
   |}
 
   |}
 +
 +
 +
===Server===
 +
*Modell:HP ProLiant DL380 G5 2x Xeon E5450
 +
*Betriebssystem: Ubuntu 16.04 LTS
 +
*Virtualisierung: KVM/QEMU
 +
 +
====Netzwerk Config====
 +
Installation Open vSwitch
 +
<source lang='text'>
 +
apt-get install openvswitch-switch openvswitch-common
 +
</source>
 +
 +
Anlegen der Open vSwitch Bridges
 +
<source lang='text'>
 +
ovs-vsctl add-br br-sw01
 +
ovs-vsctl add-port br-sw01 enp2s0f1
 +
 +
ovs-vsctl add-br br-sw02
 +
ovs-vsctl add-port br-sw02 ens1f0
 +
 +
ovs-vsctl add-br br-sw05
 +
ovs-vsctl add-port br-sw05 ens1f1
 +
</source>
 +
 +
/etc/network/interfaces
 +
<source lang='text'>
 +
# The loopback network interface
 +
auto lo
 +
iface lo inet loopback
 +
 +
# The primary network interface
 +
auto br-ffwi
 +
iface br-ffwi inet static
 +
        bridge_ports enp2s0f0
 +
        bridge_stp no
 +
        bridge_fd 0
 +
        address 10.56.2.139
 +
        netmask 255.255.192.0
 +
        gateway 10.56.0.161
 +
        dns-nameservers 10.56.0.161 10.56.0.23 10.56.0.231
 +
 +
# Uplink ffmwu-hans-sw01
 +
auto enp2s0f1
 +
iface enp2s0f1 inet manual
 +
 +
# Uplink ffmwu-hans-sw02
 +
auto ens1f0
 +
iface ens1f0 inet manual
 +
 +
# Uplink ffmwu-hans-sw05
 +
auto ens1f1
 +
iface ens1f1 inet manual
 +
</source>
 +
 +
====Libvirt Networks====
 +
Man legt z.B. nach /tmp/ die Netzwerk Definitionen ab.
 +
 +
Datei /tmp/ovs-sw01.xml
 +
<source lang='xml'>
 +
<networkstatus>
 +
  <class_id bitmap='0-2'/>
 +
  <floor sum='0'/>
 +
  <network>
 +
    <name>ovs-sw01</name>
 +
    <uuid>e5992f9c-4dc1-4f7d-b4e5-6865e80c57f0</uuid>
 +
    <forward mode='bridge'/>
 +
    <bridge name='br-sw01'/>
 +
    <virtualport type='openvswitch'/>
 +
    <portgroup name='vlan-all' default='yes'>
 +
      <vlan trunk='yes'>
 +
        <tag id='5'/>
 +
        <tag id='11'/>
 +
        <tag id='12'/>
 +
        <tag id='13'/>
 +
        <tag id='14'/>
 +
        <tag id='15'/>
 +
        <tag id='16'/>
 +
      </vlan>
 +
    </portgroup>
 +
  </network>
 +
</networkstatus>
 +
</source>
 +
 +
Datei /tmp/ovs-sw02.xml
 +
<source lang='xml'>
 +
<networkstatus>
 +
  <class_id bitmap='0-2'/>
 +
  <floor sum='0'/>
 +
  <network>
 +
    <name>ovs-sw02</name>
 +
    <uuid>3ceae5b0-cdb4-4996-a0d0-be5f206ed3c2</uuid>
 +
    <forward mode='bridge'/>
 +
    <bridge name='br-sw02'/>
 +
    <virtualport type='openvswitch'/>
 +
    <portgroup name='vlan-all' default='yes'>
 +
      <vlan trunk='yes'>
 +
        <tag id='5'/>
 +
      </vlan>
 +
    </portgroup>
 +
  </network>
 +
</networkstatus>
 +
</source>
 +
 +
Datei /tmp/ovs-sw05.xml
 +
<source lang='xml'>
 +
<networkstatus>
 +
  <class_id bitmap='0-2'/>
 +
  <floor sum='0'/>
 +
  <network>
 +
    <name>ovs-sw05</name>
 +
    <uuid>c22babeb-8513-4b83-b4eb-ea9252500477</uuid>
 +
    <forward mode='bridge'/>
 +
    <bridge name='br-sw05'/>
 +
    <virtualport type='openvswitch'/>
 +
    <portgroup name='vlan-all' default='yes'>
 +
      <vlan trunk='yes'>
 +
        <tag id='5'/>
 +
        <tag id='51'/>
 +
        <tag id='52'/>
 +
        <tag id='53'/>
 +
        <tag id='54'/>
 +
        <tag id='55'/>
 +
        <tag id='56'/>
 +
      </vlan>
 +
    </portgroup>
 +
  </network>
 +
</networkstatus>
 +
</source>
 +
 +
Netzwerk-Definitionen einlesen, starten und für den Autostart markieren.
 +
<source lang='text'>
 +
virsh net-define /tmp/ovs-sw01.xml
 +
virsh net-define /tmp/ovs-sw02.xml
 +
virsh net-define /tmp/ovs-sw05.xml
 +
 +
virsh net-start ovs-sw01
 +
virsh net-start ovs-sw02
 +
virsh net-start ovs-sw05
 +
 +
virsh net-autostart ovs-sw01
 +
virsh net-autostart ovs-sw02
 +
virsh net-autostart ovs-sw05
 +
</source>
 +
 +
====Libvirt Domain Config====
 +
<source lang='xml'>
 +
<domain type='kvm' id='1'>
 +
    <name>ffmwu-hans-core</name>
 +
    <uuid>04502792-af13-41de-9073-a777ec8eea80</uuid>
 +
    <memory unit='KiB'>524288</memory>
 +
    <currentMemory unit='KiB'>524288</currentMemory>
 +
    <vcpu placement='static'>1</vcpu>
 +
    <resource>
 +
      <partition>/machine</partition>
 +
    </resource>
 +
    <os>
 +
      <type arch='x86_64' machine='pc-i440fx-wily'>hvm</type>
 +
      <boot dev='hd'/>
 +
    </os>
 +
    <features>
 +
      <acpi/>
 +
      <apic/>
 +
      <vmport state='off'/>
 +
    </features>
 +
    <cpu mode='host-model'>
 +
      <model fallback='allow'/>
 +
    </cpu>
 +
    <clock offset='utc'>
 +
      <timer name='rtc' tickpolicy='catchup'/>
 +
      <timer name='pit' tickpolicy='delay'/>
 +
      <timer name='hpet' present='no'/>
 +
    </clock>
 +
    <on_poweroff>destroy</on_poweroff>
 +
    <on_reboot>restart</on_reboot>
 +
    <on_crash>restart</on_crash>
 +
    <pm>
 +
      <suspend-to-mem enabled='no'/>
 +
      <suspend-to-disk enabled='no'/>
 +
    </pm>
 +
    <devices>
 +
      <emulator>/usr/bin/kvm-spice</emulator>
 +
      <disk type='file' device='disk'>
 +
        <driver name='qemu' type='raw'/>
 +
        <source file='/var/lib/libvirt/images/ffmwu-hans-core.img'/>
 +
        <backingStore/>
 +
        <target dev='vda' bus='virtio'/>
 +
        <alias name='virtio-disk0'/>
 +
        <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
 +
      </disk>
 +
      <controller type='usb' index='0' model='ich9-ehci1'>
 +
        <alias name='usb'/>
 +
        <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x7'/>
 +
      </controller>
 +
      <controller type='usb' index='0' model='ich9-uhci1'>
 +
        <alias name='usb'/>
 +
        <master startport='0'/>
 +
        <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0' multifunction='on'/>
 +
      </controller>
 +
      <controller type='usb' index='0' model='ich9-uhci2'>
 +
        <alias name='usb'/>
 +
        <master startport='2'/>
 +
        <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x1'/>
 +
      </controller>
 +
      <controller type='usb' index='0' model='ich9-uhci3'>
 +
        <alias name='usb'/>
 +
        <master startport='4'/>
 +
        <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x2'/>
 +
      </controller>
 +
      <controller type='pci' index='0' model='pci-root'>
 +
        <alias name='pci.0'/>
 +
      </controller>
 +
      <controller type='virtio-serial' index='0'>
 +
        <alias name='virtio-serial0'/>
 +
        <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
 +
      </controller>
 +
      <interface type='network'>
 +
        <mac address='52:54:00:dd:cc:9d'/>
 +
        <source network='ovs-sw01' portgroup='vlan-all'/>
 +
        <actual type='bridge'>
 +
          <source bridge='br-sw01'/>
 +
          <vlan trunk='yes'>
 +
            <tag id='5'/>
 +
            <tag id='11'/>
 +
            <tag id='12'/>
 +
            <tag id='13'/>
 +
            <tag id='14'/>
 +
            <tag id='15'/>
 +
            <tag id='16'/>
 +
          </vlan>
 +
          <virtualport type='openvswitch'>
 +
            <parameters interfaceid='2aa233d9-3a8e-46db-8230-72ea0b730ee2'/>
 +
          </virtualport>
 +
        </actual>
 +
        <target dev='vnet0'/>
 +
        <model type='virtio'/>
 +
        <alias name='net0'/>
 +
        <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
 +
      </interface>
 +
      <interface type='network'>
 +
        <mac address='52:54:00:12:3b:c2'/>
 +
        <source network='ovs-sw02' portgroup='vlan-all'/>
 +
        <actual type='bridge'>
 +
          <source bridge='br-sw02'/>
 +
          <vlan trunk='yes'>
 +
            <tag id='5'/>
 +
          </vlan>
 +
          <virtualport type='openvswitch'>
 +
            <parameters interfaceid='c1a010f5-7911-4651-ae41-080b8892e3e5'/>
 +
          </virtualport>
 +
        </actual>
 +
        <target dev='vnet1'/>
 +
        <model type='virtio'/>
 +
        <alias name='net1'/>
 +
        <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
 +
      </interface>
 +
      <interface type='network'>
 +
        <mac address='52:54:00:93:ba:bb'/>
 +
        <source network='ovs-sw05' portgroup='vlan-all'/>
 +
        <actual type='bridge'>
 +
          <source bridge='br-sw05'/>
 +
          <vlan trunk='yes'>
 +
            <tag id='5'/>
 +
            <tag id='51'/>
 +
            <tag id='52'/>
 +
            <tag id='53'/>
 +
            <tag id='54'/>
 +
            <tag id='55'/>
 +
            <tag id='56'/>
 +
          </vlan>
 +
          <virtualport type='openvswitch'>
 +
            <parameters interfaceid='d0223530-25ae-4649-8103-405ba0e79761'/>
 +
          </virtualport>
 +
        </actual>
 +
        <target dev='vnet2'/>
 +
        <model type='virtio'/>
 +
        <alias name='net2'/>
 +
        <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
 +
      </interface>
 +
      <serial type='pty'>
 +
        <source path='/dev/pts/0'/>
 +
        <target port='0'/>
 +
        <alias name='serial0'/>
 +
      </serial>
 +
      <console type='pty' tty='/dev/pts/0'>
 +
        <source path='/dev/pts/0'/>
 +
        <target type='serial' port='0'/>
 +
        <alias name='serial0'/>
 +
      </console>
 +
      <channel type='spicevmc'>
 +
        <target type='virtio' name='com.redhat.spice.0' state='disconnected'/>
 +
        <alias name='channel0'/>
 +
        <address type='virtio-serial' controller='0' bus='0' port='1'/>
 +
      </channel>
 +
      <input type='mouse' bus='ps2'/>
 +
      <input type='keyboard' bus='ps2'/>
 +
      <graphics type='spice' port='5900' autoport='yes' listen='127.0.0.1'>
 +
        <listen type='address' address='127.0.0.1' fromConfig='1'/>
 +
      </graphics>
 +
      <sound model='ich6'>
 +
        <alias name='sound0'/>
 +
        <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
 +
      </sound>
 +
      <video>
 +
        <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1'/>
 +
        <alias name='video0'/>
 +
        <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
 +
      </video>
 +
      <redirdev bus='usb' type='spicevmc'>
 +
        <alias name='redir0'/>
 +
      </redirdev>
 +
      <redirdev bus='usb' type='spicevmc'>
 +
        <alias name='redir1'/>
 +
      </redirdev>
 +
      <watchdog model='i6300esb' action='reset'>
 +
        <alias name='watchdog0'/>
 +
        <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
 +
      </watchdog>
 +
      <memballoon model='virtio'>
 +
        <alias name='balloon0'/>
 +
        <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
 +
      </memballoon>
 +
    </devices>
 +
    <seclabel type='dynamic' model='apparmor' relabel='yes'>
 +
      <label>libvirt-04502792-af13-41de-9073-a777ec8eea80</label>
 +
      <imagelabel>libvirt-04502792-af13-41de-9073-a777ec8eea80</imagelabel>
 +
    </seclabel>
 +
  </domain>
 +
</source>
 +
 +
====VM-Watchdog-Script====
 +
Wenn die VM unerwartet crasht, kann diese per Remote nicht resettet werden.
 +
Dies machen wir automatisiert mit diesem Script, das in /usr/local/bin liegt.
 +
<source lang='bash'>
 +
#!/bin/bash
 +
 +
count=$( ping6 -c 5 fd56:b4dc:4b1e:0:5054:ff:fedd:cc9d | grep "bytes from" | wc -l )
 +
if [ $count -eq 0 ]
 +
then
 +
  logger "ffmwu-hans-core: Not available -> Reset VM"
 +
  virsh reset ffmwu-hans-core || virsh start ffmwu-hans-core
 +
  exit 0
 +
else
 +
  logger "ffmwu-hans-core: Up and running -> nothing to do"
 +
  exit 0
 +
fi
 +
</source>
 +
 +
Per cronjob wird es alle 20 Minuten ausgeführt
 +
<source lang='text'>
 +
# m h  dom mon dow  command
 +
*/20 * * * * /usr/local/bin/vm-watchdog.sh
 +
</source>
    
===Uplink===
 
===Uplink===
152

Bearbeitungen