-->

Пожалуйста проверьте журналы redis для получения подробной информации об ошибке rdb

Restart your redis server.

  • macOS (brew): brew services restart redis.
  • Linux: sudo service redis restart / sudo systemctl restart redis
  • Windows: Windows + R -> Type services.msc, Enter -> Search for Redis then click on restart.

I had this issue after upgrading redis with Brew (brew upgrade).

Once I restarted my laptop, it immediately worked.

answered Dec 18, 2019 at 12:27

Erowlin's user avatar

9

Using redis-cli, you can stop it trying to save the snapshot:

config set stop-writes-on-bgsave-error no

This is a quick workaround, but if you care about the data you are using it for, you should check to make sure why bgsave failed in first place.

Stephan Vierkant's user avatar

answered Jan 31, 2014 at 15:54

思考zhe's user avatar

思考zhe思考zhe

5,3352 gold badges13 silver badges9 bronze badges

10

In case you encounter the error and some important data cannot be discarded on the running redis instance (problems with permissions for the rdb file or its directory incorrectly, or running out of disk space), you can always redirect the rdb file to be written somewhere else.

Using redis-cli, you can do something like this:

CONFIG SET dir /tmp/some/directory/other/than/var
CONFIG SET dbfilename temp.rdb

After this, you might want to execute a BGSAVE command to make sure that the data will be written to the rdb file. Make sure that when you execute INFO persistence, bgsave_in_progress is already 0 and rdb_last_bgsave_status is ok. After that, you can now start backing up the generated rdb file somewhere safe.

answered Oct 30, 2013 at 3:41

Axel Advento's user avatar

Axel AdventoAxel Advento

2,9953 gold badges24 silver badges32 bronze badges

8

There might be errors during the bgsave process due to low memory. Try this (from redis background save FAQ)

echo 'vm.overcommit_memory = 1' >> /etc/sysctl.conf
sysctl vm.overcommit_memory=1

answered Dec 13, 2013 at 22:37

Chris's user avatar

ChrisChris

1,5221 gold badge12 silver badges19 bronze badges

1

This error occurs because of BGSAVE being failed. During BGSAVE, Redis forks a child process to save the data on disk. Although exact reason for failure of BGSAVE can be checked from logs (usually at /var/log/redis/redis-server.log on linux machines) but a lot of the times BGAVE fails because the fork can’t allocate memory. Many times the fork fails to allocate memory (although the machine has enough RAM available) because of a conflicting optimization by the OS.

As can be read from Redis FAQ:

Redis background saving schema relies on the copy-on-write semantic of fork in modern operating systems: Redis forks (creates a child process) that is an exact copy of the parent. The child process dumps the DB on disk and finally exits. In theory the child should use as much memory as the parent being a copy, but actually thanks to the copy-on-write semantic implemented by most modern operating systems the parent and child process will share the common memory pages. A page will be duplicated only when it changes in the child or in the parent. Since in theory all the pages may change while the child process is saving, Linux can’t tell in advance how much memory the child will take, so if the overcommit_memory setting is set to zero fork will fail unless there is as much free RAM as required to really duplicate all the parent memory pages, with the result that if you have a Redis dataset of 3 GB and just 2 GB of free memory it will fail.

Setting overcommit_memory to 1 says Linux to relax and perform the fork in a more optimistic allocation fashion, and this is indeed what you want for Redis.

Redis doesn’t need as much memory as the OS thinks it does to write to disk, so may pre-emptively fail the fork.

To Resolve this, you can:

Modify /etc/sysctl.conf and add:

vm.overcommit_memory=1

Then restart sysctl with:

On FreeBSD:

sudo /etc/rc.d/sysctl reload

On Linux:

sudo sysctl -p /etc/sysctl.conf

Community's user avatar

answered Apr 15, 2018 at 6:42

Bhindi's user avatar

BhindiBhindi

1,37311 silver badges16 bronze badges

4

In my case, it was just the privileges that I needed to allow for Redis to accept the incoming request.

So I restarted the Redis service via Homebrew brew services stop redis and brew services start redis and run the Redis server locally redis-server. The command prompt asked me to allow the incoming request and it started working.

answered May 16, 2022 at 10:23

Touseef Murtaza's user avatar

1

in case you are working on a linux machine, also recheck the file and folder permissions of the database.

The db and the path to it can be obtained via:

in redis-cli:

CONFIG GET dir

CONFIG GET dbfilename

and in the commandline ls -l. The permissions for the directory should be 755, and those for the file should be 644. Also, normally redis-server executes as the user redis, therefore its also nice to give the user redis the ownership of the folder by executing sudo chown -R redis:redis /path/to/rdb/folder. This has been elaborated in the answer here.

Community's user avatar

answered Jul 13, 2014 at 18:26

smilee89's user avatar

smilee89smilee89

5335 silver badges9 bronze badges

1

If you’re running MacOS and have recently upgraded to Catalina, you may need to run brew services restart redis as suggested in this issue.

answered Nov 11, 2019 at 5:30

Fush's user avatar

FushFush

2,46921 silver badges19 bronze badges

Thanks everyone for checking the problem, apparently the error was produced during bgsave.

For me, typing config set stop-writes-on-bgsave-error no in a shell and restarting Redis solved the problem.

answered Oct 25, 2013 at 4:45

Salvador Dali's user avatar

Salvador DaliSalvador Dali

213k147 gold badges698 silver badges752 bronze badges

5

Start Redis Server in a directory where Redis has write permissions

The answers above will definitely solve your problem, but here’s what’s actually going on:

The default location for storing the rdb.dump file is ./ (denoting current directory). You can verify this in your redis.conf file. Therefore, the directory from where you start the redis server is where a dump.rdb file will be created and updated.

It seems you have started running the redis server in a directory where redis does not have the correct permissions to create the dump.rdb file.

To make matters worse, redis will also probably not allow you to shut down the server either until it is able to create the rdb file to ensure the proper saving of data.

To solve this problem, you must go into the active redis client environment using redis-cli and update the dir key and set its value to your project folder or any folder where non-root has permissions to save. Then run BGSAVE to invoke the creation of the dump.rdb file.

CONFIG SET dir "/hardcoded/path/to/your/project/folder"
BGSAVE

(Now, if you need to save the dump.rdb file in the directory that you started the server in, then you will need to change permissions for the directory so that redis can write to it. You can search stackoverflow for how to do that).

