首页 > 解决方案 > 持久化 edgeAgent 存储的正确配置是什么?

问题描述

我正在开发一个 Azure IoT Edge 项目。目前我正在检查生产准备清单。我按照文档将主机文件系统上的存储用于 edgeAgent 和 edgeHub 模块。

当我运行sudo iotedge checkedgeHub 时可以,但 edgeAgent 会发出警告:

‼ production readiness: Edge Agent's storage directory is persisted on the host filesystem - Warning
    The edgeAgent module is not configured to persist its /tmp/edgeAgent directory on the host filesystem.
    Data might be lost if the module is deleted or updated.
    Please see https://aka.ms/iotedge-storage-host for best practices.
√ production readiness: Edge Hub's storage directory is persisted on the host filesystem - OK

这是部署模板的一个片段:

"systemModules": {
  "edgeAgent": {
    "type": "docker",
    "settings": {
      "image": "mcr.microsoft.com/azureiotedge-agent:1.0",
      "createOptions": {
        "HostConfig": {
          "Binds": [
            "/home/pi/iotedge/edgeAgent/storage/:/iotedge/storage/"
          ]
        }
      }
    },
    "env": {
      "storageFolder": {
        "value": "/iotedge/storage/"
      }
    }
  },
  "edgeHub": {
    "type": "docker",
    "status": "running",
    "restartPolicy": "always",
    "settings": {
      "image": "mcr.microsoft.com/azureiotedge-hub:1.0",
      "createOptions": {
        "HostConfig": {
          "Binds": [
            "/home/pi/iotedge/edgeHub/storage:/iotedge/storage/"
          ],
          "PortBindings": {
            "5671/tcp": [
              {
                "HostPort": "5671"
              }
            ],
            "8883/tcp": [
              {
                "HostPort": "8883"
              }
            ],
            "443/tcp": [
              {
                "HostPort": "443"
              }
            ]
          }
        }
      }
    },
    "env": {
      "storageFolder": {
        "value": "/iotedge/storage/"
      }
    }
  }
},

标签: azureazure-iot-hubazure-iot-edge

解决方案


从 1.0.9 版开始,存在一个问题,即 edgeAgent 的配置不会更新,除非其图像标签已更新。您当前状态的两个选项:

  • 在图像设置中使用特定标签(始终推荐)。例如mcr.microsoft.com/azureiotedge-agent:1.0.9

  • 删除设备上的 edgeAgent 容器:docker rm -f edgeAgent。它将在 30 秒内重新启动,并且将获取新的storageFolderenv var。

更新容器后再次运行“iotedge check”,此警告应该会消失。


推荐阅读