おそらくcapistranoでデプロイしてから、サイトからzipファイルをダウンロードする際に以下のエラーが出るようになりました。
##エラーメッセージ全文
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.
##環境
macOS High Sierra(バージョン10.13.6)
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin17]
Rails 4.2.6
##試したこと
/usr/local/redis-3.2.5/redis.confには以下の設定がされていました。
# /usr/local/redis-3.2.5/redis.conf bind 127.0.0.1 protected-mode yes port 6379 tcp-backlog 511 timeout 0 tcp-keepalive 300 daemonize no supervised no pidfile /var/run/redis_6379.pid loglevel notice logfile "" databases 16 stop-writes-on-bgsave-error yes rdbcompression yes rdbchecksum yes dbfilename dump.rdb dir ./ slave-serve-stale-data yes slave-read-only yes repl-diskless-sync no repl-diskless-sync-delay 5 repl-disable-tcp-nodelay no slave-priority 100 appendonly no appendfilename "appendonly.aof" appendfsync everysec no-appendfsync-on-rewrite no auto-aof-rewrite-percentage 100 auto-aof-rewrite-min-size 64mb aof-load-truncated yes lua-time-limit 5000 slowlog-log-slower-than 10000 slowlog-max-len 128 latency-monitor-threshold 0 notify-keyspace-events "" hash-max-ziplist-entries 512 hash-max-ziplist-value 64 list-max-ziplist-size -2 list-compress-depth 0 set-max-intset-entries 512 zset-max-ziplist-entries 128 zset-max-ziplist-value 64 hll-sparse-max-bytes 3000 activerehashing yes client-output-buffer-limit normal 0 0 0 client-output-buffer-limit slave 256mb 64mb 60 client-output-buffer-limit pubsub 32mb 8mb 60 aof-rewrite-incremental-fsync yes
# /etc/redis/6379.conf bind 127.0.0.1 protected-mode yes tcp-backlog 511 timeout 0 tcp-keepalive 300 daemonize yes supervised no pidfile redis_6379.pid loglevel notice logfile "/var/log/redis/6379.log" databases 16 save 900 1 save 300 10 save 60 10000 stop-writes-on-bgsave-error yes rdbcompression yes rdbchecksum yes dbfilename dump.rdb dir /var/run/redis slave-serve-stale-data yes slave-read-only yes repl-diskless-sync no repl-diskless-sync-delay 5 repl-disable-tcp-nodelay no slave-priority 100 appendonly no appendfilename "appendonly.aof" appendfsync everysec no-appendfsync-on-rewrite no auto-aof-rewrite-percentage 100 auto-aof-rewrite-min-size 64mb aof-load-truncated yes lua-time-limit 5000 slowlog-log-slower-than 10000 slowlog-max-len 128 latency-monitor-threshold 0 notify-keyspace-events "" hash-max-ziplist-entries 512 hash-max-ziplist-value 64 list-max-ziplist-size -2 list-compress-depth 0 set-max-intset-entries 512 zset-max-ziplist-entries 128 zset-max-ziplist-value 64 hll-sparse-max-bytes 3000 activerehashing yes client-output-buffer-limit normal 0 0 0 client-output-buffer-limit slave 256mb 64mb 60 client-output-buffer-limit pubsub 32mb 8mb 60 hz 10 aof-rewrite-incremental-fsync yes
pidfile に設定されていた/var/run/redis_6379.pidは存在しませんでした。これが原因なのでしょうか。
またredis-cliからinfoを打つと、以下のように返ってきました。
Memory used_memory:764200 used_memory_human:746.29K used_memory_rss:4902912 used_memory_rss_human:4.68M used_memory_peak:2360784 used_memory_peak_human:2.25M total_system_memory:4145164288 total_system_memory_human:3.86G used_memory_lua:37888 used_memory_lua_human:37.00K maxmemory:0 maxmemory_human:0B maxmemory_policy:noeviction mem_fragmentation_ratio:6.42 mem_allocator:jemalloc-4.0.3 Persistence loading:0 rdb_changes_since_last_save:618 rdb_bgsave_in_progress:0 rdb_last_save_time:1546658955 rdb_last_bgsave_status:err 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 aof_last_write_status:ok CPU used_cpu_sys:433.97 used_cpu_user:525.88 used_cpu_sys_children:0.00 used_cpu_user_children:0.00
おそらくメモリの容量には問題がないので、rdbファイルを設置するディレクトリの権限がない原因なのだと思うのですが、
どのようにdirディレクトリに書き込めるように権限調整を行うのかがわかりません。
redis-cliからCONFIG SET dir /path/to/ディレクトリ でできると思うのですが、どこのディレクトリを指定すればいいのかわかりません。
# 6379.log(redisのログ 1/7現在の最新) 17083:signal-handler (1545990806) Received SIGTERM scheduling shutdown... 17083:M 28 Dec 09:53:26.654 # User requested shutdown... 17083:M 28 Dec 09:53:26.654 * Saving the final RDB snapshot before exiting. 17083:M 28 Dec 09:53:26.704 * DB saved on disk 17083:M 28 Dec 09:53:26.704 * Removing the pid file. 17083:M 28 Dec 09:53:26.704 # Redis is now ready to exit, bye bye... 2180:M 05 Jan 08:19:50.287 * Increased maximum number of open files to 10032 (it was originally set to 1024). 2180:M 05 Jan 08:19:50.287 # Creating Server TCP listening socket 127.0.0.1:6379: bind: Address already in use
#ps -ef | grep redisの結果 501 3407 1 0 2018 ? 00:19:52 redis-server *:6379 501 8854 8123 0 01:20 pts/1 00:00:00 grep --color=auto redis
##追記
redis-cliからconfig set stop-writes-on-bgsave-error noというコマンドを打ってみると、機能を使えるようになりました。
ただ、これはあくまでも一時的な対処法ということで、他の方法をとってみましたがどれもうまくいきません。
####試したこと
-
sudo vi /etc/sysctl.confでvm.overcommit_memory=1 を追加後sudo sysctl -p /etc/sysctl.confでreload
-
redis-cliでCONFIG SET dbfilename dump.rdbを打つ
-
redis-cliでconfig set dir /var/run/redis
-
/usr/local/redis-3.2.5/redis.confのdir ./ の部分をdir /var/run/redis
-
sudo chkconfig --add redisとsudo chkconfig redis on
-
sudo vim /etc/redis/6379.confでpidfile /var/run/redis_6379.pid → redis_6379.pidに変更
-
sudo /etc/init.d/redis restart
-
redis-cliから
・ config set stop-writes-on-bgsave-error no
・ FLUSHALL
・ config set stop-writes-on-bgsave-error yes
##実現したいこと
エラーを修正して、サイト内で実行できなくなった機能を復旧したいです。
何かご教示いただけることがあれば何卒よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー