von Ralf Schweiger | Mai 15, 2019 | Bareos-Server, Debian, Free BSD, Free NAS, Hardware, Infiniband, Linux, Virtualsierung
Wenn Proxmox im Cluster laufen soll, benötigt es ein shared storage. Das kann NFS sein oder besser iSCSI. Für Performance ist letztendlich entscheidend das Layout des Storage-Pools und eine möglichst latenzarme Anbindung. Fiberchannel oder Infiniband sind hier die Kandidaten der Wahl. Letzteres hat allerdings die Nase vorn, wenn es um Bandbreite geht und es ist ausgereift, da es im High-Perfomance-Computing schon sehr lange im Einsatz ist. Infiniband kennen wir zudem aus dem HP POD Supercomputing Projekt bei Airbus (damals die Nr.10 auf top500.org).
Da die Auswahl an Storage-Systemen mit Infiniband-Unterstützung dünn und im bezahlbaren Bereich quasi nicht vorhanden ist, haben wir beschlossen, selbst ein Storage zu entwickeln.
Als Hardware-Basis für Storage, Virtualisierungsplattform und Backup dienen unsere bewährten getcom Superserver Green-IT-Serie der Generation 7 & 8, Voltaire Infiniband Grid Director 4036E und Cisco Switche aus der SG550X Serie.

Alle Server (Storage und Cluster-Knoten) sind mit je zwei Intel XEONs 3,2GHz und 256GB ECC RAM bestückt und laufen auf aktuellen Supermicro Boards. Für den Netzwerkstack haben alle Server neben IPMI und Dual 10GbE je eine Dual Infiniband und eine Intel X710 SFP+ Karte mit an Bord. Die Betriebssysteme laufen auf gespiegelten Intel DC SSDs. Auf dem Storage-Server ist dazu auf der Rückseite ein hotplugfähiges 2,5″ Dual Bay integriert.
Das Herzstück des I/O-Systems für Storage- & Backup-Systeme, speziell geflashte HCAs, Dual SFP+ Ethernet 10GbE, Dual Infiniband 40Gbit mit gespiegelten PCIe NAND Flash Modulen, garantiert ordentlichen Durchsatz bei minimaler Latenz:

Die Frage nach dem Filesystem hat sich schnell beantwortet: ZFS soll es sein.
Die Vorteile sind:
- schnelle Rebuildzeit (resilver), da nur die belegten Blöcke übertragen werden
- schnelle Pool-Initialisierung, auch 140TB sind in wenigen Minuten initialisiert
- die Datenintegrität ist bei ZFS immer garantiert, d.h. ein Block wird so ausgeliefert, wie er gespeichert wurde
- einfache Poolerweiterung durch größere Ersatz-Platten
- einfacher Pool-Import inklusive ACLs, Snaphots, etc., der Platten auf neuer Hardware, wenn ZFS Version gleich oder größer ist auf dem Zielsystem bei unrelevanter Plattenfolge
Aktuelle ZFS basierte Systeme, die geeignet sind, sind FreeNAS 11.2 oder OmniOSce in Verbindung mit Napp-IT.
OmniOSce/Napp-IT ist im Grunde ein Abkömmling von Solaris Version 10 => OpenSolaris => illumos / OpenIndiana und damit ein direkter Nachfahre vom Unix System V. Da es unter FreeNAS/FreeBSD einige Überraschungen in Verbindung mit HA, Infiniband und iSCSI gab, werden wir uns bei Gelegenheit OmniOSce und Napp-IT in einer eigenen Analyse näher ansehen. Die PoC-Hardware dazu steht schon bereit. Mehr dazu in einem der nächsten Blogs.
Da FreeNAS nun über OpenZFS und auch über Mellanox Infiniband Treiber verfügt, gehen wir es an.
FreeNAS Setup
Die Installation wird als erledigt vorausgesetzt. Wir haben lediglich die beiden Intel Datacenter SSDs als Spiegel für die Installation ausgewählt. Wichtig ist, dass im BIOS auf UEFI umgestellt ist vor der Installation. Anschließend ist der Hostname zu vergeben, die beiden SFP+ Ports zu lagg0 (LACP), die beiden internen 10GbE Ports zu lagg1 (LACP) zusammen zu schalten. Mehr ist hier erst einmal nicht zu tun. Auf Cisco-Seite müssen innerhalb des Stacks auf den Core und den Management Switchen ebenfalls die entsprechend verwendeten Ports unter Link Aggregation zu einem lagg zusammen geschaltet werden. Für die Stack-Implementierung ist je Switch die Cisco Tesla Hybrid Firmware in der aktuellen Version zu flashen, wenn sich verschiedene Typen im Stack befinden sollen.
ZFS
Ein Blick auf das OpenZFS, welches FreeNAS mitbringt, verrät uns, dass es nah dran ist am aktuellen Oracle ZFS, die fehlende Verschlüsselung fällt auf, womit wir aber erst mal leben können:
root@freenas1[~]# zpool upgrade -v
This system supports ZFS pool feature flags.
The following features are supported:
FEAT DESCRIPTION
-------------------------------------------------------------
async_destroy (read-only compatible)
Destroy filesystems asynchronously.
empty_bpobj (read-only compatible)
Snapshots use less space.
lz4_compress
LZ4 compression algorithm support.
multi_vdev_crash_dump
Crash dumps to multiple vdev pools.
spacemap_histogram (read-only compatible)
Spacemaps maintain space histograms.
enabled_txg (read-only compatible)
Record txg at which a feature is enabled
hole_birth
Retain hole birth txg for more precise zfs send
extensible_dataset
Enhanced dataset functionality, used by other features.
embedded_data
Blocks which compress very well use even less space.
bookmarks (read-only compatible)
"zfs bookmark" command
filesystem_limits (read-only compatible)
Filesystem and snapshot limits.
large_blocks
Support for blocks larger than 128KB.
sha512
SHA-512/256 hash algorithm.
skein
Skein hash algorithm.
device_removal
Top-level vdevs can be removed, reducing logical pool size.
obsolete_counts (read-only compatible)
Reduce memory used by removed devices when their blocks are freed or remapped.
zpool_checkpoint (read-only compatible)
Pool state can be checkpointed, allowing rewind later.
The following legacy versions are also supported:
VER DESCRIPTION
--- --------------------------------------------------------
1 Initial ZFS version
2 Ditto blocks (replicated metadata)
3 Hot spares and double parity RAID-Z
4 zpool history
5 Compression using the gzip algorithm
6 bootfs pool property
7 Separate intent log devices
8 Delegated administration
9 refquota and refreservation properties
10 Cache devices
11 Improved scrub performance
12 Snapshot properties
13 snapused property
14 passthrough-x aclinherit
15 user/group space accounting
16 stmf property support
17 Triple-parity RAID-Z
18 Snapshot user holds
19 Log device removal
20 Compression using zle (zero-length encoding)
21 Deduplication
22 Received properties
23 Slim ZIL
24 System attributes
25 Improved scrub stats
26 Improved snapshot deletion performance
27 Improved snapshot creation performance
28 Multiple vdev replacements
For more information on a particular version, including supported releases,
see the ZFS Administration Guide.
root@freenas1[~]
Infiniband
Testweise manuelles Laden der Module für Infiniband unter FreeNAS/FreeBSD:
root@freenas1[~]# kldload mlx4
kldload: can't load mlx4: module already loaded or in kernel
root@freenas1[~]# kldload mlx4ib
root@freenas1[~]# kldload ipoib
root@freenas1[~]
Das aktiviert schon einmal die Karten, die uns mit Aufleuchten der orangen und grünen LEDs signalisieren, dass die Treiber geladen und die Karten einsatzbereit sind.
Das permanente Laden erfolgt in FreeBSD über die /boot/loader.conf.local.
Anders als unter FreeBSD wird allerdings die local Datei bei Updates oder Änderungen in den Tuneables (loader) gnadenlos überschrieben. FreeNAS ist eine Appliance und somit muss man Änderungen immer über die GUI vornehmen. Das gilt für alle Appliances, nebenbei auch für pfSense. Die loader Config darf deshalb nicht manuell editiert werden, da sie vom System früher oder später überschrieben werden wird.
Die korrekte Vorgehensweise ist über die GUI => System => Tunables => Add zu gehen und die entsprechenden Werte für die beiden loader einzutragen.
Nach dem Speichern finden wir unsere loader an gewohnter Stelle wieder:
root@freenas1[~]# cat /boot/loader.conf.local
mlx4ib_load="YES" # Be sure that Kernel modul Melloanox 4 Infiniband will be loaded
ipoib_load="YES" # Be sure that Kernel modul IP over Infiniband will be loaded
kernel="kernel"
module_path="/boot/kernel;/boot/modules;/usr/local/modules"
kern.cam.ctl.ha_id=0
root@freenas1[~]
Unter FreeBSD/FreeNAS kann für IP über Infiniband keine der bekannten Loadbalancer Methoden, wie Round Robin oder LACP verwendet werden. Da wir aber iSCSI für die Virtualisierungshosts, bzw. für das Proxmox-Cluster und den VMs einsetzen möchten, ist zwingend für die Erhöhung des Durchsatzes und für die Ausfallsicherheit zu sorgen.
Damit sind wir auch gleich schon beim Thema Multipath angelangt:
Multipath
Etwas Theorie dazu, wenn es lieber mehr sein darf:
Für Multipath ist je Netzwerk Gerät eine IP aus einem eigenen Subnet zu verwenden. Da wir die Infiniband-Netze weder routen, noch für andere Zwecke, außer latenzarm iSCSI zur Verfügung stellen wollen, verwenden wir neue Subnetze, außerhalb der bisher verwendeten.
In unserem Fall 10.20.24.0/24 für ib0 und 10.20.25.0/24 für ib1. Falls zwei HCAs mit je zwei Ports eingesetzt werden, werden analog vier eigene Subnetze benötigt.
Bei FreeBSD ist der Infiniband Treiber standardmäßig auf connected mode (CM) aktiv, was bedeutet, dass TCP/IP zum Einsatz kommt. Dafür ist normalerweise die MTU auf 65520 einzustellen auf Server- und Client-Seite (Proxmox), um den maximalen Durchsatz zu ermöglichen.
Mit diesen Werten hatten wir allerdings Probleme auf der Client-Seite mit SCSI-Kernel-Fehler-Meldungen. Durch heran tasten haben wir eine MTU von 40950 als zuverlässig ermittelt. Die Ursache ist aktuell nicht ganz klar. Wir vermuten Buffer-Probleme innerhalb der Treiber-Implementierung. Das könnte der Grund sein, weshalb Mellanox die ConnectX-2 Karten nicht für FreeBSD frei gegeben hatte. Wir wollen im Zuge des OmniOSce PoC-Projektes vorher auch noch ConnectX-3 Karten unter FreeBSD testen. Möglicherweise erledigt sich das damit auch schon. Mehr dazu, wenn wir die spezifischen Tests abgeschlossen haben. Aktuell genügt uns das Setup, wie es ist, da wir insgesamt mit vier virtuellen Testmaschinen beim Performance-Test auf einen Gesamtdurchsatz von über. 3.000 MB/s kommen, was dem ermittelten maximalen Wert von 3.134 MB/s der gespiegelten Intel Optane SSDs bereits sehr nahe kommt. Faktisch geht nicht mehr viel raus zu holen.
Das Setup der Infiniband-Karte ib0 sieht damit folgendermaßen aus:

Analog dazu ist ib1 einzurichten.
Pool Setup
Für Performance ist ein RAID-Z Pool ungeeignet. Zum einen wird bei einem Rebuild dann von allen Platten gelesen, was die Performance extrem nach unten zieht, zum anderen zum anderen sind die Schreib-/Lesewerte damit nicht befriedigent.
Es ist daher dringend empfohlen, VDEVs aus je zwei gespiegelten Platten (Mirroring) zu einem Pool zusammen zu schalten. In unserem Setup sind das 16 HGST 10TB HE2 SAS3 Platten, also 8 VDEVs mit je zwei Platten im Spiegelverbund plus die zwei Intel Optanes zu einem Spiegel verbundenen VDEV als SLOG.
Der Pool hat als Sync-Methode „Standard“, „lz4“ als Kompression, der Share Type ist „Unix“, Atime ist „off“, Deduplication ist „off“, der Rest bleibt Default:

Im Pool werden dann drei Datasets benötigt, wobei die ersten beiden via NFS frei gegeben werden:
- Proxmox-ISO-Images
- Proxmox-Snapshots
- iSCSI

NFS Sharing
FreeNAS GUI => Sharing => Unix (NFS) Shares
Je Dataset Proxmox-* ist ein Share anzulegen mit aktiviertem All Dirs und mit den IPs der Proxmox-Cluster-Knoten aus dem SFP+ lagg0 Subnetz:

iSCSI Multipath Setup
Target Global Configuration
FreeNAS GUI => Sharing => Block (iSCSI) => Target Global Configuration:
Basename = iqn.2019-05.de.getcom.freenas1
Pool Availble Space Threshold (%) = 75

Portals
FreeNAS GUI => Sharing => Block (iSCSI) => Portals
Je Infiniband Subnet, bzw. IP, ist ein Portal zu erstellen.

Initiators
FreeNAS GUI => Sharing => Block (iSCSI) => Initiators
Es wird ein Initator benötigt, zuerst einmal ohne Einschränkung (ALL/ALL):

Authorized Access
FreeNAS GUI => Sharing => Block (iSCSI) => Authorized Access.
Keine Einschränkungen, das kann später geändert werden, wird aber nicht wirklich benötigt, da iSCSI nur auf den von Außen nicht erreichbaren Infiniband Subnetzen aktiv ist.

Targets
FreeNAS GUI => Sharing => Block (iSCSI) => Targets
Hier ist jetzt ein Target anzulegen. Der Name wird klein geschrieben und ist hier frei wählbar, kann also proxmox, proxmox0, iscsi oder wie in unserem Fall iscsi-target0 heißen. Dem Target sind beide Portal Group IDs „1“ + „2“ und die Initiator Group ID „1“ zuzuweisen:


Extents
FreeNAS GUI => Sharing => Block (iSCSI) => Extents
Wie im Screenshot ersichtlich, entsprechend die Werte auswählen:

Associated Targets
FreeNAS GUI => Sharing => Block (iSCSI) => Associated Targets
Wie im Screenshot ersichtlich, entsprechend auswählen:

Damit ist das iSCSI Setup abgeschlossen.
Aktivierung des iSCSI und NFS Services
FreeNAS GUI => Services => iSCSI
FreeNAS GUI => Services => NFS
Start Automatically muss ausgewählt werden und den Schalter dann nach rechts ziehen:

Damit ist das Setup auf der FreeNAS Seite abgeschlossen.
Proxmox Setup
von Ralf Schweiger | Dez. 31, 2018 | Bareos-Server, Free BSD, Free NAS
Verwendete Komponenten:



Voraussetzung für dieses Setup:
- FreeNAS 11.2-RELEASE-p6
- Vollständige Basiskonfiguration inklusive Netzwerkdevices, Storage-Pool, etc.
Um Bareos Server und die WebUI auf einem FreeNAS 11.2 Storage Server zu installieren, muss man sich über folgendes im Klaren sein:
- FreeNAS ist eine Appliance und somit ist per Design keine direkte Installation einer zusätzlichen Software vorgesehen und das muss auch so bleiben.
- FreeNAS bietet ein Plugin für Bacula, nicht jedoch für Bareos.
- Alle zusätzlichen Services, die nicht unter FreeNAS verfügbar sind, müssen daher in jeweils einem eigenen Jail laufen.
Vorgehensweise:
Wir erstellen ein Jail mit dem Namen „bareos-server“ innerhalb von FreeNAS, weisen ein Ethernet-Device zu und starten das Jail:
- Jail Name: bareos-server
- Template: FreeBSD
- IPv4 address: <static_ip>
- Autostart: Checked
- VIMAGE: Checked
- Alle anderen Optionen bleiben default (oder basierend auf einer eigenen Konfiguration)

