Zum Inhalt

Fehlerbehebung

Dieses Kapitel beschreibt haeufige Probleme im Betrieb von calServer und deren Loesung. Es richtet sich an Systemadministratoren mit Zugang zur Server-Infrastruktur.


MySQL-CrashLoop beheben

Symptome

  • MySQL-Pod im Status CrashLoopBackOff (Kubernetes/OpenShift)
  • MySQL-Container startet nicht und zeigt nur Bitnami-Startup-Logs
  • InnoDB-Fehler „LSN in the future" in den Error-Logs

Haeufige Ursachen

  • Gemischte MySQL-Versionen (5.7 und 8.0)
  • Unsauberes Herunterfahren mit innodb_fast_shutdown=2
  • Korrupter System-Tablespace (ibdata1)

Vorgehensweise

MySQL anhalten und PVC freigeben:

oc scale statefulset calwebapp-mysql --replicas=0
oc wait --for=delete pod/calwebapp-mysql-0 --timeout=180s

Fix-Pod mit gemoundetem PVC starten:

oc run mysql57-fix --restart=Never \
  --image=docker.io/bitnami/mysql:5.7.26 \
  --overrides='{
    "spec":{
      "containers":[{
        "name":"mysql",
        "image":"docker.io/bitnami/mysql:5.7.26",
        "command":["bash","-lc","sleep infinity"],
        "env":[{"name":"MYSQL_ROOT_PASSWORD","valueFrom":{"secretKeyRef":{"name":"calwebapp-mysql","key":"mysql-root-password"}}}],
        "volumeMounts":[{"name":"data","mountPath":"/bitnami/mysql"}]
      }],
      "volumes":[{"name":"data","persistentVolumeClaim":{"claimName":"data-calwebapp-mysql-0"}}]
    }}'

InnoDB-Redo-Logs zuruecksetzen:

oc exec -it mysql57-fix -- sh -c '
  for f in /bitnami/mysql/data/ib_logfile0 /bitnami/mysql/data/ib_logfile1; do
    [ -e "$f" ] && : > "$f";
  done'

MySQL im Recovery-Modus starten (bei Bedarf):

oc exec -it mysql57-fix -- sh -c '
  /opt/bitnami/mysql/bin/mysqld \
    --datadir=/bitnami/mysql/data \
    --skip-name-resolve --explicit_defaults_for_timestamp \
    --innodb-log-file-size=48M --innodb-buffer-pool-size=256M \
    --innodb-force-recovery=4 \
    --socket=/tmp/mysql.sock --pid-file=/tmp/mysqld.pid \
    --bind-address=127.0.0.1 --port=3306 &'

Dump erstellen:

oc exec -i mysql57-fix -- sh -c '
  /opt/bitnami/mysql/bin/mysqldump \
    -h127.0.0.1 -P3306 -uroot -p"$MYSQL_ROOT_PASSWORD" \
    --quick --routines --events \
    --set-gtid-purged=OFF --no-tablespaces --skip-lock-tables \
    --all-databases' | gzip -1 > full.sql.gz

Datadir neu initialisieren und Import durchfuehren:

oc exec -it mysql57-fix -- sh -c 'mv /bitnami/mysql/data /bitnami/mysql/data.bad && mkdir -p /bitnami/mysql/data'
oc delete pod mysql57-fix
oc scale statefulset calwebapp-mysql --replicas=1
oc cp ./full.sql.gz calwebapp-mysql-0:/tmp/full.sql.gz
oc exec -i calwebapp-mysql-0 -c mysql -- sh -c '
  gzip -dc /tmp/full.sql.gz | sed "/^mysqldump:/d" \
  | /opt/bitnami/mysql/bin/mysql -uroot -p"$MYSQL_ROOT_PASSWORD" --max_allowed_packet=1G'

Yii-Migration ausfuehren:

oc exec -i calwebapp-calserver-0 -c calserver \
  -- sh -c 'cd /app/httpdocs/protected && php yiic migrate up --interactive=0'

Tip

Verwenden Sie den Recovery-Level nur so hoch wie noetig (Level 2-4 genuegt in den meisten Faellen). Bleiben Sie konsistent bei MySQL 5.7 -- ein Upgrade auf 8.0 erfordert einen separaten Migrationsplan.


systemd-Journal begrenzen

Wenn das Root-Dateisystem durch Logs volllaeuft, begrenzen Sie das systemd-Journal:

Aktuellen Verbrauch pruefen:

journalctl --disk-usage

Journal sofort verkleinern:

journalctl --vacuum-size=500M

Dauerhafte Begrenzung in /etc/systemd/journald.conf:

[Journal]
SystemMaxUse=500M
SystemKeepFree=1G
Compress=yes
systemctl restart systemd-journald

SymmetricDS-Staging auslagern

Bei grossen Synchronisationen kann das Staging-Verzeichnis von SymmetricDS das Root-Dateisystem fuellen. Lagern Sie es auf ein separates Volume aus.

Verzeichnis auf dem Datadrive anlegen:

mkdir -p /datadrive/symmetricds/staging
mkdir -p /datadrive/symmetricds/tmp
chown -R 1000:1000 /datadrive/symmetricds

Docker-Volume konfigurieren (docker-compose.yml):

services:
  symmetricds:
    volumes:
      - /datadrive/symmetricds:/opt/symmetricds/data

SymmetricDS konfigurieren (symmetric.properties):

staging.directory=/opt/symmetricds/data/staging
java.io.tmpdir=/opt/symmetricds/data/tmp

Info

Planen Sie bei grossen Reloads mindestens 10-20 GB freien Speicher auf dem Staging-Volume ein.