Skip to main content

Influx - Datenbank anlegen

0 | Vorbereitungen

apt-get update
apt-get install -y \
curl gnupg ca-certificates lsb-release coreutils

1 | InfluxDB-Repository & Paketinstallation

curl --silent --location -O https://repos.influxdata.com/influxdata-archive.key
echo "943666881a1b8d9b849b74caebf02d3465d6beb716510d86a39f6c8e8dac7515  influxdata-archive.key" \
| sha256sum --check -

cat influxdata-archive.key | gpg --dearmor \
| tee /etc/apt/trusted.gpg.d/influxdata-archive.gpg >/dev/null

echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive.gpg] https://repos.influxdata.com/debian stable main' \
| tee /etc/apt/sources.list.d/influxdata.list

apt-get update
apt-get install -y influxdb2
systemctl enable --now influxdb

2 | Selbst-signiertes Zertifikat erzeugen (100 Jahre)

cat > /root/san.cnf <<'EOF'
[req]
distinguished_name = req_distinguished_name
req_extensions     = v3_req
prompt             = no
[req_distinguished_name]
C  = DE
ST = Berlin
L  = Berlin
O  = localhost
CN = influxdb.local
[v3_req]
keyUsage         = keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth
subjectAltName   = @alt_names
[alt_names]
DNS.1 = influxdb.local
IP.1  = 127.0.0.1
EOF

openssl req -new -newkey rsa:4096 -nodes \
  -keyout /etc/ssl/influxdb.key \
  -out    /etc/ssl/influxdb.csr \
  -config /root/san.cnf

openssl x509 -req -in  /etc/ssl/influxdb.csr \
  -signkey          /etc/ssl/influxdb.key \
  -out              /etc/ssl/influxdb.crt \
  -days 36500 -extensions v3_req -extfile /root/san.cnf

rm /etc/ssl/influxdb.csr /root/san.cnf
chown influxdb:influxdb /etc/ssl/influxdb.{crt,key}
chmod 644 /etc/ssl/influxdb.crt
chmod 600 /etc/ssl/influxdb.key

3 | InfluxDB auf HTTPS umstellen (vollautomatisch)

# Umgebungsdatei mit TLS-Pfaden
cat > /etc/default/influxdb2 <<'EOT'
ARG_TLS_CERT="--tls-cert /etc/ssl/influxdb.crt"
ARG_TLS_KEY="--tls-key  /etc/ssl/influxdb.key"
EOT

# Systemd-Drop-In ohne Editor anlegen
install -d /etc/systemd/system/influxdb.service.d
cat > /etc/systemd/system/influxdb.service.d/https.conf <<'EOT'
[Service]
EnvironmentFile=/etc/default/influxdb2
ExecStart=
ExecStart=/usr/bin/influxd $ARG_TLS_CERT $ARG_TLS_KEY
EOT

# Dienst neu laden & neu starten
systemctl daemon-reload
systemctl restart influxdb
systemctl status influxdb --no-pager

4 | Funktionstest

curl --insecure https://localhost:8086/api/v2/ping
# Erwartung: HTTP/1.1 204 No Content  (TLS-Handshake erfolgreich)

Hinweise

  • Selbst-signierte Zertifikate erzeugen Browser-Warnungen – für interne Netze meist unkritisch.
  • Für öffentliche Zugriffe besser Let’s Encrypt verwenden.
  • Bei InfluxDB 3 (Docker/Binaries) lassen sich TLS-Pfade direkt per Parameter setzen.