Skip to content

Docker & Redis Datenbank

Verschoben Linux
  • Ich habe es endlich geschafft, meinen Redis Container so zu starten, das er meine Konfigurationsdatei nutzt und die Daten permanent gespeichert werden. Das hier ist der erfolgreiche Aufruf.

    docker run --name redis -v /local-data/:/data -v /root/redis.conf:/redis-stack.conf -d redis/redis-stack-server:latest
    

    Ok, Docker hat einen ganzen Haufen Parameter zum Einstellen, hier ein Beispiel, nur für docker run

    [frank-ms7c92 ~]# docker run --help
    
    Usage:  docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
    
    Create and run a new container from an image
    
    Aliases:
      docker container run, docker run
    
    Options:
          --add-host list                  Add a custom host-to-IP mapping (host:ip)
      -a, --attach list                    Attach to STDIN, STDOUT or STDERR
          --blkio-weight uint16            Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0)
          --blkio-weight-device list       Block IO weight (relative device weight) (default [])
          --cap-add list                   Add Linux capabilities
          --cap-drop list                  Drop Linux capabilities
          --cgroup-parent string           Optional parent cgroup for the container
          --cgroupns string                Cgroup namespace to use (host|private)
                                           'host':    Run the container in the Docker host's cgroup namespace
                                           'private': Run the container in its own private cgroup namespace
                                           '':        Use the cgroup namespace as configured by the
                                                      default-cgroupns-mode option on the daemon (default)
          --cidfile string                 Write the container ID to the file
          --cpu-period int                 Limit CPU CFS (Completely Fair Scheduler) period
          --cpu-quota int                  Limit CPU CFS (Completely Fair Scheduler) quota
          --cpu-rt-period int              Limit CPU real-time period in microseconds
          --cpu-rt-runtime int             Limit CPU real-time runtime in microseconds
      -c, --cpu-shares int                 CPU shares (relative weight)
          --cpus decimal                   Number of CPUs
          --cpuset-cpus string             CPUs in which to allow execution (0-3, 0,1)
          --cpuset-mems string             MEMs in which to allow execution (0-3, 0,1)
      -d, --detach                         Run container in background and print container ID
          --detach-keys string             Override the key sequence for detaching a container
          --device list                    Add a host device to the container
          --device-cgroup-rule list        Add a rule to the cgroup allowed devices list
          --device-read-bps list           Limit read rate (bytes per second) from a device (default [])
          --device-read-iops list          Limit read rate (IO per second) from a device (default [])
          --device-write-bps list          Limit write rate (bytes per second) to a device (default [])
          --device-write-iops list         Limit write rate (IO per second) to a device (default [])
          --disable-content-trust          Skip image verification (default true)
          --dns list                       Set custom DNS servers
          --dns-option list                Set DNS options
          --dns-search list                Set custom DNS search domains
          --domainname string              Container NIS domain name
          --entrypoint string              Overwrite the default ENTRYPOINT of the image
      -e, --env list                       Set environment variables
          --env-file list                  Read in a file of environment variables
          --expose list                    Expose a port or a range of ports
          --gpus gpu-request               GPU devices to add to the container ('all' to pass all GPUs)
          --group-add list                 Add additional groups to join
          --health-cmd string              Command to run to check health
          --health-interval duration       Time between running the check (ms|s|m|h) (default 0s)
          --health-retries int             Consecutive failures needed to report unhealthy
          --health-start-period duration   Start period for the container to initialize before starting health-retries countdown (ms|s|m|h) (default 0s)
          --health-timeout duration        Maximum time to allow one check to run (ms|s|m|h) (default 0s)
          --help                           Print usage
      -h, --hostname string                Container host name
          --init                           Run an init inside the container that forwards signals and reaps processes
      -i, --interactive                    Keep STDIN open even if not attached
          --ip string                      IPv4 address (e.g., 172.30.100.104)
          --ip6 string                     IPv6 address (e.g., 2001:db8::33)
          --ipc string                     IPC mode to use
          --isolation string               Container isolation technology
          --kernel-memory bytes            Kernel memory limit
      -l, --label list                     Set meta data on a container
          --label-file list                Read in a line delimited file of labels
          --link list                      Add link to another container
          --link-local-ip list             Container IPv4/IPv6 link-local addresses
          --log-driver string              Logging driver for the container
          --log-opt list                   Log driver options
          --mac-address string             Container MAC address (e.g., 92:d0:c6:0a:29:33)
      -m, --memory bytes                   Memory limit
          --memory-reservation bytes       Memory soft limit
          --memory-swap bytes              Swap limit equal to memory plus swap: '-1' to enable unlimited swap
          --memory-swappiness int          Tune container memory swappiness (0 to 100) (default -1)
          --mount mount                    Attach a filesystem mount to the container
          --name string                    Assign a name to the container
          --network network                Connect a container to a network
          --network-alias list             Add network-scoped alias for the container
          --no-healthcheck                 Disable any container-specified HEALTHCHECK
          --oom-kill-disable               Disable OOM Killer
          --oom-score-adj int              Tune host's OOM preferences (-1000 to 1000)
          --pid string                     PID namespace to use
          --pids-limit int                 Tune container pids limit (set -1 for unlimited)
          --platform string                Set platform if server is multi-platform capable
          --privileged                     Give extended privileges to this container
      -p, --publish list                   Publish a container's port(s) to the host
      -P, --publish-all                    Publish all exposed ports to random ports
          --pull string                    Pull image before running ("always", "missing", "never") (default "missing")
      -q, --quiet                          Suppress the pull output
          --read-only                      Mount the container's root filesystem as read only
          --restart string                 Restart policy to apply when a container exits (default "no")
          --rm                             Automatically remove the container when it exits
          --runtime string                 Runtime to use for this container
          --security-opt list              Security Options
          --shm-size bytes                 Size of /dev/shm
          --sig-proxy                      Proxy received signals to the process (default true)
          --stop-signal string             Signal to stop the container
          --stop-timeout int               Timeout (in seconds) to stop a container
          --storage-opt list               Storage driver options for the container
          --sysctl map                     Sysctl options (default map[])
          --tmpfs list                     Mount a tmpfs directory
      -t, --tty                            Allocate a pseudo-TTY
          --ulimit ulimit                  Ulimit options (default [])
      -u, --user string                    Username or UID (format: <name|uid>[:<group|gid>])
          --userns string                  User namespace to use
          --uts string                     UTS namespace to use
      -v, --volume list                    Bind mount a volume
          --volume-driver string           Optional volume driver for the container
          --volumes-from list              Mount volumes from the specified container(s)
      -w, --workdir string                 Working directory inside the container
    

    Wir zerlegen das mal und schauen uns das Stück für Stück an. So das ich es hoffentlich dann verstehe und es auch für andere Container benutzen kann.

    docker run # Create and run a new container from an image
    

    Das ist einfach und gut zu verstehen 🙂

    --name redis # Assign a name to the container
    

    Auch nicht wirklich schwer.

    -v /local-data/:/data # Bind mount a volume
    

    Jetzt wird es endlich mal komplexer. Wir mounten einen lokalen Ordner /local-data/ Die schlanke Anleitung dazu, direkt von Docker.

    -v or --volume: Consists of three fields, separated by colon characters (:). The fields must be in the correct order, and the meaning of each field is not immediately obvious.

    In the case of named volumes, the first field is the name of the volume, and is unique on a given host machine. For anonymous volumes, the first field is omitted.

    The second field is the path where the file or directory are mounted in the container.

    The third field is optional, and is a comma-separated list of options, such as ro. These options are discussed below.

    Der Doppelpunkt dient als Trennzeichen. Und /data ist der Ordner im Docker Container. Als Zusammenfassung.

    1. /local-data/ # Lokaler Ordner auf dem Host
    2. Doppelpunkt als Trennzeichen
    3. /data # Ordner innerhalb des Docker Containers

    /local-data

    [frank-ms7c92 local-data]# ls -lha
    insgesamt 4,0K
    drwxr-xr-x 1 root root  16  7. Mär 19:10 .
    drwxr-xr-x 1 root root 272  7. Mär 19:01 ..
    -rw-r--r-- 1 root root 944  7. Mär 19:10 dump.rdb
    

    /data

    root@503c1b403529:/data# ls -lha
    total 4.0K
    drwxr-xr-x 1 root root  16 Mar  7 18:10 .
    drwxr-xr-x 1 root root 240 Mar  7 18:01 ..
    -rw-r--r-- 1 root root 944 Mar  7 18:10 dump.rdb
    

    Was mir aktuell noch unklar ist, wo wird Redis mitgeteil, die Daten in /data abzulegen? In meiner Konfiguration ist das nicht gesetzt? Ok schauen wir mal weiter, vielleicht wird es noch heller..

    -v /root/redis.conf:/redis-stack.conf  # Bind mount a volume
    

    Das jetzt in Kurzform, meine Konfiguration liegt auf dem Host im Rootverzeichnis und soll in den Container.

    1. /root/redis.conf # Konfiguration, liegt auf dem Host
    2. Doppelpunkt als Trennzeichen
    3. redis-stack.conf # Die Datei im Container

    Eben meine aktuelle Testkonfiguration

    bind 0.0.0.0
    port 6379
    databases 16
    pidfile /var/run/redis/redis-server.pid
    save 60 1
    #save 900 1
    save 300 10
    save 60 10000
    stop-writes-on-bgsave-error yes
    rdbcompression yes
    rdbchecksum yes
    dbfilename dump.rdb
    dir /
    

    Ich vermute, das die Angabe des Arbeitsverzeichnisses ( dir / ) dazu führt, das die redis-stack.conf im Rootverzeichnis auftaucht. Mir ist aktuell unklar, warum Redis die jetzt benutzt? Macht das Docker selbstständig?

    Ich weiß das sie auf alle Fälle geladen und auch benutzt wird. Habe ich über das Einstellen des Ports ausprobiert.

    Ok, hier kurz die Frage, warum taucht das dump.rdb im /data Verzeichnis auf? Macht das Docker von alleine?

    Ihe seht, ich habe hier leider immer noch viel Fragezeichen....

    -d # Run container in background and print container ID
    

    Das ist wieder etwas einfacher. Das startet den Docker Container als Daemon im Hintergrund. Kann man einfach mal ausprobieren und das -d weglassen, dann seht ihr was ich meine 😉

     redis/redis-stack-server:latest # Image
    

    Das ist das Image, was zum Bau des Docker Containers benutzt wird.

  • @FrankM sagte in Docker & Redis Datenbank:

    save 60 1
    #save 900 1
    save 300 10
    save 60 10000

    Hier kann man auch noch schön sehen, wie ich gekämpft habe, bis ich mal eine dump.rdb gesehen habe. Auch irgendwie logisch, das ich nie eine gesehen hatte, wenn man weiß das

    save 900 1
    

    bedeutet, das er alle 900 Sekunden speichert, wenn mindestens eine Änderung vorhanden ist. Das kann dann schon was dauern. Ich habe das dann mal verkürzt, damit ich schneller ein Ergebnis habe.

    save 60 1
    

    Das brachte mich dann dem Ziel näher. Danach konnte ich die dump.rdb auch finden.

    Bitte keine Redis DB ohne Passwort laufen lassen!

  • FrankMF FrankM verschob dieses Thema von Privat am

  • Redis ändert das Lizenz Modell

    Redis
    2
    0 Stimmen
    2 Beiträge
    36 Aufrufe
    FrankMF

    Ein Artikel von Heise zum Thema

    Link Preview Image Datenbankanbieter Redis ändert sein Lizenzmodell – erneut

    Die No-SQL-Datenbank wird künftig nach einem dualen Modell lizenziert: Redis Source Available License Version 2 oder Server-Side Public License Version 1.​

    favicon

    Developer (www.heise.de)

  • NodeBB - v3.6.0

    NodeBB
    1
    0 Stimmen
    1 Beiträge
    57 Aufrufe
    Niemand hat geantwortet
  • Proxmox 8.1 released

    Linux
    1
    0 Stimmen
    1 Beiträge
    95 Aufrufe
    Niemand hat geantwortet
  • RISC-V

    VisionFive 2
    1
    0 Stimmen
    1 Beiträge
    63 Aufrufe
    Niemand hat geantwortet
  • ReactPHP auf einem ROCKPro64 testen

    Linux
    1
    0 Stimmen
    1 Beiträge
    172 Aufrufe
    Niemand hat geantwortet
  • NAS - Cups & Sane

    Linux
    1
    0 Stimmen
    1 Beiträge
    468 Aufrufe
    Niemand hat geantwortet
  • Installation von Grav & NGinx & PHP7.2

    Angeheftet Verschoben Grav
    2
    0 Stimmen
    2 Beiträge
    1k Aufrufe
    FrankMF

    Nachdem ich den ROCKPro64 jetzt auf den Mainline umgestellt habe, lief meine Testinstallation von Grav nicht mehr.

    Hilfreiche Sache um das Problem zu lösen -> https://gist.github.com/GhazanfarMir/03bd1f1f770a3834d47274586d46ea62

    Ich bekam immer 502 Bad Gateway, Grund war ein nicht korrekt gestarteter php-pfm Service.

    rock64@rockpro64v2_0:/usr/local/bin$ sudo service php7.2-fpm start rock64@rockpro64v2_0:/usr/local/bin$ sudo service php7.2-fpm status ● php7.2-fpm.service - The PHP 7.2 FastCGI Process Manager Loaded: loaded (/lib/systemd/system/php7.2-fpm.service; enabled; vendor preset: enabled) Active: active (running) since Thu 2018-08-16 20:15:20 CEST; 21s ago Docs: man:php-fpm7.2(8) Main PID: 3206 (php-fpm7.2) Status: "Processes active: 0, idle: 2, Requests: 3, slow: 0, Traffic: 0.2req/sec" Tasks: 3 (limit: 4622) CGroup: /system.slice/php7.2-fpm.service ├─3206 php-fpm: master process (/etc/php/7.2/fpm/php-fpm.conf) ├─3207 php-fpm: pool www └─3208 php-fpm: pool www Aug 16 20:15:19 rockpro64v2_0 systemd[1]: Starting The PHP 7.2 FastCGI Process Manager... Aug 16 20:15:20 rockpro64v2_0 systemd[1]: Started The PHP 7.2 FastCGI Process Manager.
  • 0 Stimmen
    1 Beiträge
    810 Aufrufe
    Niemand hat geantwortet