I suggest moving the Redis database save files outside of the root partition. In this example we will use /redis as the database destination.

To use Redis with the presented configuration, client programs need to access Redis’s socket at /var/run/redis/redis-server.sock. You need to add the running client users to the redis group. As an alternative you can also use socat to create a copy of the socket with the appropriate permissions.

See also

  • amazon ec2 - Redis reports read-only filesystem, but it isn’t - Server Fault 1

  1. install the dependencies

    apt-get update
    apt-get install redis-server rsync
  2. create the new redis directory and move existing content. Make sure to create a new partition first

    systemctl stop redis.service
    mkdir /redis
    # Mount the new partition here.
    rsync --avAX /var/lib/redis/dump.rdb /redis
  3. edit the configuration file like this

     2protected-mode yes
     3port 0
     4tcp-backlog 511
     5unixsocket /var/run/redis/redis-server.sock
     6unixsocketperm 770
     7timeout 0
     8tcp-keepalive 300
     9daemonize yes
    10supervised no
    11pidfile /var/run/redis/
    12loglevel verbose
    13logfile /var/log/redis/redis-server.log
    14databases 32
    15always-show-logo no
    16save 900 1000
    17save 300 10000
    18save 60 10000000
    19stop-writes-on-bgsave-error yes
    20rdbcompression yes
    21rdbchecksum yes
    22dbfilename dump.rdb
    23dir /redis
    24replica-serve-stale-data yes
    25replica-read-only yes
    26repl-diskless-sync no
    27repl-diskless-sync-delay 5
    28repl-disable-tcp-nodelay no
    29replica-priority 100
    30lazyfree-lazy-eviction no
    31lazyfree-lazy-expire no
    32lazyfree-lazy-server-del no
    33replica-lazy-flush no
    34appendonly no
    35appendfilename "appendonly.aof"
    36appendfsync everysec
    37no-appendfsync-on-rewrite no
    38auto-aof-rewrite-percentage 100
    39auto-aof-rewrite-min-size 64mb
    40aof-load-truncated yes
    41aof-use-rdb-preamble yes
    42lua-time-limit 5000
    43slowlog-log-slower-than 10000
    44slowlog-max-len 128
    45latency-monitor-threshold 0
    46notify-keyspace-events ""
    47hash-max-ziplist-entries 512
    48hash-max-ziplist-value 64
    49list-max-ziplist-size -2
    50list-compress-depth 0
    51set-max-intset-entries 512
    52zset-max-ziplist-entries 128
    53zset-max-ziplist-value 64
    54hll-sparse-max-bytes 3000
    55stream-node-max-bytes 4096
    56stream-node-max-entries 100
    57activerehashing no
    58client-output-buffer-limit normal 0 0 0
    59client-output-buffer-limit replica 256mb 64mb 60
    60client-output-buffer-limit pubsub 32mb 8mb 60
    61hz 10
    62dynamic-hz yes
    63aof-rewrite-incremental-fsync yes
    64rdb-save-incremental-fsync yes
  4. edit the service unit file

    systemctl edit redis.service

    Add this content

  5. restart the service

    systemctl restart redis.service


1 CC BY-SA 4.0, Copyright (c) 2018 contributors