Redis nextcloud 18

Support intro

Nextcloud version 18:
Debian 10 :
Apache version 2.4.38
PHP version 7.3

Following an installation of nextcloud with redis, I encounter various problems.

  1. Error no app in context RedisException: Permission denied - Into nextcloud interface
  2. redis-server.service: Can’t open PID file /run/redis/redis-server.pid (yet?) after start: No such file or directory

here’s what I have on the rights of the directory /run/redis

ls -alt /run/redis/
total 4
drwxr-xr-x 26 root  root     760 févr.  7 10:17 ..
drwxr-xr-x  2 redis www-data  80 févr.  5 14:48 .
-rw-rw----  1 redis www-data   5 févr.  5 14:48 redis-server.pid
srwxrwx---  1 redis www-data   0 févr.  5 14:48 redis-server.sock

My user is present in the group www-data

cat /etc/group |grep redis
redis:x:119:www-data

here’s my redis configuration file

redis config

bind 127.0.0.1

protected-mode yes

port 0

unixsocket /var/run/redis/redis-server.sock
unixsocketperm 770

timeout 0

tcp-keepalive 300

daemonize yes

supervised no

pidfile /var/run/redis/redis-server.pid

logfile /var/log/redis/redis-server.log

databases 16

save 900 1
save 300 10
save 60 10000

rdbchecksum yes

dbfilename dump.rdb

replica-serve-stale-data yes

replica-read-only yes

repl-diskless-sync no

repl-disable-tcp-nodelay no

replica-priority 100

maxclients 512

lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no

appendonly no

appendfilename "appendonly.aof"

appendfsync everysec

no-appendfsync-on-rewrite no

auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb

aof-load-truncated yes

aof-use-rdb-preamble yes

lua-time-limit 5000

notify-keyspace-events ""

hash-max-ziplist-entries 512
hash-max-ziplist-value 64

list-max-ziplist-size -2

list-compress-depth 0

set-max-intset-entries 512

zset-max-ziplist-entries 128
zset-max-ziplist-value 64

hll-sparse-max-bytes 3000

stream-node-max-bytes 4096
stream-node-max-entries 100

client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60

hz 10

dynamic-hz yes

aof-rewrite-incremental-fsync yes

rdb-save-incremental-fsync yes

Here’s my redis logs

Redis log

1638:M 05 Feb 2020 14:38:48.754 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
1638:M 05 Feb 2020 14:38:48.754 # Server initialized
1638:M 05 Feb 2020 14:38:48.754 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
1638:M 05 Feb 2020 14:38:48.754 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
1638:M 05 Feb 2020 14:38:48.754 * DB loaded from disk: 0.000 seconds
1638:M 05 Feb 2020 14:38:48.754 * The server is now ready to accept connections at /var/run/redis/redis-server.sock
1638:M 05 Feb 2020 14:45:14.550 * 10 changes in 300 seconds. Saving...
1638:M 05 Feb 2020 14:45:14.551 * Background saving started by pid 2023
2023:C 05 Feb 2020 14:45:14.708 * DB saved on disk
2023:C 05 Feb 2020 14:45:14.708 * RDB: 4 MB of memory used by copy-on-write
1638:M 05 Feb 2020 14:45:14.752 * Background saving terminated with success
1638:signal-handler (1580910480) Received SIGTERM scheduling shutdown...
1638:signal-handler (1580910480) Received SIGTERM scheduling shutdown...
1638:M 05 Feb 2020 14:48:00.765 # User requested shutdown...
1638:M 05 Feb 2020 14:48:00.765 * Saving the final RDB snapshot before exiting.
1638:M 05 Feb 2020 14:48:01.117 * DB saved on disk
1638:M 05 Feb 2020 14:48:01.117 * Removing the pid file.
1638:M 05 Feb 2020 14:48:01.117 * Removing the unix socket file.
1638:M 05 Feb 2020 14:48:01.117 # Redis is now ready to exit, bye bye...
2436:C 05 Feb 2020 14:48:01.263 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
2436:C 05 Feb 2020 14:48:01.263 # Redis version=5.0.3, bits=64, commit=00000000, modified=0, pid=2436, just started
2436:C 05 Feb 2020 14:48:01.263 # Configuration loaded
                _._
           _.-``__ ''-._
      _.-``    `.  `_.  ''-._           Redis 5.0.3 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 0
 |    `-._   `._    /     _.-'    |     PID: 2437
  `-._    `-._  `-./  _.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |           http://redis.io
  `-._    `-._`-.__.-'_.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |
  `-._    `-._`-.__.-'_.-'    _.-'
      `-._    `-.__.-'    _.-'
          `-._        _.-'
              `-.__.-'

2437:M 05 Feb 2020 14:48:01.267 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
2437:M 05 Feb 2020 14:48:01.267 # Server initialized
2437:M 05 Feb 2020 14:48:01.268 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
2437:M 05 Feb 2020 14:48:01.268 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
2437:M 05 Feb 2020 14:48:01.268 * DB loaded from disk: 0.000 seconds
2437:M 05 Feb 2020 14:48:01.268 * The server is now ready to accept connections at /var/run/redis/redis-server.sock


2437:M 06 Feb 2020 10:05:05.052 * Background saving started by pid 11364
11364:C 06 Feb 2020 10:05:05.134 * DB saved on disk
11364:C 06 Feb 2020 10:05:05.135 * RDB: 2 MB of memory used by copy-on-write
2437:M 06 Feb 2020 10:05:05.153 * Background saving terminated with success
2437:M 06 Feb 2020 10:10:06.074 * 10 changes in 300 seconds. Saving...
2437:M 06 Feb 2020 10:10:06.075 * Background saving started by pid 11528
11528:C 06 Feb 2020 10:10:06.139 * DB saved on disk
11528:C 06 Feb 2020 10:10:06.140 * RDB: 2 MB of memory used by copy-on-write
2437:M 06 Feb 2020 10:10:06.175 * Background saving terminated with success
2437:M 06 Feb 2020 10:25:01.745 * 10 changes in 300 seconds. Saving...
2437:M 06 Feb 2020 10:25:01.746 * Background saving started by pid 11544
11544:C 06 Feb 2020 10:25:01.816 * DB saved on disk
11544:C 06 Feb 2020 10:25:01.817 * RDB: 2 MB of memory used by copy-on-write
2437:M 06 Feb 2020 10:25:01.847 * Background saving terminated with success
2437:M 06 Feb 2020 10:40:02.191 * 1 changes in 900 seconds. Saving...
2437:M 06 Feb 2020 10:40:02.192 * Background saving started by pid 11718
11718:C 06 Feb 2020 10:40:02.288 * DB saved on disk
11718:C 06 Feb 2020 10:40:02.289 * RDB: 2 MB of memory used by copy-on-write
2437:M 06 Feb 2020 10:40:02.292 * Background saving terminated with success
2437:M 06 Feb 2020 10:55:02.215 * 10 changes in 300 seconds. Saving...
2437:M 06 Feb 2020 10:55:02.215 * Background saving started by pid 11733
11733:C 06 Feb 2020 10:55:02.398 * DB saved on disk
11733:C 06 Feb 2020 10:55:02.399 * RDB: 0 MB of memory used by copy-on-write
2437:M 06 Feb 2020 10:55:02.468 * Background saving terminated with success
2437:M 06 Feb 2020 11:10:01.638 * 10 changes in 300 seconds. Saving...
2437:M 06 Feb 2020 11:10:01.639 * Background saving started by pid 11906
11906:C 06 Feb 2020 11:10:01.890 * DB saved on disk
11906:C 06 Feb 2020 11:10:01.891 * RDB: 2 MB of memory used by copy-on-write
2437:M 06 Feb 2020 11:10:01.959 * Background saving terminated with success
2437:M 06 Feb 2020 11:25:01.726 * 10 changes in 300 seconds. Saving...
2437:M 06 Feb 2020 11:25:01.727 * Background saving started by pid 11924
11924:C 06 Feb 2020 11:25:01.855 * DB saved on disk
11924:C 06 Feb 2020 11:25:01.855 * RDB: 0 MB of memory used by copy-on-write
2437:M 06 Feb 2020 11:25:01.928 * Background saving terminated with success
2437:M 06 Feb 2020 11:40:01.981 * 10 changes in 300 seconds. Saving...
2437:M 06 Feb 2020 11:40:01.982 * Background saving started by pid 12097
12097:C 06 Feb 2020 11:40:02.136 * DB saved on disk
12097:C 06 Feb 2020 11:40:02.137 * RDB: 2 MB of memory used by copy-on-write
2437:M 06 Feb 2020 11:40:02.207 * Background saving terminated with success
2437:M 06 Feb 2020 11:55:02.044 * 10 changes in 300 seconds. Saving...
2437:M 06 Feb 2020 11:55:02.044 * Background saving started by pid 12112
12112:C 06 Feb 2020 11:55:02.159 * DB saved on disk
12112:C 06 Feb 2020 11:55:02.159 * RDB: 0 MB of memory used by copy-on-write
2437:M 06 Feb 2020 11:55:02.245 * Background saving terminated with success
2437:M 06 Feb 2020 12:10:01.451 * 10 changes in 300 seconds. Saving...
2437:M 06 Feb 2020 12:10:01.453 * Background saving started by pid 12286
12286:C 06 Feb 2020 12:10:01.800 * DB saved on disk
12286:C 06 Feb 2020 12:10:01.801 * RDB: 2 MB of memory used by copy-on-write
2437:M 06 Feb 2020 12:10:01.853 * Background saving terminated with success
2437:M 06 Feb 2020 12:25:01.776 * 10 changes in 300 seconds. Saving...
2437:M 06 Feb 2020 12:25:01.777 * Background saving started by pid 12304
12304:C 06 Feb 2020 12:25:01.973 * DB saved on disk
12304:C 06 Feb 2020 12:25:01.974 * RDB: 0 MB of memory used by copy-on-write
2437:M 06 Feb 2020 12:25:01.978 * Background saving terminated with success
2437:M 06 Feb 2020 12:40:01.376 * 10 changes in 300 seconds. Saving...
2437:M 06 Feb 2020 12:40:01.377 * Background saving started by pid 12477
12477:C 06 Feb 2020 12:40:01.487 * DB saved on disk
12477:C 06 Feb 2020 12:40:01.488 * RDB: 2 MB of memory used by copy-on-write
2437:M 06 Feb 2020 12:40:01.578 * Background saving terminated with success
2437:M 06 Feb 2020 12:55:01.392 * 10 changes in 300 seconds. Saving...
2437:M 06 Feb 2020 12:55:01.393 * Background saving started by pid 12745
12745:C 06 Feb 2020 12:55:01.558 * DB saved on disk
12745:C 06 Feb 2020 12:55:01.559 * RDB: 0 MB of memory used by copy-on-write
2437:M 06 Feb 2020 12:55:01.594 * Background saving terminated with success
2437:M 07 Feb 2020 10:40:02.048 * 1 changes in 900 seconds. Saving...
2437:M 07 Feb 2020 10:40:02.049 * Background saving started by pid 8504
8504:C 07 Feb 2020 10:40:02.148 * DB saved on disk
8504:C 07 Feb 2020 10:40:02.149 * RDB: 2 MB of memory used by copy-on-write
2437:M 07 Feb 2020 10:40:02.150 * Background saving terminated with success

Do you have any solutions for me?

I assume that you’ve set the ownership of the socket and pid file incorrectly. Ususally the uid and gid should both be “redis”. By adding “www-data” to the “redis” group Nextcloud should be able to access the socket afterwards with this configuration:

  'redis' =>
  array (
    'host' => '/run/redis/redis-server.sock',
    'port' => 0,
    'timeout' => 0.0,

Oups, I forgot to give another item.

Here’s my nextcloud config.php file

'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'overwriteprotocol' => 'https',
  'preview_max_x' => 1024,
  'preview_max_y' => 768,
  'preview_max_scale_factor' => 1,
  'redis' =>
  array (
    'host' => '/var/run/redis/redis-server.sock',
    'port' => 0,
    'timeout' => 0.0,
  ),

I hope /var/run is a symbolic link to /run :wink:

Yes, /var/run is a symbolic link to /run

ls -alt /var/run
lrwxrwxrwx 1 root root 4 févr.  4 13:58 /var/run -> /run

up, need help

Due to the fact that this is an error from the Redis service and not Nextcloud I still believe that it is caused by incorrectly set access rights, as I already wrote. Correct the access rights so that the Redis services starts without an error first.

From the redis.log it looks like it is working and something is successfully using/ accessing redis.
Is it possible, that you use php-fpm and it needs access granted to the redis-server.sock?

I cannot check my server right now if I added entries for redis in my service config file. Maybe you want to give it a shot:

Hello,

It’s the first thing I check when I’m in trouble.

Hello,

I don’t have PHP-FPM.