如何配置Cygnus以保存在mysql中 [英] How to configure Cygnus to save in mysql

查看:78
本文介绍了如何配置Cygnus以保存在mysql中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试配置Cygnus,以便将Orion上下文数据持久化在MySQL数据库中.我已经安装了phpmyadmin,并且正在尝试使用此数据库来保存数据.整个工作流程如下:Orion接收一些数据,然后将其发送到Cygnus,最后Cygnus将其发送到SQL db.

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.

这是我的配置:

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

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 

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

(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.

这些列如下所示: recvTime-datetime, 字段1, 场2 .... field1_md-varchar, field2_md-varchar ....

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

如果您更改

cygnusagent.sinks.mysql-sink.attr_persistence = column

cygnusagent.sinks.mysql-sink.attr_persistence = row

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

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

希望对您有帮助.

这篇关于如何配置Cygnus以保存在mysql中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