Skip to content

Docker & Redis Datenbank

Verschoben Linux
2 1 263
  • 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
  • Hey, Fediverse, let's drop #Linux for a second:

    Uncategorized linux amiga atarist
    2
    0 Stimmen
    2 Beiträge
    32 Aufrufe
    frankm@nrw.socialF
    @transcendentempress #Amiga But i have sold my Amiga4000, what a mistake.
  • AI Bots aussperren

    Linux linux block-ai nginx
    2
    0 Stimmen
    2 Beiträge
    147 Aufrufe
    FrankMF
    Wir können das noch für eine sanfte Methode erweitern, das ist die Datei robots.txt, wo man sich in alten Zeiten mal dran hielt. Einige Bots machen das, andere nicht. Praktisch, das o.g. Projekt bietet diese Datei auch an. Dann werden wir das kurz mal mit einbauen. ai-block.sh #!/bin/bash # Script um AI-Bots zu blocken # https://github.com/ai-robots-txt/ai.robots.txt/tree/main mkdir /root/AI-test cd /root/AI-test ## Daten holen curl -O https://raw.githubusercontent.com/ai-robots-txt/ai.robots.txt/master/nginx-block-ai-bots.conf curl -O https://raw.githubusercontent.com/ai-robots-txt/ai.robots.txt/master/robots.txt ## Daten in nginx einbauen mv nginx-block-ai-bots.conf /etc/nginx/blocklists/ mv robots.txt /var/www/html ## NGINX neustarten systemctl restart nginx.service Damit das in nginx funktioniert. Den Server Block um folgendes erweitern. # Serve robots.txt directly from Nginx location = /robots.txt { root /var/www/html; try_files $uri =404; } Kurzer Test https://<DOMAIN>/robots.txt Ergebnis User-agent: AI2Bot User-agent: Ai2Bot-Dolma User-agent: Amazonbot User-agent: anthropic-ai User-agent: Applebot User-agent: Applebot-Extended User-agent: Brightbot 1.0 User-agent: Bytespider User-agent: CCBot User-agent: ChatGPT-User User-agent: Claude-Web User-agent: ClaudeBot User-agent: cohere-ai User-agent: cohere-training-data-crawler User-agent: Crawlspace User-agent: Diffbot User-agent: DuckAssistBot User-agent: FacebookBot User-agent: FriendlyCrawler User-agent: Google-Extended User-agent: GoogleOther User-agent: GoogleOther-Image User-agent: GoogleOther-Video User-agent: GPTBot User-agent: iaskspider/2.0 User-agent: ICC-Crawler User-agent: ImagesiftBot User-agent: img2dataset User-agent: imgproxy User-agent: ISSCyberRiskCrawler User-agent: Kangaroo Bot User-agent: Meta-ExternalAgent User-agent: Meta-ExternalFetcher User-agent: OAI-SearchBot User-agent: omgili User-agent: omgilibot User-agent: PanguBot User-agent: Perplexity-User User-agent: PerplexityBot User-agent: PetalBot User-agent: Scrapy User-agent: SemrushBot-OCOB User-agent: SemrushBot-SWA User-agent: Sidetrade indexer bot User-agent: Timpibot User-agent: VelenPublicWebCrawler User-agent: Webzio-Extended User-agent: YouBot Disallow: /
  • Redis Replication - Can't handle RDB format version 10

    Verschoben Redis redis
    1
    0 Stimmen
    1 Beiträge
    3k Aufrufe
    Niemand hat geantwortet
  • 0 Stimmen
    1 Beiträge
    307 Aufrufe
    Niemand hat geantwortet
  • Debian 11 Bullseye released!

    Linux debian linux
    4
    0 Stimmen
    4 Beiträge
    371 Aufrufe
    FrankMF
    Mein Systemadmin auf der Arbeit meinte heute, angesprochen auf das Problem, läuft der Network-Manager? Ok, gute Frage...... Schauen wir mal. Ich bin mir leider nicht 100% sicher, ob er vor meinem Eingreifen lief, ich denke aber schon. Warum ich unsicher bin? root@debian:~# systemctl enable systemd-networkd.service Created symlink /etc/systemd/system/dbus-org.freedesktop.network1.service → /lib/systemd/system/systemd-networkd.service. Created symlink /etc/systemd/system/multi-user.target.wants/systemd-networkd.service → /lib/systemd/system/systemd-networkd.service. Created symlink /etc/systemd/system/sockets.target.wants/systemd-networkd.socket → /lib/systemd/system/systemd-networkd.socket. Created symlink /etc/systemd/system/network-online.target.wants/systemd-networkd-wait-online.service → /lib/systemd/system/systemd-networkd-wait-online.service. Ok, danach root@debian:~# systemctl start systemd-networkd.service root@debian:~# systemctl status systemd-networkd.service ● systemd-networkd.service - Network Service Loaded: loaded (/lib/systemd/system/systemd-networkd.service; enabled; ven> Active: active (running) since Tue 2021-08-17 17:36:38 CEST; 6s ago TriggeredBy: ● systemd-networkd.socket Docs: man:systemd-networkd.service(8) Main PID: 1288 (systemd-network) Status: "Processing requests..." Tasks: 1 (limit: 19087) Memory: 3.9M CPU: 39ms CGroup: /system.slice/systemd-networkd.service └─1288 /lib/systemd/systemd-networkd Aug 17 17:36:38 debian systemd[1]: Starting Network Service... Aug 17 17:36:38 debian systemd-networkd[1288]: enp25s0: Gained IPv6LL Aug 17 17:36:38 debian systemd-networkd[1288]: Enumeration completed Aug 17 17:36:38 debian systemd[1]: Started Network Service. Danach ging immer noch nix. root@debian:/etc/network# ^C root@debian:/etc/network# nmcli device show GENERAL.DEVICE: wlx7cdd907cbec2 GENERAL.TYPE: wifi GENERAL.HWADDR: BA:59:C0:76:C7:F5 GENERAL.MTU: 1500 GENERAL.STATE: 20 (nicht verfügbar) GENERAL.CONNECTION: -- GENERAL.CON-PATH: -- GENERAL.DEVICE: enp25s0 GENERAL.TYPE: ethernet GENERAL.HWADDR: 30:9C:23:60:C6:8E GENERAL.MTU: 1500 GENERAL.STATE: 10 (nicht verwaltet) GENERAL.CONNECTION: -- GENERAL.CON-PATH: -- WIRED-PROPERTIES.CARRIER: an IP4.ADDRESS[1]: 192.168.3.169/24 IP4.GATEWAY: 192.168.3.1 IP4.ROUTE[1]: dst = 192.168.3.0/24, nh = 0.0.0.0, mt = 0 IP4.ROUTE[2]: dst = 0.0.0.0/0, nh = 192.168.3.1, mt = 0 IP6.ADDRESS[1]: 2a02:908:1260:13bc:329c:23ff:xxxx:xxxx/64 IP6.ADDRESS[2]: fd8a:6ff:2880:0:329c:23ff:fe60:c68e/64 IP6.ADDRESS[3]: fe80::329c:23ff:fe60:c68e/64 IP6.GATEWAY: fe80::e4d3:f0ff:fe8f:2354 IP6.ROUTE[1]: dst = fe80::/64, nh = ::, mt = 256 IP6.ROUTE[2]: dst = ::/0, nh = fe80::e4d3:f0ff:fe8f:2354, mt = 1024 IP6.ROUTE[3]: dst = 2a02:908:xxxx:xxxx::/64, nh = ::, mt = 256 IP6.ROUTE[4]: dst = fd8a:6ff:2880::/64, nh = ::, mt = 256 Jetzt hatte ich das erste Mal einen Ansatz, wonach ich suchen musste. GENERAL.STATE: 10 (nicht verwaltet) Etwas Suche im Netz und dann das nano /etc/NetworkManager/NetworkManager.conf Inhalt der Datei [main] plugins=ifupdown,keyfile [ifupdown] managed=false Das false in true geändert. Danach ein systemctl restart NetworkManager und ich konnte den Network-Manager auf dem Desktop benutzen!?!?!? [image: 1629216580219-bildschirmfoto-vom-2021-08-17-18-07-25.png] Irgendwas ist da durcheinander im Bullseye
  • VSCodium - Nach Umzug die Entwicklungsumgebung wieder aktivieren

    Linux linux vscodium
    1
    2
    0 Stimmen
    1 Beiträge
    200 Aufrufe
    Niemand hat geantwortet
  • Ubiquiti ER-X - Switch

    Verschoben OpenWRT & Ubiquiti ER-X openwrt linux er-x
    1
    1
    0 Stimmen
    1 Beiträge
    300 Aufrufe
    Niemand hat geantwortet
  • ROCKPro64 - Kamils neuer 0.10.x Release

    ROCKPro64 linux rockpro64
    1
    1
    0 Stimmen
    1 Beiträge
    258 Aufrufe
    Niemand hat geantwortet