You should now be able to shut down the redis server. Note that we hardcoded the path. Hardcoding is rarely a good practice and I highly recommend starting the redis server from your project directory and changing the dir key back to./`.

CONFIG SET dir "./"
BGSAVE

That way when you need redis for another project, the dump file will be created in your current project’s directory and not in the hardcoded path’s project directory.

answered Sep 23, 2017 at 19:57

Govind Rai's user avatar

Govind RaiGovind Rai

14.2k9 gold badges70 silver badges83 bronze badges

2

$ redis-cli

config set stop-writes-on-bgsave-error no

According to Redis documentation, this is recommended only if you don’t have RDB snapshots enabled or if you don’t care about data persistence in the snapshots.

«By default Redis will stop accepting writes if RDB snapshots are enabled (at least one save point) and the latest background save failed. This will make the user aware (in a hard way) that data is not persisting on disk properly, otherwise,strong text chances are that no one will notice and some disaster will happen.»

What u should be doing is :

# redis-cli
127.0.0.1:6379> CONFIG SET dir /data/tmp
OK
127.0.0.1:6379> CONFIG SET dbfilename temp.rdb
OK
127.0.0.1:6379> BGSAVE
Background saving started
127.0.0.1:6379>

Please Make sure /data/tmp has enough disk space.

jas's user avatar

jas

10.6k2 gold badges30 silver badges41 bronze badges

answered Mar 4, 2021 at 10:33

Vinayak S.'s user avatar

Vinayak S.Vinayak S.

3722 silver badges7 bronze badges

1

Had encountered this error and was able to figure out from log that the error is because of the disk space not being enough. All the data that was inserted in my case was not needed any longer. So I tried to FLUSHALL. Since redis-rdb-bgsave process was running, it was not allowing to FLUSH the data also. I followed below steps and was able to continue.

  1. Login to redis client
  2. Execute config set stop-writes-on-bgsave-error no
  3. Execute FLUSHALL (Data stored was not needed)
  4. Execute config set stop-writes-on-bgsave-error yes

The process redis-rdb-bgsave was no longer running after the above steps.

answered Sep 4, 2018 at 7:09

RCK's user avatar

RCKRCK

3112 silver badges4 bronze badges

I faced the similar issue, the main reason behind this was the memory(RAM) consumption by redis.
My EC2 machine had 8GB RAM(arounf 7.4 available for consumption)

When my program was running the RAM usage went upto 7.2 GB leaving hardly ~100MB in RAM , this generally triggers the MISCONF Redis error ...

You can determine the RAM consumption using the htop command. Look for the Mem attribute after running htop command. If it shows high consumtion (like in my case it was 7.2GB/7.4GB) It’s better to upgrade the instance’s with larger Memory.
In this scenario using config set stop-writes-on-bgsave-error no will be a disaster for the server and may result in disrupting other services running on the server(if any). So, it better to avoid the config command and UPGRADE YOUR REDIS MACHINE.

FYI: You may need to install htop to make this work : sudo apt-get install htop

One more solution to this can be some other RAM heavy service running on your system, check for other service running on your server/machine/instance and stop it if its not necessary. To check all the services running on your machine use service --status-all

And a suggestion for people directly pasting the config command , please do reasearch a bit and atleast warn the user before using such commands. And as @Rodrigo mentioned in his comment : «It does not look cool to ignore the errors.»

—UPDATE—

YOu can also configure maxmemory and maxmemory-policy to define the behavior of Redis when a specific limit of memory is reached.
For example, if I want to keep the memory limit of 6GB and delete the least recently used keys from the DB to make sure that redis mem usage do not exceed 6GB, then we can set these two parameters (in redis.conf or CONFIG SET command):

maxmemory 6gb
maxmemory-policy allkeys-lru

There are a lot of other values which you can set for these two parameters you can read about this from here: https://redis.io/topics/lru-cache

answered Feb 15, 2019 at 13:57

im_bhatman's user avatar

im_bhatmanim_bhatman

8761 gold badge18 silver badges28 bronze badges

Nowadays the Redis write-access problems that give this error message to the client re-emerged in the official redis docker containers.

Redis from the official redis image tries to write the .rdb file in the containers /data folder, which is rather unfortunate, as it is a root-owned folder and it is a non-persistent location too (data written there will disappear if your container/pod crashes).

So after an hour of inactivity, if you have run your redis container as a non-root user (e.g. docker run -u 1007 rather than default docker run -u 0), you will get a nicely detailed error msg in your server log (see docker logs redis):

1:M 29 Jun 2019 21:11:22.014 * 1 changes in 3600 seconds. Saving...
1:M 29 Jun 2019 21:11:22.015 * Background saving started by pid 499
499:C 29 Jun 2019 21:11:22.015 # Failed opening the RDB file dump.rdb (in server root dir /data) for saving: Permission denied
1:M 29 Jun 2019 21:11:22.115 # Background saving error

So what you need to do is to map container’s /data folder to an external location (where the non-root user, here: 1007, has write access, such as /tmp on the host machine), e.g:

docker run --rm -d --name redis -p 6379:6379 -u 1007 -v /tmp:/data redis

So it is a misconfiguration of the official docker image (which should write to /tmp not /data) that produces this «time bomb» that you will most likely encounter only in production… overnight over some particularly quiet holiday weekend :/

answered Jun 30, 2019 at 8:52

mirekphd's user avatar

mirekphdmirekphd

4,4313 gold badges36 silver badges58 bronze badges

5

for me

config set stop-writes-on-bgsave-error no

and I reload my mac, it works

answered Aug 15, 2019 at 2:33

wuhaiwei's user avatar

wuhaiweiwuhaiwei

911 silver badge2 bronze badges

On redis.conf line ~235 let’s try to change config like this

- stop-writes-on-bgsave-error yes
+ stop-writes-on-bgsave-error no

Dharman's user avatar

Dharman

30.5k22 gold badges85 silver badges133 bronze badges

answered Nov 27, 2020 at 12:14

Binh Ho's user avatar

Binh HoBinh Ho

3,4811 gold badge30 silver badges31 bronze badges

1

A more permanent fix might be to look in /etc/redis/redis.conf around lines 200-250 there are settings for the rdb features, that were not a part of redis back in the 2.x days.

notably

dir ./

can be changed to

dir /home/someuser/redislogfiledirectory

or you could comment out all the save lines, and not worry about persistence. (See the comments in /etc/redis/redis.conf)

Also, don’t forget

service redis-server stop
service redis-server start

answered Sep 19, 2016 at 4:26

Soup Cup's user avatar

Soup CupSoup Cup

1011 silver badge5 bronze badges

1

all of those answers do not explain the reason why the rdb save failed.


as my case, I checked the redis log and found:

14975:M 18 Jun 13:23:07.354 # Background saving terminated by signal 9

run the following command in terminal:

sudo egrep -i -r 'killed process' /var/log/

it display:

/var/log/kern.log.1:Jun 18 13:23:07 10-10-88-16 kernel: [28152358.208108] Killed process 28416 (redis-server) total-vm:7660204kB, anon-rss:2285492kB, file-rss:0kB

that is it! this process(redis save rdb) is killed by OOM killer

refers:

https://github.com/antirez/redis/issues/1886

Finding which process was killed by Linux OOM killer

Community's user avatar

answered Jun 19, 2017 at 3:54

carton.swing's user avatar

carton.swingcarton.swing

1,44717 silver badges12 bronze badges

Yep, this happing because current use does not have the permission to modify the «dump.rdb».

So, instead of creating a new RDB file, You can also give permission to old file(change the ownership of it).

In redis-cli enter:

config get dir

you will get «/usr/local/var/db/redis» (this is the location where redis writes the data)

go to this location using terminal

cd 
cd /usr/local/var/db

Type this command(with our username):

sudo chown -R [username] db

This will change to owner.

This works for me.

answered Jun 11, 2021 at 5:58

krishnkant jaiswal's user avatar

I know this thread is slightly older, but here’s what worked for me when I got this error earlier, knowing I was nowhere near memory limit- both answers were found above.

Hopefully this could help someone in the future if they need it.

  1. Checked CHMOD on dir folder… found somehow the symbolic notation was different. CHMOD dir folder to 755
  2. dbfilename permissions were good, no changes needed
  3. Restarted redis-server
  4. (Should’ve done this first, but ah well) Referenced the redis-server.log and found that the error was the result of access being denied.

Again- unsure how the permissions on the DIR folder got changed, but I’m assuming CHMOD back to 755 and restarting redis-server took care of it as I was able to ping redis server afterwards.

Also- to note, redis did have ownership of the dbfilename and DIR folder.

answered Jun 21, 2020 at 6:14

Dustin's user avatar

I too was facing the same issue. Both the answers (the most upvoted one and the accepted one) just give a temporary fix for the same.

Moreover, the config set stop-writes-on-bgsave-error no is a horrible way to over look this error, since what this option does is stop redis from notifying that writes have been stopped and to move on without writing the data in a snapshot. This is simply ignoring this error.
Refer this

As for setting dir in config in redis-cli, once you restart the redis service, this shall get cleared too and the same error shall pop up again. The default value of dir in redis.conf is ./ , and if you start redis as root user, then ./ is / to which write permissions aren’t granted, and hence the error.

The best way is to set the dir parameter in redis.conf file and set proper permissions to that directory. Most of the debian distributions shall have it in /etc/redis/redis.conf

answered Jun 11, 2018 at 9:03

Mayank Sharma's user avatar

Check your Redis log before taking any action. Some of the solutions in this thread may erase your Redis data, so be careful about what you are doing.

In my case, the machine was running out of RAM. This also can happen when there is no more free disk space on the host.

answered Apr 17, 2020 at 22:24

Erfun's user avatar

ErfunErfun

1,0792 gold badges11 silver badges26 bronze badges

1

After banging my head through so many SO questions finally —
for me @Axel Advento’ s answer worked but with few extra steps —
I was still facing the permission issues.
I had to switch user to redis, create a new dir in it’s home dir and then set it as redis’s dir.

sudo su - redis -s /bin/bash
mkdir redis_dir
redis-cli CONFIG SET dir $(realpath redis_dir)
exit # to logout from redis user (optional)

answered May 2, 2020 at 5:21

markroxor's user avatar

markroxormarkroxor

5,8682 gold badges34 silver badges43 bronze badges

In my Case the Ubuntu Virtual Machine’s Disk space got Full and that’s why I was getting this Error. After deleting some files from the Disk has Solved the Issue.

answered May 29, 2021 at 17:51

Amar Kumar's user avatar

Amar KumarAmar Kumar

2,3242 gold badges25 silver badges33 bronze badges

In case you are using docker/docker-compose and want to prevent redis from writing to file, you can create a redis config and mount into a container

docker.compose.override.yml

  redis:¬
      volumes:¬
        - ./redis.conf:/usr/local/etc/redis/redis.conf¬
      ports:¬
        - 6379:6379¬

You can download the default config from here

in the redis.conf file make sure you comment out these 3 lines

save 900 1
save 300 10
save 60 10000

myou can view more solutions for removing the persistent data here

answered Jun 23, 2019 at 2:05

Nic Wanavit's user avatar

Nic WanavitNic Wanavit

2,2235 gold badges19 silver badges31 bronze badges

I hit this problem while working on a server with AFS disk space because my authentication token had expired, which yielded Permission Denied responses when the redis-server tried to save. I solved this by refreshing my token:

kinit USERNAME_HERE -l 30d && aklog

answered Oct 28, 2017 at 12:44

duhaime's user avatar

duhaimeduhaime

25.2k17 gold badges165 silver badges222 bronze badges

In my case it happened because I just installed redis using the quick way. So redis is not running as root.
I was able to solve this problem by following the instructions under the Installing Redis more properly section of their Quick Start Guide. After doing so, the problem was solved and redis is now running as root. Check it out.

answered Jan 22, 2020 at 7:31

meow2x's user avatar

meow2xmeow2x

2,04622 silver badges27 bronze badges

In my case it was related to disk free space. (you can check it with df -h bash command) when I free some space this error disappeared.

answered Aug 6, 2019 at 6:40

Mohammad Reza Esmaeilzadeh's user avatar

If you are running Redis locally on a windows machine, try to «run as administrator» and see if it works. With me, the problem was that Redis was located in the «Program Files» folder, which restricts permissions by default. As it should.

However, do not automatically run Redis as an administrator You don’t want to grant it more rights that it is supposed to have. You want to solve this by the book.

So, we have been able to quickly identify the problem by running it as an administrator, but this is not the cure. A likely scenario is that you have put Redis in a folder that doesn’t have write rights and as a consequence the DB file is stored in that same location.

You can solve this by opening the redis.windows.conf and to search for the following configuration:

    # The working directory.
    #
    # The DB will be written inside this directory, with the filename specified
    # above using the 'dbfilename' configuration directive.
    #
    # The Append Only File will also be created inside this directory.
    #
    # Note that you must specify a directory here, not a file name.
    dir ./

Change dir ./ to a path you have regular read/write permissions for

You could also just move the Redis folder in it’s entirety to a folder you know has the right permissions.

Aurelio's user avatar

Aurelio

24.5k9 gold badges59 silver badges63 bronze badges

answered Jun 19, 2018 at 8:54

Pascalculator's user avatar

PascalculatorPascalculator

8701 gold badge10 silver badges17 bronze badges

Restart your redis server.

  • macOS (brew): brew services restart redis.
  • Linux: sudo service redis restart / sudo systemctl restart redis
  • Windows: Windows + R -> Type services.msc, Enter -> Search for Redis then click on restart.

I personally had this issue after upgrading redis with Brew (brew upgrade).
After rebooting the laptop, it immediately worked.

answered Dec 18, 2019 at 12:27

Erowlin's user avatar

12

Using redis-cli, you can stop it trying to save the snapshot:

config set stop-writes-on-bgsave-error no

This is a quick workaround, but if you care about the data you are using it for, you should check to make sure why bgsave failed in first place.

Stephan Vierkant's user avatar

answered Jan 31, 2014 at 15:54

思考zhe's user avatar

思考zhe思考zhe

5,1972 gold badges12 silver badges8 bronze badges

10

In case you encounter the error and some important data cannot be discarded on the running redis instance (problems with permissions for the rdb file or its directory incorrectly, or running out of disk space), you can always redirect the rdb file to be written somewhere else.

Using redis-cli, you can do something like this:

CONFIG SET dir /tmp/some/directory/other/than/var
CONFIG SET dbfilename temp.rdb

After this, you might want to execute a BGSAVE command to make sure that the data will be written to the rdb file. Make sure that when you execute INFO persistence, bgsave_in_progress is already 0 and rdb_last_bgsave_status is ok. After that, you can now start backing up the generated rdb file somewhere safe.

answered Oct 30, 2013 at 3:41

Axel Advento's user avatar

Axel AdventoAxel Advento

2,9753 gold badges24 silver badges32 bronze badges

9

There might be errors during the bgsave process due to low memory. Try this (from redis background save FAQ)

echo 'vm.overcommit_memory = 1' >> /etc/sysctl.conf
sysctl vm.overcommit_memory=1

answered Dec 13, 2013 at 22:37

Chris's user avatar

ChrisChris

1,5121 gold badge12 silver badges19 bronze badges

1

This error occurs because of BGSAVE being failed. During BGSAVE, Redis forks a child process to save the data on disk. Although exact reason for failure of BGSAVE can be checked from logs (usually at /var/log/redis/redis-server.log on linux machines) but a lot of the times BGAVE fails because the fork can’t allocate memory. Many times the fork fails to allocate memory (although the machine has enough RAM available) because of a conflicting optimization by the OS.

As can be read from Redis FAQ:

Redis background saving schema relies on the copy-on-write semantic of fork in modern operating systems: Redis forks (creates a child process) that is an exact copy of the parent. The child process dumps the DB on disk and finally exits. In theory the child should use as much memory as the parent being a copy, but actually thanks to the copy-on-write semantic implemented by most modern operating systems the parent and child process will share the common memory pages. A page will be duplicated only when it changes in the child or in the parent. Since in theory all the pages may change while the child process is saving, Linux can’t tell in advance how much memory the child will take, so if the overcommit_memory setting is set to zero fork will fail unless there is as much free RAM as required to really duplicate all the parent memory pages, with the result that if you have a Redis dataset of 3 GB and just 2 GB of free memory it will fail.

Setting overcommit_memory to 1 says Linux to relax and perform the fork in a more optimistic allocation fashion, and this is indeed what you want for Redis.

Redis doesn’t need as much memory as the OS thinks it does to write to disk, so may pre-emptively fail the fork.

To Resolve this, you can:

Modify /etc/sysctl.conf and add:

vm.overcommit_memory=1

Then restart sysctl with:

On FreeBSD:

sudo /etc/rc.d/sysctl reload

On Linux:

sudo sysctl -p /etc/sysctl.conf

Community's user avatar

answered Apr 15, 2018 at 6:42

Bhindi's user avatar

BhindiBhindi

1,32411 silver badges15 bronze badges

5

In my case, it was just the privileges that I needed to allow for Redis to accept the incoming request.

So I restarted the Redis service via Homebrew brew services stop redis and brew services start redis and run the Redis server locally redis-server. The command prompt asked me to allow the incoming request and it started working.

answered May 16, 2022 at 10:23

Touseef Murtaza's user avatar

3

in case you are working on a linux machine, also recheck the file and folder permissions of the database.

The db and the path to it can be obtained via:

in redis-cli:

CONFIG GET dir

CONFIG GET dbfilename

and in the commandline ls -l. The permissions for the directory should be 755, and those for the file should be 644. Also, normally redis-server executes as the user redis, therefore its also nice to give the user redis the ownership of the folder by executing sudo chown -R redis:redis /path/to/rdb/folder. This has been elaborated in the answer here.

Community's user avatar

answered Jul 13, 2014 at 18:26

smilee89's user avatar

smilee89smilee89

5035 silver badges9 bronze badges

1

If you’re running MacOS and have recently upgraded to Catalina, you may need to run brew services restart redis as suggested in this issue.

answered Nov 11, 2019 at 5:30

Fush's user avatar

FushFush

2,41920 silver badges19 bronze badges

Thanks everyone for checking the problem, apparently the error was produced during bgsave.

For me, typing config set stop-writes-on-bgsave-error no in a shell and restarting Redis solved the problem.

answered Oct 25, 2013 at 4:45

Salvador Dali's user avatar

Salvador DaliSalvador Dali

209k145 gold badges690 silver badges749 bronze badges

5

Start Redis Server in a directory where Redis has write permissions

The answers above will definitely solve your problem, but here’s what’s actually going on:

The default location for storing the rdb.dump file is ./ (denoting current directory). You can verify this in your redis.conf file. Therefore, the directory from where you start the redis server is where a dump.rdb file will be created and updated.

It seems you have started running the redis server in a directory where redis does not have the correct permissions to create the dump.rdb file.

To make matters worse, redis will also probably not allow you to shut down the server either until it is able to create the rdb file to ensure the proper saving of data.

To solve this problem, you must go into the active redis client environment using redis-cli and update the dir key and set its value to your project folder or any folder where non-root has permissions to save. Then run BGSAVE to invoke the creation of the dump.rdb file.

CONFIG SET dir "/hardcoded/path/to/your/project/folder"
BGSAVE

(Now, if you need to save the dump.rdb file in the directory that you started the server in, then you will need to change permissions for the directory so that redis can write to it. You can search stackoverflow for how to do that).

You should now be able to shut down the redis server. Note that we hardcoded the path. Hardcoding is rarely a good practice and I highly recommend starting the redis server from your project directory and changing the dir key back to./`.

CONFIG SET dir "./"
BGSAVE

That way when you need redis for another project, the dump file will be created in your current project’s directory and not in the hardcoded path’s project directory.

answered Sep 23, 2017 at 19:57

Govind Rai's user avatar

Govind RaiGovind Rai

13.6k9 gold badges68 silver badges81 bronze badges

2

$ redis-cli

config set stop-writes-on-bgsave-error no

According to Redis documentation, this is recommended only if you don’t have RDB snapshots enabled or if you don’t care about data persistence in the snapshots.

«By default Redis will stop accepting writes if RDB snapshots are enabled (at least one save point) and the latest background save failed. This will make the user aware (in a hard way) that data is not persisting on disk properly, otherwise,strong text chances are that no one will notice and some disaster will happen.»

What u should be doing is :

# redis-cli
127.0.0.1:6379> CONFIG SET dir /data/tmp
OK
127.0.0.1:6379> CONFIG SET dbfilename temp.rdb
OK
127.0.0.1:6379> BGSAVE
Background saving started
127.0.0.1:6379>

Please Make sure /data/tmp has enough disk space.

jas's user avatar

jas

10.6k2 gold badges32 silver badges41 bronze badges

answered Mar 4, 2021 at 10:33

Vinayak S.'s user avatar

Vinayak S.Vinayak S.

2342 silver badges7 bronze badges

1

Had encountered this error and was able to figure out from log that the error is because of the disk space not being enough. All the data that was inserted in my case was not needed any longer. So I tried to FLUSHALL. Since redis-rdb-bgsave process was running, it was not allowing to FLUSH the data also. I followed below steps and was able to continue.

  1. Login to redis client
  2. Execute config set stop-writes-on-bgsave-error no
  3. Execute FLUSHALL (Data stored was not needed)
  4. Execute config set stop-writes-on-bgsave-error yes

The process redis-rdb-bgsave was no longer running after the above steps.

answered Sep 4, 2018 at 7:09

RCK's user avatar

RCKRCK

3012 silver badges4 bronze badges

I faced the similar issue, the main reason behind this was the memory(RAM) consumption by redis.
My EC2 machine had 8GB RAM(arounf 7.4 available for consumption)

When my program was running the RAM usage went upto 7.2 GB leaving hardly ~100MB in RAM , this generally triggers the MISCONF Redis error ...

You can determine the RAM consumption using the htop command. Look for the Mem attribute after running htop command. If it shows high consumtion (like in my case it was 7.2GB/7.4GB) It’s better to upgrade the instance’s with larger Memory.
In this scenario using config set stop-writes-on-bgsave-error no will be a disaster for the server and may result in disrupting other services running on the server(if any). So, it better to avoid the config command and UPGRADE YOUR REDIS MACHINE.

FYI: You may need to install htop to make this work : sudo apt-get install htop

One more solution to this can be some other RAM heavy service running on your system, check for other service running on your server/machine/instance and stop it if its not necessary. To check all the services running on your machine use service --status-all

And a suggestion for people directly pasting the config command , please do reasearch a bit and atleast warn the user before using such commands. And as @Rodrigo mentioned in his comment : «It does not look cool to ignore the errors.»

—UPDATE—

YOu can also configure maxmemory and maxmemory-policy to define the behavior of Redis when a specific limit of memory is reached.
For example, if I want to keep the memory limit of 6GB and delete the least recently used keys from the DB to make sure that redis mem usage do not exceed 6GB, then we can set these two parameters (in redis.conf or CONFIG SET command):

maxmemory 6gb
maxmemory-policy allkeys-lru

There are a lot of other values which you can set for these two parameters you can read about this from here: https://redis.io/topics/lru-cache

answered Feb 15, 2019 at 13:57

im_bhatman's user avatar

im_bhatmanim_bhatman

8061 gold badge18 silver badges26 bronze badges

for me

config set stop-writes-on-bgsave-error no

and I reload my mac, it works

answered Aug 15, 2019 at 2:33

wuhaiwei's user avatar

wuhaiweiwuhaiwei

911 silver badge2 bronze badges

A more permanent fix might be to look in /etc/redis/redis.conf around lines 200-250 there are settings for the rdb features, that were not a part of redis back in the 2.x days.

notably

dir ./

can be changed to

dir /home/someuser/redislogfiledirectory

or you could comment out all the save lines, and not worry about persistence. (See the comments in /etc/redis/redis.conf)

Also, don’t forget

service redis-server stop
service redis-server start

answered Sep 19, 2016 at 4:26

Soup Cup's user avatar

Soup CupSoup Cup

1011 silver badge5 bronze badges

1

Nowadays the Redis write-access problems that give this error message to the client re-emerged in the official redis docker containers.

Redis from the official redis image tries to write the .rdb file in the containers /data folder, which is rather unfortunate, as it is a root-owned folder and it is a non-persistent location too (data written there will disappear if your container/pod crashes).

So after an hour of inactivity, if you have run your redis container as a non-root user (e.g. docker run -u 1007 rather than default docker run -u 0), you will get a nicely detailed error msg in your server log (see docker logs redis):

1:M 29 Jun 2019 21:11:22.014 * 1 changes in 3600 seconds. Saving...
1:M 29 Jun 2019 21:11:22.015 * Background saving started by pid 499
499:C 29 Jun 2019 21:11:22.015 # Failed opening the RDB file dump.rdb (in server root dir /data) for saving: Permission denied
1:M 29 Jun 2019 21:11:22.115 # Background saving error

So what you need to do is to map container’s /data folder to an external location (where the non-root user, here: 1007, has write access, such as /tmp on the host machine), e.g:

docker run --rm -d --name redis -p 6379:6379 -u 1007 -v /tmp:/data redis

So it is a misconfiguration of the official docker image (which should write to /tmp not /data) that produces this «time bomb» that you will most likely encounter only in production… overnight over some particularly quiet holiday weekend :/

answered Jun 30, 2019 at 8:52

mirekphd's user avatar

mirekphdmirekphd

3,7002 gold badges31 silver badges48 bronze badges

5

On redis.conf line ~235 let’s try to change config like this

- stop-writes-on-bgsave-error yes
+ stop-writes-on-bgsave-error no

Dharman's user avatar

Dharman

29.2k21 gold badges79 silver badges131 bronze badges

answered Nov 27, 2020 at 12:14

Binh Ho's user avatar

Binh HoBinh Ho

3,1051 gold badge25 silver badges30 bronze badges

1

all of those answers do not explain the reason why the rdb save failed.


as my case, I checked the redis log and found:

14975:M 18 Jun 13:23:07.354 # Background saving terminated by signal 9

run the following command in terminal:

sudo egrep -i -r 'killed process' /var/log/

it display:

/var/log/kern.log.1:Jun 18 13:23:07 10-10-88-16 kernel: [28152358.208108] Killed process 28416 (redis-server) total-vm:7660204kB, anon-rss:2285492kB, file-rss:0kB

that is it! this process(redis save rdb) is killed by OOM killer

refers:

https://github.com/antirez/redis/issues/1886

Finding which process was killed by Linux OOM killer

Community's user avatar

answered Jun 19, 2017 at 3:54

carton.swing's user avatar

carton.swingcarton.swing

1,35714 silver badges12 bronze badges

Yep, this happing because current use does not have the permission to modify the «dump.rdb».

So, instead of creating a new RDB file, You can also give permission to old file(change the ownership of it).

In redis-cli enter:

config get dir

you will get «/usr/local/var/db/redis» (this is the location where redis writes the data)

go to this location using terminal

cd 
cd /usr/local/var/db

Type this command(with our username):

sudo chown -R [username] db

This will change to owner.

This works for me.

answered Jun 11, 2021 at 5:58

krishnkant jaiswal's user avatar

I know this thread is slightly older, but here’s what worked for me when I got this error earlier, knowing I was nowhere near memory limit- both answers were found above.

Hopefully this could help someone in the future if they need it.

  1. Checked CHMOD on dir folder… found somehow the symbolic notation was different. CHMOD dir folder to 755
  2. dbfilename permissions were good, no changes needed
  3. Restarted redis-server
  4. (Should’ve done this first, but ah well) Referenced the redis-server.log and found that the error was the result of access being denied.

Again- unsure how the permissions on the DIR folder got changed, but I’m assuming CHMOD back to 755 and restarting redis-server took care of it as I was able to ping redis server afterwards.

Also- to note, redis did have ownership of the dbfilename and DIR folder.

answered Jun 21, 2020 at 6:14

Dustin's user avatar

I too was facing the same issue. Both the answers (the most upvoted one and the accepted one) just give a temporary fix for the same.

Moreover, the config set stop-writes-on-bgsave-error no is a horrible way to over look this error, since what this option does is stop redis from notifying that writes have been stopped and to move on without writing the data in a snapshot. This is simply ignoring this error.
Refer this

As for setting dir in config in redis-cli, once you restart the redis service, this shall get cleared too and the same error shall pop up again. The default value of dir in redis.conf is ./ , and if you start redis as root user, then ./ is / to which write permissions aren’t granted, and hence the error.

The best way is to set the dir parameter in redis.conf file and set proper permissions to that directory. Most of the debian distributions shall have it in /etc/redis/redis.conf

answered Jun 11, 2018 at 9:03

Mayank Sharma's user avatar

After banging my head through so many SO questions finally —
for me @Axel Advento’ s answer worked but with few extra steps —
I was still facing the permission issues.
I had to switch user to redis, create a new dir in it’s home dir and then set it as redis’s dir.

sudo su - redis -s /bin/bash
mkdir redis_dir
redis-cli CONFIG SET dir $(realpath redis_dir)
exit # to logout from redis user (optional)

answered May 2, 2020 at 5:21

markroxor's user avatar

markroxormarkroxor

5,6282 gold badges33 silver badges43 bronze badges

In case you are using docker/docker-compose and want to prevent redis from writing to file, you can create a redis config and mount into a container

docker.compose.override.yml

  redis:¬
      volumes:¬
        - ./redis.conf:/usr/local/etc/redis/redis.conf¬
      ports:¬
        - 6379:6379¬

You can download the default config from here

in the redis.conf file make sure you comment out these 3 lines

save 900 1
save 300 10
save 60 10000

myou can view more solutions for removing the persistent data here

answered Jun 23, 2019 at 2:05

Nic Wanavit's user avatar

Nic WanavitNic Wanavit

2,0235 gold badges16 silver badges29 bronze badges

Check your Redis log before taking any action. Some of the solutions in this thread may erase your Redis data, so be careful about what you are doing.

In my case, the machine was running out of RAM. This also can happen when there is no more free disk space on the host.

answered Apr 17, 2020 at 22:24

Erfun's user avatar

ErfunErfun

1,0492 gold badges11 silver badges25 bronze badges

1

In my Case the Ubuntu Virtual Machine’s Disk space got Full and that’s why I was getting this Error. After deleting some files from the Disk has Solved the Issue.

answered May 29, 2021 at 17:51

Amar Kumar's user avatar

Amar KumarAmar Kumar

2,1942 gold badges22 silver badges33 bronze badges

I hit this problem while working on a server with AFS disk space because my authentication token had expired, which yielded Permission Denied responses when the redis-server tried to save. I solved this by refreshing my token:

kinit USERNAME_HERE -l 30d && aklog

answered Oct 28, 2017 at 12:44

duhaime's user avatar

duhaimeduhaime

24.5k15 gold badges162 silver badges209 bronze badges

In my case it happened because I just installed redis using the quick way. So redis is not running as root.
I was able to solve this problem by following the instructions under the Installing Redis more properly section of their Quick Start Guide. After doing so, the problem was solved and redis is now running as root. Check it out.

answered Jan 22, 2020 at 7:31

meow2x's user avatar

meow2xmeow2x

1,99624 silver badges27 bronze badges

In my case it was related to disk free space. (you can check it with df -h bash command) when I free some space this error disappeared.

answered Aug 6, 2019 at 6:40

Mohammad Reza Esmaeilzadeh's user avatar

If you are running Redis locally on a windows machine, try to «run as administrator» and see if it works. With me, the problem was that Redis was located in the «Program Files» folder, which restricts permissions by default. As it should.

However, do not automatically run Redis as an administrator You don’t want to grant it more rights that it is supposed to have. You want to solve this by the book.

So, we have been able to quickly identify the problem by running it as an administrator, but this is not the cure. A likely scenario is that you have put Redis in a folder that doesn’t have write rights and as a consequence the DB file is stored in that same location.

You can solve this by opening the redis.windows.conf and to search for the following configuration:

    # The working directory.
    #
    # The DB will be written inside this directory, with the filename specified
    # above using the 'dbfilename' configuration directive.
    #
    # The Append Only File will also be created inside this directory.
    #
    # Note that you must specify a directory here, not a file name.
    dir ./

Change dir ./ to a path you have regular read/write permissions for

You could also just move the Redis folder in it’s entirety to a folder you know has the right permissions.

Aurelio's user avatar

Aurelio

24k9 gold badges58 silver badges63 bronze badges

answered Jun 19, 2018 at 8:54

Pascalculator's user avatar

PascalculatorPascalculator

8701 gold badge10 silver badges17 bronze badges

Restart your redis server.

  • macOS (brew): brew services restart redis.
  • Linux: sudo service redis restart / sudo systemctl restart redis
  • Windows: Windows + R -> Type services.msc, Enter -> Search for Redis then click on restart.

I personally had this issue after upgrading redis with Brew (brew upgrade).
After rebooting the laptop, it immediately worked.

answered Dec 18, 2019 at 12:27

Erowlin's user avatar

12

Using redis-cli, you can stop it trying to save the snapshot:

config set stop-writes-on-bgsave-error no

This is a quick workaround, but if you care about the data you are using it for, you should check to make sure why bgsave failed in first place.

Stephan Vierkant's user avatar

answered Jan 31, 2014 at 15:54

思考zhe's user avatar

思考zhe思考zhe

5,1972 gold badges12 silver badges8 bronze badges

10

In case you encounter the error and some important data cannot be discarded on the running redis instance (problems with permissions for the rdb file or its directory incorrectly, or running out of disk space), you can always redirect the rdb file to be written somewhere else.

Using redis-cli, you can do something like this:

CONFIG SET dir /tmp/some/directory/other/than/var
CONFIG SET dbfilename temp.rdb

After this, you might want to execute a BGSAVE command to make sure that the data will be written to the rdb file. Make sure that when you execute INFO persistence, bgsave_in_progress is already 0 and rdb_last_bgsave_status is ok. After that, you can now start backing up the generated rdb file somewhere safe.

answered Oct 30, 2013 at 3:41

Axel Advento's user avatar

Axel AdventoAxel Advento

2,9753 gold badges24 silver badges32 bronze badges

9

There might be errors during the bgsave process due to low memory. Try this (from redis background save FAQ)

echo 'vm.overcommit_memory = 1' >> /etc/sysctl.conf
sysctl vm.overcommit_memory=1

answered Dec 13, 2013 at 22:37

Chris's user avatar

ChrisChris

1,5121 gold badge12 silver badges19 bronze badges

1

This error occurs because of BGSAVE being failed. During BGSAVE, Redis forks a child process to save the data on disk. Although exact reason for failure of BGSAVE can be checked from logs (usually at /var/log/redis/redis-server.log on linux machines) but a lot of the times BGAVE fails because the fork can’t allocate memory. Many times the fork fails to allocate memory (although the machine has enough RAM available) because of a conflicting optimization by the OS.

As can be read from Redis FAQ:

Redis background saving schema relies on the copy-on-write semantic of fork in modern operating systems: Redis forks (creates a child process) that is an exact copy of the parent. The child process dumps the DB on disk and finally exits. In theory the child should use as much memory as the parent being a copy, but actually thanks to the copy-on-write semantic implemented by most modern operating systems the parent and child process will share the common memory pages. A page will be duplicated only when it changes in the child or in the parent. Since in theory all the pages may change while the child process is saving, Linux can’t tell in advance how much memory the child will take, so if the overcommit_memory setting is set to zero fork will fail unless there is as much free RAM as required to really duplicate all the parent memory pages, with the result that if you have a Redis dataset of 3 GB and just 2 GB of free memory it will fail.

Setting overcommit_memory to 1 says Linux to relax and perform the fork in a more optimistic allocation fashion, and this is indeed what you want for Redis.

Redis doesn’t need as much memory as the OS thinks it does to write to disk, so may pre-emptively fail the fork.

To Resolve this, you can:

Modify /etc/sysctl.conf and add:

vm.overcommit_memory=1

Then restart sysctl with:

On FreeBSD:

sudo /etc/rc.d/sysctl reload

On Linux:

sudo sysctl -p /etc/sysctl.conf

Community's user avatar

answered Apr 15, 2018 at 6:42

Bhindi's user avatar

BhindiBhindi

1,32411 silver badges15 bronze badges

5

In my case, it was just the privileges that I needed to allow for Redis to accept the incoming request.

So I restarted the Redis service via Homebrew brew services stop redis and brew services start redis and run the Redis server locally redis-server. The command prompt asked me to allow the incoming request and it started working.

answered May 16, 2022 at 10:23

Touseef Murtaza's user avatar

3

in case you are working on a linux machine, also recheck the file and folder permissions of the database.

The db and the path to it can be obtained via:

in redis-cli:

CONFIG GET dir

CONFIG GET dbfilename

and in the commandline ls -l. The permissions for the directory should be 755, and those for the file should be 644. Also, normally redis-server executes as the user redis, therefore its also nice to give the user redis the ownership of the folder by executing sudo chown -R redis:redis /path/to/rdb/folder. This has been elaborated in the answer here.

