redis不遵循redis.conf设置

时间:2018-09-23 07:08:00

标签: python django redis gunicorn

我正在运行redis服务器,并且在redis.conf文件中将dir设置为/var/lib/redis,并将dbfilename设置为dump.rdb,但是我注意到redis在下面开始产生这些错误

120844:C 23 Sep 02:59:31.098 # Failed opening .rdb for saving: Read-only file system
42657:M 23 Sep 02:59:31.198 # Background saving error
42657:M 23 Sep 02:59:37.018 * 1 changes in 900 seconds. Saving...
42657:M 23 Sep 02:59:37.019 * Background saving started by pid 120868
120868:C 23 Sep 02:59:37.019 # Failed opening .rdb for saving: Read-only file system
42657:M 23 Sep 02:59:37.119 # Background saving error
42657:M 23 Sep 02:59:43.035 * 1 changes in 900 seconds. Saving...
42657:M 23 Sep 02:59:43.036 * Background saving started by pid 120869
120869:C 23 Sep 02:59:43.036 # Failed opening .rdb for saving: Read-only file system
42657:M 23 Sep 02:59:43.136 # Background saving error
42657:M 23 Sep 02:59:49.052 * 1 changes in 900 seconds. Saving...
42657:M 23 Sep 02:59:49.052 * Background saving started by pid 120895
120895:C 23 Sep 02:59:49.053 # Failed opening .rdb for saving: Read-only file system
42657:M 23 Sep 02:59:49.153 # Background saving error
42657:M 23 Sep 02:59:55.067 * 1 changes in 900 seconds. Saving...
42657:M 23 Sep 02:59:55.067 * Background saving started by pid 120939

然后我进入redis-cli使用以下命令修复此问题

127.0.0.1:6379> config set dbfilename dump.rdb
OK
127.0.0.1:6379> config set dir /var/lib/redis
OK
127.0.0.1:6379> exit

然后我现在检查redis日志,然后工作正常

42657:M 23 Sep 03:00:43.011 * Background saving started by pid 121168
121168:C 23 Sep 03:00:43.011 # Failed opening .rdb for saving: Read-only file system
42657:M 23 Sep 03:00:43.122 # Background saving error
42657:M 23 Sep 03:00:49.035 * 1 changes in 900 seconds. Saving...
42657:M 23 Sep 03:00:49.036 * Background saving started by pid 121170
121170:C 23 Sep 03:00:49.233 * DB saved on disk
121170:C 23 Sep 03:00:49.233 * RDB: 0 MB of memory used by copy-on-write
42657:M 23 Sep 03:00:49.236 * Background saving terminated with success

然后几分钟后,redis再次回到先前的错误,请注意。.redis.conf文件已设置了dir和dbfilename,因此不确定发生了什么。

我该如何解决错误?不知道这是一个常见的错误还是什么。 我正在运行Redis redis-server --version

Redis server v=3.0.6 sha=00000000:0 malloc=jemalloc-3.6.0 bits=64 build=687a2a319020fa42

P.S。我正在运行一些使用gunicorn运行的django应用程序,这些应用程序使用redis数据库..每当redis运行正常时,应用程序就可以正常运行,并且只要redis开始给出上述错误,应用程序就会开始显示502错误,我得到发生的错误

 [error] 1808#1808: *14662 upstream prematurely closed connection while reading response header from upstream, client: 172.xxx.xxx.xxx, server: xxxxx.com, request: "GET /U/example-url/ HTTP/1.1", upstream: "http://unix:/mnt/http/nginx/xxxxx.com/run/gunicorn.sock:/U/example-url/", host: "xxxxx.com"

所以不能确定应用是否杀死了Redis或Redis是否杀死了应用程序..无论哪种方式,为什么Redis设置会被杀死,以及如何持久保存dir和dbfilename设置?

谢谢

更新:

这是redis-cli info命令的输出

127.0.0.1:6379> info
# Server
redis_version:3.0.6
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:687a2a319020fa42
redis_mode:standalone
os:Linux 4.4.0-133-generic x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:5.3.1
process_id:3957
run_id:dfac396ca05cb307c830abcdcd10b916f536b6fd
tcp_port:6379
uptime_in_seconds:263
uptime_in_days:0
hz:10
lru_clock:10965575
config_file:/etc/redis/redis.conf

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

# Memory
used_memory:4663560
used_memory_human:4.45M
used_memory_rss:7491584
used_memory_peak:4726624
used_memory_peak_human:4.51M
used_memory_lua:36864
mem_fragmentation_ratio:1.61
mem_allocator:jemalloc-3.6.0

# Persistence
loading:0
rdb_changes_since_last_save:84
rdb_bgsave_in_progress:0
rdb_last_save_time:1537691968
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:-1
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

# Stats
total_connections_received:44
total_commands_processed:325
instantaneous_ops_per_sec:0
total_net_input_bytes:25453
total_net_output_bytes:652106
instantaneous_input_kbps:0.00
instantaneous_output_kbps:0.00
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:84
evicted_keys:0
keyspace_hits:88
keyspace_misses:109
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:0
migrate_cached_sockets:0

# Replication
role:master
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0

# CPU
used_cpu_sys:0.08
used_cpu_user:0.23
used_cpu_sys_children:0.00
used_cpu_user_children:0.00

# Cluster
cluster_enabled:0

# Keyspace
db0:keys=10,expires=0,avg_ttl=0
db5:keys=2,expires=2,avg_ttl=32239229
db6:keys=14432,expires=0,avg_ttl=0
db8:keys=10,expires=10,avg_ttl=1821207715
db9:keys=873,expires=0,avg_ttl=0

0 个答案:

没有答案