Allgemeines
Die Instanz der MariaDB läuft als Docker-Container auf dem NAS
Einbettung in die Systemlandschaft
Die folgenden Systeme interagieren mit der MariaDB:
- NAS
- Server der Datenbank (In Container-Station)
- Server der Datenbank (In Container-Station)
- FHEM
- Verwendet die Datenbank als Logging-Tool
- Speichern der Konfigurationsdaten
- Kritisch: Die Datenbank verwendet eine Verzeichnis des FHEM-Containers. Dadurch kann die Datenbank nur gestartet werden, wenn auch der FHEM-Container läuft. Gleichzeitig verwendet FHEM die DB…
- Fusion-Charts
- Die Datenbank enthält die Konfigurationsdaten für Charts
- Die Datenbank enthält die Konfigurationsdaten für Charts
- PHPMyAdmin2
- Die Datenbank enthält die Konfigurationsdaten
- Dient als Pflegetool der Oberfläche
Konfiguration
Die folgenden Einstellungen sind in der Container-Station hinterlegt.
Basis Settings:
| Parameter | Wert |
|---|---|
| Image | mariadb |
| Name | MariaDB |
| Command | mysqld |
| Entrypoint | docker-entrypoint.sh |
| Auto start | Nein |
| CPU Limit | 89% |
| Memory Limit | 7127 MB |
Environment:
| NAME | VALUE |
|---|---|
| GOSU_VERSION | 1.10 |
| GPG_KEYS | 199369E5404BD5FC7D2FE43BCBCB082A1BB943DB 177F4010FE56CA3336300305F1656F24C74CD1D8 430BDF5C56E7C94E848EE60C1C4CBDCDCD2EFD2A 4D1BB29D63D98E422B2113B19334A25F8507EFA5 |
| MARIADB_MAJOR | 10.3 |
| MARIADB_VERSION | 1:10.3.10+maria~bionic |
| MYSQL_ROOT_PASSWORD | example |
| PATH | /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin |
Network:
Container Hostname: MariaDB
Container MAC Address: —
Network Mode: NAT
| Host | Container | Protocol |
|---|---|---|
| 32722 | 22 | TCP |
| 3306 | 3306 | TCP |
Device:
Nichts hinterlegt
Shared Folders:
| Shared Folders | ||
|---|---|---|
| /opt/fhem | /share/CE_CACHEDEV1_DATA/Container/container-station-data/lib/docker/volumes/FHEM/_data | Read/Write |
| /opt/yowsup-config | /share/CE_CACHEDEV1_DATA/Container/container-station-data/lib/docker/volumes/YOWSUP/_data | Read/Write |
| /var/lib/mysql | /share/CE_CACHEDEV1_DATA/Container/container-station-data/lib/docker/volumes/MYSQL/_data | Read/Write |
Zugang über SSH
Obwohl zwar grundsätzlich ein Konsolen-Zugang durch eine Port-Weiterleitung eingerichtet wurde, funktioniert diese nicht. Der Konsolen-Zugang ist jedoch trotzdem möglich, indem als Umweg das NAS verwendet wird:
Dafür mit Putty via Konsole am NAS anmelden: 192.168.178.45:22 (admin)
Im Shell dann den folgenden Befehl verwenden:
docker exec -it MariaDB bash
SQL-Zugang über die Konsole erreicht man dann mit;
mysql -u root -p
Die Konfigurationsdatei kann so angepasst werden:
nano /etc/mysql/my.cnf
- In der Konfigurationsdatei habe ich das Performance-Schema aktiviert. Die entsprechende Stelle ist mit „SBL“ gekennzeichnet
- Ich habe zudem den Ereignisplaner permanent aktiviert: Im Abschnitt [mysqld] folgendes eingefügt: event_scheduler=on
Habe ich ebenfalls mit SBL markiert.
Parameter der DB:
- Server: 192.168.178.45:3306 via TCP/IP
- Server-Typ: MariaDB
- Server-Verbindung: SSL wird nicht verwendet
- Server-Version: 10.3.10-MariaDB-1:10.3.10+maria~bionic – mariadb.org binary distribution
- Protokoll-Version: 10
- Benutzer: root@10.0.3.1
- Server-Zeichensatz: UTF-8 Unicode (utf8)
Zusätzliche Installationen
Installation der Connect-Engine zum Zugriff auf JSON usw.:
sudo apt-get install libodbc1
sudo apt-get install mariadb-plugin-connect
How-to
Zugriff auf eine JSON-Datei
Beispiel für das Crate-Statement. Standard-Pfad ist das Verzeichnis in der die Datenbank abgelegt ist.
jsample CREATE TABLE `jsample` (
`type` char(17) DEFAULT NULL,
`name` char(11) DEFAULT NULL,
`features_type` char(7) DEFAULT NULL `field_format`='$.features[0].type',
`features_properties_FID` bigint(8) DEFAULT NULL `field_format`='$.features[*].properties.FID',
`features_properties_IdBundesland` bigint(1) NOT NULL `FIELD_FORMAT`='$.features[*].properties.IdBundesland',
`features_properties_Bundesland` char(18) NOT NULL `FIELD_FORMAT`='$.features[*].properties.Bundesland',
`features_properties_Landkreis` char(12) NOT NULL `FIELD_FORMAT`='$.features[*].properties.Landkreis',
`features_properties_Altersgruppe` char(7) NOT NULL `FIELD_FORMAT`='$.features[*].properties.Altersgruppe',
`features_properties_Geschlech` char(1) NOT NULL `FIELD_FORMAT`='$.features[*].properties.Geschlecht',
`features_properties_AnzahlFall` bigint(1) NOT NULL `FIELD_FORMAT`='$.features[*].properties.AnzahlFall',
`features_properties_AnzahlTodesfall` bigint(1) NOT NULL `FIELD_FORMAT`='$.features[*].properties.AnzahlTodesfall',
`features_properties_Meldedatum` char(19) NOT NULL `FIELD_FORMAT`='$.features[*].properties.Meldedatum',
`features_properties_IdLandkreis` char(5) NOT NULL `FIELD_FORMAT`='$.features[*].properties.IdLandkreis',
`features_properties_Datenstand` char(21) NOT NULL `FIELD_FORMAT`='$.features[*].properties.Datenstand',
`features_properties_NeuerFall` bigint(1) NOT NULL `FIELD_FORMAT`='$.features[*].properties.NeuerFall',
`features_properties_NeuerTodesfall` bigint(2) NOT NULL `FIELD_FORMAT`='$.features[*].properties.NeuerTodesfall',
`features_properties_Refdatum` char(19) NOT NULL `FIELD_FORMAT`='$.features[*].properties.Refdatum',
`features_properties_NeuGenesen` bigint(1) NOT NULL `FIELD_FORMAT`='$.features[*].properties.NeuGenesen',
`features_properties_AnzahlGenesen` bigint(1) NOT NULL `FIELD_FORMAT`='$.features[*].properties.AnzahlGenesen',
`features_properties_IstErkrankungsbeginn` bigint(1) NOT NULL `FIELD_FORMAT`='$.features[*].properties.IstErkrankungsbeginn',
`features_properties_Altersgruppe2` char(18) NOT NULL `FIELD_FORMAT`='$.features[*].properties.Altersgruppe2'
) ENGINE=CONNECT DEFAULT CHARSET=utf8 `TABLE_TYPE`='JSON' `FILE_NAME`='RKI_COVID19.geojson' `OPTION_LIST`='level=2,Limit=200000'
Links
Im folgenden sind ein paar nützliche Links aufgeführt:

Schreibe einen Kommentar