我尝试使用 docker-compose 启动 redis docker 容器,但总是收到此错误。这是我的 docker-compose 运行命令
docker-compose -f docker-compose.yml build
和 docker-compose -f docker-compose.yml up -d --force-recreate
。我在 aws ecs 上运行 docker 容器并使用 t2.micro ec2 实例。我不确定这是否是原因。任何见解都会有所帮助。
我还包含了我的 docker-compose.yml
version: '2.1'
services:
redis:
image: redis:latest
container_name: redis
volumes:
- redis_data:/data
ports:
- 6379:6379
app:
image: custom_image
build: .
depends_on:
redis:
condition: service_started
ports:
- 8003:8003
links:
- redis
volumes:
redis_data:
错误
1:C 11 Sep 00:18:34.345 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1:C 11 Sep 00:18:34.348 # Redis version=4.0.11, bits=64, commit=00000000, modified=0, pid=1, just started
1:C 11 Sep 00:18:34.348 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
1:M 11 Sep 00:18:34.349 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
1:M 11 Sep 00:18:34.349 # Server can't set maximum open files to 10032 because of OS error: Operation not permitted.
1:M 11 Sep 00:18:34.349 # Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
1:M 11 Sep 00:18:34.350 * Running mode=standalone, port=6379.
1:M 11 Sep 00:18:34.350 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
1:M 11 Sep 00:18:34.350 # Server initialized
1:M 11 Sep 00:18:34.350 # 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.
1:M 11 Sep 00:18:34.350 # 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.
1:M 11 Sep 00:18:34.350 * Ready to accept connections
1:signal-handler (1536625117) Received SIGTERM scheduling shutdown...
1:M 11 Sep 00:18:37.375 # User requested shutdown...
1:M 11 Sep 00:18:37.375 * Saving the final RDB snapshot before exiting.
1:M 11 Sep 00:18:37.378 * DB saved on disk
1:M 11 Sep 00:18:37.378 # Redis is now ready to exit, bye bye...
我也遇到这个问题了
redis 09:20:50.89 INFO ==> ** Starting Redis **
1:C 15 Jul 2024 09:20:50.903 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. 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.
1:C 15 Jul 2024 09:20:50.903 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1:C 15 Jul 2024 09:20:50.903 * Redis version=7.2.5, bits=64, commit=00000000, modified=0, pid=1, just started
1:C 15 Jul 2024 09:20:50.903 * Configuration loaded
1:M 15 Jul 2024 09:20:50.904 * monotonic clock: POSIX clock_gettime
1:M 15 Jul 2024 09:20:50.905 * Running mode=standalone, port=6379.
1:M 15 Jul 2024 09:20:50.905 * Server initialized
1:M 15 Jul 2024 09:20:50.908 * Creating AOF base file appendonly.aof.1.base.rdb on server start
1:M 15 Jul 2024 09:20:50.910 * Creating AOF incr file appendonly.aof.1.incr.aof on server start
1:M 15 Jul 2024 09:20:50.910 * Ready to accept connections tcp
1:M 15 Jul 2024 09:46:41.917 * Creating AOF incr file appendonly.aof.2.incr.aof on background rewrite
1:M 15 Jul 2024 09:46:41.917 * Background append only file rewriting started by pid 42
42:C 15 Jul 2024 09:46:41.920 * Successfully created the temporary AOF base file temp-rewriteaof-bg-42.aof
42:C 15 Jul 2024 09:46:41.920 * Fork CoW for AOF rewrite: current 0 MB, peak 0 MB, average 0 MB
1:M 15 Jul 2024 09:46:41.935 * Background AOF rewrite terminated with success
1:M 15 Jul 2024 09:46:41.935 * Successfully renamed the temporary AOF base file temp-rewriteaof-bg-42.aof into appendonly.aof.2.base.rdb
1:M 15 Jul 2024 09:46:41.937 * Removing the history file appendonly.aof.1.incr.aof in the background
1:M 15 Jul 2024 09:46:41.938 * Removing the history file appendonly.aof.1.base.rdb in the background
1:M 15 Jul 2024 09:46:41.940 * Background AOF rewrite finished successfully
1:M 15 Jul 2024 12:07:24.234 # Possible SECURITY ATTACK detected. It looks like somebody is sending POST or Host: commands to Redis. This is likely due to an attacker attempting to use Cross Protocol Scripting to compromise your Redis instance. Connection from 87.236.176.241:45309 aborted.
1:signal-handler (1721055163) Received SIGTERM scheduling shutdown...
1:M 15 Jul 2024 14:52:43.385 * User requested shutdown...
1:M 15 Jul 2024 14:52:43.385 * Calling fsync() on the AOF file.
1:M 15 Jul 2024 14:52:43.385 * Removing the pid file.
1:M 15 Jul 2024 14:52:43.385 # Redis is now ready to exit, bye bye...
不知道为什么又重启了
这是我的作文
services:
redis:
image: bitnami/redis:latest
environment:
- ALLOW_EMPTY_PASSWORD=no
- REDIS_PASSWORD=password
- REDIS_DISABLE_COMMANDS=FLUSHDB,FLUSHALL
- REDIS_ALLOW_REMOTE_CONNECTIONS=yes
ports:
- '6379:6379'
volumes:
- 'redis_data:/bitnami/redis/data'
volumes:
redis_data:
driver: local
遇到同样的问题。经过一番挖掘,我们发现它由于不活动而被 systemd 杀死。 运行
systemctl show docker.service
命令显示非活动和活动输入时间戳与 redis 服务停止和重新启动的时间相匹配。
InactiveEnterTimestamp=Tue 2021-08-03 22:07:19 AEST
ActiveEnterTimestamp=Wed 2021-08-04 09:30:36 AEST
我们的解决方案只是在redis上执行一些活动,这样它就不会进入非活动状态。