Set up an environment on Ubuntu 16.04

Updated at:

This topic describes how to set up a runtime environment for Link IoT Edge Standard Edition (LE Standard) on Ubuntu 16.04.

The Link IoT Edge Standard Edition package is compatible with Ubuntu versions 16.04 through 18.04 and has been tested and verified on the following platforms.
ArchitectureOperating system
x86_64Ubuntu 16.04 to Ubuntu 18.04
ARMv7Ubuntu 16.04 to Ubuntu 18.04
ARMv8 (AArch64)Ubuntu 16.04 to Ubuntu 18.04

Although IoT Edge may run on other Ubuntu versions, we recommend using an officially supported OS version for optimal stability and security. This topic uses an x86_64 Ubuntu 16.04 platform as an example to demonstrate how to install and deploy Link IoT Edge Standard Edition. You can download the Standard Edition packages for other architectures that are compatible with Ubuntu 16.04 to 18.04 from the Standard Edition section in the Download center.

Preparations

Prepare a PC or virtual machine (VM) running Ubuntu 16.04. Ensure that the PC or VM has an active internet connection. If you are unfamiliar with installing Ubuntu 16.04, see the Ubuntu 16.04 installation guide.

Set up the environment

Set up the environment required for IoT Edge to run on an x86_64 Ubuntu 16.04 machine.

  1. On your x86_64 Ubuntu 16.04 machine, run the following commands in a local or Secure Shell (SSH) terminal to download and run the environment check tool.
    wget http://iotedge-web.oss-cn-shanghai.aliyuncs.com/public/testingTool/link-iot-edge_env-check.sh
    sudo chmod +x ./link-iot-edge_env-check.sh
    sudo ./link-iot-edge_env-check.sh
    Note link-iot-edge_env-check.sh script must be run with root permissions on platforms that support IoT Edge. These platforms must also support the following Linux commands:

    printf, echo, cat, ls, expr, grep, test, uname, set, head, sort, cut, uniq, xargs, and ifconfig

  2. Follow the prompts from the environment check tool to install all required dependencies on your machine. After the tool finishes running, the following information is displayed. This output indicates that your machine is ready to run IoT Edge.
    1

Create an edge instance and a gateway

  1. Log on to the Link IoT Edge console.
  2. In the left-side navigation pane, click Edge Instances.
  3. Create an edge instance.
    1. Click Create Instance. In the Create Instance dialog box, enter an instance name.
      Note The instance name must be 1 to 20 characters in length, and can contain letters, digits, underscores (_), and hyphens (-).
    2. Select the required specifications for the Link IoT Edge product based on the environment that you build. For more information, see Product specifications.
      Link IoT Edge supports automatic gateway allocation to edge instances. You can skip setting other parameters for the new instance and proceed directly to Step 4. Link IoT Edge automatically creates a gateway product named LEGatewayAuto for your edge instance, and adds a randomly named gateway device under this product.
      Note
      • When Link IoT Edge automatically creates the LEGatewayAuto product for you, if a product with this name already exists, a random suffix will be added to the name as the automatically created gateway product.
      • After Link IoT Edge has automatically created the LEGatewayAuto product for you once, when you create new edge instances with automatic gateway allocation, a new gateway device will be added under the LEGatewayAuto product and allocated to your new edge instance.
    3. Optional. In the Tag Information section, click Add Tag to add tags to the instance. Tags provide an efficient method to identify and group instances. This parameter is optional.
      To set an instance tag, you must enter a tag key and tag value.
      Table 3. Parameters
      Parameter Description
      Tag Key You must specify a tag key for each tag. The tag key must be 1 to 20 characters in length, and can contain letters. The key of each tag is unique for an instance.
      Tag Value You must specify a tag value for each tag. The tag value must be 1 to 20 characters in length, and can contain letters, digits, underscores (_), and hyphens (-).
  4. (Optional) If you want to manually create a gateway product and device and allocate them to an edge instance, perform the following steps.
    1. In the Create Instance dialog box, click Advanced Options.
    2. In the Gateway Products section, click Create Gateway Product to create a gateway for the instance.
      Gateways in Link IoT Edge provide edge computing capabilities. Each instance must be associated with a gateway device. A gateway device can be associated with only one edge instance at a time.Create Gateway Product
    3. In the Create Product dialog box, set the gateway product parameters, and then click OK.
      Create Gateway Product in Link IoT Edge inherits the features of Device Management > Products in the IoT Platform console. The procedure to create a product is simplified. You can create gateway products that are applicable to Link IoT Edge in a quick manner.Create Product
      Table 4. Parameters
      Parameter Description
      Product Name Set a name for the gateway product. The name is used for subsequent query and identification of gateway products. The name can contain letters, digits, underscores (_), and Chinese characters. The name must be 4 to 30 characters in length. A Chinese character counts as 2 characters.
      Category

      Select a category to define the Thing Specification Language (TSL) model for the product.

      Valid values:

      • Standard Category: Select a category predefined by IoT Platform to quickly complete the feature definition of the product. After you select a product template, you can edit, modify, or add features based on the template.
      • Custom Category: You need to define product features based on actual requirements.

      If the gateway you need does not have special feature definitions, we recommend that you select Custom Category.

      Product Description Enter a description for the product. The description can be up to 100 characters in length. This parameter is optional.

      After the product is created, you are automatically redirected to the Create Instance dialog box. The created gateway product is automatically assigned in the Gateway Products parameter.

    4. In the Create Instance dialog box, click Create Gateway Device under Gateway Devices to add a device to the gateway product.
      The Create Gateway Device feature in Link IoT Edge inherits the features of Device Management > Devices in the IoT Platform console.Create Gateway Device
    5. Set the required parameters as prompted and click OK.
      Table 5. Parameters
      Parameter Description
      Product The system automatically associates the gateway product created in the previous step.
      Device Name Set a name for the gateway device. The device name must be unique within the product. If you do not specify this parameter, the system automatically generates a name.
      Note The device name must be 4 to 32 characters in length. It can contain letters, digits, and special characters, including hyphens (-), underscores (_), at signs (@), periods (.), and colons (:).
  5. After you configure the required parameters, click OK.

Install and start IoT Edge

After you create an edge instance and a gateway, you must install and start Link IoT Edge on the gateway.

  1. On the Edge Instances page, click Install Software in the Actions column of the required edge instance.
    Download command
  2. Set the download parameters based on your environment and click Generate Command.
    生成下载命令
    Table 1. Parameter description
    ParameterDescription
    Edge Gateway CPU Architecture
    The CPU architecture of your device. Select x86-64.
    Product Specifications
    The IoT Edge version used by the instance was selected when you created the edge instance. This parameter cannot be changed.
    Edge Version

    Select a published version of IoT Edge.

    Operating System
    The OS of your device. Select Linux.
  3. Copy the command for later use.
    标准版linux复制命令
  4. Log in to your x86_64 Ubuntu 16.04 machine.
  5. Run the command copied in step 3 in any directory.
    The command is used to download, configure, and start Link IoT Edge with one click. After the command is executed, the link-iot-edge-standard.sh script is downloaded to the current directory.
    Note If this is not your first time to install and start Link IoT Edge, you can execute the link-iot-edge-standard.sh script to restart or stop Link IoT Edge, obtain its status, and modify its configuration parameters. The following figure shows the commands in the script.Additional operations
  6. Run the following command to check the status of the IoT Edge core service.
    sudo ./link-iot-edge-standard.sh --status

    If the following information is displayed, the IoT Edge core service has started successfully.

    网关启动成功

    You can also go to the IoT Edge console. In the navigation pane on the left, click Edge Instances. Find the instance that you created and click View in the Actions column. On the Instance Details page, click the Gateway tab to view the gateway status.

    网关在线

    Turn on the Remote Access switch to remotely manage the gateway. For more information, see Remote service access.

  7. Optional. On the Instance Details page, check the CPU utilization, memory usage, and storage usage, and authorize instance processes to access CloudMonitor.
    1. Add a role or attach an existing role. Make sure that the role has the required permissions to manage CloudMonitor. For more information, see Cloud Resource Access.
    2. Click the Monitoring tab and turn on the CloudMonitor Status switch, as shown in the following figure.
  8. Optional. Authorize other Alibaba Cloud users to perform the required operations on the instance.
    On the Edge Instances page, click Authorize in the upper-left corner of the page. In the dialog box that appears, click Add Authorization. In the dialog box that appears, set the required parameters as prompted.Authorization
    Table 6. Parameters
    Parameter Description
    Authorized User UID The Alibaba Cloud account ID of the user that you want to authorize.
    Authorized Instance The edge instance on which you want to authorize the Alibaba Cloud account to perform remote O&M.

Use systemd to manage Link IoT Edge

Use systemd to start or stop Link IoT Edge or view the status of Link IoT Edge.

The systemd service file of Link IoT Edge is as follows:

[Unit]
Description=Link IoT Edge

[Service]
Type=forking
Restart=on-failure
ExecStart=/linkedge/gateway/build/script/iot_gateway_start.sh
ExecReload=/linkedge/gateway/build/script/iot_gateway_start.sh
ExecStop=/linkedge/gateway/build/script/iot_gateway_stop.sh

[Install]
WantedBy=multi-user.target

Run the following commands to download the service file and copy it to the /etc/systemd/system/ directory.

wget http://iotedge-web.oss-cn-shanghai.aliyuncs.com/public/testingTool/LinkIoTEdge.service
sudo cp LinkIoTEdge.service /etc/systemd/system/LinkIoTEdge.service

Run the following commands to start or restart Link IoT Edge:

  • Start Link IoT Edge: sudo systemctl start LinkIoTEdge.service
  • Restart Link IoT Edge: sudo systemctl restart LinkIoTEdge.service

Run the following command to stop Link IoT Edge:

sudo systemctl stop LinkIoTEdge.service

Run the following command to enable service running at startup:

sudo systemctl enable LinkIoTEdge.service

What to do next

After the environment is built, you can connect your devices to Link IoT Edge by referring to Device access. You can also allocate additional resources, such as Function Compute resources and message routers, to edge instances to manage your devices.

After you connect a device to Link IoT Edge or allocate additional resources to an edge instance, you must perform the following steps to deploy the edge instance:

  1. On the Instance Details page, click Deploy in the upper-right corner. In the message that appears, click OK.
  2. If the deployment status is Deployed, the instance is deployed. You can click View Logs to view deployment details. You can also click View Deployment Logs in the upper-right corner of the Instance Details page to view the deployment history.
    View Deployment Logs