Community's user avatar

answered Jul 13, 2014 at 18:26

smilee89's user avatar

smilee89smilee89

5035 silver badges9 bronze badges

1

If you’re running MacOS and have recently upgraded to Catalina, you may need to run brew services restart redis as suggested in this issue.

answered Nov 11, 2019 at 5:30

Fush's user avatar

FushFush

2,41920 silver badges19 bronze badges

Thanks everyone for checking the problem, apparently the error was produced during bgsave.

For me, typing config set stop-writes-on-bgsave-error no in a shell and restarting Redis solved the problem.

answered Oct 25, 2013 at 4:45

Salvador Dali's user avatar

Salvador DaliSalvador Dali

209k145 gold badges690 silver badges749 bronze badges

5

Start Redis Server in a directory where Redis has write permissions

The answers above will definitely solve your problem, but here’s what’s actually going on:

The default location for storing the rdb.dump file is ./ (denoting current directory). You can verify this in your redis.conf file. Therefore, the directory from where you start the redis server is where a dump.rdb file will be created and updated.

It seems you have started running the redis server in a directory where redis does not have the correct permissions to create the dump.rdb file.

To make matters worse, redis will also probably not allow you to shut down the server either until it is able to create the rdb file to ensure the proper saving of data.

To solve this problem, you must go into the active redis client environment using redis-cli and update the dir key and set its value to your project folder or any folder where non-root has permissions to save. Then run BGSAVE to invoke the creation of the dump.rdb file.

CONFIG SET dir "/hardcoded/path/to/your/project/folder"
BGSAVE

(Now, if you need to save the dump.rdb file in the directory that you started the server in, then you will need to change permissions for the directory so that redis can write to it. You can search stackoverflow for how to do that).

