2

我想订阅 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

读完这个问题后,我在这一行更改了我的 agent_mysql.conf: 并cygnusagent.sinks.mysql-sink.attr_persistence = column重新 cygnusagent.sinks.mysql-sink.attr_persistence = row启动了服务。然后我更新了 orion 实体并查询了数据库,但什么也没发生。

天鹅座日志文件:http://pastebin.com/B2FNKcVf

注意:我的 JAVA_HOME 已设置。

4

1 回答 1

1

正如您在发布的日志中看到的那样,Cygnus 日志文件存在问题:

java.io.FileNotFoundException: ./logs/cygnus.log (No such file or directory)

在那之后,天鹅座停止了。您必须检查有关 log4j 的配置,一切都在/usr/cygnus/conf/log4j.properties(它应该存在,它是由 RPM 创建的......如果不存在 - 因为您是从源代码而不是 RPM 中创建的 - 必须从可用模板创建)。另外,您可以发布您的实例配置文件吗?无论如何,您正在运行哪个版本?

编辑 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.

于 2015-10-27T07:34:04.027 回答