我想,才能在一个MySQL数据库坚持猎户座上下文数据配置天鹅。 我已经安装phpMyAdmin的,和我想利用这个数据库来保存数据。 整个工作流程如下之一:猎户收到<br/>一些数据,然后将它发送到天鹅座,最后天鹅将其发送到SQL数据库。
这是我的配置:
# 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
正确的配置文件是这样的:
# 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 - 日期时间,字段1,字段2 .... field1_md - VARCHAR,field2_md - VARCHAR ....
如果你改变
cygnusagent.sinks.mysql-sink.attr_persistence = column
至
cygnusagent.sinks.mysql-sink.attr_persistence = row
表自动创建的,但我更喜欢列的方式来保存和处理数据。
我希望这可以帮助你。