This article is a mirror article of machine translation, please click here to jump to the original article.

View: 47166|Reply: 1

[Source] Redis MISCONF Redis is configured to save RDB snapshots

[Copy link]
Posted on 2021-5-14 21:18:50 | | | |
Using StackExchange.Redis to manipulate the redis cache, the error is as follows:

StackExchange.Redis.RedisServerException: 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.

Temporary solution, modify the redis.windows.conf file,The Redis service needs to be restarted, set as follows:
If you don't want to restart the Redis service, you can use the redis-cli command to set it up as follows:



The explanation is as follows:
# 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.
Simply put: Redis needs to fork a main process in order to avoid the main process from faking death when saving data to the hard disk, and then complete the operation of saving data to the hard disk in the fork process, if the main process uses 4GB of memory, an additional 4GB is needed when the fork sub-process is needed, at this time the memory is not enough, the fork fails, and then the data saving hard disk also fails.

To view the redis logs, you need to configure redis.windows.conf as follows:

# Specify the log file name. Also 'stdout' can be used to force
# Redis to log on the standard output.
logfile "E:/Redis-x64-3.2.100/redis.txt"

The log exceptions are as follows:

[8984] 14 May 14:05:09.060 * Background saving started by pid 8672
[8672] 14 May 14:05:09.169 #
The Windows version of Redis reserves heap memory from the system paging file
for sharing with the forked process used for persistence operations. At this time there is insufficient contiguous free space available in the
system paging file. You may increase the size of the system paging file.
Sometimes a reboot will defragment the system paging file sufficiently for
this operation to complete successfully.

Redis can not continue. Exiting.
[8984] 14 May 14:05:09.278 # fork operation failed



After analysis, it turned out that the problem with the maximum heap size "maxheap" configuration was due to insufficient available memory.

Solution

Open Redis' configuration file "redis.windows.conf" and find the following code section:


# The Redis heap must be larger than the value specified by the maxmemory
# flag, as the heap allocator has its own memory requirements and
# fragmentation of the heap is inevitable. If only the maxmemory flag is
# specified, maxheap will be set at 1.5*maxmemory. If the maxheap flag is
# specified along with maxmemory, the maxheap flag will be automatically
# increased if it is smaller than 1.5*maxmemory.
#  
# maxheap <bytes>

Adding this setting is good,The Redis service fails to start!!!!!!!
The default value is: maxheap 1024000000≈976.56M

I didn't find this comment in the conf file, I found something like this:
# Don't use more memory than the specified amount of bytes.
# When the memory limit is reached Redis will try to remove keys
# according to the eviction policy selected (see maxmemory-policy).
#
# If Redis can't remove keys according to the policy, or if the policy is
# set to 'noeviction', Redis will start to reply with errors to commands
# that would use more memory, like SET, LPUSH, and so on, and will continue
# to reply to read-only commands like GET.
#
# This option is usually useful when using Redis as an LRU cache, or to set
# a hard memory limit for an instance (using the 'noeviction' policy).
#
# WARNING: If you have slaves attached to an instance with maxmemory on,
# the size of the output buffers needed to feed the slaves are subtracted
# from the used memory count, so that network problems / resyncs will
# not trigger a loop where keys are evicted, and in turn the output
# buffer of slaves is full with DELs of keys evicted triggering the deletion
# of more keys, and so forth until the database is completely emptied.
#
# In short... if you have slaves attached it is suggested that you set a lower
# limit for maxmemory so that there is some free RAM on the system for slave
# output buffers (but this is not needed if the policy is 'noeviction').
#
# WARNING: not setting maxmemory will cause Redis to terminate with an
# out-of-memory exception if the heap limit is reached.
#
# NOTE: since Redis uses the system paging file to allocate the heap memory,
# the Working Set memory usage showed by the Windows Task Manager or by other
# tools such as ProcessExplorer will not always be accurate. For example, right
# after a background save of the RDB or the AOF files, the working set value
# may drop significantly. In order to check the correct amount of memory used
# by the redis-server to store the data, use the INFO client command. The INFO
# command shows only the memory used to store the redis data, not the extra
# memory used by the Windows process for its own requirements. Th3 extra amount
# of memory not reported by the INFO command can be calculated subtracting the
# Peak Working Set reported by the Windows Task Manager and the used_memory_peak
# reported by the INFO command.
#
# maxmemory <bytes>

Warning: If the heap limit is reached, not setting maxmemory will cause Redis to terminate with an out-of-memory exception.

Note: Due toRedis uses system paging files to allocate heap memory

Windows Task Manager or other tools like ProcessExplorer don't always show accurate workset memory usage. In simple terms,The memory usage shown by Task Manager is not accurate!!!

Use the info command to query as follows:

# Memory
used_memory:2011338768
used_memory_human:1.87G
used_memory_rss:2011279992
used_memory_rss_human:1.87G
used_memory_peak:2011338768
used_memory_peak_human:1.87G
total_system_memory:0
total_system_memory_human:0B
used_memory_lua:37888
used_memory_lua_human:37.00K
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
mem_fragmentation_ratio:1.00
mem_allocator:jemalloc-3.6.0



The settings are as follows:

1073741824 bytes = 1G
After the setting, the redis .net client adds a cache error as follows:

OOM command not allowed when used memory > 'maxmemory'.
# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
# is reached. You can select among five behaviors:
#
# volatile-lru -> remove the key with an expire set using an LRU algorithm
# allkeys-lru -> remove any key according to the LRU algorithm
# volatile-random -> remove a random key with an expire set
# allkeys-random -> remove a random key, any key
# volatile-ttl -> remove the key with the nearest expire time (minor TTL)
# noeviction -> don't expire at all, just return an error on write operations
#
# Note: with any of the above policies, Redis will return an error on write
#       operations, when there are no suitable keys for eviction.
#
#       At the date of writing these commands are: set setnx setex append
#       incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd
#       sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby
#       zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby
#       getset mset msetnx exec sort
#
# The default is:
#
# maxmemory-policy noeviction
#MAXMEMORY策略: When MAXMEMORY

#到达. You can choose from five behaviors:

#

#volatile LRU-> uses the LRU algorithm to remove keys with expire sets

#allkeys LRU-> delete any key according to the LRU algorithm

#volatile random - > remove random keys with expired sets

#allkeys random-> delete random keys, arbitrary keys

#volatile TTL-> Delete the key with the nearest expiration time (Minor TTL)

#noeviction-> does not expire at all, only returns write operation errors

#

#注意: For any of the above strategies, Redis returns an error on write

#操作, when there is no suitable key for eviction.

#

#在编写之日, these commands are: set setnx setex append

#递增递减rpush lpushx lpushx linsert lset rpoplpush sadd

#烧结店sunion sunionstore sdiff sdiffstore zadd zincrby

#zunionstore Zinterstore Hset Hsetnx HMSET Hincrby Incrby Decrby

#getset mset msetnx exec sorting

#

#默认值为:

#

#maxmemory策略无效
You also need to set up the following configurations:

The default redis setting is very conservative, that is, it is not stored after the memory limit is exceeded, and the policy can be changed to the LRU algorithm (the least used algorithm recently) - the newly stored information will replace the old information.

Review:

Redis Persistence Difference Between RDB and AOF
https://www.itsvse.com/thread-9555-1-1.html

The Docker installation runs the Redis cache
https://www.itsvse.com/thread-8995-1-1.html

Examples explain what Redis cache penetration, cache avalanche, and cache breakdown are
https://www.itsvse.com/thread-8968-1-1.html

redis wildcards to delete keys in bulk
https://www.itsvse.com/thread-7957-1-1.html

CentOS 7 installation Redis 5.0.3 tutorial
https://www.itsvse.com/thread-7201-1-1.html

Install the redis extension under php 5.5.7 under CentOS
https://www.itsvse.com/thread-7200-1-1.html

How many keys can be stored in a redis instance, and what are the maximum keys and values?
https://www.itsvse.com/thread-6848-1-1.html

The issue of redis Chinese cannot be displayed properly
https://www.itsvse.com/thread-5032-1-1.html

Redis enables remote access
https://www.itsvse.com/thread-5011-1-1.html

Windows fails to start the Redis service, error 1067: Process terminates unexpectedly.
https://www.itsvse.com/thread-5010-1-1.html

CentOS installed Redis 4.0.8
https://www.itsvse.com/thread-4614-1-1.html

Redis sets up remote connection and access passwords
https://www.itsvse.com/thread-4101-1-1.html

redis empties the data cache
https://www.itsvse.com/thread-4027-1-1.html

redis persistence configuration and off persistence
https://www.itsvse.com/thread-4012-1-1.html

The difference between save and bgsave in redis
https://www.itsvse.com/thread-4010-1-1.html

Redis two persistence methods and principles
https://www.itsvse.com/thread-4009-1-1.html

Redis has three ways to start
https://www.itsvse.com/thread-4008-1-1.html

Redis method of hiding command-line windows
https://www.itsvse.com/thread-2988-1-1.html

Redis Hash Hash Hash Value Problem
https://www.itsvse.com/thread-2587-1-1.html

5 Things You Must Know Before Using Redis
https://www.itsvse.com/thread-2580-1-1.html

Redis modifies the default port number and sets the access password
https://www.itsvse.com/thread-2577-1-1.html

Redis windows 64-bit download, official download address
https://www.itsvse.com/thread-2576-1-1.html

Redis uses Lua scripts for detailed explanations
https://www.itsvse.com/thread-9634-1-1.html

Redis Benchmark performance test
https://www.itsvse.com/thread-9645-1-1.html

(End)






Previous:NPOI judgment of cell date type
Next:NPOI Operation Excel Detailed Explanation
 Landlord| Posted on 2023-7-12 21:08:55 |
Redis memory eight elimination strategies
https://www.itsvse.com/thread-10626-1-1.html
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com