Redis必须启用内存过量使用

zpgglvta  于 7个月前  发布在  Redis
关注(0)|答案(1)|浏览(126)

我正在本地Windows机器上托管的Docker容器上运行Redis服务器,但由于此警告,我无法存储数据

WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can 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.

字符串
有什么办法可以实现这个功能吗?

version: '3'
services:
  redis:
    image: "redis"
    ports:
      - "6379:6379"
    networks:
      - my-service

networks:
  my-service:
    external: true

eagi6jfj

eagi6jfj1#

首先,它与Redis镜像或容器本身无关,也没有任何直接的方法可以通过docker-compose或docker run命令来解决它。它只与主机操作系统有关,在Windows情况下,主机操作系统是Linux hypervisor,docker在其上运行。
如果你像我一样使用WSL 2后端在Windows上运行docker,你可以通过简单地启动一个WSL分发版并运行以下命令来临时更改它:

sudo sysctl -w vm.overcommit_memory=1

字符串
不幸的是,处理这个问题需要对Linux有很好的了解,以对抗用户权限,奇怪的访问拒绝,包管理器等,对我来说,来自Windows背景,进一步深入研究这个问题是一项坚韧的任务。

相关问题