1

我正在尝试配置 Cygnus 以便将 Orion 上下文数据持久保存在 MySQL 数据库中。我已经安装了 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
4

1 回答 1

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、field2 .... field1_md - varchar、field2_md - varchar ....

如果你改变

cygnusagent.sinks.mysql-sink.attr_persistence = column

cygnusagent.sinks.mysql-sink.attr_persistence = row

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

我希望这可以帮助你。

于 2015-08-24T13:39:23.830 回答