You can use the data forwarding feature of the rules engine to forward processed data to ApsaraDB RDS instances for storage. This topic describes how to forward data to a destination instance.
Prerequisites
- An IoT Platform instance whose data can be forwarded to ApsaraDB RDS is created in a region that supports data forwarding to ApsaraDB RDS.
Supported instances Supported regions Enterprise Edition instances: Standard and Video - China (Shanghai)
- Japan (Tokyo)
Public instances - China (Shanghai)
- Singapore
- Japan (Tokyo)
- Germany (Frankfurt)
- US (Silicon Valley) and US (Virginia)
- An ApsaraDB RDS instance is created in the region where your IoT Platform instance resides. The database engine of the instance must be MySQL or Microsoft SQL Server and the network type of the instance must be VPC. A database and table are created. For more information about how to use ApsaraDB RDS, see the ApsaraDB RDS documentation.
- A data forwarding rule is created and an SQL statement that is used to process data is written. For more information, see Configure a data forwarding rule.
Background information
After you configure the data destination, the following configurations are automatically completed. Then, you can forward the device data to the ApsaraDB RDS instance by using the rules engine of IoT Platform.- IoT Platform occupies two IP addresses of the vSwitch in which the ApsaraDB RDS instance resides. The IPv4 CIDR block of the vSwitch is added to the whitelist of the ApsaraDB RDS instance.
- A managed security group is created in the virtual private cloud (VPC) in which the ApsaraDB RDS instance resides. The default name of the security group starts with sg-nsm-.
Limits
- Data forwarding is supported between IoT Platform instances and ApsaraDB RDS instances that reside in the same region. For example, you can forward the data of an IoT Platform instance in the China (Shanghai) region only to an ApsaraDB RDS table that resides in the China (Shanghai) region.
- You can forward data to ApsaraDB RDS instances that resides in VPCs only.
- You can forward data to MySQL and SQL Server instances.
- Data forwarding is supported between standard databases and privileged databases.
- You can forward only data in the JSON format.
Usage notes
You can use the new version or old version of the data forwarding feature to forward data to ApsaraDB RDS. For more information about how to use the new version of the data forwarding feature, see Use the new version of the data forwarding feature to forward data to ApsaraDB RDS.
Procedure
- Log on to the IoT Platform console.
- On the Overview page, find the instance that you want to manage and click the instance name to go to the Instance Details page.
Important Enterprise Edition instances are available in the China (Shanghai) and Japan (Tokyo) regions. If the Enterprise Edition instances are unavailable in the region that you select, skip this step.
- In the left-side navigation pane, choose .
- Click View next to the rule that you want to manage. The Data Forwarding Rule page appears.
Important If the new version of the Data Forwarding page is displayed, click Back to Previous Version in the upper-right corner, and then click View in the Actions column of the rule that you want to manage.
- In the Forward Data section, click Add Operation.
- In the Add Operation dialog box, select Store Data to ApsaraDB RDS in the Operation field. Set the parameters and click OK.
Parameter Description Operation Select Store Data to ApsaraDB RDS. Region Select the region where your IoT Platform instance resides. RDS Instance Select the ApsaraDB RDS instance to which you want to forward data. Database Enter the database name. Note If you use a privileged database, you must manually specify the database name.Account Enter the account of the ApsaraDB RDS instance. This account must have the read and write permissions on the database. Otherwise, the rules engine cannot write data to the ApsaraDB RDS instance. Note After the rules engine obtains the account, the rules engine writes only the data that matches the specified rule to the database. No extra operations are performed.Password Enter the password that is used to log on to the ApsaraDB RDS instance. Table Name Enter the name of the table that is created in the database. The rules engine writes data to the table. Key Enter the name of a field in the table. The rules engine writes data to the field. Value Enter the value of a field in the topic that you specified in the SQL statement. The rules engine writes the value to the field that you specified by using the Key parameter. Note- The data type of the Key parameter must be the same as the data type of the Value parameter. Otherwise, you may fail to save your parameter settings.
- You can enter a variable, such as
${deviceName}
.
Role Authorize IoT Platform to write data to ApsaraDB RDS. If no RAM roles exist, click Create RAM Role to go to the Resource Access Management (RAM) console, create a RAM role, and then grant permissions to the RAM role. For more information, see Create a RAM role.
- Go to the Data Forwarding page, find the rule that you managed, and then click Start in the Actions column of the rule.
- Log on to the ApsaraDB RDS console. On the Data Security page, create a whitelist or view whitelists. After you set the parameters, the rules engine adds the following IP addresses to the ApsaraDB RDS whitelist. Then, the rules engine can communicate with ApsaraDB RDS. If one of the following IP addresses is not displayed in the whitelist, you must manually add the IP address. For more information, see What is ApsaraDB RDS?.
- China (Shanghai):
100.104.53.192/26, 100.104.148.64/26, 100.104.6.192/26, 100.104.143.128/26, 100.104.76.0/24, 100.104.73.128/26, 100.104.200.64/26, 100.104.40.64/26, 100.104.3.0/26, 100.104.29.128/26, 100.104.121.0/26, and 100.104.84.64/26
- Singapore (Singapore): 100.104.106.0/24
- US (Silicon Valley):
100.104.8.0/24
- US (Virginia):
100.104.133.64/26
- Germany (Frankfurt):
100.104.160.192/26
- Japan (Tokyo):
100.104.160.192/26
- China (Shanghai):