redis exception: Background saving error

created at 10-02-2021 views: 83

error log

1:M 29 Sep 2021 15:36:17.136 # Background saving error
1:M 29 Sep 2021 15:36:23.050 * 10 changes in 300 seconds. Saving...
1:M 29 Sep 2021 15:36:23.052 * Background saving started by pid 94
94:C 29 Sep 2021 15:36:23.052 # Failed opening the RDB file crontab (in server root dir /etc) for saving: Permission 
1:M 29 Sep 2021 15:36:47.113 # Background saving error
1:M 29 Sep 2021 15:36:53.027 * 10 changes in 300 seconds. Saving...
1:M 29 Sep 2021 15:36:53.029 * Background saving started by pid 103
103:C 29 Sep 2021 15:36:53.029 # Failed opening the RDB file crontab (in server root dir /etc) for saving: Permission denied
1:M 29 Sep 2021 15:36:53.129 # Background saving error
1:M 29 Sep 2021 15:36:56.458 # Failed opening the RDB file backup.db (in server root dir /etc) for saving: Permission denied
1:M 29 Sep 2021 15:36:56.462 # Failed opening the RDB file backup.db (in server root dir /etc) for saving: Permission denied
1:M 29 Sep 2021 15:36:56.480 # Failed opening the RDB file root (in server root dir /etc) for saving: Permission denied
1:M 29 Sep 2021 15:36:56.484 # Failed opening the RDB file root (in server root dir /etc) for saving: Permission denied
1:M 29 Sep 2021 15:36:56.485 # Failed opening the RDB file root (in server root dir /etc) for saving: Permission denied
1:M 29 Sep 2021 15:36:56.503 # Failed opening the RDB file zzh (in server root dir /etc) for saving: Permission denied
1:M 29 Sep 2021 15:36:56.510 # Failed opening the RDB file crontab (in server root dir /etc) for saving: Permission denied

The online redis key was inexplicably emptied

Troubleshoot issues:

1) Is it possible that the timeout period is too short?
After investigation, it is found that this is not the problem, and the timeout period of the redis key is clearly set in the project.
2) Is it possible which part of the project called the redis clearing operation?
After investigation, I did not find that there was an operation to clear redis.
3) Could it be a problem with the redis service?
Log in to the redis client, set a key separately and set the timeout period, and use the ttl command to view the key timeout period
Then it was found that all the keys were invalid in a period of time
At this time, check the redis log and find the error log above. With the help of Google, it is found that there is no permission when it is persisted.
Then executed the following code:

sudo chmod 777 /var/lib/redis/

It relapsed again after half an hour, and then executed again

127.0.0.1:6379> config get dir
1) "dir"
2) "/etc"
127.0.0.1:6379>

Found that the file path was wrong, and then modified it again

127.0.0.1:6379> config set dir /data
OK
127.0.0.1:6379>

After setting it up, the original problem appeared again after ten minutes. . . .
Finally, I chose to change the redis version. I used the image: redis downloaded before. I don’t know which version it is.
Later, I modified it to redis:5.0.13-buster

docker-compose script

  redis:
    image: redis:5.0.13-buster
    ports:
      - 6379:6379
    restart: always
    container_name: redis
    volumes:
    - ./redis/data:/data
    - ./redis/redis.conf:/usr/local/etc/redis/redis.conf

At the very least, no problems were found after observing for a period of time. . . Use it first, there is a problem with the previous version

created at:10-02-2021
edited at: 10-02-2021: