Cygnus 没有更新数据库
Cygnus didn't update database
我想订阅 Orion 向 Cygnus 发送通知。然后 cygnus 会将所有数据保存在 mysql 数据库中。我用这个脚本订阅car1的速度属性
(curl 130.206.118.44:1026/v1/subscribeContext -s -S --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Fiware-Service: vehicles' --header 'Fiware-ServicePath: /4wheels' -d @- | python -mjson.tool) <<EOF
{
"entities": [
{
"type": "car",
"isPattern": "false",
"id": "car1"
}
],
"attributes": [
"speed",
"oil_level"
],
"reference": "http://192.168.1.49:5050/notify",
"duration": "P1M",
"notifyConditions": [
{
"type": "ONCHANGE",
"condValues": [
"speed"
]
}
],
"throttling": "PT1S"
}
EOF
但是当我更新1号车的速度属性时,cygnus并没有更新数据库。
可用的数据库:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
关于我的 cygnus 服务和我的 cygnus 配置的一些信息 (systemctl status cygnus
):
cygnus.service - SYSV: cygnus
Loaded: loaded (/etc/rc.d/init.d/cygnus)
Active: active (exited) since Wed 2015-10-21 17:54:07 UTC; 8min ago
Process: 31566 ExecStop=/etc/rc.d/init.d/cygnus stop (code=exited, status=0/SUCCESS)
Process: 31588 ExecStart=/etc/rc.d/init.d/cygnus start (code=exited, status=0/SUCCESS)
Oct 21 17:54:05 cygnus systemd[1]: Starting SYSV: cygnus...
Oct 21 17:54:05 cygnus su[31593]: (to cygnus) root on none
Oct 21 17:54:07 cygnus cygnus[31588]: Starting Cygnus mysql... [ OK ]
Oct 21 17:54:07 cygnus systemd[1]: Started SYSV: cygnus.
agent_mysql.conf:
# main configuration
cygnusagent.sources = http-source
cygnusagent.sinks = mysql-sink
cygnusagent.channels = mysql-channel
# source configuration
cygnusagent.sources.http-source.channels = mysql-channel
cygnusagent.sources.http-source.type = org.apache.flume.source.http.HTTPSource
cygnusagent.sources.http-source.port = 5050
cygnusagent.sources.http-source.handler = com.telefonica.iot.cygnus.handlers.OrionRestHandler
# url target
cygnusagent.sources.http-source.handler.notification_target = /notify
cygnusagent.sources.http-source.handler.default_service = def_serv
cygnusagent.sources.http-source.handler.default_service_path = def_servpath
cygnusagent.sources.http-source.handler.events_ttl = 10
cygnusagent.sources.http-source.interceptors = ts gi
cygnusagent.sources.http-source.interceptors.ts.type = timestamp
cygnusagent.sources.http-source.interceptors.gi.type = com.telefonica.iot.cygnus.interceptors.GroupingInterceptor$Builder
cygnusagent.sources.http-source.interceptors.gi.grouping_rules_conf_file = /usr/cygnus/conf/grouping_rules.conf
#Orion MysqlSink Configuration
cygnusagent.sinks.mysql-sink.channel = mysql-channel
cygnusagent.sinks.mysql-sink.type = com.telefonica.iot.cygnus.sinks.OrionMySQLSink
cygnusagent.sinks.mysql-sink.enable_grouping = false
# mysqldb ip
cygnusagent.sinks.mysql-sink.mysql_host = 127.0.0.1
# mysqldb port
cygnusagent.sinks.mysql-sink.mysql_port = 3306
cygnusagent.sinks.mysql-sink.mysql_username = root
cygnusagent.sinks.mysql-sink.mysql_password = 12345
cygnusagent.sinks.mysql-sink.attr_persistence = column
cygnusagent.sinks.mysql-sink.table_type = table-by-destination
# configuracao do canal mysql
cygnusagent.channels.mysql-channel.type = memory
cygnusagent.channels.mysql-channel.capacity = 1000
cygnusagent.channels.mysql-channel.transactionCapacity = 100
阅读 this 问题后,我在这一行中更改了 agent_mysql.conf:
cygnusagent.sinks.mysql-sink.attr_persistence = column
到 cygnusagent.sinks.mysql-sink.attr_persistence = row
并重新启动了服务。然后我更新了 orion 实体并查询了数据库,但没有任何反应。
Cygnus 日志文件:http://pastebin.com/B2FNKcVf
注意:我的JAVA_HOME设置好了。
正如您在 post 编辑的日志中看到的,Cygnus 日志文件存在问题:
java.io.FileNotFoundException: ./logs/cygnus.log (No such file or directory)
之后,Cygnus 停了下来。您必须检查有关 log4j 的配置,所有内容都在 /usr/cygnus/conf/log4j.properties
(它应该存在,它是由 RPM 创建的...如果不存在 - 因为您是从源而不是 RPM 获取的,它必须从创建可用模板)。另外,可以post你的实例配置文件吗?不管怎样,你是哪个版本运行?
编辑 1
最近,我们发现另一个用户处理同样的错误,问题是 /usr/cygnus/conf/log4j.properties
文件的内容是:
flume.root.logger=INFO,LOGFILE
flume.log.dir=./log
flume.log.file=flume.log
而不是模板包含的内容:
flume.root.logger=INFO,LOGFILE
flume.log.dir=/var/log/cygnus/
flume.log.file=flume.log
更改后它起作用了,因为 RPM 创建 /var/log/cygnus
但不是 ./log
。
我想订阅 Orion 向 Cygnus 发送通知。然后 cygnus 会将所有数据保存在 mysql 数据库中。我用这个脚本订阅car1的速度属性
(curl 130.206.118.44:1026/v1/subscribeContext -s -S --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Fiware-Service: vehicles' --header 'Fiware-ServicePath: /4wheels' -d @- | python -mjson.tool) <<EOF
{
"entities": [
{
"type": "car",
"isPattern": "false",
"id": "car1"
}
],
"attributes": [
"speed",
"oil_level"
],
"reference": "http://192.168.1.49:5050/notify",
"duration": "P1M",
"notifyConditions": [
{
"type": "ONCHANGE",
"condValues": [
"speed"
]
}
],
"throttling": "PT1S"
}
EOF
但是当我更新1号车的速度属性时,cygnus并没有更新数据库。
可用的数据库:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
关于我的 cygnus 服务和我的 cygnus 配置的一些信息 (systemctl status cygnus
):
cygnus.service - SYSV: cygnus
Loaded: loaded (/etc/rc.d/init.d/cygnus)
Active: active (exited) since Wed 2015-10-21 17:54:07 UTC; 8min ago
Process: 31566 ExecStop=/etc/rc.d/init.d/cygnus stop (code=exited, status=0/SUCCESS)
Process: 31588 ExecStart=/etc/rc.d/init.d/cygnus start (code=exited, status=0/SUCCESS)
Oct 21 17:54:05 cygnus systemd[1]: Starting SYSV: cygnus...
Oct 21 17:54:05 cygnus su[31593]: (to cygnus) root on none
Oct 21 17:54:07 cygnus cygnus[31588]: Starting Cygnus mysql... [ OK ]
Oct 21 17:54:07 cygnus systemd[1]: Started SYSV: cygnus.
agent_mysql.conf:
# main configuration
cygnusagent.sources = http-source
cygnusagent.sinks = mysql-sink
cygnusagent.channels = mysql-channel
# source configuration
cygnusagent.sources.http-source.channels = mysql-channel
cygnusagent.sources.http-source.type = org.apache.flume.source.http.HTTPSource
cygnusagent.sources.http-source.port = 5050
cygnusagent.sources.http-source.handler = com.telefonica.iot.cygnus.handlers.OrionRestHandler
# url target
cygnusagent.sources.http-source.handler.notification_target = /notify
cygnusagent.sources.http-source.handler.default_service = def_serv
cygnusagent.sources.http-source.handler.default_service_path = def_servpath
cygnusagent.sources.http-source.handler.events_ttl = 10
cygnusagent.sources.http-source.interceptors = ts gi
cygnusagent.sources.http-source.interceptors.ts.type = timestamp
cygnusagent.sources.http-source.interceptors.gi.type = com.telefonica.iot.cygnus.interceptors.GroupingInterceptor$Builder
cygnusagent.sources.http-source.interceptors.gi.grouping_rules_conf_file = /usr/cygnus/conf/grouping_rules.conf
#Orion MysqlSink Configuration
cygnusagent.sinks.mysql-sink.channel = mysql-channel
cygnusagent.sinks.mysql-sink.type = com.telefonica.iot.cygnus.sinks.OrionMySQLSink
cygnusagent.sinks.mysql-sink.enable_grouping = false
# mysqldb ip
cygnusagent.sinks.mysql-sink.mysql_host = 127.0.0.1
# mysqldb port
cygnusagent.sinks.mysql-sink.mysql_port = 3306
cygnusagent.sinks.mysql-sink.mysql_username = root
cygnusagent.sinks.mysql-sink.mysql_password = 12345
cygnusagent.sinks.mysql-sink.attr_persistence = column
cygnusagent.sinks.mysql-sink.table_type = table-by-destination
# configuracao do canal mysql
cygnusagent.channels.mysql-channel.type = memory
cygnusagent.channels.mysql-channel.capacity = 1000
cygnusagent.channels.mysql-channel.transactionCapacity = 100
阅读 this 问题后,我在这一行中更改了 agent_mysql.conf:
cygnusagent.sinks.mysql-sink.attr_persistence = column
到 cygnusagent.sinks.mysql-sink.attr_persistence = row
并重新启动了服务。然后我更新了 orion 实体并查询了数据库,但没有任何反应。
Cygnus 日志文件:http://pastebin.com/B2FNKcVf
注意:我的JAVA_HOME设置好了。
正如您在 post 编辑的日志中看到的,Cygnus 日志文件存在问题:
java.io.FileNotFoundException: ./logs/cygnus.log (No such file or directory)
之后,Cygnus 停了下来。您必须检查有关 log4j 的配置,所有内容都在 /usr/cygnus/conf/log4j.properties
(它应该存在,它是由 RPM 创建的...如果不存在 - 因为您是从源而不是 RPM 获取的,它必须从创建可用模板)。另外,可以post你的实例配置文件吗?不管怎样,你是哪个版本运行?
编辑 1
最近,我们发现另一个用户处理同样的错误,问题是 /usr/cygnus/conf/log4j.properties
文件的内容是:
flume.root.logger=INFO,LOGFILE
flume.log.dir=./log
flume.log.file=flume.log
而不是模板包含的内容:
flume.root.logger=INFO,LOGFILE
flume.log.dir=/var/log/cygnus/
flume.log.file=flume.log
更改后它起作用了,因为 RPM 创建 /var/log/cygnus
但不是 ./log
。