gpt4 book ai didi

fiware - Cygnus MySQL 接收器错误(attr_persistence = 列)

转载 作者:行者123 更新时间:2023-12-01 15:15:13 26 4
gpt4 key购买 nike

我正在使用 cygnus 在 MySQL 数据库和 Cosmos 中存储数据。将数据存储在 cosmos 中可以正常工作,但是当存储在 MySQL 中时,特别是使用属性“cygnusagent.sinks.mysql-sink.attr_persistence = column”而不是“cygnusagent.sinks.mysql-sink.attr_persistence = row”时,数据不是存储,我在水槽日志中收到一些错误。

由于在使用列属性时需要预先创建表(更多信息:https://github.com/telefonicaid/fiware-cygnus/blob/master/doc/design/OrionMySQLSink.md#important-notes-regarding-the-persistence-mode),我创建表:

CREATE TABLE def_servpath_sensorreading4_sensorreading(systemid int,value float, sensorid int, nodeid int);

DESCRIBE def_servpath_sensorreading4_sensorreading(systemid int,value float, sensorid int, nodeid int);
mysql> DESCRIBE def_servpath_sensorreading4_sensorreading;
+----------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+---------+------+-----+---------+-------+
| systemid | int(11) | YES | | NULL | |
| value | float | YES | | NULL | |
| sensorid | int(11) | YES | | NULL | |
| nodeid | int(11) | YES | | NULL | |
+----------+---------+------+-----+---------+-------+
4 rows in set (0.00 sec)

这是水槽日志:

11 Aug 2015 11:40:31,977 INFO  [SinkRunner-PollingRunner-DefaultSinkProcessor] (com.telefonica.iot.cygnus.sinks.OrionMySQLSink.persist:240)  - [mysql-sink] Persisting data at OrionMySQLSink. Database: def_serv, Table: def_servpath_sensorreading3_sensorreading, Timestamp: 2015-08-11T08:40:31.969, Data (attrs): {systemid=1, value=29.2, sensorid=2, nodeid=1}, (metadata): {sensorid_md=[], systemid_md=[], value_md=[], nodeid_md=[]}
11 Aug 2015 11:40:31,978 WARN [SinkRunner-PollingRunner-DefaultSinkProcessor] (com.telefonica.iot.cygnus.sinks.OrionSink.process:182) - Bad context data (Unknown column 'systemid' in 'field list')
11 Aug 2015 11:40:31,978 INFO [SinkRunner-PollingRunner-DefaultSinkProcessor] (com.telefonica.iot.cygnus.sinks.OrionSink.process:193) - Finishing transaction (1439278647-655-0000000005)
11 Aug 2015 11:40:32,369 INFO [SinkRunner-PollingRunner-DefaultSinkProcessor] (com.telefonica.iot.cygnus.sinks.OrionHDFSSink.persist:356) - [hdfs-sink] Persisting data at OrionHDFSSink. HDFS file (def_serv/def_servpath/sensorreading3_sensorreading/sensorreading3_sensorreading.txt), Data ({"recvTime":"2015-08-11T08:40:31.969Z","nodeid":"1", "nodeid_md":[],"sensorid":"2", "sensorid_md":[],"systemid":"1", "systemid_md":[],"value":"29.2", "value_md":[]})
11 Aug 2015 11:40:32,858 INFO [SinkRunner-PollingRunner-DefaultSinkProcessor] (com.telefonica.iot.cygnus.sinks.OrionSink.process:193) - Finishing transaction (1439278647-655-0000000005)

我在哪里收到以下错误:

Bad context data (Unknown column 'systemid' in 'field list')

我是否需要在与元数据相关的表中创建更多列?我是否正确地创建了表格?

提前致谢。

最佳答案

是的,this文档的一部分详细说明了必须为每个属性添加一个关于元数据的附加列(通过在属性名称后加上 _md)。然而,没有给出一个例子(顺便说一句,有待改进),所以这里是(根据您的具体情况量身定制):

create table def_servpath_sensorreading4_sensorreading(recvTime text, systemid int, systemid_md text, value float, value_md text, sensorid int, sensorid_md text, nodeid int, nodeid_md text);

属性名称与表中的字段匹配非常重要。我的意思是,您的实体必须具有名为systemid 的属性;如果您的属性将被命名为 system_id 那么它也必须是字段名称(作为元数据字段 system_id_md)。

如您所见,有一个关于接收时间的附加列 (recvTime),因为每次收到通知时 Cygnus 都会保留这样的值。

关于表名,你写得很完美:它必须是通知的FIWARE服务路径、实体ID和实体类型的串联('_'作为串联字符)。这样的表必须存在于名为通知的 FIWARE 服务的数据库中。

关于fiware - Cygnus MySQL 接收器错误(attr_persistence = 列),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31937580/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com