How to configure Cygnus to save in mysql

五迷三道 提交于 2019-12-14 02:49:34

问题


I'm trying to configure Cygnus in order to persist Orion context data in a MySQL database. I have installed phpmyadmin, and I'm trying to use this database to save the data. The whole workflow is the following one: Orion recives some data, then it is sent to Cygnus, and finally Cygnus sends it to the SQL db.

This is my configuration:

# 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:


A correct configuration file look like this:

# 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

You should also have a look at the iptables and open the MySQL port (default port is 3306)

For testing purposes you can run contextbroker in your terminal (don't forget to stop the service before) with

contextBroker -port 1026

and cygnus in other terminal (don't forget to stop the service before) with

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

(take care to change "YOURAGENT.CONF" and "cygnusagent" if you changed the name of the agent)

so you could see the output in realtime.

The database tables are not created automatically in column mode. So you would have to create the tables.

The columns look like : recvTime - datetime , field1 , field2 .... field1_md - varchar , field2_md - varchar ....

If you change

cygnusagent.sinks.mysql-sink.attr_persistence = column

to

cygnusagent.sinks.mysql-sink.attr_persistence = row

tables are created automatically, but I prefer the column way to save and handle data.

I hope this helps you.



来源:https://stackoverflow.com/questions/31704141/how-to-configure-cygnus-to-save-in-mysql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!