redis數據庫寫入數據時提示redis.exceptions.ResponseError錯誤


今天運行Django項目在redis數據庫寫入數據時提示如下錯誤:

ERROR log 228 Internal Server Error: /image_code/cf9ccd75-d274-45c0-94a4-a83c8c189965/
Traceback (most recent call last):
  File "/home/sky/.virtualenvs/dj_xm31/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/sky/.virtualenvs/dj_xm31/lib/python3.6/site-packages/django/core/handlers/base.py", line 126, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/sky/.virtualenvs/dj_xm31/lib/python3.6/site-packages/django/core/handlers/base.py", line 124, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/sky/code/djxm31/xm31/dj13/dj13/apps/verifications/views.py", line 14, in image_code
    redis_conn.setex('img_{}'.format(img_id).encode('utf8'),300,text)
  File "/home/sky/.virtualenvs/dj_xm31/lib/python3.6/site-packages/redis/client.py", line 1787, in setex
    return self.execute_command('SETEX', name, time, value)
  File "/home/sky/.virtualenvs/dj_xm31/lib/python3.6/site-packages/redis/client.py", line 878, in execute_command
    return self.parse_response(conn, command_name, **options)
  File "/home/sky/.virtualenvs/dj_xm31/lib/python3.6/site-packages/redis/client.py", line 892, in parse_response
    response = connection.read_response()
  File "/home/sky/.virtualenvs/dj_xm31/lib/python3.6/site-packages/redis/connection.py", line 752, in read_response
    raise response
redis.exceptions.ResponseError: MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error.
ERROR basehttp 154 "GET /image_code/cf9ccd75-d274-45c0-94a4-a83c8c189965/ HTTP/1.1" 500 89760


原因
強制關閉Redis快照導致不能持久化。

解決方案
將stop-writes-on-bgsave-error設置為no

(dj14) sky@py:~$ redis-cli 
127.0.0.1:6379> config set stop-writes-on-bgsave-error no
OK
127.0.0.1:6379>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM