VMinProxmox

Aus Freifunk Dresden - Anwender-Wiki
Zur Navigation springen Zur Suche springen
Proxmox.PNG

Proxmox installieren

Entweder der Anbieter der Serverlösung bietet selbt eine vorgefertigtes Image oder man muss selbst Hand anlegen.

Getestete Images in Bezug auf den Freifunk Server bei Servdiscount:

Debian Proxmox Funktion Hinweis / EOL DEB & PXMX
7 3.5-16 läuft / 2016-04 & 2017-02
8 4.4-13 läuft / 2018-06 & 2018-06
8 4.4-22 läuft aber bmxd im zusammenspiel mit dem virtio fehlerhaft, Adapter: "VMware vmxnet3" empfohlen / 2018-06 & 2018-06
9 5.1-51, von Hand läuft aber bmxd im zusammenspiel mit dem virtio fehlerhaft, Adapter: "VMware vmxnet3" empfohlen / TBA

Auf Debian 9 von Hand

echo "deb http://download.proxmox.com/debian/pve stretch pve-no-subscription" > /etc/apt/sources.list.d/pve-install-repo.list
wget http://download.proxmox.com/debian/proxmox-ve-release-5.x.gpg -O /etc/apt/trusted.gpg.d/proxmox-ve-release-5.x.gpg
apt update
apt dist-upgrade
apt install proxmox-ve postfix open-iscsi
#Postfix Configuration -> No configuration
Möglicher Fehler: 
Errors were encountered while processing:
/var/cache/apt/archives/pve-firmware_2.0-4_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
^Mögliche Lösung: 
dpkg -i --force-overwrite /var/cache/apt/archives/pve-firmware_2.0-4_all.deb
apt --fix-broken install

Debian 9 etc/networks/interfaces

# The loopback network interface
auto lo
iface lo inet loopback 
# The primary network interface
allow-hotplug enp2s0
iface enp2s0 inet manual
auto vmbr0
iface vmbr0 inet static
        address 93.xx.xx.39/25
        gateway 93.xx.xx.1
        bridge_ports enp2s0
        bridge_stp off
        bridge_fd 1

Host installieren

Kurzanleitung für Proxmox 4.1 auf Debian 8, Ubuntu 14.4 LTS amd64 Server als Gastsystem. Zuvor muss das *.iso Image heruntergeladen und auf die Hostmaschine hochgeladen werden.

Alternativ direkt auf die Hostmaschiene ziehen:

wget /var/lib/vz/template/iso http://ubuntu.mirror.tudos.de/ubuntu-releases/16.04.4/ubuntu-16.04.4-server-amd64.iso

Proxmox Host konfigurieren

Unter Netzwerk Linux Bridge erstellen: Mit der Konsole die Datei /etc/networks/interfaces-new anpassen:

auto lo
iface lo inet looback

allow-hotplug eth0 # eth0=ens18* ab Ubuntu 16

iface eth0 inet manual # eth0=ens18* ab Ubuntu 16
#	address y.y.y.y
#	netmask 255.255.255.128
#	gateway y.y.y.x
#	broadcast z.z.z.z
#	network y.y.y.0 
#	dns-nameservers 8.8.8.8

iface eth0 inet manual # eth0=ens18* ab Ubuntu 16

auto vmbr0
iface vmbr0 inet static
	address y.y.y.y # IP Adresse des Hosts
	netmask 255.255.255.128
	gateway y.y.y.x # Gateway des Anbieters der Hostmaschine
	bridge_ports eth0
	bridge_stp yes
	bridge_fd 5 #Timeout für die Brücke

Speichern und Neustarten.

Virtuelle Maschine erstellen

  1. Name vergeben
  2. OS: Linux 4.x auswählen
  3. CD/DVD: ubuntu 14.04. server-amd64 wählen
  4. Laufwerk: 20 GB, VIRTIO
  5. CPU: Cores 2 und Typ:host
  6. Speicher: Min 1GB, empfohlen >2 GB (nach der Installation des Betriebssystems kann der Speicher noch erhöht werden)
  7. Netzwerk: Bridge mode (vmbr0), VirtIO(paravirtualized)

Anschließend: Unter Hardware, Tastaturlayout: German(de) setzen, dass ist wichtig für die Tastaturerkennung und das Passwort.

Es empfiehlt sich außerdem die Optionen "Beim Booten starten"=Ja zu setzen.

Installation des Gastsystems

Server ohne Zusätze installieren.

Anmelden mit Benutzername und Passwort.

sudo nano /etc/network/interfaces

"iface eth0 inet dhcp" bearbeiten:

iface eth0 inet static 			# eth0=ens18* ab Ubuntu 16
	address y.y.y.y 			# IP Adresse der VM
	netmask 255.255.255.255
	pointopoint x.x.x.x 			# Gateway des Anbieters der Hostmaschine
	gateway x.x.x.x 			# Gateway des Anbieters der Hostmaschine
	dns-nameservers 1.1.1.1 85.214.20.141   # DNS Server 

Speichern und Neustart mit

sudo reboot now

Netzwerktest:

ping freifunk-dresden.de

Installation des Freifunk-Servers

sudo su               #dauerhaft Superuser=Root
apt-get update        #Paketquellen aktualisieren
apt-get install ssh   #Optional Wartungstool: Fernzugriff per SSH
apt-get install htop  #Optional Wartungstool: Schickeres TOP
apt-get install iftop #Optional Wartungstool: Das TOP für den Netzwerkverkehr

apt-get install git   #git installieren
mkdir /root/freifunk
cd /root/freifunk
git clone https://github.com/ddmesh/vserver-base.git
cd vserver-base
bash vserver-install.sh

Konfigurieren des Freifunk-Servers

Für die /etc/nvram.conf benötigt man einen fastd Key:

bash /etc/init.d/S53backbone-fastd genkey

und eine Knotennummer. Die Knotennummer wird durch den Registrierungsserver zugewiesen. Zuvor muss man dafür den voreingestellten 64stelligen (Default)registerkey in der nvram ersetzen. Einen Zufallscode (zweimal md5summen aus den IP-Adressen des System und der aktuellen Zeit) gibt es so:

echo $(ip addr|md5sum)$(date|md5sum) | sed 'sx\(..\)x\1:xg' | sed 's/ -://g'
Server-nvramconf.PNG

Diese Hexadezimalzahlenkombination wird in der nvram.conf unter ddmesh_registerkey jenen ersetzen. Anschließend wird das Registrierungscript ausgeführt.

freifunk-register-local-node.sh

Die zurückgegebene Knotennummer ersetzt die ddmesh_node im nvram.conf

Wichtige Punkte:

  • Erzeugter Registerkey
  • zurückgegebene Knotennummer
  • erzeugten fastd-Keys
  • Servername Local-DNS (oder freie DNSServer)
  • bei Bedarf Geokoordinaten
  • Wichtig: Kontaktinformationen!

Die nvram.conf sollte außerhalb des Servers gesichert werden, somit lässt sich schnell der entsprechende Server bei Problemen wieder aufsetzen.

Konfigurieren des des Tunnels

Für einen Tunnel muss mit der per

bash /etc/openvpn/gen-config.sh PfadZumConfigFile.conf 

die Konfiguration erstellt werden.

Anschließend müssen im erstellten "openvpn.conf"-File die Pfade für cert, key und crl-verify angepasst werden.

Server untereinander verbinden

Server können untereinander per vtun verbunden werden.

Ein Server arbeitet dabei als Server, dort wird in der nvram.conf folgendes konfiguriert:

backbone_accept_1=r51xxx:t0talg3h3ime5pas5wor7:tcp #r51xxx Akzeptierte Knotennummer mit r davor.

Die Gegenstelle arbeitet als Client, dort wird in der nvram.conf folgendes konfiguriert:

backbone_host_0=HostnameUnterDerDerServerErreichbarIst.wahrheitsgetr.eu:5000:t0talg3h3ime5pas5wor7:tcp

Anschließend:

/etc/init.d/S53backbone restart

Server Scripte

Mit dem Script freifunk-gateway-check.sh überprüft man den Gateway.

VM auf anderen Host

Der Umzug ist recht schnell gemacht, in 5-10 Minuten, wenn die Hostmaschinen eine gute Anbindung haben. Als erstes muss dem Storage "lokal" der typ "VZDump backup" hinzugefügt werden.

Vorbereitung in der GUI

Rechenzentrum(Datacenter)->Storage->Hinzufügen(Add)
ID: local
Verzeichniss(Directory): '/var/lib/vz'	
Inhalt(Content): VZDump

Backup erstellen

ssh root@f032.biz
root@f032:cd /var/lib/vz/dump 
root@f032:/var/lib/vz/dump# vzdump 100 #ID der VM. Optional das Image mit [--compress gzip] oder [--compress lzo] packen.
INFO: starting new backup job: vzdump 100
INFO: Starting Backup of VM 100 (qemu)
INFO: status = stopped
INFO: update VM 100: -lock backup
INFO: backup mode: stop
INFO: ionice priority: 7
INFO: VM Name: VPN3-Server2
INFO: include disk 'virtio0' 'local:100/vm-100-disk-1.qcow2' 20G
INFO: snapshots found (not included into backup)
INFO: creating archive '/var/lib/vz/dump/vzdump-qemu-100-2018_04_15-18_36_14.vma'
INFO: starting kvm to execute backup task
INFO: started backup task '4ef444ba-4e45-4fda-8fd8-06a79533fb6e'
INFO: status: 0% (135266304/21474836480), sparse 0% (39522304), duration 3, 45/31 MB/s
INFO: status: 1% (288751616/21474836480), sparse 0% (52772864), duration 6, 51/46 MB/s
INFO: status: 2% (486670336/21474836480), sparse 0% (75874304), duration 9, 65/58 MB/s
INFO: status: 3% (718536704/21474836480), sparse 0% (88006656), duration 12, 77/73 MB/s
INFO: status: 4% (862912512/21474836480), sparse 0% (89247744), duration 15, 48/47 MB/s
INFO: status: 5% (1075838976/21474836480), sparse 0% (96858112), duration 20, 42/41 MB/s
INFO: status: 6% (1319043072/21474836480), sparse 0% (109592576), duration 28, 30/28 MB/s
INFO: status: 7% (1516765184/21474836480), sparse 0% (117940224), duration 34, 32/31 MB/s
INFO: status: 8% (1752432640/21474836480), sparse 0% (122040320), duration 39, 47/46 MB/s
INFO: status: 9% (1935081472/21474836480), sparse 0% (136323072), duration 43, 45/42 MB/s
INFO: status: 10% (2286682112/21474836480), sparse 1% (248762368), duration 49, 58/39 MB/s
INFO: status: 11% (2398552064/21474836480), sparse 1% (249585664), duration 52, 37/37 MB/s
INFO: status: 12% (2581069824/21474836480), sparse 1% (250785792), duration 56, 45/45 MB/s
INFO: status: 13% (2817458176/21474836480), sparse 1% (251793408), duration 61, 47/47 MB/s
INFO: status: 14% (3036741632/21474836480), sparse 1% (259866624), duration 65, 54/52 MB/s
INFO: status: 15% (3234856960/21474836480), sparse 1% (275673088), duration 68, 66/60 MB/s
INFO: status: 16% (3470524416/21474836480), sparse 1% (283660288), duration 73, 47/45 MB/s
INFO: status: 17% (3702390784/21474836480), sparse 1% (299192320), duration 77, 57/54 MB/s
INFO: status: 18% (3978559488/21474836480), sparse 1% (344612864), duration 80, 92/76 MB/s
INFO: status: 21% (4690542592/21474836480), sparse 4% (880152576), duration 83, 237/58 MB/s
INFO: status: 31% (6739525632/21474836480), sparse 12% (2757976064), duration 86, 682/57 MB/s
INFO: status: 40% (8779464704/21474836480), sparse 21% (4673409024), duration 89, 679/41 MB/s
INFO: status: 41% (8913616896/21474836480), sparse 21% (4673417216), duration 92, 44/44 MB/s
INFO: status: 50% (10920591360/21474836480), sparse 30% (6526320640), duration 95, 668/51 MB/s
INFO: status: 60% (13068992512/21474836480), sparse 39% (8571621376), duration 98, 716/34 MB/s
INFO: status: 61% (13269663744/21474836480), sparse 39% (8576716800), duration 101, 66/65 MB/s
INFO: status: 71% (15261827072/21474836480), sparse 48% (10420334592), duration 104, 664/49 MB/s
INFO: status: 75% (16279470080/21474836480), sparse 52% (11359080448), duration 107, 339/26 MB/s
INFO: status: 80% (17355833344/21474836480), sparse 57% (12379205632), duration 110, 358/18 MB/s
INFO: status: 91% (19595853824/21474836480), sparse 67% (14523760640), duration 113, 746/31 MB/s
INFO: status: 100% (21474836480/21474836480), sparse 76% (16381767680), duration 115, 939/10 MB/s
INFO: transferred 21474 MB in 115 seconds (186 MB/s)
INFO: stopping kvm after backup task
INFO: archive file size: 4.75GB
INFO: Finished Backup of VM 100 (00:01:59)
INFO: Backup job finished successfully
root@f032:/var/lib/vz/dump# ls -al
total 4976560
drwxr-xr-x 2 root root       4096 Apr 15 18:38 .
drwxr-xr-x 6 root root       4096 Jul  4  2017 ..
-rw-r--r-- 1 root root       4226 Apr 15 18:38 vzdump-qemu-100-2018_04_15-18_36_14.log
-rw-r--r-- 1 root root 5095974400 Apr 15 18:38 vzdump-qemu-100-2018_04_15-18_36_14.vma