Um Zugriff von Außen via SSH auf den neuen „bareos-server“ zu erhalten, sind folgende Schritte nötig:
Rechts am Ende des Jail-Eintrags befinden sich drei Punkte. Beim Klick darauf öffnet sich ein Kontextmenü. Hier eine Shell öffnen. (Jails > Jails > bareos-server > Shell)
Innerhalb der Shell des „bareos-server“ Jails folgende Änderungen vornehmen:
Änderung /etc/rc.conf:
echo 'sshd_enable="YES"' >>/etc/rc.conf
- Erlaube root login. (alternativ kann man einen Benutzer anlegen und sudo verwenden)
- Start SSH service.
- Ändere das root Passwort.
passwd
- Folge dem Prompt, um das Passwort zu ändern.
Von nun an kann man sich direkt via SSH am bareos-server anmelden mit
Anschließend sind folgende Vorbereitungen notwendig:
sed -i '' s/quarterly/latest/g /etc/pkg/FreeBSD.conf
pkg search bareos
pkg install bareos-client bareos-server bareos-webui postgresql95-server nginx php72 php72-xml php72-session php72-simplexml php72-gd php72-ctype php72-mbstring php72-zlib php72-tokenizer php72-iconv php72-pecl-mcrypt php72-pear-DB_ldap php72-zip php72-dom php72-sqlite3 php72-gettext php72-curl php72-json php72-opcache php72-wddx php72-hash php72-soap
echo 'bareos_sd_enable="YES"' >>/etc/rc.conf
Mit der zweiten Zeile wird der bareos_sd service beim Booten des Jails mit gestartet.
Nun ist noch eine Konfiguration notwendig, die alle bareos-sd.d/* Konfigurationen lädt:
echo '@/usr/local/etc/bareos/bareos-sd.d/*/*' >>/usr/local/etc/bareos/bareos-sd.conf
Nun benötigen wir einen pgsql login und setzen die Collation auf deutsch, da wir bei der Suche deutsche Umlaute erwarten:
cat >> /etc/login.conf << __EOF
# PostgreSQL
pgsql:\
:lang=de_DE.UTF-8:\
:setenv=LC_COLLATE=C:\
:tc=default:
__EOF
Neuladen der Login-Datenbank:
Nun initialisieren wir die Datenbanken:
/usr/local/etc/rc.d/postgresql initdb

Nun starten wir den PostgreSQL:
root@bareos-server:~ # /usr/local/etc/rc.d/postgresql start
LOG: Logausgabe nach stderr endet
TIPP: Die weitere Logausgabe geht an Logziel "syslog".
Wir kümmern uns nun um die Bareos Server Konfiguration. Die nicht benötigten*.sample
Files werden gelöscht und die Permissions korrigiert:
chown -R bareos:bareos /usr/local/etc/bareos
find /usr/local/etc/bareos -type f -exec chmod 640 {} ';'
find /usr/local/etc/bareos -type d -exec chmod 750 {} ';'
find /usr/local/etc/bareos -name \*\.sample -delete
Für das „Tracking“ behalten wir eine Kopie der originalen Konfiguration:
cp -a /usr/local/etc/bareos /usr/local/etc/bareos.orig
Nun passen wie die Bareos Catalog Konfiguration an unter:
/usr/local/etc/bareos.ORG/bareos-dir.d/catalog/MyCatalog.conf
Nach der Anpassung sieht das so aus (das Passwort ist natürlich entsprechend anzupassen):
Catalog {
Name = MyCatalog
dbdriver = "postgresql"
dbname = "bareos"
dbuser = "bareos"
dbpassword = "BAREOS-DATABASE-PASSWORD"
}
Wir prüfen, ob beide Benutzer in der bareos-Gruppe sind:
root@bareos-server:~ # pw groupmod bareos -m pgsql
root@bareos-server:~ # id pgsql
uid=70(pgsql) gid=70(pgsql) groups=70(pgsql),997(bareos)
root@bareos-server:~ # pw groupmod bareos -m www
root@bareos-server:~ # id www
uid=80(www) gid=80(www) groups=80(www),997(bareos)
Nun wird die PostgreSQL Datenbank für die Bareos Instanz vorbereitet. Dazu verwenden wir die Skripte aus dem Bareos Paket unter /usr/local/lib/bareos/scripts
.
root@bareos-server:~ # su - pgsql
$ whoami
pgsql
$ /usr/local/lib/bareos/scripts/create_bareos_database
Creating postgresql database
CREATE DATABASE
ALTER DATABASE
Database encoding OK
Creating of bareos database succeeded.
$ /usr/local/lib/bareos/scripts/make_bareos_tables
Making postgresql tables
CREATE TABLE
ALTER TABLE
CREATE INDEX
CREATE TABLE
CREATE INDEX
CREATE INDEX
CREATE TABLE
CREATE INDEX
CREATE TABLE
CREATE INDEX
CREATE TABLE
CREATE INDEX
CREATE TABLE
CREATE TABLE
CREATE INDEX
CREATE TABLE
CREATE INDEX
CREATE TABLE
CREATE INDEX
CREATE INDEX
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE INDEX
CREATE TABLE
CREATE INDEX
CREATE TABLE
CREATE INDEX
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE INDEX
CREATE TABLE
CREATE INDEX
CREATE TABLE
CREATE INDEX
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE TABLE
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
DELETE 0
INSERT 0 1
Creation of Bareos PostgreSQL tables succeeded.
$ /usr/local/lib/bareos/scripts/grant_bareos_privileges
Granting postgresql tables
CREATE ROLE
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
GRANT
Privileges for user bareos granted ON database bareos.
$
Verfizierung, ob die benötigte DB vorhanden ist:
su -m bareos -c 'psql -l'
List of databases
Name | Owner | Encoding | Collate | Ctype |Access privileges
-----------+-------+-----------+---------+-------------+-----------------
bareos | pgsql | SQL_ASCII | C | C |
postgres | pgsql | UTF8 | C | de_DE.UTF-8 |
template0 | pgsql | UTF8 | C | de_DE.UTF-8 | =c/pgsql +
| | | | | pgsql=CTc/pgsql
template1 | pgsql | UTF8 | C | de_DE.UTF-8 | =c/pgsql +
| | | | | pgsql=CTc/pgsql
(4 rows)
Wir fügen die PostgreSQL Database Jobs ein in crontab(1):
root@bareos-server:~ # su - pgsql
$ whoami
pgsql
$ cat >/usr/local/pgsql/vacuum.sh << __EOF
#! /bin/sh
/usr/local/bin/vacuumdb -a -z 1> /dev/null 2> /dev/null
/usr/local/bin/reindexdb -a 1> /dev/null 2> /dev/null
/usr/local/bin/reindexdb -s 1> /dev/null 2> /dev/null
__EOF
$ chmod +x /usr/local/pgsql/vacuum.sh
$ cat /usr/local/pgsql/vacuum.sh
#! /bin/sh
/usr/local/bin/vacuumdb -a -z 1> /dev/null 2> /dev/null
/usr/local/bin/reindexdb -a 1> /dev/null 2> /dev/null
/usr/local/bin/reindexdb -s 1> /dev/null 2> /dev/null
$ crontab -e
crontab: no crontab for pgsql - using an empty one
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.Be9j9VVCUa installed on Thu Apr 26 21:45:04 2018)
# (Cron version -- $FreeBSD$)
0 0 * * * /usr/local/pgsql/vacuum.sh
/tmp/crontab.g8mCztyvSv: 5 lines, 191 characters.
crontab: installing new crontab
$ crontab -l
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.Be9j9VVCUa installed on Thu Apr 26 21:45:04 2018)
# (Cron version -- $FreeBSD$)
0 0 * * * /usr/local/pgsql/vacuum.sh
$ exit
root@bareos-server:~ # cat /var/cron/tabs/pgsql
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.g8mCztyvSv installed on Mon Dec 31 05:01:54 2018)
# (Cron version -- $FreeBSD: releng/11.2/usr.sbin/cron/crontab/crontab.c 321241 2017-07-19 20:22:16Z ngie $)
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.Be9j9VVCUa installed on Thu Apr 26 21:45:04 2018)
# (Cron version -- $FreeBSD$)
0 0 * * * /usr/local/pgsql/vacuum.sh
root@bareos-server:~ # su -m pgsql -c 'crontab -l'
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.Be9j9VVCUa installed on Thu Apr 26 21:45:04 2018)
# (Cron version -- $FreeBSD$)
0 0 * * * /usr/local/pgsql/vacuum.sh
Wir legen nun lokal die bareos-Verzeichnisse an, das /bareos-dr dient später als NFS mount point für ein weiteres DR-Storage:
root@bareos-server:~ # mkdir -p /bareos/bootstrap
root@bareos-server:~ # mkdir -p /bareos/restore
root@bareos-server:~ # mkdir -p /bareos/storage/FileStorage
root@bareos-server:~ # mkdir -p /bareos/storage/FileStorage2
root@bareos-server:~ # mkdir -p /bareos-dr/bootstrap
root@bareos-server:~ # mkdir -p /bareos-dr/restore
root@bareos-server:~ # mkdir -p /bareos-dr/storage/FileStorage
root@bareos-server:~ # mkdir -p /bareos-dr/storage/FileStorage2
root@bareos-server:~ # chown -R bareos:bareos /bareos /bareos-dr
root@bareos-server:~ # find /bareos /bareos-dr -ls | column -t
120761 1 drwxr-xr-x 5 bareos bareos 5 Dec 31 05:20 /bareos
120774 1 drwxr-xr-x 3 bareos bareos 3 Dec 31 05:20 /bareos/storage
120775 1 drwxr-xr-x 2 bareos bareos 2 Dec 31 05:20 /bareos/storage/FileStorage
120786 1 drwxr-xr-x 2 bareos bareos 2 Dec 31 05:20 /bareos/storage/FileStorage2
120768 1 drwxr-xr-x 2 bareos bareos 2 Dec 31 05:20 /bareos/restore
120762 1 drwxr-xr-x 2 bareos bareos 2 Dec 31 05:20 /bareos/bootstrap
120776 1 drwxr-xr-x 5 bareos bareos 5 Dec 31 05:21 /bareos-dr
120777 1 drwxr-xr-x 2 bareos bareos 2 Dec 31 05:20 /bareos-dr/bootstrap
120783 1 drwxr-xr-x 2 bareos bareos 2 Dec 31 05:20 /bareos-dr/restore
120784 1 drwxr-xr-x 3 bareos bareos 3 Dec 31 05:21 /bareos-dr/storage
120785 1 drwxr-xr-x 2 bareos bareos 2 Dec 31 05:21 /bareos-dr/storage/FileStorage
120787 1 drwxr-xr-x 2 bareos bareos 2 Dec 31 05:21 /bareos-dr/storage/FileStorage2
Bareos
Im nächsten Schritt benötigen wir die Passwörter für die Bareos Subsysteme, wie wir das bereits analog für dasBAREOS-DATABASE-PASSWORD
für den bareos
User für die PostgreSQL Bareos Datenbank erstellt hatten:
- BAREOS-DATABASE-PASSWORD
- BAREOS-DIR-PASSWORD
- BAREOS-SD-PASSWORD
- BAREOS-FD-PASSWORD
- BAREOS-MON-PASSWORD
- ADMIN-PASSWORD
Wir verwenden dabei /dev/urandom zur Generierung der jeweiligen Passwörter, wie hier im Beispiel (je länger, je sicherer):
root@bareos-server:~ # cat /dev/urandom | env LC_CTYPE=C tr -dc a-zA-Z0-9 | head -c 60 ; echo
R32CERWerLmlHunzCfiTOEjhG2oo4oaWmTChzlQiuOEh50sSSwb7xKccOw8g
Wir haben bereits die MyCatalog.conf
mit nachfolgendem Inhalt angelegt:
# cat /usr/local/etc/bareos/bareos-dir.d/catalog/MyCatalog.conf
Catalog {
Name = MyCatalog
dbdriver = "postgresql"
dbname = "bareos"
dbuser = "bareos"
dbpassword = "BAREOS-DATABASE-PASSWORD"
}
Anlegen von /usr/local/etc/bareos/bconsole.d falls nicht vorhanden:
# test -d /usr/local/etc/bareos/bconsole.d/ || mkdir -p /usr/local/etc/bareos/bconsole.d/;\
chown bareos.bareos /usr/local/etc/bareos/bconsole.d
Symbolischen Link erstellen, falls notwendig:
# test -n /usr/local/etc/bareos/bconsole.d/bconsole.conf || \
ln -s /usr/local/etc/bareos/bconsole.conf /usr/local/etc/bareos/bconsole.d/
Inhalt von /usr/local/etc/bareos/bconsole.d/bconsole.conf
nach der Anpassung:
# cat /usr/local/etc/bareos/bconsole.d/bconsole.conf
#
# Bareos User Agent (or Console) Configuration File
#
Director {
Name = bareos-server.getcom.de
address = localhost
Password = "BAREOS-DIR-PASSWORD"
Description = "Bareos Console credentials for local Director"
}
Inhalt von/usr/local/etc/bareos/bareos-dir.d/director/bareos-dir.conf
nach der Anpassung:
# cat /usr/local/etc/bareos/bareos-dir.d/director/bareos-dir.conf
Director {
Name = bareos-server.getcom.de
QueryFile = "/usr/local/lib/bareos/scripts/query.sql"
Maximum Concurrent Jobs = 100
Password = "BAREOS-DIR-PASSWORD"
Messages = Daemon
Auditing = yes
# Enable the Heartbeat if you experience connection losses
# (eg. because of your router or firewall configuration).
# Additionally the Heartbeat can be enabled in bareos-sd and bareos-fd.
#
# Heartbeat Interval = 1 min
# remove comment in next line to load dynamic backends from specified directory
# Backend Directory = /usr/local/lib
# remove comment from "Plugin Directory" to load plugins from specified directory.
# if "Plugin Names" is defined, only the specified plugins will be loaded,
# otherwise all director plugins (*-dir.so) from the "Plugin Directory".
#
# Plugin Directory = /usr/local/lib/bareos/plugins
# Plugin Names = ""
}
Inhalt von /usr/local/etc/bareos/bareos-dir.d/job/RestoreFiles.conf
nach der Anpassung:
# cat /usr/local/etc/bareos/bareos-dir.d/job/RestoreFiles.conf
Job {
Name = "RestoreFiles"
Description = "Standard Restore."
Type = Restore
Client = Default
FileSet = "SelfTest"
Storage = File
Pool = BR-MO
Messages = Standard
Where = /bareos/restore
Accurate = yes
}
Neues File /usr/local/etc/bareos/bareos-dir.d/client/Default.conf
:
# cat /usr/local/etc/bareos/bareos-dir.d/client/Default.conf
Client {
Name = Default
address = bareos-server.getcom.de
Password = "BAREOS-FD-PASSWORD"
}
Neues File /usr/local/etc/bareos/bareos-dir.d/client/bareos-server.getcom.de.conf
:
# cat /usr/local/etc/bareos/bareos-dir.d/client/bareos-server.getcom.de.conf
Client {
Name = bareos-server.getcom.de
Description = "Client resource of the Director itself."
address = bareos-server.getcom.de
Password = "BAREOS-FD-PASSWORD"
}
Nachfolgendes File ist ohne Änderung:
# cat /usr/local/etc/bareos/bareos-dir.d/job/BackupCatalog.conf
Job {
Name = "BackupCatalog"
Description = "Backup the catalog database (after the nightly save)"
JobDefs = "DefaultJob"
Level = Full
FileSet="Catalog"
Schedule = "WeeklyCycleAfterBackup"
# This creates an ASCII copy of the catalog
# Arguments to make_catalog_backup.pl are:
# make_catalog_backup.pl
RunBeforeJob = "/usr/local/lib/bareos/scripts/make_catalog_backup.pl MyCatalog"
# This deletes the copy of the catalog
RunAfterJob = "/usr/local/lib/bareos/scripts/delete_catalog_backup"
# This sends the bootstrap via mail for disaster recovery.
# Should be sent to another system, please change recipient accordingly
Write Bootstrap = "|/usr/local/bin/bsmtp -h localhost -f \"\(Bareos\) \" -s \"Bootstrap for Job %j\" root@localhost" # (#01)
Priority = 11 # run after main backup
}
Nachfolgendes File ist ohne Änderung:
# cat /usr/local/etc/bareos/bareos-dir.d/messages/Standard.conf
Messages {
Name = Standard
Description = "Reasonable message delivery -- send most everything to email address and to the console."
operatorcommand = "/usr/local/bin/bsmtp -h localhost -f \"\(Bareos\) \\" -s \"Bareos: Intervention needed for %j\" %r"
mailcommand = "/usr/local/bin/bsmtp -h localhost -f \"\(Bareos\) \\" -s \"Bareos: %t %e of %c %l\" %r"
operator = root@localhost = mount # (#03)
mail = root@localhost = all, !skipped, !saved, !audit # (#02)
console = all, !skipped, !saved, !audit
append = "/var/log/bareos/bareos.log" = all, !skipped, !saved, !audit
catalog = all, !skipped, !saved, !audit
}
Nachfolgendes File ist ohne Änderung:
# cat /usr/local/etc/bareos/bareos-dir.d/messages/Daemon.conf
Messages {
Name = Daemon
Description = "Message delivery for daemon messages (no job)."
mailcommand = "/usr/local/bin/bsmtp -h localhost -f \"\(Bareos\) \\" -s \"Bareos daemon message\" %r"
mail = root@localhost = all, !skipped, !audit # (#02)
console = all, !skipped, !saved, !audit
append = "/var/log/bareos/bareos.log" = all, !skipped, !audit
append = "/var/log/bareos/bareos-audit.log" = audit
}
Pools
Per default hat Bareos vier Pools konfiguriert. Da wir sie nicht benutzen, löschen wir sie:
# ls -l /usr/local/etc/bareos/bareos-dir.d/pool
total 14
-rw-rw---- 1 bareos bareos 536 Apr 16 08:14 Differential.conf
-rw-rw---- 1 bareos bareos 512 Apr 16 08:14 Full.conf
-rw-rw---- 1 bareos bareos 534 Apr 16 08:14 Incremental.conf
-rw-rw---- 1 bareos bareos 48 Apr 16 08:14 Scratch.conf
# rm -f /usr/local/etc/bareos/bareos-dir.d/pool/*.conf
Wir legen nun zwei Pools für DAILY Backups und MONTHLY Backups an:
# cat /usr/local/etc/bareos/bareos-dir.d/pool/BRONZE-DAILY-POOL.conf
Pool {
Name = BR-DA
Pool Type = Backup
Recycle = yes # Bareos can automatically recycle Volumes
AutoPrune = yes # Prune expired volumes
Volume Retention = 7 days # How long should the Full Backups be kept? (#06)
Maximum Volume Bytes = 2G # Limit Volume size to something reasonable
Maximum Volumes = 100000 # Limit number of Volumes in Pool
Label Format = "BR-DA-" # Volumes will be labeled "BR-DA-"
}
# cat /usr/local/etc/bareos/bareos-dir.d/pool/BRONZE-MONTHLY-POOL.conf
Pool {
Name = BR-MO
Pool Type = Backup
Recycle = yes # Bareos can automatically recycle Volumes
AutoPrune = yes # Prune expired volumes
Volume Retention = 120 days # How long should the Full Backups be kept? (#06)
Maximum Volume Bytes = 2G # Limit Volume size to something reasonable
Maximum Volumes = 100000 # Limit number of Volumes in Pool
Label Format = "BR-MO-" # Volumes will be labeled "BR-MO-"
}
Nachfolgendes File ist ohne Änderung:
# cat /usr/local/etc/bareos/bareos-dir.d/schedule/WeeklyCycle.conf
Schedule {
Name = "WeeklyCycle"
Run = Full 1st sat at 21:00 # (#04)
Run = Differential 2nd-5th sat at 21:00 # (#07)
Run = Incremental mon-fri at 21:00 # (#10)
}
Nachfolgendes File ist ohne Änderung:
# cat /usr/local/etc/bareos/bareos-dir.d/schedule/WeeklyCycle.conf
Schedule {
Name = "WeeklyCycle"
Run = Full 1st sat at 21:00 # (#04)
Run = Differential 2nd-5th sat at 21:00 # (#07)
Run = Incremental mon-fri at 21:00 # (#10)
}
Inhalt von/usr/local/etc/bareos/bareos-dir.d/jobdefs/DefaultJob.conf
nach der Änderung:
# cat /usr/local/etc/bareos/bareos-dir.d/jobdefs/DefaultJob.conf
JobDefs {
Name = "DefaultJob"
Type = Backup
Level = Differential
Client = Default
FileSet = "SelfTest"
Schedule = "WeeklyCycle"
Storage = File
Messages = Standard
Pool = BR-DA
Priority = 10
Write Bootstrap = "/bareos/bootstrap/%c.bsr"
}
Inhalt von /usr/local/etc/bareos/bareos-dir.d/storage/File.conf
nach der Änderung:
# cat /usr/local/etc/bareos/bareos-dir.d/storage/File.conf
Storage {
Name = File
Address = bareos-server.getcom.de
Password = "BAREOS-SD-PASSWORD"
Device = FileStorage
Media Type = File
}
Inhalt von /usr/local/etc/bareos/bareos-dir.d/console/bareos-mon.conf
nach der Änderung:
# cat /usr/local/etc/bareos/bareos-dir.d/console/bareos-mon.conf
Console {
Name = bareos-mon
Description = "Restricted console used by tray-monitor to get the status of the director."
Password = "BAREOS-MON-PASSWORD"
CommandACL = status, .status
JobACL = *all*
}
Inhalt von /usr/local/etc/bareos/bareos-dir.d/fileset/Catalog.conf
nach der Änderung:
# cat /usr/local/etc/bareos/bareos-dir.d/fileset/Catalog.conf
FileSet {
Name = "Catalog"
Description = "Backup the catalog dump and Bareos configuration files."
Include {
Options {
signature = MD5
Compression = lzo
}
File = "/var/db/bareos"
File = "/usr/local/etc/bareos"
}
}
Inhalt von /usr/local/etc/bareos/bareos-dir.d/fileset/SelfTest.conf
nach der Änderung:
# cat /usr/local/etc/bareos/bareos-dir.d/fileset/SelfTest.conf
FileSet {
Name = "SelfTest"
Description = "fileset just to backup some files for selftest"
Include {
Options {
Signature = MD5
Compression = lzo
}
File = "/usr/local/sbin"
}
}
Wir benötigen kein gebundeltes LinuxAll.conf
und WindowsAllDrives.conf
filesets, daher löschen wir das:
# ls -l /usr/local/etc/bareos/bareos-dir.d/fileset/
total 18
-rw-rw---- 1 bareos bareos 250 Apr 27 02:25 Catalog.conf
-rw-rw---- 1 bareos bareos 765 Apr 16 08:14 LinuxAll.conf
-rw-rw---- 1 bareos bareos 210 Apr 27 02:27 SelfTest.conf
-rw-rw---- 1 bareos bareos 362 Apr 16 08:14 WindowsAllDrives.conf
# rm -f /usr/local/etc/bareos/bareos-dir.d/fileset/LinuxAll.conf
# rm -f /usr/local/etc/bareos/bareos-dir.d/fileset/Windows*All*Drives.conf
Wir definieren nun zwei neue filesets Windows.conf
und UNIX.conf
:
Neue Datei /usr/local/etc/bareos/bareos-dir.d/fileset/Windows.conf
:
# cat /usr/local/etc/bareos/bareos-dir.d/fileset/Windows.conf
FileSet {
Name = Windows
Enable VSS = yes
Include {
Options {
Signature = MD5
Drive Type = fixed
IgnoreCase = yes
WildFile = "[A-Z]:/pagefile.sys"
WildDir = "[A-Z]:/RECYCLER"
WildDir = "[A-Z]:/$RECYCLE.BIN"
WildDir = "[A-Z]:/System Volume Information"
Exclude = yes
Compression = lzo
}
File = /
}
Neue Datei
/usr/local/etc/bareos/bareos-dir.d/fileset/UNIX.conf
:
# cat /usr/local/etc/bareos/bareos-dir.d/fileset/UNIX.conf
FileSet {
Name = "UNIX"
Include {
Options {
Signature = MD5 # calculate md5 checksum per file
One FS = No # change into other filessytems
FS Type = ufs
FS Type = btrfs
FS Type = ext2 # filesystems of given types will be backed up
FS Type = ext3 # others will be ignored
FS Type = ext4
FS Type = reiserfs
FS Type = jfs
FS Type = xfs
FS Type = zfs
noatime = yes
Compression = lzo
}
File = /
}
# Things that usually have to be excluded
# You have to exclude /tmp
# on your bareos server
Exclude {
File = /var/db/bareos
File = /tmp
File = /proc
File = /sys
File = /var/tmp
File = /.journal
File = /.fsck
}
}
Nachfolgendes File ist ohne Änderung:
# cat /usr/local/etc/bareos/bareos-dir.d/profile/operator.conf
Profile {
Name = operator
Description = "Profile allowing normal Bareos operations."
Command ACL = !.bvfs_clear_cache, !.exit, !.sql
Command ACL = !configure, !create, !delete, !purge, !sqlquery, !umount, !unmount
Command ACL = *all*
Catalog ACL = *all*
Client ACL = *all*
FileSet ACL = *all*
Job ACL = *all*
Plugin Options ACL = *all*
Pool ACL = *all*
Schedule ACL = *all*
Storage ACL = *all*
Where ACL = *all*
}
Inhalt von /usr/local/etc/bareos/bareos-sd.d/messages/Standard.conf
nach der Änderung:
# cat /usr/local/etc/bareos/bareos-sd.d/messages/Standard.conf
Messages {
Name = Standard
Director = bareos-server.getcom.de = all
Description = "Send all messages to the Director."
}
Wir fügen den Pfad /bareos/storage/FileStorage
als unseren FileStorage
Platz hinzu:
Inhalt von /usr/local/etc/bareos/bareos-sd.d/device/FileStorage.conf
nach der Änderung:
# cat /usr/local/etc/bareos/bareos-sd.d/device/FileStorage.conf
Device {
Name = FileStorage
Media Type = File
Archive Device = /bareos/storage/FileStorage
LabelMedia = yes; # lets Bareos label unlabeled media
Random Access = yes;
AutomaticMount = yes; # when device opened, read it
RemovableMedia = no;
AlwaysOpen = no;
Description = "File device. A connecting Director must have the same Name and MediaType."
}
Inhalt von /usr/local/etc/bareos/bareos-sd.d/storage/bareos-sd.conf
nach der Änderung:
# cat /usr/local/etc/bareos/bareos-sd.d/storage/bareos-sd.conf
Storage {
Name = bareos-server.getcom.de
Maximum Concurrent Jobs = 20
# remove comment from "Plugin Directory" to load plugins from specified directory.
# if "Plugin Names" is defined, only the specified plugins will be loaded,
# otherwise all storage plugins (*-sd.so) from the "Plugin Directory".
#
# Plugin Directory = /usr/local/lib/bareos/plugins
# Plugin Names = ""
}
Inhalt von /usr/local/etc/bareos/bareos-sd.d/director/bareos-mon.conf
nach der Änderung:
# cat /usr/local/etc/bareos/bareos-sd.d/director/bareos-mon.conf
Director {
Name = bareos-mon
Password = "BAREOS-SD-PASSWORD"
Monitor = yes
Description = "Restricted Director, used by tray-monitor to get the status of this storage daemon."
}
Inhalt von /usr/local/etc/bareos/bareos-sd.d/director/bareos-dir.conf
nach der Änderung:
# cat /usr/local/etc/bareos/bareos-sd.d/director/bareos-dir.conf
Director {
Name = bareos-server.getcom.de
Password = "BAREOS-SD-PASSWORD"
Description = "Director, who is permitted to contact this storage daemon."
}
Inhalt von /usr/local/etc/bareos/bareos-fd.d/messages/Standard.conf
nach der Änderung:
# cat /usr/local/etc/bareos/bareos-fd.d/messages/Standard.conf
Messages {
Name = Standard
Director = bareos-server.getcom.de = all, !skipped, !restored
Description = "Send relevant messages to the Director."
}
Inhalt von /usr/local/etc/bareos/bareos-fd.d/director/bareos-dir.conf
nach der Änderung:
# cat /usr/local/etc/bareos/bareos-fd.d/director/bareos-dir.conf
Director {
Name = bareos-server.getcom.de
Password = "BAREOS-FD-PASSWORD"
Description = "Allow the configured Director to access this file daemon."
}
Inhalt von /usr/local/etc/bareos/bareos-fd.d/director/bareos-mon.conf
nach der Änderung:
# cat /usr/local/etc/bareos/bareos-fd.d/director/bareos-mon.conf
Director {
Name = bareos-mon
Password = "BAREOS-MON-PASSWORD"
Monitor = yes
Description = "Restricted Director, used by tray-monitor to get the status of this file daemon."
}
Inhalt von/usr/local/etc/bareos/bareos-fd.d/client/myself.conf
nach der Änderung:
# cat /usr/local/etc/bareos/bareos-fd.d/client/myself.conf
Client {
Name = bareos-server.getcom.de
Maximum Concurrent Jobs = 20
# remove comment from "Plugin Directory" to load plugins from specified directory.
# if "Plugin Names" is defined, only the specified plugins will be loaded,
# otherwise all storage plugins (*-fd.so) from the "Plugin Directory".
#
# Plugin Directory = /usr/local/lib/bareos/plugins
# Plugin Names = ""
# if compatible is set to yes, we are compatible with bacula
# if set to no, new bareos features are enabled which is the default
# compatible = yes
}
Inhalt von /usr/local/etc/bareos/bareos-dir.d/client/bareos-fd.conf
nach der Änderung:
# cat /usr/local/etc/bareos/bareos-dir.d/client/bareos-fd.conf
Client {
Name = bareos-fd
Description = "Client resource of the Director itself."
Address = localhost
Password = "BAREOS-FD-PASSWORD"
}
Wir prüfen, welches Passwort in welchem File gesetzt ist:
# pwd
/usr/local/etc/bareos
# grep -r Password . | sort -k 4 | column -t
./bareos-dir.d/director/bareos-dir.conf: Password = "BAREOS-DIR-PASSWORD"
./bconsole.d/bconsole.conf: Password = "BAREOS-DIR-PASSWORD"
./bareos-dir.d/client/Default.conf: Password = "BAREOS-FD-PASSWORD"
./bareos-dir.d/client/bareos-fd.conf: Password = "BAREOS-FD-PASSWORD"
./bareos-dir.d/client/replica.backup.org.conf: Password = "BAREOS-FD-PASSWORD"
./bareos-fd.d/director/bareos-dir.conf: Password = "BAREOS-FD-PASSWORD"
./bareos-dir.d/console/bareos-mon.conf: Password = "BAREOS-MON-PASSWORD"
./bareos-fd.d/director/bareos-mon.conf: Password = "BAREOS-MON-PASSWORD"
./bareos-dir.d/storage/File.conf: Password = "BAREOS-SD-PASSWORD"
./bareos-sd.d/director/bareos-dir.conf: Password = "BAREOS-SD-PASSWORD"
./bareos-sd.d/director/bareos-mon.conf: Password = "BAREOS-SD-PASSWORD"
Wir bereinigen die Berechtigungen:
# chown -R bareos:bareos /usr/local/etc/bareos
# find /usr/local/etc/bareos -type f -exec chmod 640 {} ';'
# find /usr/local/etc/bareos -type d -exec chmod 750 {} ';'
Bareos WebUI
Wir ergänzen oder ändern die Konfigurationen für das Bareos WebUI Interface.
Die Nginx Webserver Konfiguration Datei:
# cat /usr/local/etc/nginx/nginx.conf
user www;
worker_processes 4;
worker_rlimit_nofile 51200;
error_log /var/log/nginx/error.log;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" ';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
server {
listen 9100;
server_name replica.backup.org bareos;
root /usr/local/www/bareos-webui/public;
location / {
index index.php;
try_files $uri $uri/ /index.php?$query_string;
}
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param APPLICATION_ENV production;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
try_files $uri =404;
}
}
}
Für PHP ändern wir die Konfigurationsdatei aus dem Paket /usr/local/etc/php.ini-production
:
# cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini
# vi /usr/local/etc/php.ini
Wir fügen die Zeitzone Europe/Berlin hinzu:
# diff -u php.ini-production php.ini
--- php.ini-production 2019-02-13 03:23:36.000000000 +0200
+++ php.ini 2019-02-13 13:50:40.513138000 +0200
@@ -934,6 +934,7 @@
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
-;date.timezone =
+date.timezone = Europe/Berlin
; http://php.net/date.default-latitude
;date.default_latitude = 31.7667
Inhalt der php-fpm
daemon Konfiguration:
# cat /usr/local/etc/php-fpm.conf
[global]
pid = run/php-fpm.pid
log_level = notice
[www]
user = www
group = www
listen = 127.0.0.1:9000
listen.backlog = -1
listen.owner = www
listen.group = www
listen.mode = 0660
listen.allowed_clients = 127.0.0.1
pm = static
pm.max_children = 4
pm.start_servers = 1
pm.min_spare_servers = 0
pm.max_spare_servers = 4
pm.process_idle_timeout = 1000s;
pm.max_requests = 500
request_terminate_timeout = 0
rlimit_files = 51200
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
Der verbliebene Rest der Bareos WebUI Konfiguration:
Neue Datei /usr/local/etc/bareos/bareos-dir.d/console/admin.conf
:
# cat /usr/local/etc/bareos/bareos-dir.d/console/admin.conf
Console {
Name = admin
Password = ADMIN-PASSWORD
Profile = webui-admin
}
Neue Datei /usr/local/etc/bareos/bareos-dir.d/profile/webui-admin.conf
:
# cat /usr/local/etc/bareos/bareos-dir.d/profile/webui-admin.conf
Profile {
Name = webui-admin
CommandACL = !.bvfs_clear_cache, !.exit, !.sql, !configure, !create, !delete, !purge, !sqlquery, !umount, !unmount, *all*
Job ACL = *all*
Schedule ACL = *all*
Catalog ACL = *all*
Pool ACL = *all*
Storage ACL = *all*
Client ACL = *all*
FileSet ACL = *all*
Where ACL = *all*
Plugin Options ACL = *all*
}
Man kann hier durchaus auch weitere Bareos directors hinzu fügen:
Geänderte /usr/local/etc/bareos-webui/directors.ini
:
# test -d /usr/local/etc/bareos-webui || mkdir -p /usr/local/etc/bareos-webui
# chown bareos.bareos /usr/local/etc/bareos-webui
# cat /usr/local/etc/bareos-webui/directors.ini
;------------------------------------------------------------------------------
; Section localhost-dir
;------------------------------------------------------------------------------
[bareos-server.getcom.de]
enabled = "yes"
diraddress = "bareos-server.getcom.de"
dirport = 9101
catalog = "MyCatalog"
Geänderte Datei /usr/local/etc/bareos-webui/configuration.ini
:
# cat /usr/local/etc/bareos-webui/configuration.ini
;------------------------------------------------------------------------------
; SESSION SETTINGS
;------------------------------------------------------------------------------
[session]
timeout=3600
;------------------------------------------------------------------------------
; DASHBOARD SETTINGS
;------------------------------------------------------------------------------
[dashboard]
autorefresh_interval=60000
;------------------------------------------------------------------------------
; TABLE SETTINGS
;------------------------------------------------------------------------------
[tables]
pagination_values=10,25,50,100
pagination_default_value=25
save_previous_state=false
;------------------------------------------------------------------------------
; VARIOUS SETTINGS
;------------------------------------------------------------------------------
[autochanger]
labelpooltype=scratch
Zuletzt noch die Berechtigungen setzen für Bareos WebUI Konfigurations-Dateien:
# chown -R www:www /usr/local/etc/bareos-webui
# chown -R www:www /usr/local/www/bareos-webui
Logs
Erstellung der Log files, Verzeichnisse und Änderung der Berechtigungen:
# chown -R bareos:bareos /var/log/bareos
# :> /var/log/php-fpm.log
# chown -R www:www /var/log/php-fpm.log
# chown -R www:www /var/log/nginx
Wir benötigen noch Regeln für den newsyslog(8)
log rotate daemon, um zu verhindern, dass das Dateisystem früher oder später geflutet wird:
Für den newsyslog daemon verwenden wird die *.conf.d
Verzeichnisse, anstatt das File /etc/newsyslog.conf
zu editieren:
# grep conf\\.d /etc/newsyslog.conf
/etc/newsyslog.conf.d/*
/usr/local/etc/newsyslog.conf.d/*
# mkdir -p /usr/local/etc/newsyslog.conf.d
# cat > /usr/local/etc/newsyslog.conf.d/bareos << __EOF
# BAREOS
/var/log/php-fpm.log www:www 640 7 100 @T00 J
/var/log/nginx/access.log www:www 640 7 100 @T00 J
/var/log/nginx/error.log www:www 640 7 100 @T00 J
/var/log/bareos/bareos.log bareos:bareos 640 7 100 @T00 J
/var/log/bareos/bareos-audit.log bareos:bareos 640 7 100 @T00 J
__EOF
Wir verifizieren, ob newsyslog(8)
unsere Konfiguration versteht:
# newsyslog -v | tail -5
/var/log/php-fpm.log : --> will trim at Tue May 1 00:00:00 2019
/var/log/nginx/access.log : --> will trim at Tue May 1 00:00:00 2019
/var/log/nginx/error.log : --> will trim at Tue May 1 00:00:00 2019
/var/log/bareos/bareos.log : --> will trim at Tue May 1 00:00:00 2019
/var/log/bareos/bareos-audit.log : --> will trim at Tue May 1 00:00:00 2019
Skel
Wir legen nun die sogenannten Bareos skel files für das rc(8)
Script an, um das komplette Setup über ein File zu triggern.
Wenn wir das nicht tun würden, würde der Bareos services nicht stoppen und folgender Fehler würde ausgegeben werden:
# /usr/local/etc/rc.d/bareos-sd onestart
Starting bareos_sd.
27-Apr 02:59 bareos-sd JobId 0: Error: parse_conf.c:580 Failed to read config file "/usr/local/etc/bareos/bareos-sd.conf"
bareos-sd ERROR TERMINATION
parse_conf.c:148 Failed to find config filename.
/usr/local/etc/rc.d/bareos-sd: WARNING: failed to start bareos_sd
Wir legen sie an:
# cat > /usr/local/etc/bareos/bareos-dir.conf << __EOF
@/usr/local/etc/bareos/bareos-dir.d/*/*
__EOF
# cat > /usr/local/etc/bareos/bareos-fd.conf << __EOF
@/usr/local/etc/bareos/bareos-fd.d/*/*
__EOF
# cat > /usr/local/etc/bareos/bareos-sd.conf << __EOF
@/usr/local/etc/bareos/bareos-sd.d/*/*
__EOF
# cat > /usr/local/etc/bareos/bconsole.conf << __EOF
@/usr/local/etc/bareos/bconsole.d/*
__EOF
Die Verifizierung:
# cat /usr/local/etc/bareos/bareos-dir.conf
@/usr/local/etc/bareos/bareos-dir.d/*/*
# cat /usr/local/etc/bareos/bareos-fd.conf
@/usr/local/etc/bareos/bareos-fd.d/*/*
# cat /usr/local/etc/bareos/bareos-sd.conf
@/usr/local/etc/bareos/bareos-sd.d/*/*
# cat /usr/local/etc/bareos/bconsole.conf
@/usr/local/etc/bareos/bconsole.d/*
Nach all den Änderungen und Anlegen neuer Files, versichern wir uns, dass alle Files unterhalb von /usr/local/etc/bareos
die richtigen Berechtigungen haben werden:
# chown -R bareos:bareos /usr/local/etc/bareos
# find /usr/local/etc/bareos -type f -exec chmod 640 {} ';'
# find /usr/local/etc/bareos -type d -exec chmod 750 {} ';'
Es ist soweit…
Der main FreeBSD Service Start /etc/rc.conf
fehlt nur noch.
Nach den Änderungen der /etc/rc.conf
sieht das so aus:
# cat /etc/rc.conf
# NETWORK
hostname=bareos-server.getcom.de
ifconfig_em0="inet 10.144.88.11/24 up"
defaultrouter="10.144.88.1"
# DAEMONS
zfs_enable=YES
sshd_enable=YES
nfs_client_enable=YES
syslogd_flags="-ss"
sendmail_enable=NONE
# OTHER
clear_tmp_enable=YES
dumpdev=NO
# BAREOS
postgresql_enable=YES
postgresql_class=pgsql
bareos_dir_enable=YES
bareos_sd_enable=YES
bareos_fd_enable=YES
php_fpm_enable=YES
nginx_enable=YES
Der PostgreSQL läuft bereits:
# /usr/local/etc/rc.d/postgresql status
pg_ctl: server is running (PID: 28424)
/usr/local/bin/postgres "-D" "/usr/local/pgsql/data"
Wir starten nun den Rest von Bareos:
Zuerest den PHP php-fpm
daemon:
# /usr/local/etc/rc.d/php-fpm start
Performing sanity check on php-fpm configuration:
[23-Feb-2019 02:57:09] NOTICE: configuration file /usr/local/etc/php-fpm.conf test is successful
Starting php_fpm.
Der Nginx webserver:
# /usr/local/etc/rc.d/nginx start
Performing sanity check on nginx configuration:
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
Starting nginx.
Bareos Storage Daemon:
# /usr/local/etc/rc.d/bareos-sd start
Starting bareos_sd.
Bareos File Daemon, bekannt als Bareos Client:
# /usr/local/etc/rc.d/bareos-fd start
Starting bareos_f
… und zuletzt der wichtigste daemon, der Bareos Director:
# /usr/local/etc/rc.d/bareos-dir start
Starting bareos_dir.
Wir prüfen noch, auf welchen Ports die Daemons lauschen:
# sockstat -l4
USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS
bareos bareos-dir 89823 4 tcp4 *:9101 *:*
root bareos-fd 73066 3 tcp4 *:9102 *:*
www nginx 33857 6 tcp4 *:9100 *:*
www nginx 28675 6 tcp4 *:9100 *:*
www nginx 20960 6 tcp4 *:9100 *:*
www nginx 15881 6 tcp4 *:9100 *:*
root nginx 14388 6 tcp4 *:9100 *:*
www php-fpm 84047 0 tcp4 127.0.0.1:9000 *:*
www php-fpm 82285 0 tcp4 127.0.0.1:9000 *:*
www php-fpm 80688 0 tcp4 127.0.0.1:9000 *:*
www php-fpm 74735 0 tcp4 127.0.0.1:9000 *:*
root php-fpm 70518 8 tcp4 127.0.0.1:9000 *:*
bareos bareos-sd 5151 3 tcp4 *:9103 *:*
pgsql postgres 20009 4 tcp4 127.0.0.1:5432 *:*
root sshd 49253 4 tcp4 *:22 *:*
Um noch zu prüfen, in welcher Reihenfolge gestartet wurde, befragen wir das rc(8)
Subsystem:
# rcorder /etc/rc.d/* /usr/local/etc/rc.d/* | grep -E '(bareos|php-fpm|nginx|postgresql)'
/usr/local/etc/rc.d/postgresql
/usr/local/etc/rc.d/php-fpm
/usr/local/etc/rc.d/nginx
/usr/local/etc/rc.d/bareos-sd
/usr/local/etc/rc.d/bareos-fd
/usr/local/etc/rc.d/bareos-dir
Über die URL http://bareos-server.getcom.de:9100 erreichen wir den Webservice:
Wir können uns nun mit dem admin
Benutzer und ADMIN-PASSWORD
Anmelden.
Nach dem Login sehen wir ein leeres Bareos Dashboard.
Jobs
Hier kommt nun eine Skript-Sammlung, um Clients zum Bareos Server hinzu zu fügen.
Der BRONZE-job.sh
und BRONZE-sched.sh
generiert Bareos files für neue Jobs und Sicherungszeiten. Wir legen das nach /root/bin
# mkdir /root/bin
Die Basisskripte sind hier zu finden:
Nach dem Download benennen wir sie um:
# mv BRONZE-sched.sh.key BRONZE-sched.sh
# mv BRONZE-job.sh.key BRONZE-job.sh
Wir machen das ausführbar:
# chmod +x /root/bin/BRONZE-sched.sh
# chmod +x /root/bin/BRONZE-job.sh
Die Hilfe:
# /root/bin/BRONZE-sched.sh
usage: BRONZE-sched.sh GROUP TIME
example:
BRONZE-sched.sh 01 21:00
# /root/bin/BRONZE-job.sh
usage: BRONZE-job.sh GROUP TIME CLIENT TYPE
GROUP option: 01 | 02 | 03
TIME option: 00:00 - 23:59
CLIENT option: FQDN
TYPE option: UNIX | Windows
example:
BRONZE-job.sh 01 21:00 CLIENT.domain.com UNIX
Clients
Mögliche Firewall-Probleme auf Clients
Auf einem 3CX Server verhindert per default die Firewall einen Zugriff auf den Port 9002 (bacula-fd). Der entsprechende Job schlägt daher fehl mit einem timeout auf den bacula-fd service des zu sichernden Clients.
Abhilfe:
Identifizierung der iptables Regel-IDs der zuständigen Regeln:
iptables -L INPUT --line-numbers | grep -e 5060 -e 5090 | grep tcp
2 ACCEPT tcp -- anywhere anywhere multiport dports http,https,sip,sip-tls,5090 tcp flags:FIN,SYN,RST,ACK/SYN ctstate NEW
13 ACCEPT tcp -- anywhere anywhere multiport dports http,https,5000,5001,5015,sip,sip-tls,5090 tcp flags:FIN,SYN,RST,ACK/SYN ctstate NEW
Identifizierung der vollständigen Regeln:
iptables -S INPUT | grep -e 5060 -e 5090 | grep tcp
-A INPUT -p tcp -m multiport --dports 80,443,5060,5061,5090,9101,9102,9103 -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -m conntrack --ctstate NEW -j ACCEPT
-A INPUT -p tcp -m multiport --dports 80,443,5000,5001,5015,5060,5061,5090,9101,9102,9103 -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -m conntrack --ctstate NEW -j ACCEPT
Änderungen einspielen mit Angabe der obigen Regel-IDs:
/sbin/iptables -R INPUT 2 -p tcp -m multiport --dports 80,443,5060,5061,5090,9102 -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -m conntrack --ctstate NEW -j ACCEPT
/sbin/iptables -R INPUT 13 -p tcp -m multiport --dports 80,443,5000,5001,5015,5060,5061,5090,9102 -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -m conntrack --ctstate NEW -j ACCEPT
Permanente Speicherung der Regelketten:
service netfilter-persistent save
Verwendete Quellen für diesen Beitrag: