gpt4 book ai didi

docker - 如何在Windows 10上修复 “Redis must be restarted after THP is disabled”警告?

转载 作者:行者123 更新时间:2023-12-02 21:05:48 25 4
gpt4 key购买 nike

我有一个docker-compose.yml文件。运行此命令时,出现警告“禁用THP后必须重新启动Redis”。

以下是我的docker-compose.yml:

version: '3'
services:
myapp:
# container_name: myapp
restart: always
build: .
ports:
- '52000:52000'
# - '8080:8080'
# - '4300:4300'
# - '4301:4301'
command: ["./wait-for-it.sh", "redis:6379", "--", "npm", "start"]
links:
- redis
- mongo
mongo:
# container_name: myapp-mongo
image: 'mongo:latest'
ports:
- '28107:28107'
# - '27017:27017'
redis:
# container_name: myapp-redis
# restart: always
image: 'redis:4.0.11'
# command: ["redis-server", "--appendonly", "yes"]
ports:
- '6379:6379'

以下是我的日志:
redis_1  | 1:C 24 Sep 10:21:09.224 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis_1 | 1:C 24 Sep 10:21:09.236 # Redis version=4.0.11, bits=64, commit=00000000, modified=0, pid=1, just started
redis_1 | 1:C 24 Sep 10:21:09.236 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
redis_1 | 1:M 24 Sep 10:21:09.239 * Running mode=standalone, port=6379.
redis_1 | 1:M 24 Sep 10:21:09.239 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redis_1 | 1:M 24 Sep 10:21:09.239 # Server initialized
mongo_1 | 2019-09-24T10:21:10.304+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
redis_1 | 1:M 24 Sep 10:21:09.239 # 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.
redis_1 | 1:M 24 Sep 10:21:09.239 * Ready to accept connections

最佳答案

# 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.



从错误中,您可以在Docker主机上使用 'echo never > /sys/kernel/mm/transparent_hugepage/enabled'修复您的问题。

但是,我知道您在Windows上并且无法访问hyper-v MobyLinuxVM,因此您应该在下一步中使用解决方法:

docker-compose.yaml:
version: '3'
services:
redis:
image: 'redis:4.0.11'
ports:
- '6379:6379'
depends_on:
- helper
sysctls:
- net.core.somaxconn=511
helper:
image: alpine
command: sh -c "echo never > /sys/kernel/mm/transparent_hugepage/enabled"
privileged: true

上面将首先启动一个辅助容器,该容器将 never设置为 /sys/kernel/mm/transparent_hugepage/enabled,因为所有容器将共享相同的主机内核,因此稍后启动的redis容器也将从中受益,请参见下一个执行日志:
PS E:\abc> docker-compose up
Starting abc_helper_1 ... done
Recreating 29ea8bfaeafc_abc_redis_1 ... done
Attaching to abc_helper_1, abc_redis_1
redis_1 | 1:C 25 Sep 15:38:17.822 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis_1 | 1:C 25 Sep 15:38:17.822 # Redis version=4.0.11, bits=64, commit=00000000, modified=0, pid=1, just started
redis_1 | 1:C 25 Sep 15:38:17.822 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
redis_1 | 1:M 25 Sep 15:38:17.822 * Running mode=standalone, port=6379.
redis_1 | 1:M 25 Sep 15:38:17.823 # Server initialized
redis_1 | 1:M 25 Sep 15:38:17.823 * DB loaded from disk: 0.000 seconds
redis_1 | 1:M 25 Sep 15:38:17.823 * Ready to accept connections

关于docker - 如何在Windows 10上修复 “Redis must be restarted after THP is disabled”警告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58078237/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com