[Redis] Failed opening the RDB file root (in server root dir /var/spool/cron) for saving: Read-only file system 에러 (bgsave)
Linux 서버에 Redis를 설치 후 정상적으로 작동되는것을 확인하고 나중에 다시 사용하려 하니 정상적으로 사용을 할 수가 없었다.
문제
사용하려 할 시 아래와 같은 에러로그가 보여졌다.
set testkey testValue (error) 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.
1004lucifer
서버의 Redis로그를 확인해보니 아래와 같았다.
21982:C 26 Nov 07:55:15.563 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
21982:C 26 Nov 07:55:15.563 # Redis version=4.0.9, bits=64, commit=00000000, modified=0, pid=21982, just started
21982:C 26 Nov 07:55:15.563 # Configuration loaded
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 4.0.9 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 22007
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
1004lucifer
22007:M 26 Nov 07:55:15.568 # Server initialized
22007:M 26 Nov 07:55:15.568 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
22007:M 26 Nov 07:55:15.568 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
22007:M 26 Nov 07:55:15.569 * DB loaded from disk: 0.002 seconds
22007:M 26 Nov 07:55:15.570 * Ready to accept connections
22007:M 26 Nov 09:46:12.033 * DB saved on disk
22007:M 26 Nov 09:46:12.050 * DB saved on disk
22007:M 26 Nov 09:46:12.104 * DB saved on disk
22007:M 26 Nov 09:46:12.123 * DB saved on disk
22007:M 26 Nov 09:46:12.146 * DB saved on disk
22007:M 26 Nov 09:46:12.184 * DB saved on disk
22007:M 26 Nov 09:46:12.197 * DB saved on disk
22007:M 26 Nov 09:46:12.270 * DB saved on disk
22007:M 26 Nov 09:46:12.278 * DB saved on disk
22007:M 26 Nov 09:46:12.312 * DB saved on disk
22007:M 26 Nov 09:46:12.362 * DB saved on disk
22007:M 26 Nov 09:46:12.394 * DB saved on disk
22007:M 26 Nov 09:46:12.402 * DB saved on disk
22007:M 26 Nov 09:46:12.484 * DB saved on disk
22007:M 26 Nov 09:46:12.660 # Failed opening the RDB file root (in server root dir /var/spool/cron) for saving: Read-only file system
22007:M 26 Nov 09:46:12.667 # Failed opening the RDB file root (in server root dir /var/spool/cron) for saving: Read-only file system
22007:M 26 Nov 09:46:12.712 # Failed opening the RDB file root (in server root dir /var/spool/cron) for saving: Read-only file system
22007:M 26 Nov 09:46:12.722 # Failed opening the RDB file backup.db (in server root dir /var/spool/cron) for saving: Read-only file system
22007:M 26 Nov 09:46:12.755 # Failed opening the RDB file backup.db (in server root dir /var/spool/cron) for saving: Read-only file system
22007:M 26 Nov 09:46:12.785 # Failed opening the RDB file backup.db (in server root dir /var/spool/cron) for saving: Read-only file system
22007:M 26 Nov 09:46:12.794 # Failed opening the RDB file backup.db (in server root dir /var/spool/cron) for saving: Read-only file system
22007:M 26 Nov 09:46:12.856 # Failed opening the RDB file backup.db (in server root dir /var/spool/cron) for saving: Read-only file system
22007:M 26 Nov 09:46:12.892 # Failed opening the RDB file root (in server root dir /var/spool/cron) for saving: Read-only file system
22007:M 26 Nov 09:46:12.935 # Failed opening the RDB file backup.db (in server root dir /var/spool/cron) for saving: Read-only file system
22007:M 26 Nov 09:46:13.001 # Failed opening the RDB file backup.db (in server root dir /var/spool/cron) for saving: Read-only file system
22007:M 26 Nov 09:46:13.064 # Failed opening the RDB file backup.db (in server root dir /var/spool/cron) for saving: Read-only file system
22007:M 26 Nov 09:46:13.065 # Failed opening the RDB file backup.db (in server root dir /var/spool/cron) for saving: Read-only file system
22007:M 26 Nov 09:46:13.157 # Failed opening the RDB file backup.db (in server root dir /var/spool/cron) for saving: Read-only file system
22007:M 26 Nov 09:46:13.301 # Failed opening the RDB file root (in server root dir /var/spool/cron) for saving: Read-only file system
22007:M 26 Nov 09:46:13.303 # Failed opening the RDB file root (in server root dir /var/spool/cron) for saving: Read-only file system
22007:M 26 Nov 09:46:13.443 # Failed opening the RDB file root (in server root dir /var/spool/cron) for saving: Read-only file system
22007:M 26 Nov 09:46:13.447 # Failed opening the RDB file root (in server root dir /var/spool/cron) for saving: Read-only file system
22007:M 26 Nov 09:46:13.565 # Failed opening the RDB file root (in server root dir /var/spool/cron) for saving: Read-only file system
22007:M 26 Nov 09:46:13.657 # Failed opening the RDB file root (in server root dir /var/spool/cron) for saving: Read-only file system 1004lucifer
22007:M 26 Nov 09:46:13.745 # Failed opening the RDB file root (in server root dir /var/spool/cron) for saving: Read-only file system
22007:M 26 Nov 09:46:13.839 # Failed opening the RDB file root (in server root dir /var/spool/cron) for saving: Read-only file system
22007:M 26 Nov 09:46:13.839 # Failed opening the RDB file root (in server root dir /var/spool/cron) for saving: Read-only file system
22007:M 26 Nov 09:46:13.917 # Failed opening the RDB file root (in server root dir /var/spool/cron) for saving: Read-only file system
22007:M 26 Nov 09:46:14.046 # Failed opening the RDB file root (in server root dir /var/spool/cron) for saving: Read-only file system
22007:M 26 Nov 09:46:14.141 # Failed opening the RDB file root (in server root dir /var/spool/cron) for saving: Read-only file system
22007:M 26 Nov 09:51:13.079 * 10 changes in 300 seconds. Saving...
22007:M 26 Nov 09:51:13.080 * Background saving started by pid 22345
22345:C 26 Nov 09:51:13.080 # Failed opening the RDB file root (in server root dir /var/spool/cron) for saving: Read-only file system
22007:M 26 Nov 09:51:13.180 # Background saving error
22007:M 26 Nov 09:51:19.090 * 10 changes in 300 seconds. Saving...
22007:M 26 Nov 09:51:19.090 * Background saving started by pid 22346
22346:C 26 Nov 09:51:19.090 # Failed opening the RDB file root (in server root dir /var/spool/cron) for saving: Read-only file system
22007:M 26 Nov 09:51:19.190 # Background saving error
22007:M 26 Nov 09:51:25.100 * 10 changes in 300 seconds. Saving...
22007:M 26 Nov 09:51:25.102 * Background saving started by pid 22347
22347:C 26 Nov 09:51:25.102 # Failed opening the RDB file root (in server root dir /var/spool/cron) for saving: Read-only file system
22007:M 26 Nov 09:51:25.202 # Background saving error
22007:M 26 Nov 09:51:31.012 * 10 changes in 300 seconds. Saving...
22007:M 26 Nov 09:51:31.012 * Background saving started by pid 22350
22350:C 26 Nov 09:51:31.012 # Failed opening the RDB file root (in server root dir /var/spool/cron) for saving: Read-only file system
22007:M 26 Nov 09:51:31.112 # Background saving error
22007:M 26 Nov 09:51:37.021 * 10 changes in 300 seconds. Saving...
22007:M 26 Nov 09:51:37.021 * Background saving started by pid 22351
22351:C 26 Nov 09:51:37.022 # Failed opening the RDB file root (in server root dir /var/spool/cron) for saving: Read-only file system
22007:M 26 Nov 09:51:37.122 # Background saving error
22007:M 26 Nov 09:51:43.031 * 10 changes in 300 seconds. Saving...
22007:M 26 Nov 09:51:43.032 * Background saving started by pid 22352
22352:C 26 Nov 09:51:43.032 # Failed opening the RDB file root (in server root dir /var/spool/cron) for saving: Read-only file system
22007:M 26 Nov 09:51:43.132 # Background saving error
22007:M 26 Nov 09:51:49.041 * 10 changes in 300 seconds. Saving...
22007:M 26 Nov 09:51:49.041 * Background saving started by pid 22353
22353:C 26 Nov 09:51:49.041 # Failed opening the RDB file root (in server root dir /var/spool/cron) for saving: Read-only file system
22007:M 26 Nov 09:51:49.141 # Background saving error
22007:M 26 Nov 09:51:55.050 * 10 changes in 300 seconds. Saving...
22007:M 26 Nov 09:51:55.050 * Background saving started by pid 22354
22354:C 26 Nov 09:51:55.051 # Failed opening the RDB file root (in server root dir /var/spool/cron) for saving: Read-only file system
22007:M 26 Nov 09:51:55.151 # Background saving error
22007:M 26 Nov 09:52:01.061 * 10 changes in 300 seconds. Saving...
22007:M 26 Nov 09:52:01.061 * Background saving started by pid 22357
22357:C 26 Nov 09:52:01.061 # Failed opening the RDB file root (in server root dir /var/spool/cron) for saving: Read-only file system
22007:M 26 Nov 09:52:01.161 # Background saving error
... (위 에러가 계속 있음)
원인 및 해결방법
Redis 서버에 패스워드를 지정하지 않았고 기본포트로 되어있다 보니 누구나 접근이 가능했다.
스택오버플로우에서 외부 공격으로 인해 그럴 수 있으니 방화벽 설정을 해두라는 이야기를 듣고 사용할 곳의 IP를 제외하고는 다른곳에서 접속할 수 없게 했더니 더 이상 문제가 발생하지 않았다.
댓글
댓글 쓰기