简体   繁体   English

如何限制Edge设备上edgeAgent的内存

[英]how to limit memory for edgeAgent on an Edge device

I have found out from Azure team that the memory limit for Edge modules including edgeHub can be controlled by specifying createOptions -> HostConfig -> Memory . 我从Azure团队发现,可以通过指定createOptions -> HostConfig -> Memory来控制Edge模块(包括edgeHub的内存限制。 How to control memory limit for edgeAgent Docker container as it is created by edgeAgent ? 如何控制edgeAgent创建的edgeAgent Docker容器的内存限制? Is this documented? 有记录吗? Currently here it shows as 1.88GB on a 2GB VM. 当前在2GB VM上显示为1.88GB。

Below is an extract from docker stats 以下是docker stats的摘录

fd66aaa4dbe1        edgeAgent                 0.01%               40.59MiB / 1.885GiB   2.10%               2.18MB / 1.13MB     55.6MB / 705kB      15

Setting the memory limit is not specific to the edgeHub module but it is the same for any other docker module used with IotEdge. 设置内存限制并非特定于edgeHub模块,但是与IotEdge一起使用的任何其他docker模块相同。 You can add the Memory setting to the HostConfig section in the createOptions of any module. 您可以在任何模块的createOptions中将Memory设置添加到HostConfig部分。

For the edgeAgent the deployment setting would look like this: 对于edgeAgent,部署设置如下所示:

"systemModules": {
          "edgeAgent": {
            "type": "docker",
            "settings": {
              "image": "mcr.microsoft.com/azureiotedge-agent:1.0",
              "createOptions": "{\"HostConfig\":{\"Memory\":536870912}}"
            }
          },
          "edgeHub": {
          ...
          }
        }

With this do a new deployment. 以此进行新的部署。

For the changes to take affect on your machine you have to remove the edgeAgent module so it will create a new one according to your changed deployment rules. 为了使更改对您的计算机生效,您必须删除edgeAgent模块,以便它根据更改后的部署规则创建一个新模块。 You can do so with the following command: 您可以使用以下命令进行操作:

sudo docker rmi mcr.microsoft.com/azureiotedge-agent:1.0 -f 须藤docker rmi mcr.microsoft.com/azureiotedge-agent:1.0 -f

After that restart the iotEdge Deamon with 之后,使用以下命令重新启动iotEdge Deamon

sudo systemctl restart iotedge sudo systemctl重新启动iotedge

After that the memory will be limited for the edgeAgent module. 之后,将限制edgeAgent模块的内存。

Note: If you want to limit memory on a Raspberry Pi, be aware that memory limit support is turned off by default. 注意:如果要限制Raspberry Pi上的内存,请注意默认情况下已禁用内存限制支持。 You can find a HowTo for enabling it here: https://blog.raveland.org/post/docker_raspian/ 您可以在此处找到如何启用它的方法: https//blog.raveland.org/post/docker_raspian/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM