如何增加 AWS ECS fargate 中的 vm.max_map_count?

How to increase the vm.max_map_count in AWS ECS fargate?

我正在尝试 运行 AWS fargate 平台上的声纳应用程序。当我 运行 原始 docker 图像时,它就像一个魅力。但是如果我将 JDBC 属性作为参数传递给容器,我将面临以下问题。显然,弹性搜索需要一个新的配置。如果它是一个 ECS 集群,我会通过 ssh 进入 EC2 实例并更新这些属性。对于 fargate,我该如何实现?

max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

从 github 问题看来这不可能,因为 Fargate 中没有 EC2 实例或主机 ivolvole。

the workarounds for the max_map_count error appear to be setting max_memory_map directly on the host (which may result in undesirable side effects, or using the sysctl flag on on the docker run command. Unfortunately, neither of these options are not supported in Fargate since it involves interacting with the container instance itself.

但另一种方法是增加file limit并禁用mmap检查。

I had to properly configure U limits on my ECS task definition, something like:
"ulimits": [
  {
    "name": "nofile",
    "softLimit": 65535,
    "hardLimit": 65535
  }
]

I've disabled mmap in ElasticSearch, which gets rid of the max_map_count setting requirement. This can be done by configuring the sonar.search.javaAdditionalOpts SonarQube setting. I wasn't able to do it with an environment variable since ECS seems to be eating them, but in the end I just passed it as a parameter to the container, which works since the entrypoint is set and consumes arguments properly. In my case:

"command": [
  "-Dsonar.search.javaAdditionalOpts=-Dnode.store.allow_mmapfs=false"
]

sonarqube disable nmap

在任务定义的“环境变量”部分(编辑 es 容器)下添加变量 discovery.type = single-node 解决了我的问题。如果您使用的是 json 文件,请添加以下部分

"environment": [
        {
          "name": "discovery.type",
          "value": "single-node"
        }
      ],

不幸的是,我不知道为什么会这样。