Backup übertragen

root@f032:/var/lib/vz/dump# scp vzdump-qemu-100-2018_04_15-18_36_14.vma root@93.88.88.39:/var/lib/vz/dump/vzdump-qemu-100-2018_04_15-18_36_14.vma
root@93.88.88.39's password:
vzdump-qemu-100-2018_04_15-18_36_14.vma                                               100% 4860MB  68.5MB/s   01:11

Hostserver wechseln

root@f032:/var/lib/vz/dump# exit
logout
Connection to pm.i24.i24.cc closed.
PS C:\Users\2> ssh root@93.88.88.39
root@93.88.88.39's password:
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sat Apr 14 14:51:24 2018

Backup einspielen

root@srv54054:~# cd /var/lib/vz/dump/
root@srv54054:/var/lib/vz/dump# ls -al
total 4976552
drwxr-xr-x 2 root root       4096 Apr 15 18:52 .
drwxr-xr-x 6 root root       4096 Apr 11 13:02 ..
-rw-r--r-- 1 root root 5095974400 Apr 15 18:53 vzdump-qemu-100-2018_04_15-18_36_14.vma
root@srv54054:/var/lib/vz/dump#

root@srv54054:/var/lib/vz/dump# qmrestore vzdump-qemu-100-2018_04_15-18_36_14.vma 200#ID der VM, kann beliebig gewählt werden sofern noch nicht vergeben
restore vma archive: vma extract -v -r /var/tmp/vzdumptmp17826.fifo /var/lib/vz/dump/vzdump-qemu-100-2018_04_15-18_36_14.vma /var/tmp/vzdumptmp17826
CFG: size: 388 name: qemu-server.conf
DEV: dev_id=1 size: 21474836480 devname: drive-virtio0
CTIME: Sun Apr 15 18:36:16 2018
Formatting '/var/lib/vz/images/200/vm-200-disk-1.qcow2', fmt=qcow2 size=21474836480 encryption=off cluster_size=65536 preallocation=metadata lazy_refcounts=off refcount_bits=16
new volume ID is 'local:200/vm-200-disk-1.qcow2'
map 'drive-virtio0' to '/var/lib/vz/images/200/vm-200-disk-1.qcow2' (write zeros = 0)
progress 1% (read 214761472 bytes, duration 0 sec)
progress 2% (read 429522944 bytes, duration 0 sec)
progress 3% (read 644284416 bytes, duration 1 sec)
progress 4% (read 859045888 bytes, duration 7 sec)
progress 5% (read 1073741824 bytes, duration 9 sec)
progress 6% (read 1288503296 bytes, duration 10 sec)
progress 7% (read 1503264768 bytes, duration 13 sec)
progress 8% (read 1718026240 bytes, duration 18 sec)
progress 9% (read 1932787712 bytes, duration 19 sec)
progress 10% (read 2147483648 bytes, duration 21 sec)
progress 11% (read 2362245120 bytes, duration 22 sec)
progress 12% (read 2577006592 bytes, duration 25 sec)
progress 13% (read 2791768064 bytes, duration 31 sec)
progress 14% (read 3006529536 bytes, duration 32 sec)
progress 15% (read 3221225472 bytes, duration 33 sec)
progress 16% (read 3435986944 bytes, duration 36 sec)
progress 17% (read 3650748416 bytes, duration 39 sec)
progress 18% (read 3865509888 bytes, duration 44 sec)
progress 19% (read 4080271360 bytes, duration 45 sec)
progress 20% (read 4294967296 bytes, duration 45 sec)
progress 21% (read 4509728768 bytes, duration 45 sec)
progress 22% (read 4724490240 bytes, duration 45 sec)
progress 23% (read 4939251712 bytes, duration 45 sec)
progress 24% (read 5154013184 bytes, duration 45 sec)
progress 25% (read 5368709120 bytes, duration 45 sec)
progress 26% (read 5583470592 bytes, duration 45 sec)
progress 27% (read 5798232064 bytes, duration 45 sec)
progress 28% (read 6012993536 bytes, duration 45 sec)
progress 29% (read 6227755008 bytes, duration 45 sec)
progress 30% (read 6442450944 bytes, duration 45 sec)
progress 31% (read 6657212416 bytes, duration 46 sec)
progress 32% (read 6871973888 bytes, duration 47 sec)
progress 33% (read 7086735360 bytes, duration 47 sec)
progress 34% (read 7301496832 bytes, duration 47 sec)
progress 35% (read 7516192768 bytes, duration 47 sec)
progress 36% (read 7730954240 bytes, duration 47 sec)
progress 37% (read 7945715712 bytes, duration 47 sec)
progress 38% (read 8160477184 bytes, duration 47 sec)
progress 39% (read 8375238656 bytes, duration 47 sec)
progress 40% (read 8589934592 bytes, duration 47 sec)
progress 41% (read 8804696064 bytes, duration 49 sec)
progress 42% (read 9019457536 bytes, duration 55 sec)
progress 43% (read 9234219008 bytes, duration 55 sec)
progress 44% (read 9448980480 bytes, duration 55 sec)
progress 45% (read 9663676416 bytes, duration 55 sec)
progress 46% (read 9878437888 bytes, duration 55 sec)
progress 47% (read 10093199360 bytes, duration 55 sec)
progress 48% (read 10307960832 bytes, duration 55 sec)
progress 49% (read 10522722304 bytes, duration 55 sec)
progress 50% (read 10737418240 bytes, duration 55 sec)
progress 51% (read 10952179712 bytes, duration 56 sec)
progress 52% (read 11166941184 bytes, duration 56 sec)
progress 53% (read 11381702656 bytes, duration 56 sec)
progress 54% (read 11596464128 bytes, duration 56 sec)
progress 55% (read 11811160064 bytes, duration 56 sec)
progress 56% (read 12025921536 bytes, duration 56 sec)
progress 57% (read 12240683008 bytes, duration 56 sec)
progress 58% (read 12455444480 bytes, duration 56 sec)
progress 59% (read 12670205952 bytes, duration 56 sec)
progress 60% (read 12884901888 bytes, duration 56 sec)
progress 61% (read 13099663360 bytes, duration 56 sec)
progress 62% (read 13314424832 bytes, duration 58 sec)
progress 63% (read 13529186304 bytes, duration 58 sec)
progress 64% (read 13743947776 bytes, duration 58 sec)
progress 65% (read 13958643712 bytes, duration 58 sec)
progress 66% (read 14173405184 bytes, duration 58 sec)
progress 67% (read 14388166656 bytes, duration 58 sec)
progress 68% (read 14602928128 bytes, duration 58 sec)
progress 69% (read 14817689600 bytes, duration 58 sec)
progress 70% (read 15032385536 bytes, duration 58 sec)
progress 71% (read 15247147008 bytes, duration 58 sec)
progress 72% (read 15461908480 bytes, duration 59 sec)
progress 73% (read 15676669952 bytes, duration 59 sec)
progress 74% (read 15891431424 bytes, duration 59 sec)
progress 75% (read 16106127360 bytes, duration 59 sec)
progress 76% (read 16320888832 bytes, duration 59 sec)
progress 77% (read 16535650304 bytes, duration 59 sec)
progress 78% (read 16750411776 bytes, duration 59 sec)
progress 79% (read 16965173248 bytes, duration 59 sec)
progress 80% (read 17179869184 bytes, duration 59 sec)
progress 81% (read 17394630656 bytes, duration 61 sec)
progress 82% (read 17609392128 bytes, duration 62 sec)
progress 83% (read 17824153600 bytes, duration 62 sec)
progress 84% (read 18038915072 bytes, duration 62 sec)
progress 85% (read 18253611008 bytes, duration 62 sec)
progress 86% (read 18468372480 bytes, duration 62 sec)
progress 87% (read 18683133952 bytes, duration 62 sec)
progress 88% (read 18897895424 bytes, duration 62 sec)
progress 89% (read 19112656896 bytes, duration 62 sec)
progress 90% (read 19327352832 bytes, duration 62 sec)
progress 91% (read 19542114304 bytes, duration 62 sec)
progress 92% (read 19756875776 bytes, duration 62 sec)
progress 93% (read 19971637248 bytes, duration 62 sec)
progress 94% (read 20186398720 bytes, duration 62 sec)
progress 95% (read 20401094656 bytes, duration 62 sec)
progress 96% (read 20615856128 bytes, duration 62 sec)
progress 97% (read 20830617600 bytes, duration 62 sec)
progress 98% (read 21045379072 bytes, duration 62 sec)
progress 99% (read 21260140544 bytes, duration 62 sec)
progress 100% (read 21474836480 bytes, duration 62 sec)
total bytes read 21474836480, sparse bytes 16381767680 (76.3%)
space reduction due to 4K zero blocks 0.73%
root@srv54054:/var/lib/vz/dump#

Abschlußarbeiten

Noch daran denken, unter /ete/network die ip angepasst werden müssen. Ebenso die /etc/nvram.conf nochmal checken.