You should now be able to shut down the redis server. Note that we hardcoded the path. Hardcoding is rarely a good practice and I highly recommend starting the redis server from your project directory and changing the dir key back to./`.

CONFIG SET dir "./"
BGSAVE

That way when you need redis for another project, the dump file will be created in your current project’s directory and not in the hardcoded path’s project directory.

answered Sep 23, 2017 at 19:57

Govind Rai's user avatar

Govind RaiGovind Rai

13.6k9 gold badges68 silver badges81 bronze badges

2

$ redis-cli

config set stop-writes-on-bgsave-error no

According to Redis documentation, this is recommended only if you don’t have RDB snapshots enabled or if you don’t care about data persistence in the snapshots.

«By default Redis will stop accepting writes if RDB snapshots are enabled (at least one save point) and the latest background save failed. This will make the user aware (in a hard way) that data is not persisting on disk properly, otherwise,strong text chances are that no one will notice and some disaster will happen.»

What u should be doing is :

# redis-cli
127.0.0.1:6379> CONFIG SET dir /data/tmp
OK
127.0.0.1:6379> CONFIG SET dbfilename temp.rdb
OK
127.0.0.1:6379> BGSAVE
Background saving started
127.0.0.1:6379>

Please Make sure /data/tmp has enough disk space.

jas's user avatar

jas

10.6k2 gold badges32 silver badges41 bronze badges

answered Mar 4, 2021 at 10:33

Vinayak S.'s user avatar

Vinayak S.Vinayak S.

2342 silver badges7 bronze badges

1

Had encountered this error and was able to figure out from log that the error is because of the disk space not being enough. All the data that was inserted in my case was not needed any longer. So I tried to FLUSHALL. Since redis-rdb-bgsave process was running, it was not allowing to FLUSH the data also. I followed below steps and was able to continue.

  1. Login to redis client
  2. Execute config set stop-writes-on-bgsave-error no
  3. Execute FLUSHALL (Data stored was not needed)
  4. Execute config set stop-writes-on-bgsave-error yes

The process redis-rdb-bgsave was no longer running after the above steps.

answered Sep 4, 2018 at 7:09

RCK's user avatar

RCKRCK

3012 silver badges4 bronze badges

I faced the similar issue, the main reason behind this was the memory(RAM) consumption by redis.
My EC2 machine had 8GB RAM(arounf 7.4 available for consumption)

When my program was running the RAM usage went upto 7.2 GB leaving hardly ~100MB in RAM , this generally triggers the MISCONF Redis error ...

You can determine the RAM consumption using the htop command. Look for the Mem attribute after running htop command. If it shows high consumtion (like in my case it was 7.2GB/7.4GB) It’s better to upgrade the instance’s with larger Memory.
In this scenario using config set stop-writes-on-bgsave-error no will be a disaster for the server and may result in disrupting other services running on the server(if any). So, it better to avoid the config command and UPGRADE YOUR REDIS MACHINE.

FYI: You may need to install htop to make this work : sudo apt-get install htop

One more solution to this can be some other RAM heavy service running on your system, check for other service running on your server/machine/instance and stop it if its not necessary. To check all the services running on your machine use service --status-all

And a suggestion for people directly pasting the config command , please do reasearch a bit and atleast warn the user before using such commands. And as @Rodrigo mentioned in his comment : «It does not look cool to ignore the errors.»

—UPDATE—

YOu can also configure maxmemory and maxmemory-policy to define the behavior of Redis when a specific limit of memory is reached.
For example, if I want to keep the memory limit of 6GB and delete the least recently used keys from the DB to make sure that redis mem usage do not exceed 6GB, then we can set these two parameters (in redis.conf or CONFIG SET command):

maxmemory 6gb
maxmemory-policy allkeys-lru

There are a lot of other values which you can set for these two parameters you can read about this from here: https://redis.io/topics/lru-cache

answered Feb 15, 2019 at 13:57

im_bhatman's user avatar

im_bhatmanim_bhatman

8061 gold badge18 silver badges26 bronze badges

for me

config set stop-writes-on-bgsave-error no

and I reload my mac, it works

answered Aug 15, 2019 at 2:33

wuhaiwei's user avatar

wuhaiweiwuhaiwei

911 silver badge2 bronze badges

A more permanent fix might be to look in /etc/redis/redis.conf around lines 200-250 there are settings for the rdb features, that were not a part of redis back in the 2.x days.

notably

dir ./

can be changed to

dir /home/someuser/redislogfiledirectory

or you could comment out all the save lines, and not worry about persistence. (See the comments in /etc/redis/redis.conf)

Also, don’t forget

service redis-server stop
service redis-server start

answered Sep 19, 2016 at 4:26

Soup Cup's user avatar

Soup CupSoup Cup

1011 silver badge5 bronze badges

1

Nowadays the Redis write-access problems that give this error message to the client re-emerged in the official redis docker containers.

Redis from the official redis image tries to write the .rdb file in the containers /data folder, which is rather unfortunate, as it is a root-owned folder and it is a non-persistent location too (data written there will disappear if your container/pod crashes).

So after an hour of inactivity, if you have run your redis container as a non-root user (e.g. docker run -u 1007 rather than default docker run -u 0), you will get a nicely detailed error msg in your server log (see docker logs redis):

1:M 29 Jun 2019 21:11:22.014 * 1 changes in 3600 seconds. Saving...
1:M 29 Jun 2019 21:11:22.015 * Background saving started by pid 499
499:C 29 Jun 2019 21:11:22.015 # Failed opening the RDB file dump.rdb (in server root dir /data) for saving: Permission denied
1:M 29 Jun 2019 21:11:22.115 # Background saving error

So what you need to do is to map container’s /data folder to an external location (where the non-root user, here: 1007, has write access, such as /tmp on the host machine), e.g:

docker run --rm -d --name redis -p 6379:6379 -u 1007 -v /tmp:/data redis

So it is a misconfiguration of the official docker image (which should write to /tmp not /data) that produces this «time bomb» that you will most likely encounter only in production… overnight over some particularly quiet holiday weekend :/

answered Jun 30, 2019 at 8:52

mirekphd's user avatar

mirekphdmirekphd

3,7002 gold badges31 silver badges48 bronze badges

5

On redis.conf line ~235 let’s try to change config like this

- stop-writes-on-bgsave-error yes
+ stop-writes-on-bgsave-error no

Dharman's user avatar

Dharman

29.2k21 gold badges79 silver badges131 bronze badges

answered Nov 27, 2020 at 12:14

Binh Ho's user avatar

Binh HoBinh Ho

3,1051 gold badge25 silver badges30 bronze badges

1

all of those answers do not explain the reason why the rdb save failed.


as my case, I checked the redis log and found:

14975:M 18 Jun 13:23:07.354 # Background saving terminated by signal 9

run the following command in terminal:

sudo egrep -i -r 'killed process' /var/log/

it display:

/var/log/kern.log.1:Jun 18 13:23:07 10-10-88-16 kernel: [28152358.208108] Killed process 28416 (redis-server) total-vm:7660204kB, anon-rss:2285492kB, file-rss:0kB

that is it! this process(redis save rdb) is killed by OOM killer

refers:

https://github.com/antirez/redis/issues/1886

Finding which process was killed by Linux OOM killer

Community's user avatar

answered Jun 19, 2017 at 3:54

carton.swing's user avatar

carton.swingcarton.swing

1,35714 silver badges12 bronze badges

Yep, this happing because current use does not have the permission to modify the «dump.rdb».

So, instead of creating a new RDB file, You can also give permission to old file(change the ownership of it).

In redis-cli enter:

config get dir

you will get «/usr/local/var/db/redis» (this is the location where redis writes the data)

go to this location using terminal

cd 
cd /usr/local/var/db

Type this command(with our username):

sudo chown -R [username] db

This will change to owner.

This works for me.

answered Jun 11, 2021 at 5:58

krishnkant jaiswal's user avatar

I know this thread is slightly older, but here’s what worked for me when I got this error earlier, knowing I was nowhere near memory limit- both answers were found above.

Hopefully this could help someone in the future if they need it.

  1. Checked CHMOD on dir folder… found somehow the symbolic notation was different. CHMOD dir folder to 755
  2. dbfilename permissions were good, no changes needed
  3. Restarted redis-server
  4. (Should’ve done this first, but ah well) Referenced the redis-server.log and found that the error was the result of access being denied.

Again- unsure how the permissions on the DIR folder got changed, but I’m assuming CHMOD back to 755 and restarting redis-server took care of it as I was able to ping redis server afterwards.

Also- to note, redis did have ownership of the dbfilename and DIR folder.

answered Jun 21, 2020 at 6:14

Dustin's user avatar

I too was facing the same issue. Both the answers (the most upvoted one and the accepted one) just give a temporary fix for the same.

Moreover, the config set stop-writes-on-bgsave-error no is a horrible way to over look this error, since what this option does is stop redis from notifying that writes have been stopped and to move on without writing the data in a snapshot. This is simply ignoring this error.
Refer this

As for setting dir in config in redis-cli, once you restart the redis service, this shall get cleared too and the same error shall pop up again. The default value of dir in redis.conf is ./ , and if you start redis as root user, then ./ is / to which write permissions aren’t granted, and hence the error.

The best way is to set the dir parameter in redis.conf file and set proper permissions to that directory. Most of the debian distributions shall have it in /etc/redis/redis.conf

answered Jun 11, 2018 at 9:03

Mayank Sharma's user avatar

After banging my head through so many SO questions finally —
for me @Axel Advento’ s answer worked but with few extra steps —
I was still facing the permission issues.
I had to switch user to redis, create a new dir in it’s home dir and then set it as redis’s dir.

sudo su - redis -s /bin/bash
mkdir redis_dir
redis-cli CONFIG SET dir $(realpath redis_dir)
exit # to logout from redis user (optional)

answered May 2, 2020 at 5:21

markroxor's user avatar

markroxormarkroxor

5,6282 gold badges33 silver badges43 bronze badges

In case you are using docker/docker-compose and want to prevent redis from writing to file, you can create a redis config and mount into a container

docker.compose.override.yml

  redis:¬
      volumes:¬
        - ./redis.conf:/usr/local/etc/redis/redis.conf¬
      ports:¬
        - 6379:6379¬

You can download the default config from here

in the redis.conf file make sure you comment out these 3 lines

save 900 1
save 300 10
save 60 10000

myou can view more solutions for removing the persistent data here

answered Jun 23, 2019 at 2:05

Nic Wanavit's user avatar

Nic WanavitNic Wanavit

2,0235 gold badges16 silver badges29 bronze badges

Check your Redis log before taking any action. Some of the solutions in this thread may erase your Redis data, so be careful about what you are doing.

In my case, the machine was running out of RAM. This also can happen when there is no more free disk space on the host.

answered Apr 17, 2020 at 22:24

Erfun's user avatar

ErfunErfun

1,0492 gold badges11 silver badges25 bronze badges

1

In my Case the Ubuntu Virtual Machine’s Disk space got Full and that’s why I was getting this Error. After deleting some files from the Disk has Solved the Issue.

answered May 29, 2021 at 17:51

Amar Kumar's user avatar

Amar KumarAmar Kumar

2,1942 gold badges22 silver badges33 bronze badges

I hit this problem while working on a server with AFS disk space because my authentication token had expired, which yielded Permission Denied responses when the redis-server tried to save. I solved this by refreshing my token:

kinit USERNAME_HERE -l 30d && aklog

answered Oct 28, 2017 at 12:44

duhaime's user avatar

duhaimeduhaime

24.5k15 gold badges162 silver badges209 bronze badges

In my case it happened because I just installed redis using the quick way. So redis is not running as root.
I was able to solve this problem by following the instructions under the Installing Redis more properly section of their Quick Start Guide. After doing so, the problem was solved and redis is now running as root. Check it out.

answered Jan 22, 2020 at 7:31

meow2x's user avatar

meow2xmeow2x

1,99624 silver badges27 bronze badges

In my case it was related to disk free space. (you can check it with df -h bash command) when I free some space this error disappeared.

answered Aug 6, 2019 at 6:40

Mohammad Reza Esmaeilzadeh's user avatar

If you are running Redis locally on a windows machine, try to «run as administrator» and see if it works. With me, the problem was that Redis was located in the «Program Files» folder, which restricts permissions by default. As it should.

However, do not automatically run Redis as an administrator You don’t want to grant it more rights that it is supposed to have. You want to solve this by the book.

So, we have been able to quickly identify the problem by running it as an administrator, but this is not the cure. A likely scenario is that you have put Redis in a folder that doesn’t have write rights and as a consequence the DB file is stored in that same location.

You can solve this by opening the redis.windows.conf and to search for the following configuration:

    # The working directory.
    #
    # The DB will be written inside this directory, with the filename specified
    # above using the 'dbfilename' configuration directive.
    #
    # The Append Only File will also be created inside this directory.
    #
    # Note that you must specify a directory here, not a file name.
    dir ./

Change dir ./ to a path you have regular read/write permissions for

You could also just move the Redis folder in it’s entirety to a folder you know has the right permissions.

Aurelio's user avatar

Aurelio

24k9 gold badges58 silver badges63 bronze badges

answered Jun 19, 2018 at 8:54

Pascalculator's user avatar

PascalculatorPascalculator

8701 gold badge10 silver badges17 bronze badges

Содержание

  1. RedisError: MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error. #584
  2. Comments
  3. Clients
  4. Memory
  5. Persistence
  6. Stats
  7. Replication
  8. Commandstats
  9. Cluster
  10. Keyspace
  11. Debugging: MISCONF Redis is configured to save RDB snapshots
  12. Override Error in Redis Configuration
  13. Save Redis on Low Memory
  14. Почему Redis меняет свои параметры dir и dbfilename и падает с ошибкой MISCONF Redis is configured to save RDB snapshots?
  15. kapkaev / gist:4619127
  16. MISCONF Redis настроен для сохранения снимков RDB
  17. 18 ответов
  18. запустите сервер Redis в каталоге, где Redis имеет разрешения на запись

RedisError: MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error. #584

Here is the detail from the log:

=== REDIS BUG REPORT START: Cut & paste starting from here === [0/428]
[9701] 18 Jul 02:21:30.542 # Redis 2.9.7 crashed by signal: 11
[9701] 18 Jul 02:21:30.542 # Failed assertion: (:0)
[9701] 18 Jul 02:21:30.542 # — STACK TRACE
/usr/local/bin/redis-server(logStackTrace+0x52)[0x4390d2]
/usr/local/bin/redis-server(dictNext+0x68)[0x4128d8]
/lib/x86_64-linux-gnu/libpthread.so.0(+0xfcb0)[0x7fcdf3a84cb0]
/usr/local/bin/redis-server(dictNext+0x68)[0x4128d8]
/usr/local/bin/redis-server(rdbSave+0x228)[0x4255a8]
/usr/local/bin/redis-server(rdbSaveBackground+0x6f)[0x4257af]
/usr/local/bin/redis-server(serverCron+0x467)[0x414f77]
/usr/local/bin/redis-server(aeProcessEvents+0x1f3)[0x410dd3]
/usr/local/bin/redis-server(aeMain+0x2b)[0x410fbb]
/usr/local/bin/redis-server(main+0x2c4)[0x40fe34]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed)[0x7fcdf36d976d]
/usr/local/bin/redis-server[0x40ff9d]
[9701] 18 Jul 02:21:30.542 # — INFO OUTPUT
[9701] 18 Jul 02:21:30.542 # # Server
redis_version:2.9.7
redis_git_sha1:a2db8e48
redis_git_dirty:1
os:Linux 3.2.0-23-generic x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.6.3
process_id:9701
run_id:5f48a144472ae281c1de68f5b18c8574caf48e49
tcp_port:6379
uptime_in_seconds:231
uptime_in_days:0
lru_clock:37199

Clients

connected_clients:1
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0

Memory

used_memory:4908282496
used_memory_human:4.57G
used_memory_rss:5015216128
used_memory_peak:4908397808
used_memory_peak_human:4.57G
used_memory_lua:30720
mem_fragmentation_ratio:1.02
mem_allocator:jemalloc-3.0.0

Persistence

loading:0
rdb_changes_since_last_save:17534
rdb_bgsave_in_progress:0
rdb_last_save_time:1342549047
rdb_last_bgsave_status:err
rdb_last_bgsave_time_sec:13
rdb_current_bgsave_time_sec:-1
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1

Stats

total_connections_received:4
total_commands_processed:44173
instantaneous_ops_per_sec:0
rejected_connections:0
expired_keys:0
evicted_keys:0
keyspace_hits:9198
keyspace_misses:1520
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:50434

Replication

used_cpu_sys:0.59
used_cpu_user:11.56
used_cpu_sys_children:0.00
used_cpu_user_children:0.00

Commandstats

cmdstat_sadd:calls=6410,usec=14064,usec_per_call=2.19
cmdstat_zadd:calls=3957,usec=19042,usec_per_call=4.81
cmdstat_zscore:calls=364,usec=1363,usec_per_call=3.74
cmdstat_hset:calls=2410,usec=4998,usec_per_call=2.07
cmdstat_hget:calls=4355,usec=5004,usec_per_call=1.15
cmdstat_hmset:calls=6369,usec=50431,usec_per_call=7.92
cmdstat_hmget:calls=5999,usec=10266,usec_per_call=1.71
cmdstat_select:calls=5,usec=5,usec_per_call=1.00
cmdstat_keys:calls=1,usec=1219,usec_per_call=1219.00
cmdstat_multi:calls=4766,usec=1480,usec_per_call=0.31
cmdstat_exec:calls=4766,usec=16059,usec_per_call=3.37
cmdstat_info:calls=5,usec=504,usec_per_call=100.80
cmdstat_watch:calls=4766,usec=4115,usec_per_call=0.86

Cluster

Keyspace

db0:keys=7595100,expires=0
db1:keys=3412,expires=0
hash_init_value: 1342206335

[9701] 18 Jul 02:21:30.542 # — CLIENT LIST OUTPUT
[9701] 18 Jul 02:21:30.542 # addr=127.0.0.1:35864 fd=6 age=231 idle=40 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=info

[9701] 18 Jul 02:21:30.542 # — REGISTERS
[9701] 18 Jul 02:21:30.542 #
RAX:00007bcdd25eef40 RBX:00007fcdf2c5a080
RCX:ff4febb51ed00b65 RDX:000000000000002e
RDI:00007fccc6c09340 RSI:00007fcdbdf25600
RBP:0000000000000000 RSP:00007fff24cc7028
R8 :0000000001f34ce0 R9 :1ed00b74615f6574
R10:73616c09064febb5 R11:00007fcdbdf255f5
R12:0000000000000000 R13:00007fccc6c09340
R14:00007fcdbdf79db0 R15:00000138962c3e94
RIP:00000000004128d8 EFL:0000000000010202
CSGSFS:0000000000000033
[9701] 18 Jul 02:21:30.542 # (00007fff24cc70a0) -> 3037392d706d6574
[9701] 18 Jul 02:21:30.542 # (00007fff24cc7098) -> 0000000000467775
[9701] 18 Jul 02:21:30.542 # (00007fff24cc7090) -> 0000000000000000
[9701] 18 Jul 02:21:30.542 # (00007fff24cc7088) -> 00007fcdbdf25618
[9701] 18 Jul 02:21:30.542 # (00007fff24cc7080) -> 00000001f3000010
[9701] 18 Jul 02:21:30.542 # (00007fff24cc7078) -> 00007fcdf3000198
[9701] 18 Jul 02:21:30.542 # (00007fff24cc7070) -> 0000000000000000
[9701] 18 Jul 02:21:30.542 # (00007fff24cc7068) -> 0000000001f34c00
[9701] 18 Jul 02:21:30.542 # (00007fff24cc7060) -> ccec6b508c3dbb83
[9701] 18 Jul 02:21:30.542 # (00007fff24cc7058) -> 0000000000441490
[9701] 18 Jul 02:21:30.542 # (00007fff24cc7050) -> 0000000000441370
[9701] 18 Jul 02:21:30.542 # (00007fff24cc7048) -> 0000000000441380
[9701] 18 Jul 02:21:30.542 # (00007fff24cc7040) -> 00000000004413a0
[9701] 18 Jul 02:21:30.542 # (00007fff24cc7038) -> 00007fcdf2c10040
[9701] 18 Jul 02:21:30.542 # (00007fff24cc7030) -> 0000000001f34c00
[9701] 18 Jul 02:21:30.542 # (00007fff24cc7028) -> 00000000004255a8
[9701] 18 Jul 02:21:30.542 #
=== REDIS BUG REPORT END. Make sure to include from START to END. ===

The text was updated successfully, but these errors were encountered:

Источник

Debugging: MISCONF Redis is configured to save RDB snapshots

This error occurs because of BGSAVE being failed. A lot of the times BGSAVE fails because the fork can’t allocate memory. Many times the fork fails to allocate memory (although the machine has enough RAM available) because of a conflicting optimization by the OS.

Sometimes Redis will throw out error:

Override Error in Redis Configuration

Using redis-cli , you can stop it trying to save the snapshot:

This is a quick workaround, but if you care about the data you are using it for, you should check to make sure why BGSAVE failed in first place.

This gives a temporary fix to the problem. However, it is a horrible way to over look this error, since what this option does is stop redis from notifying that writes have been stopped and to move on without writing the data in a snapshot. This is simply ignoring this error.

Save Redis on Low Memory

There might be errors during the bgsave process due to low memory.

This error occurs because of BGSAVE being failed. During BGSAVE , Redis forks a child process to save the data on disk. Although exact reason for failure of BGSAVE can be checked from logs (usually at /var/log/redis/redis-server.log on linux machines) but a lot of the times BGSAVE fails because the fork can’t allocate memory. Many times the fork fails to allocate memory (although the machine has enough RAM available) because of a conflicting optimization by the OS.

As can be read from Redis FAQ:

Background saving is failing with a fork() error under Linux even if I’ve a lot of free RAM!

Redis background saving schema relies on the copy-on-write semantic of fork in modern operating systems: Redis forks (creates a child process) that is an exact copy of the parent. The child process dumps the DB on disk and finally exits. In theory the child should use as much memory as the parent being a copy, but actually thanks to the copy-on-write semantic implemented by most modern operating systems the parent and child process will share the common memory pages. A page will be duplicated only when it changes in the child or in the parent. Since in theory all the pages may change while the child process is saving, Linux can’t tell in advance how much memory the child will take, so if the overcommit_memory setting is set to zero fork will fail unless there is as much free RAM as required to really duplicate all the parent memory pages, with the result that if you have a Redis dataset of 3 GB and just 2 GB of free memory it will fail.

Setting overcommit_memory to 1 tells Linux to relax and perform the fork in a more optimistic allocation fashion, and this is indeed what you want for Redis.

Redis doesn’t need as much memory as the OS thinks it does to write to disk, so may pre-emptively fail the fork.

Источник

Почему Redis меняет свои параметры dir и dbfilename и падает с ошибкой MISCONF Redis is configured to save RDB snapshots?

[80927] 24 Jan 07:04:41.643 * 1 changes in 900 seconds. Saving.
[80927] 24 Jan 07:04:41.648 * Background saving started by pid 52245
[52245] 24 Jan 07:04:41.649 # Error moving temp DB file on the final destination: Is a directory
[80927] 24 Jan 07:04:41.748 # Background saving error

Ручками забиваю пути к дампу:

но спустя какое-то время, пути сбиваются снова:

df -h
Filesystem Size Used Avail Capacity Mounted on
/dev/vdisk 6.0G 5G 1.1G 82% /
devfs 1.0k 1.0k 0B 100% /dev

при попытке изменения политики выделения памяти в sysctl под рутом, получаю:
sysctl vm.overcommit=1
vm.overcommit: 0
sysctl: vm.overcommit=1: Operation not permitted
Ответ службы поддержки:

Здравствуйте.
На данной системе виртуализации данный параметр изменить нельзя.

Буду, конечно, переносить проекты на другой сервер. если ничего с падениями поделать нельзя. хотя этот сценарий очень нежелателен..

redis 127.0.0.1:6379> INFO
# Server
redis_version:2.6.12
redis_git_sha1:00000000
redis_git_dirty:0
redis_mode:standalone
os:FreeBSD 8.3-STABLE amd64
arch_bits:64
multiplexing_api:kqueue
gcc_version:4.2.1
process_id:80927
run_id:9f7e6b9b08f49c85f335abe0e21e8d8c4f094d71
tcp_port:6379
uptime_in_seconds:79856
uptime_in_days:0
hz:10
lru_clock:658666

# Clients
connected_clients:1
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0

# Memory
used_memory:1164464
used_memory_human:1.11M
used_memory_rss:1164464
used_memory_peak:1244280
used_memory_peak_human:1.19M
used_memory_lua:31744
mem_fragmentation_ratio:1.00
mem_allocator:libc

# Persistence
loading:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1453621516
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:0
rdb_current_bgsave_time_sec:-1
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok

# Stats
total_connections_received:290
total_commands_processed:1077
instantaneous_ops_per_sec:0
rejected_connections:0
expired_keys:2
evicted_keys:0
keyspace_hits:722
keyspace_misses:36
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:346

# Replication
role:master
connected_slaves:0

# CPU
used_cpu_sys:106.24
used_cpu_user:5.95
used_cpu_sys_children:136.74
used_cpu_user_children:14.78

# Keyspace
db0:keys=1,expires=0
db1:keys=4,expires=3

Источник

kapkaev / gist:4619127

This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters

$ redis-cli
> config set stop-writes-on-bgsave-error no

I checked the Redis logs which lead me to «Can’t save in background: fork: Cannot allocate memory». This in turn lead me to this

Redis background saving schema relies on the copy-on-write semantic of fork in modern operating systems: Redis forks (creates a child process) that is an exact copy of the parent. The child process dumps the DB on disk and finally exits. In theory the child should use as much memory as the parent being a copy, but actually thanks to the copy-on-write semantic implemented by most modern operating systems the parent and child process will share the common memory pages. A page will be duplicated only when it changes in the child or in the parent. Since in theory all the pages may change while the child process is saving, Linux can’t tell in advance how much memory the child will take, so if the overcommit_memory setting is set to zero fork will fail unless there is as much free RAM as required to really duplicate all the parent memory pages, with the result that if you have a Redis dataset of 3 GB and just 2 GB of free memory it will fail.

Setting overcommit_memory to 1 says Linux to relax and perform the fork in a more optimistic allocation fashion, and this is indeed what you want for Redis.

Источник

MISCONF Redis настроен для сохранения снимков RDB

во время записи в Redis ( SET foo bar ) Я получаю следующую ошибку:

MISCONF Redis настроен для сохранения снимков RDB, но в настоящее время не удается сохранить на диске. Команды, которые могут изменять набор данных: нетрудоспособный. Пожалуйста, проверьте журналы Redis для получения подробной информации об ошибке.

в основном я понимаю, что проблема в том, что redis не может сохранять данные на диске, но не знаю, как избавиться от проблема.

и следующий вопрос имеет ту же проблему, она давно заброшена без ответов и, скорее всего, без попыток решить проблему.

18 ответов

в случае, если вы столкнулись с ошибкой, и некоторые важные данные не могут быть отброшены на работающем экземпляре redis (проблемы с разрешениями для rdb файл или его каталог неправильно, или заканчивается дисковое пространство), вы всегда можете перенаправить rdb файл для записи в другом месте.

используя redis-cli , вы можете сделать что-то вроде этого:

после этого вы можете выполнить чтобы убедиться, что данные будут записаны в the . Убедитесь, что при выполнении INFO , bgsave_in_progress уже 0 (либо операция прошла успешно, либо произошла ошибка). После этого вы можете начать резервное копирование сгенерированного rdb файл в безопасном месте.

вы можете остановить его, пытаясь сохранить снимок:

это быстрый обходной путь, но если вы заботитесь о данных, вы используете его для, Вы должны проверить, чтобы убедиться, почему bgsave не удалось в первую очередь.

могут быть ошибки во время процесса bgsave из-за нехватки памяти. Попробуйте это (из redis background save FAQ)

слишком кратко об ответе. откройте терминал и введите следующие команды

если вы работаете на машине linux, также проверьте права доступа к файлам и папкам базы данных.

БД и путь к нему можно получить через:

CONFIG получить dbfilename

и в командной строке ls -l . Разрешения для каталога должны быть 755, а те для файла должны быть 644. Также, как правило, redis-сервер выполняется как пользователь redis , поэтому его также приятно дать пользователю redis владение папкой путем выполнения sudo chown -R redis:redis /path/to/rdb/folder . Это было разработано в ответе здесь.

спасибо всем за проверку проблемы, по-видимому, ошибка была произведена во время bgsave .

для меня, введя config set stop-writes-on-bgsave-error no в оболочке и перезапуск Redis решили проблему.

ответы выше определенно решат вашу проблему, но вот что на самом деле происходит:

папку по умолчанию для хранения и ./ (обозначение текущего каталога). Вы можете проверить это в своем . Поэтому каталог, из которого вы запускаете сервер redis, находится там, где dump.rdb файл будет создан и обновлен.

кажется, вы запустили сервер redis в каталоге, где redis не имеет правильных разрешений для создания .

что еще хуже, redis также, вероятно, не позволит вам закрыть сервер либо до тех пор, пока он не сможет создать файл rdb для обеспечения надлежащего сохранения данных.

чтобы решить эту проблему, вы должны войти в активную клиентскую среду redis, используя redis-cli обновить dir ключ и установите его значение для вашего проекта папка или любая папка, в которой не root имеет разрешения на сохранение. Затем запустите BGSAVE , чтобы вызвать создание .

(теперь, если вы нужно сохранить дамп.файл rdb в каталоге, в котором вы запустили сервер, затем вам нужно будет изменить разрешения для каталога, чтобы redis мог писать в него. Вы можете найти stackoverflow для того, как это сделать).

теперь вы должны иметь возможность закрыть сервер redis. Обратите внимание, что мы жестко путь. Hardcoding редко является хорошей практикой, и я настоятельно рекомендую запустить сервер redis из каталога проекта и изменить dir key back to ./`.

