如何配置Cygnus以保存在mysql中

时间:2015-07-29 14:58:49

标签: fiware fiware-orion fiware-cygnus

我试图配置Cygnus以便在MySQL数据库中保留Orion上下文数据。我已经安装了phpmyadmin,我试图使用这个数据库来保存数据。整个工作流程如下:Orion收集一些数据,然后将其发送到Cygnus,最后Cygnus将其发送到SQL db。

这是我的配置:

# OrionMySQLSink configuration
# channel name from where to read notification events
cygnusagent.sinks.mysql-sink.channel = mysql-channel
# sink class, must not be changed
cygnusagent.sinks.mysql-sink.type = com.telefonica.iot.cygnus.sinks.OrionMySQLSink
# the FQDN/IP address where the MySQL server runs 
cygnusagent.sinks.mysql-sink.mysql_host = x.y.z.w
# the port where the MySQL server listens for incomming connections
cygnusagent.sinks.mysql-sink.mysql_port = 3306
# a valid user in the MySQL server
cygnusagent.sinks.mysql-sink.mysql_username = root
# password for the user above
cygnusagent.sinks.mysql-sink.mysql_password = xxxxxxxxxxxx
# how the attributes are stored, either per row either per column (row, column)
cygnusagent.sinks.mysql-sink.attr_persistence = column

1 个答案:

答案 0 :(得分:1)

正确的配置文件如下所示:

# channel name from where to read notification events
cygnusagent.sinks.mysql-sink.channel = mysql-channel
# sink class, must not be changed
cygnusagent.sinks.mysql-sink.type = com.telefonica.iot.cygnus.sinks.OrionMySQLSink
# the FQDN/IP address where the MySQL server runs
cygnusagent.sinks.mysql-sink.mysql_host = localhost 
# the port where the MySQL server listes for incomming connections
cygnusagent.sinks.mysql-sink.mysql_port = 3306
# a valid user in the MySQL server
cygnusagent.sinks.mysql-sink.mysql_username = YOURUSERNAME
# password for the user above
cygnusagent.sinks.mysql-sink.mysql_password = YOURPASSWORD
# how the attributes are stored, either per row either per column (row, column)
cygnusagent.sinks.mysql-sink.attr_persistence = column

您还应该查看iptables并打开MySQL端口(默认端口是3306)

出于测试目的,您可以在终端中运行contextbroker(不要忘记以前停止服务)

contextBroker -port 1026

和其他终端的天鹅座(不要忘记以前停止服务)

/usr/cygnus/bin/cygnus-flume-ng agent --conf /usr/cygnus/conf/ -f /usr/cygnus/conf/YOURAGENT.CONF -n cygnusagent -Dflume.root.logger=INFO,console 

(如果您更改了代理商的名称,请注意更改“YOURAGENT.CONF”和“cygnusagent”)

所以你可以实时看到输出。

不会在列模式下自动创建数据库表。所以你必须创建表格。

列看起来像: recvTime - datetime, field1, 域2 .... field1_md - varchar, field2_md - varchar ....

如果你改变了

cygnusagent.sinks.mysql-sink.attr_persistence = column

cygnusagent.sinks.mysql-sink.attr_persistence = row

表是自动创建的,但我更喜欢使用列方式来保存和处理数据。

我希望这会对你有所帮助。