таким образом, когда вам нужно redis для другого проекта, файл дампа будет создан в каталоге текущего проекта, а не в каталоге проекта жестко закодированного пути.

эта ошибка возникает из-за сбоя BGSAVE. Во время BGSAVE Redis разветвляет дочерний процесс для сохранения данных на диске. Хотя точную причину отказа BGSAVE можно проверить из журналов (обычно при /var/log/redis/redis-server.log на машинах с Linux), но много раз БДАЛ не потому, что вилка не может выделить память. Много раз вилка не может выделить память (хотя машина имеет достаточно оперативной памяти) из-за конфликтной оптимизации ОС.

Redis схема сохранения фона зависит от семантики копирования на запись fork в современных операционных системах: Redis forks (создает дочерний процесс), который является точной копией родительского. Дочерний процесс сбрасывает БД на диск и, наконец, завершает работу. Теоретически ребенок должен использовать столько же памяти, сколько и родитель, являющийся копией, но на самом деле благодаря семантике copy-on-write, реализованной большинством современных операционных систем, Родительский и дочерний процесс будет общие страницы памяти. Страница будет дублироваться только при изменении дочернего или родительского элемента. Поскольку теоретически все страницы могут изменяться во время сохранения дочернего процесса, Linux не может заранее сказать, сколько памяти займет ребенок, поэтому, если параметр overcommit_memory установлен в нулевую вилку, произойдет сбой, если не будет столько свободного ОЗУ, сколько требуется, чтобы действительно дублировать все родительские страницы памяти, в результате чего, если у вас есть набор данных Redis 3 ГБ и всего 2 ГБ свободной памяти, потерпеть неудачу.

установка overcommit_memory в 1 говорит Linux, чтобы расслабиться и выполнить вилку в более оптимистичном режиме распределения, и это действительно то, что вы хотите для Redis.

Redis не нужно столько памяти, сколько ОС думает, что это делает для записи на диск, поэтому может упреждающе сбой вилки.

Источник



во время записи в Redis (SET foo bar ) Я получаю следующую ошибку:

MISCONF Redis настроен для сохранения снимков RDB, но в настоящее время
не удается сохранить на диске. Команды, которые могут изменить набор данных
нетрудоспособный. Пожалуйста, проверьте журналы Redis для получения подробной информации об ошибке.

в основном я понимаю, что проблема в том, что redis не может сохранить данные на диске, но понятия не имею, как избавиться от проблема.

также следующий вопрос имеет ту же проблему, он давно заброшен без ответов и, скорее всего, не пытается решить проблему.


564  


18  

18 ответов:

в случае, если вы столкнулись с ошибкой и некоторые важные данные не могут быть отброшены на запущенном экземпляре redis (проблемы с разрешениями для rdb файл или его каталог неправильно, или не хватает места на диске), вы всегда можете перенаправить rdb файл для записи в другом месте.

используя redis-cli, вы можете сделать что-то вроде этого:

CONFIG SET dir /tmp/some/directory/other/than/var
CONFIG SET dbfilename temp.rdb

после этого, вы можете выполнить BGSAVE команда, чтобы убедиться, что данные будут записаны элемент . Убедитесь, что при выполнении INFO,bgsave_in_progress уже 0 (либо операция выполнена успешно или ошибка). После этого вы можете начать резервное копирование сгенерированного rdb файл в безопасном месте.

вы можете остановить его, пытаясь сохранить снимок:

config set stop-writes-on-bgsave-error no

Это быстрый обходной путь, но если вы заботитесь о данных, которые вы используете для него, вы должны проверить, чтобы убедиться, почему bgsave не удалось в первую очередь.

могут быть ошибки во время процесса bgsave из-за нехватки памяти. Попробуйте это (из redis background save FAQ)

echo 'vm.overcommit_memory = 1' >> /etc/sysctl.conf
sysctl vm.overcommit_memory=1

слишком кратко об ответе. откройте терминал и введите следующие команды

redis-cli

и теперь типа

config set stop-writes-on-bgsave-error no

в случае, если вы работаете на машине linux, также проверьте права доступа к файлам и папкам базы данных.

БД и путь к нему можно получить через:

на redis-cli:

CONFIG GET dir

CONFIG получить dbfilename

и в командной строке ls -l. Разрешения для каталога должны быть 755, а те для файла должны быть 644. Кроме того, обычно redis-сервер выполняется как пользователь redis, поэтому его также приятно дать пользователю redis право собственности на папки выполняется sudo chown -R redis:redis /path/to/rdb/folder. Это было разработано в ответе здесь.

спасибо всем за проверку проблемы, по-видимому, ошибка была произведена во время bgsave.

для меня, введя config set stop-writes-on-bgsave-error no в оболочке и перезапуск Redis решили проблему.

запустите сервер Redis в каталоге, где Redis имеет права на запись

ответы выше, безусловно, решить вашу проблему, но вот что на самом деле происходит:

папку по умолчанию для хранения и ./ (обозначение текущего каталога). Вы можете проверить это в своем . Поэтому каталог, из которого вы запускаете сервер redis, находится там, где dump.rdb файл будет создан и обновлен.

кажется, вы запустили сервер redis в каталоге, где redis не имеет правильных разрешений для создания .

что еще хуже, redis также, вероятно, не позволит вам закрыть сервер, пока он не сможет создать файл rdb для обеспечения надлежащего сохранения данных.

чтобы решить эту проблему, необходимо перейти в активную клиентскую среду redis с помощью redis-cli обновить dir ключ и установите его значение для вашего проекта папка или любая папка, в которой не root имеет разрешения на сохранение. Тогда беги BGSAVE, чтобы вызвать создание .

CONFIG SET dir "/hardcoded/path/to/your/project/folder"
BGSAVE

(теперь, если вы нужно сохранить дамп.файл rdb в каталоге, в котором вы запустили сервер, затем вам нужно будет изменить разрешения для каталога, чтобы redis мог писать в него. Вы можете искать stackoverflow для того, как это сделать).

теперь вы должны быть в состоянии выключить сервер redis. Отметим, что мы жестко путь. Жесткое кодирование редко является хорошей практикой, и я настоятельно рекомендую запустить сервер redis из каталога проекта и изменить dir key back to./`.

CONFIG SET dir "./"
BGSAVE

таким образом, когда вам нужен redis для другого проекта, файл дампа будет создан в каталоге вашего текущего проекта, а не в каталоге проекта жестко заданного пути.

эта ошибка возникает из-за сбоя BGSAVE. Во время BGSAVE Redis разветвляет дочерний процесс для сохранения данных на диске. Хотя точную причину сбоя BGSAVE можно проверить из журналов (обычно при /var/log/redis/redis-server.log на машинах с Linux), но много раз БДАЛ не потому, что вилка не может выделить память. Много раз вилка не может выделить память (хотя машина имеет достаточно оперативной памяти) из-за конфликтной оптимизации ОС.

как можно прочитать из Redis FAQ:

схема сохранения фона Redis основана на семантике копирования при записи fork в современных операционных системах: Redis forks (создает дочерний процесс), который является точной копией родительского. Дочерний процесс сбрасывает БД на диск и, наконец, завершает работу. Теоретически ребенок должен использовать столько же памяти, сколько и родитель, являющийся копией, но на самом деле благодаря семантике копирования на запись, реализованной большинством современных операционных систем, Родительский и дочерний процесс будут общие страницы памяти. Страница будет дублироваться только тогда, когда она изменяется в дочернем или родительском элементе. Поскольку в теории все страницы может измениться, в то время как дочерний процесс-это экономия, линукс не могу сказать заранее, сколько памяти ребенка, поэтому если overcommit_memory параметр установлен в ноль вилка будет выполнена, если есть столько свободной оперативной памяти, как это требуется, чтобы действительно дублировать все родительские страниц памяти, поэтому если у вас есть Redis для набора данных 3 ГБ оперативной и всего 2 ГБ свободной памяти это потерпеть неудачу.

установка overcommit_memory в 1 говорит, что Linux расслабляется и выполняет вилку более оптимистичным способом распределения, и это действительно то, что вы хотите для Redis.

Redis не нужно столько памяти, сколько ОС думает, что это делает для записи на диск, так что может упреждающе провалить вилку.

чтобы решить эту проблему, можно:

изменить /etc/sysctl.conf и добавить:

vm.overcommit_memory=1

затем перезапустите sysctl с помощью:

On FreeBSD:

sudo /etc/rc.d/sysctl reload

На Linux:

sudo sysctl -p /etc/sysctl.conf

более постоянным исправлением может быть просмотр в /etc/redis/redis.conf вокруг строк 200-250 есть настройки для функций rdb, которые не были частью redis обратно в 2.х дней.

в частности

dir ./

можно изменить на

dir /home/someuser/redislogfiledirectory

или вы можете закомментировать все строки сохранения,и не беспокоиться о постоянстве. (См. комментарии в /etc / redis / redis.conf)

кроме того, не забывайте

service redis-server stop
service redis-server start

все эти ответы не объясняют причину, по которой не удалось сохранить rdb.


как и в моем случае, я проверил журнал redis и нашел:

14975: M 18 Jun 13: 23: 07.354 # сохранение фона прекращено сигналом 9

выполните следующую команду в терминале:

sudo egrep -i -r 'killed process' /var/log/

дисплей:

/var / log / kern.бревно.1:18 июня 13:23: 07 10-10-88-16 ядро: [28152358.208108] убитый процесс 28416 (redis-сервер) итого-ВМ:7660204kB, Анон-RSS-канал:2285492kB, файл-RSS-канал:0 КБ

что это! этот процесс (redis save rdb) убит убийца ООТ

говорится:

https://github.com/antirez/redis/issues/1886

найти, какой процесс был убит Linux OOM killer

столкнулся с этой ошибкой и смог выяснить из журнала, что ошибка связана с тем, что дискового пространства недостаточно. Все данные, которые были вставлены в моем случае, больше не нужны. Так что я попробовал FLUSHALL. Поскольку процесс redis-rdb-bgsave был запущен, он также не позволял сбросить данные. Я последовал ниже шагов и смог продолжить.

  1. войдите в redis client
  2. выполнить конфигурация установка стоп-пишет-на-bgsave-ошибка нет
  3. выполнить FLUSHALL (сохраненные данные не нужны)
  4. выполнить config set stop-writes-on-bgsave-error yes

процесс redis-rdb-bgsave больше не выполнялся после вышеуказанных шагов.

Как указал @Chris проблема, скорее всего, с низкой памятью. Мы начали испытывать это, когда мы выделили слишком много оперативной памяти для MySQL (innodb_buffer_pool_size).

чтобы обеспечить достаточное количество оперативной памяти для Redis и других услуг, мы сократили innodb_buffer_pool_size на MySQL.

я столкнулся с этой проблемой во время работы на сервере с дисковым пространством AFS, потому что мой токен аутентификации истек, что дало Permission Denied ответы, когда redis-сервер пытался сохранить. Я решил это, обновив свой токен:

kinit USERNAME_HERE -l 30d && aklog

в моем случае причиной было очень мало свободного места на диске (всего 35 Мб). Я сделал следующее —

  1. остановил все связанные с Redis процессы
  2. удалите некоторые файлы на диске, чтобы сделать достаточное свободное пространство
  3. удалить файл дампа redis (если существующие данные не нужны)

    sudo rm /var/lib/redis/*

  4. удалить все ключи из всех существующих баз данных

    sudo redis-cli flushall

  5. перезапустить все задачи сельдерея и проверьте соответствующие журналы для любых проблем

я тоже столкнулся с той же проблемой. Оба ответа (самый популярный и принятый) просто дают временное исправление для того же самого.

кроме того,config set stop-writes-on-bgsave-error no Это ужасный способ просмотреть эту ошибку, так как этот параметр останавливает redis от уведомления о том, что записи были остановлены и двигаться дальше без записи данных в моментальный снимок. Это просто игнорирование этой ошибки.
обратитесь к этому

а dir in config in redis-cli, как только вы перезапустите службу redis, это также будет очищено, и снова появится та же ошибка. Значение по умолчанию dir in redis.conf и ./, и если вы начинаете redis как пользователь root, то ./ и / для которых разрешения на запись не предоставляются, и, следовательно, ошибка.

лучший способ-установить dir параметр в redis.файл conf и установите соответствующие разрешения для этого каталога. Большинство дистрибутивов debian должны иметь его в /etc/redis/redis.conf

Если вы используете Redis локально на машине windows, попробуйте «запустить от имени администратора» и посмотреть, работает ли он. Со мной проблема заключалась в том, что Redis был расположен в папке «Program Files», которая по умолчанию ограничивает разрешения. Как и положено.

, не запускайте Redis автоматически от имени администратора вы не хотите предоставлять ему больше прав, которые он должен иметь. Вы хотите решить это по книге.

Итак, мы смогли быстро выявить проблему, запустив ее от имени администратора, но это не лекарство. Вероятный сценарий заключается в том, что вы поместили Redis в папку, которая не имеет прав на запись, и, как следствие, файл DB хранится в том же месте.

вы можете решить эту проблему путем открытия redis.windows.conf и искать следующую конфигурацию:

# The working directory.
#
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
#
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
dir ./

изменить dir ./ к пути у вас есть регулярные разрешения на чтение / запись для

вы могли также просто переместите папку Redis целиком в папку, которая, как вы знаете, имеет правильные разрешения.

решение для @Govind Rai’, чтобы сохранить дамп.файл rdb в каталоге, в котором вы запустили сервер в’:

щелкните правой кнопкой мыши папку Redis, выберите пункт Свойства, а затем перейдите на вкладку Безопасность.
Нажмите кнопку Изменить, чтобы открыть диалоговое окно разрешения для.

щелкните все пакеты приложений

в поле разрешения для установите флажок Разрешить «полный контроль».

во время записи в Redis (SET foo bar ) Я получаю следующую ошибку:

MISCONF Redis настроен для сохранения снимков RDB, но в настоящее время
не удается сохранить на диске. Команды, которые могут изменять набор данных:
нетрудоспособный. Пожалуйста, проверьте журналы Redis для получения подробной информации об ошибке.

в основном я понимаю, что проблема в том, что redis не может сохранять данные на диске, но не знаю, как избавиться от проблема.

и следующий вопрос имеет ту же проблему, она давно заброшена без ответов и, скорее всего, без попыток решить проблему.

18 ответов


в случае, если вы столкнулись с ошибкой, и некоторые важные данные не могут быть отброшены на работающем экземпляре redis (проблемы с разрешениями для rdb файл или его каталог неправильно, или заканчивается дисковое пространство), вы всегда можете перенаправить rdb файл для записи в другом месте.

используя redis-cli, вы можете сделать что-то вроде этого:

CONFIG SET dir /tmp/some/directory/other/than/var
CONFIG SET dbfilename temp.rdb

после этого вы можете выполнить чтобы убедиться, что данные будут записаны в the . Убедитесь, что при выполнении INFO, bgsave_in_progress уже 0 (либо операция прошла успешно, либо произошла ошибка). После этого вы можете начать резервное копирование сгенерированного rdb файл в безопасном месте.


вы можете остановить его, пытаясь сохранить снимок:

config set stop-writes-on-bgsave-error no

это быстрый обходной путь, но если вы заботитесь о данных, вы используете его для, Вы должны проверить, чтобы убедиться, почему bgsave не удалось в первую очередь.


могут быть ошибки во время процесса bgsave из-за нехватки памяти. Попробуйте это (из redis background save FAQ)

echo 'vm.overcommit_memory = 1' >> /etc/sysctl.conf
sysctl vm.overcommit_memory=1

слишком кратко об ответе. откройте терминал и введите следующие команды

redis-cli

и теперь типа

config set stop-writes-on-bgsave-error no

если вы работаете на машине linux, также проверьте права доступа к файлам и папкам базы данных.

БД и путь к нему можно получить через:

на redis-cli:

CONFIG GET dir

CONFIG получить dbfilename

и в командной строке ls -l. Разрешения для каталога должны быть 755, а те для файла должны быть 644. Также, как правило, redis-сервер выполняется как пользователь redis, поэтому его также приятно дать пользователю redis владение папкой путем выполнения sudo chown -R redis:redis /path/to/rdb/folder. Это было разработано в ответе здесь.


спасибо всем за проверку проблемы, по-видимому, ошибка была произведена во время bgsave.

для меня, введя config set stop-writes-on-bgsave-error no в оболочке и перезапуск Redis решили проблему.


запустите сервер Redis в каталоге, где Redis имеет разрешения на запись

ответы выше определенно решат вашу проблему, но вот что на самом деле происходит:

папку по умолчанию для хранения и ./ (обозначение текущего каталога). Вы можете проверить это в своем . Поэтому каталог, из которого вы запускаете сервер redis, находится там, где dump.rdb файл будет создан и обновлен.

кажется, вы запустили сервер redis в каталоге, где redis не имеет правильных разрешений для создания .

что еще хуже, redis также, вероятно, не позволит вам закрыть сервер либо до тех пор, пока он не сможет создать файл rdb для обеспечения надлежащего сохранения данных.

чтобы решить эту проблему, вы должны войти в активную клиентскую среду redis, используя redis-cli обновить dir ключ и установите его значение для вашего проекта папка или любая папка, в которой не root имеет разрешения на сохранение. Затем запустите BGSAVE, чтобы вызвать создание .

CONFIG SET dir "/hardcoded/path/to/your/project/folder"
BGSAVE

(теперь, если вы нужно сохранить дамп.файл rdb в каталоге, в котором вы запустили сервер, затем вам нужно будет изменить разрешения для каталога, чтобы redis мог писать в него. Вы можете найти stackoverflow для того, как это сделать).

теперь вы должны иметь возможность закрыть сервер redis. Обратите внимание, что мы жестко путь. Hardcoding редко является хорошей практикой, и я настоятельно рекомендую запустить сервер redis из каталога проекта и изменить dir key back to./`.

CONFIG SET dir "./"
BGSAVE

таким образом, когда вам нужно redis для другого проекта, файл дампа будет создан в каталоге текущего проекта, а не в каталоге проекта жестко закодированного пути.


эта ошибка возникает из-за сбоя BGSAVE. Во время BGSAVE Redis разветвляет дочерний процесс для сохранения данных на диске. Хотя точную причину отказа BGSAVE можно проверить из журналов (обычно при /var/log/redis/redis-server.log на машинах с Linux), но много раз БДАЛ не потому, что вилка не может выделить память. Много раз вилка не может выделить память (хотя машина имеет достаточно оперативной памяти) из-за конфликтной оптимизации ОС.

как можно прочитать из Рэдис часто задаваемые вопросы:

Redis схема сохранения фона зависит от семантики копирования на запись fork в современных операционных системах: Redis forks (создает дочерний процесс), который является точной копией родительского. Дочерний процесс сбрасывает БД на диск и, наконец, завершает работу. Теоретически ребенок должен использовать столько же памяти, сколько и родитель, являющийся копией, но на самом деле благодаря семантике copy-on-write, реализованной большинством современных операционных систем, Родительский и дочерний процесс будет общие страницы памяти. Страница будет дублироваться только при изменении дочернего или родительского элемента. Поскольку теоретически все страницы могут изменяться во время сохранения дочернего процесса, Linux не может заранее сказать, сколько памяти займет ребенок, поэтому, если параметр overcommit_memory установлен в нулевую вилку, произойдет сбой, если не будет столько свободного ОЗУ, сколько требуется, чтобы действительно дублировать все родительские страницы памяти, в результате чего, если у вас есть набор данных Redis 3 ГБ и всего 2 ГБ свободной памяти, потерпеть неудачу.

установка overcommit_memory в 1 говорит Linux, чтобы расслабиться и выполнить вилку в более оптимистичном режиме распределения, и это действительно то, что вы хотите для Redis.

Redis не нужно столько памяти, сколько ОС думает, что это делает для записи на диск, поэтому может упреждающе сбой вилки.

чтобы решить эту проблему, можно:

изменить /etc/sysctl.conf и добавить:

vm.overcommit_memory=1

затем перезапустите sysctl с помощью:

на FreeBSD:

sudo /etc/rc.d/sysctl reload

В Linux:

sudo sysctl -p /etc/sysctl.conf

более постоянным исправлением может быть поиск в /etc/redis / redis.conf вокруг строк 200-250 есть настройки для функций rdb,которые не были частью redis в 2.х дней.

в частности

dir ./

можно изменить на

dir /home/someuser/redislogfiledirectory

или вы можете прокомментировать все строки сохранения и не беспокоиться о настойчивости. (См. комментарии в /etc/redis / redis.conf)

кроме того, не забывайте

service redis-server stop
service redis-server start

все эти ответы не объясняют причину, по которой не удалось сохранить rdb.


в моем случае я проверил журнал redis и нашел:

14975: M 18 Jun 13: 23: 07.354 # сохранение фона прекращено сигналом 9

выполните следующую команду в терминале:

sudo egrep -i -r 'killed process' /var/log/

дисплей:

/var / log / kern.бревно.1:Jun 18 13:23: 07 10-10-88-16 ядро: [28152358.208108] убитый процесс 28416 (redis-сервер) итого-ВМ:7660204kB, Анон-RSS-канал:2285492kB, файл-RSS-канал:0 КБ

что это! этот процесс (redis save rdb) убит убийца ООТ

говорится:

https://github.com/antirez/redis/issues/1886

поиск, какой процесс был убит Linux OOM killer



столкнулся с этой ошибкой и смог выяснить из журнала, что ошибка из-за дискового пространства не хватает. Все данные, которые были вставлены в мой случай, больше не нужны. Поэтому я попробовал FLUSHALL. Поскольку процесс redis-rdb-bgsave был запущен, он также не позволял сбросить данные. Я последовал ниже ступеней и смог продолжить.

  1. войдите в клиент redis
  2. выполнить config set stop-writes-on-bgsave-error нет!—7—>
  3. выполнить FLUSHALL (сохраненные данные не были необходимы)
  4. выполнить config set stop-writes-on-bgsave-ошибка да

процесс redis-rdb-bgsave больше не выполнялся после вышеуказанных шагов.


Как указал @Chris, проблема, вероятно, будет с низкой памятью. Мы начали испытывать это, когда мы выделили слишком много ОЗУ MySQL (innodb_buffer_pool_size).

чтобы обеспечить достаточное количество ОЗУ для Redis и других услуг, которые мы сократили innodb_buffer_pool_size на MySQL.

1

автор: Mugoma J. Okomba


Я ударил эту проблему во время работы на сервере с дисковым пространством AFS, потому что мой токен аутентификации истек, что дало Permission Denied ответы, когда redis-сервер пытался сохранить. Я решил это, обновив свой токен:

kinit USERNAME_HERE -l 30d && aklog


в моем случае причиной было очень мало свободного места на диске (всего 35 Мб). Я сделал следующее … —3—>

  1. остановил все связанные с Redis processe
  2. удалить некоторые файлы на диске, чтобы сделать достаточное свободное пространство
  3. удалить файл дампа redis (если существующие данные не нужны)

    sudo rm /var/lib/redis/*

  4. удалить все ключи из всех существующих баз данных

    sudo redis-cli flushall

  5. перезапустить все задачи сельдерея и проверьте соответствующие журналы для любых проблем

я тоже столкнулся с той же проблемой. Оба ответа (самый популярный и принятый) просто дают временное исправление для того же самого.

кроме того,config set stop-writes-on-bgsave-error no Это ужасный способ просмотреть эту ошибку, так как эта опция останавливает redis от уведомления о том, что записи были остановлены и двигаться дальше без записи данных в моментальном снимке. Это просто игнорирование этой ошибки.
передать этот

а dir на config in redis-cli, как только вы перезапустите службу redis, это тоже очистится, и та же ошибка появится снова. Значение по умолчанию dir на redis.conf is ./, и если вы запустите redis как пользователь root, то ./ is / которому не предоставляются разрешения на запись, и, следовательно, ошибка.

лучший способ-установить dir параметр в redis.conf-файл и установите соответствующие разрешения для этого каталога. Большинство дистрибутивов debian должны иметь его в /etc/redis/redis.conf


Если вы используете Redis локально на машине windows, попробуйте «запустить от имени администратора» и посмотреть, работает ли он. Со мной проблема заключалась в том, что Redis был расположен в папке «Program Files», которая по умолчанию ограничивает разрешения. Как надо.

, не запускайте Redis автоматически от имени администратора вы не хотите предоставлять ему больше прав, которые он должен иметь. Вы хотите решить это по книге.

Итак, мы смогли быстро определите проблему, запустив ее как администратор, но это не лекарство. Вероятный сценарий заключается в том, что вы поместили Redis в папку, которая не имеет прав на запись, и, как следствие, файл БД хранится в том же месте.

вы можете решить эту проблему путем открытия redis.windows.conf и искать следующую конфигурацию:

# The working directory.
#
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
#
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
dir ./

изменить dir ./ на пути регулярного чтения/записи для

вы могли также просто переместите папку Redis полностью в папку, у которой, как вы знаете, есть правильные разрешения.


решение для @Govind Rai’, чтобы сохранить дамп.файл rdb в каталоге, в котором вы запустили сервер в’:

щелкните правой кнопкой мыши папку Redis, выберите пункт Свойства и перейдите на вкладку Безопасность.
Нажмите кнопку Изменить, чтобы открыть диалоговое окно разрешения для.

щелкните все пакеты приложений

в поле разрешения для установите флажок Разрешить «полный контроль».


Используя redis-cli , вы можете остановить попытки сохранить снимок:

config set stop-writes-on-bgsave-error no

Это быстрый обходной путь, но если вам важны данные, для которых вы его используете, вы должны сначала выяснить, почему произошел сбой bgsave.

В случае , если вы столкнулись ошибки и некоторые важные данные не могут быть отброшены на экземпляре бегущего Redis (проблемы с разрешениями на rdb файл или его каталог неправильно, или нехватка дискового пространства), вы всегда можете перенаправить rdb файл для записи в другое место.

Используя redis-cli , вы можете сделать что-то вроде этого:

CONFIG SET dir /tmp/some/directory/other/than/var
CONFIG SET dbfilename temp.rdb

После этого вы можете захотеть выполнить команду BGSAVE чтобы убедиться, что данные будут записаны в файл rdb . Убедитесь, что при выполнении INFO persistence bgsave_in_progress уже равно 0 а rdb_last_bgsave_status равно ok . После этого вы можете начать резервное копирование сгенерированного файла rdb безопасном месте.

Перезагрузите сервер Redis.

  • macOS (варить) : brew services restart redis .
  • Linux: sudo service redis restart / sudo systemctl restart redis
  • Windows: Windows + R -> Введите services.msc , Enter -> Найдите Redis затем нажмите restart .

У меня лично возникла эта проблема после обновления Redis с помощью Brew ( brew upgrade ). После перезагрузки ноута сразу заработало.

Во время процесса bgsave могут возникнуть ошибки из-за нехватки памяти. Попробуйте это (из FAQ по сохранению фона Redis)

echo 'vm.overcommit_memory = 1' >> /etc/sysctl.conf
sysctl vm.overcommit_memory=1

Эта ошибка возникает из-за сбоя BGSAVE. Во время BGSAVE Redis создает дочерний процесс для сохранения данных на диске. Хотя точную причину сбоя BGSAVE можно проверить из журналов (обычно по адресу /var/log/redis/redis-server.log на Linux-машинах), но в большинстве случаев BGAVE дает сбой, потому что вилка не может выделить память. Часто вилка не может выделить память (хотя на машине достаточно оперативной памяти) из-за конфликтующей оптимизации ОС.

Как можно прочитать в FAQ по Redis :

Схема фонового сохранения Redis основана на семантике копирования при записи fork в современных операционных системах: Redis выполняет форк (создает дочерний процесс), который является точной копией родительского процесса. Дочерний процесс выгружает БД на диск и, наконец, завершает свою работу. Теоретически дочерний процесс должен использовать столько памяти, сколько родительский процесс является копией, но на самом деле благодаря семантике копирования при записи, реализованной в большинстве современных операционных систем, родительский и дочерний процессы будут совместно использовать общие страницы памяти. Страница будет дублироваться только при ее изменении в дочернем или родительском. Поскольку теоретически все страницы могут изменяться во время сохранения дочернего процесса, Linux не может заранее сказать, сколько памяти займет дочерний процесс, поэтому, если для параметра overcommit_memory установлено значение 0, вилка завершится ошибкой, если не будет столько свободной оперативной памяти, сколько требуется, чтобы действительно дублировать все родительские страницы памяти, в результате чего, если у вас есть набор данных Redis размером 3 ГБ и всего 2 ГБ свободной памяти, он выйдет из строя.

Установка overcommit_memory на 1 говорит Linux, что нужно расслабиться и выполнить форк более оптимистично, и это действительно то, что вам нужно для Redis.

Redis не требует столько памяти, сколько думает ОС, для записи на диск, поэтому может превентивно выйти из строя форк.

Чтобы решить эту проблему, вы можете:

Измените /etc/sysctl.conf и добавьте:

vm.overcommit_memory=1

Затем перезапустите sysctl с помощью:

На FreeBSD:

sudo /etc/rc.d/sysctl reload

В Linux:

sudo sysctl -p /etc/sysctl.conf

Если вы работаете на Linux-машине, также перепроверьте права доступа к файлам и папкам в базе данных.

БД и путь к нему можно получить через:

в redis-cli :

КОНФИГУРАЦИЯ ПОЛУЧИТЬ каталог

КОНФИГУРАЦИЯ ПОЛУЧИТЬ dbfilename

и в командной строке ls -l . Разрешения для каталога должны быть 755 , а для файла должны быть 644 . Кроме того, обычно redis-server выполняется от имени пользователя redis , поэтому также неплохо предоставить пользователю redis право владения папкой, выполнив sudo chown -R redis:redis /path/to/rdb/folder . Это подробно описано в ответе здесь .

Спасибо всем за проверку проблемы, по всей видимости, ошибка возникла во время bgsave .

Для меня набор config set stop-writes-on-bgsave-error no в оболочке и перезапуск Redis решил проблему.

Запустите Redis Server в каталоге, в котором Redis имеет права на запись.

Приведенные выше ответы определенно решат вашу проблему, но вот что происходит на самом деле:

Расположение по умолчанию для хранения файла rdb.dump./ (обозначает текущий каталог). Вы можете проверить это в своем файле redis.conf . Следовательно, каталог, из которого вы запускаете сервер Redis, — это то место, где будет создан и обновлен файл dump.rdb .

Похоже, вы запустили сервер Redis в каталоге, где у Redis нет необходимых разрешений для создания файла dump.rdb .

Что еще хуже, redis также, вероятно, не позволит вам выключить сервер до тех пор, пока он не сможет создать файл rdb для обеспечения надлежащего сохранения данных.

Чтобы решить эту проблему, вы должны войти в активную клиентскую среду Redis с помощью redis-cli и обновить ключ dir и установить его значение в папку вашего проекта или любую папку, где у пользователя без полномочий root есть разрешения на сохранение. . Затем запустите BGSAVE чтобы вызвать создание файла dump.rdb .

CONFIG SET dir "/hardcoded/path/to/your/project/folder"
BGSAVE

(Теперь, если вам нужно сохранить файл dump.rdb в каталоге, в котором вы запустили сервер, вам нужно будет изменить разрешения для этого каталога, чтобы redis мог писать в него. Вы можете найти в stackoverflow, как это сделать ).

Теперь вы можете выключить сервер Redis. Обратите внимание, что мы жестко запрограммировали путь. Жесткое кодирование редко бывает хорошей практикой, и я настоятельно рекомендую запустить сервер Redis из каталога вашего проекта и изменить dir key back to . / `.

CONFIG SET dir "./"
BGSAVE

Таким образом, когда вам понадобится redis для другого проекта, файл дампа будет создан в каталоге вашего текущего проекта, а не в каталоге проекта с жестко заданным путем.

Обнаружил эту ошибку и смог выяснить из журнала, что ошибка связана с нехваткой места на диске. Все данные, которые были вставлены в моем случае, больше не понадобились. Так что я попытался ПРОМЫТЬ. Поскольку процесс redis-rdb-bgsave был запущен, он также не позволял ПРОМЫВАТЬ данные. Я выполнил следующие шаги и смог продолжить.

  1. Войдите в клиент Redis
  2. Выполнить набор конфигурации stop-write-on-bgsave-error no
  3. Выполнить FLUSHALL (сохраненные данные не нужны)
  4. Выполнить набор настроек stop-write-on-bgsave-error да

После вышеуказанных шагов процесс redis-rdb-bgsave больше не выполнялся.

Если вы используете MacOS и недавно обновились до Catalina, вам может потребоваться запустить brew services restart redis как предлагается в этом выпуске .

Теги:  redis  redis

Информация об ошибке

1. Подключите Redis

Подключите удаленное

redis-cli -h host -p port -a password

Хост: remote Redis Server Host

 Порт: сервисный порт удаленного Redis

 Пароль: пароль службы удаленного Redis (если нет пароля, он не требует -А параметров)

Подключитесь к локальной области, введите каталог Bin Redis, выполнить

redis-cli

2. Исполнение

config set stop-writes-on-bgsave-error no

Заканчивать


Интеллектуальная рекомендация

KVC начинается с комментариев файла заголовка

1. Введение В статьях про KVC (key-value coding) можно сказать, что улицы гнилые и гнилые. Более того, об этом я люблю спрашивать на собеседовании. Не знаю почему, возможно, у меня слишком плохая техн…

8.3 Возвращаемое значение

Функция не всегда отображает вывод напрямую, наоборот, она может обрабатывать некоторые данные и возвращать значение или набор значений. Значение, возвращаемое функцией, называется возвращаемым значен…

Вам также может понравиться

2018-05-30-Django-04 шаблон шаблона

Django шаблон этикетки Очки знаний: Основные понятия Обычная этикетка Пример этикеток шаблона Наследование и приложение шаблона Примечания тег Метка шаблона Этикетки обеспечивают любую логику во время…

MySQL основные команды

Создать нового пользователя   Обновить таблицу системных разрешений   Авторизуйте минимального пользователя, чтобы иметь все разрешения для базы данных дерева   Удалить пользователя &nb…

Статьи по теме

  • Android Studio импортирует старый проект AAPT2 ошибка: проверьте журналы для получения подробной информации об ошибке
  • Решение — MISCONF Redis настроен для сохранения снимков RDB, но в настоящее время не может быть сохранен на диске. Команды, которые могут изменить набор данных, отключены. Пожалуйста, проверьте журналы Redis для деталей об ошибке.
  • Запишите ошибку Redis RDB, вызванные исключением службы
  • (Ошибка) misconf redis настроен для сохранения снимков RDB …
  • Ошибка отчета об исключении Redis
  • Redis RDB постоянство подробно
  • MISCONF Redis настроен для сохранения снимков RDB, но … (Redis сообщил об ошибке)
  • Ошибка redis #misconf redis настроен для сохранения снимков RDB, но в настоящее время не
  • Springboot работает Redis ошибка misconf redis, чтобы сохранить снимки RDB
  • Redis написан (ошибка) misconf redis настроен для сохранения снимков RDB

популярные статьи

  • Ext.ajax.request синхронное реализация запроса
  • Данные MySQL для команд экспорта и импорта
  • Facebook с открытым исходным исходным кодом Спектр обработки изображений, оптимизация генерации мобильных изображений
  • Разработка Hive UDTF
  • Используйте Petalinux для записи диска
  • SpringCloud (6) шлюз прокси
  • 25VUE — Выход Функции
  • [Запись ошибок] дети должны быть ключами
  • И проверить + сегментное дерево сегмента LA 4730 Королевство
  • MySQL CREATE_TIME/UPDATE_TIME Автоматически создает/обновление

рекомендованная статья

  • C # первая яма
  • Docker Реестр Docker Learning
  • Идея создает проект Javaee и настраивает Tomcat (подробный графический учебник)
  • Динамическое планирование_ ракета перехвата
  • AUGUI MASKALEGRAPHIC Анализ исходного кода, RETTEMASK2D и маска
  • Используйте командную строку для просмотра цены зашифрованной валюты, такой как биткойн с командной строкой | Linux China
  • Node.js——HTTP
  • Торговый центр: заказ
  • Пользовательский компонент
  • Меч относится к предложению — количество массив — наименьшее число

Связанные теги

  • MISCONF Redis настроен для сохранения снимков RDB, но в настоящее время не может
  • Cannot connect to redis
  • MISCONF Redis is configured to save
  • redis
  • жесткий диск
  • база данных
  • ubuntu
  • Redis
  • Springboot
  • Продолжительная ошибка

Я использую Centos 6.9. Я установил Redis с помощью yum:

sudo yum update

sudo yum install redis

Ошибок при установке не выдавало.

Я могу запустить Redis, используя redis-cli. Это дает мне подсказку, как и ожидалось:

127.0.0.1:6379>

Однако всякий раз, когда я выдаю команды (например, PING или SET foo bar), появляется следующее сообщение об ошибке:

(ошибка) MISCONF Redis настроен на сохранение снимков RDB, но в настоящее время не может сохраняться на диске. Команды, которые могут изменять набор данных, отключены. Пожалуйста, проверьте журналы Redis для получения подробной информации об ошибке.

Я обнаружил, что MISCONF Redis настроен на сохранение моментальных снимков RDB . и прошел через это, но ни один из советов там не работает.

Принятый ответ на приведенный выше вопрос заключался в использовании CONFIG SET для изменения каталога, в котором Redis хранил данные. Я попробовал это в некорневом каталоге CONFIG SET dir /home/andy, но все равно выдает то же сообщение об ошибке.

Если я выполняю BGSAVE, он говорит: «Началось фоновое сохранение», но затем попытка SET foo bar возвращает меня к ошибке, указанной выше.

В других ответах обсуждалось, что это проблема разрешений. Однако я не понимаю, как это применимо, потому что я пытался запустить Redis как root, так и под своей учетной записью (andy), и происходит то же самое.

Я не уверен, что это та же проблема, что описана в ссылке, или что-то еще.

Как я могу диагностировать это дальше? Я разработчик PHP по профессии, поэтому это не моя область знаний, однако я пытаюсь установить Redis, чтобы использовать его с приложением PHP, которое имеет собственный интерфейс для Redis.

3 ответа

Похоже, что установка yum создает пользователя redis, и ваш экземпляр Redis запускается этим пользователем. Таким образом, даже если вы установите для dir значение /home/andy, этот пользователь redis по-прежнему не имеет разрешения на запись в домашний каталог andy.

Используйте ps aux |grep redis, чтобы получить пользователя, который работает с Redis, и настройте dir в каталог, для которого у этого пользователя есть разрешение на запись.


1

for_stack
25 Июл 2018 в 12:57

Я решил проблему, выполнив следующие команды:

$ redis-cli
> config set stop-writes-on-bgsave-error no


-1

officialrahulmandal
19 Ноя 2020 в 00:39

Быстрое исправление этой ошибки: перейдите к redis-cli и установите следующее

127.0.0.1:6379> config set stop-writes-on-bgsave-error no

Выше, как просто игнорировать его


0

Gaurav Patil
10 Авг 2021 в 08:33

# By default Redis will stop accepting writes if RDB snapshots are enabled
# (at least one save point) and the latest background save failed.
# This will make the user aware (in a hard way) that data is not persisting
# on disk properly, otherwise chances are that no one will notice and some
# disaster will happen.
#
# If the background saving process will start working again Redis will
# automatically allow writes again.
#
# However if you have setup your proper monitoring of the Redis server
# and persistence, you may want to disable this feature so that Redis will
# continue to work as usual even if there are problems with disk,
# permissions, and so forth.   
stop-writes-on-bgsave-error no

Возможно, вам также будет интересно:

  • Пожалуйста при входе одевайте бахилы ошибки
  • Пожалуйста повторите попытку еще раз возникла ошибка при проведении операции
  • Пожалуйста оденьте бахилы какая лексическая ошибка
  • Пожалуйста исправьте указанные ниже ошибки
  • Поезд прибыл на станцию согласно расписанию где ошибка

  • Понравилась статья? Поделить с друзьями:
    0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии