oracle - Elasticsearch + 甲骨文 JDBC 河

标签 oracle elasticsearch elasticsearch-jdbc-river

也许这是一个简单的问题,但我是 ElasticSearch 的新手。安装了 es 1.4,Oracle 10g 已启动并正在运行,在 ES 中加载的 jdbc 插件没有问题。 Marvel 也在工作.. 试图在 Marvel/Sense 中用这个语句创建一条河流:


PUT _river/mydata/_meta 
{
  "type": "jdbc",
  "jdbc": {
        "driver": "oracle.jdbc.OracleDriver",
        "url": “jdbc:oracle:thin:@host:1521:SID",
        "user": “oracleusr",
        "password": “ oraclepass",
        "index": “myindex",
        "type": “mytype",
        "sql": "select * from aTable"
      }
}

我总是收到这个错误:

{
   "error": "MapperParsingException[failed to parse]; nested: ElasticsearchParseException[Failed to derive xcontent from (offset=0, length=323): [80, 85, 84, 32, 95, 114, 105, 118, 101, 114, 47, 109, 52, 99, 47, 95, 109, 101, 116, 97, 32, 10, 123, 10, 32, 32, 34, 116, 121, 112, 101, 34, 58, 32, 34, 106, 100, 98, 99, 34, 44, 10, 32, 32, 34, 106, 100, 98, 99, 34, 58, 32, 123, 10, 32, 32, 32, 32, 32, 32, 32, 32, 34, 100, 114, 105, 118, 101, 114, 34, 58, 32, 34, 111, 114, 97, 99, 108, 101, 46, 106, 100, 98, 99, 46, 79, 114, 97, 99, 108, 101, 68, 114, 105, 118, 101, 114, 34, 44, 10, 32, 32, 32, 32, 32, 32, 32, 32, 34, 117, 114, 108, 34, 58, 32, -30, -128, -100, 106, 100, 98, 99, 58, 111, 114, 97, 99, 108, 101, 58, 116, 104, 105, 110, 58, 64, 49, 48, 46, 49, 57, 52, 46, 49, 55, 46, 49, 55, 51, 58, 49, 53, 50, 49, 58, 109, 52, 99, 34, 44, 10, 32, 32, 32, 32, 32, 32, 32, 32, 34, 117, 115, 101, 114, 34, 58, 32, -30, -128, -100, 109, 52, 99, 34, 44, 10, 32, 32, 32, 32, 32, 32, 32, 32, 34, 112, 97, 115, 115, 119, 111, 114, 100, 34, 58, 32, -30, -128, -100, 32, 109, 52, 99, 49, 50, 48, 57, 48, 53, 34, 44, 10, 32, 32, 32, 32, 32, 32, 32, 32, 34, 105, 110, 100, 101, 120, 34, 58, 32, -30, -128, -100, 109, 52, 99, 34, 44, 10, 32, 32, 32, 32, 32, 32, 32, 32, 34, 116, 121, 112, 101, 34, 58, 32, -30, -128, -100, 112, 97, 105, 115, 34, 44, 10, 32, 32, 32, 32, 32, 32, 32, 32, 34, 115, 113, 108, 34, 58, 32, 34, 115, 101, 108, 101, 99, 116, 32, 42, 32, 102, 114, 111, 109, 32, 77, 52, 67, 80, 65, 73, 83, 34, 10, 32, 32, 32, 32, 32, 32, 125, 10, 125, 10]]; ",
   "status": 400
}

在 CLI 上我得到:

    org.elasticsearch.index.mapper.MapperParsingException: failed to parse
    at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:562)
    at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:490)
    at org.elasticsearch.index.shard.service.InternalIndexShard.prepareIndex(InternalIndexShard.java:413)
    at org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:189)
    at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:511)
    at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:419)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.elasticsearch.ElasticsearchParseException: Failed to derive xcontent from (offset=0, length=323)

虽然我首先是连接问题,但检查它似乎是 ES 和 Oracle 中的映射问题。有人做过ES+Oracle River集成吗?非常感谢任何帮助。

最佳答案

我找到了一个非常直接的解决方案。而不是将命令放在我所做的事情上,而是有一个像这样的 json 配置文件:

{
    "type" : "jdbc" ,
    "jdbc" :{
        "strategy" : "oneshot",
        "driver" : "oracle.jdbc.OracleDriver",
        "url" : "jdbc:oracle:thin:@host:1521:DNS",
        "user" : "user",
        "password" : "password",
        "sql" : "select * from aTable",
        "poll" : "1h",
        "scale" : 0,
        "autocommit" : false,
        "fetchsize" : 100,
        "max_rows" : 0,
        "max_retries" : 3,
        "max_retries_wait" : "10s"
    },
    "index" : {
        "index" : "aIndex",
        "type" : "aType",
        "bulk_size" : 100
    }
}

然后像这样用 curl 调用它:

'http://127.0.0.1:9200/_river/jdbcriver/_meta' -d @config.json

我不知道这是解析器问题还是什么,但这种方式非常有效。

谢谢

关于oracle - Elasticsearch + 甲骨文 JDBC 河,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28385265/

相关文章:

sql - Oracle SQL - 检查约束

elasticsearch - Elasticsearch 与字段中的空间最匹配

python - 基于Elasticsearch的交互式反馈更新分数

java - 自动将 ElasticSearch 与 SQL 同步

Elasticsearch 数据库同步

sql - 具有多个GROUP BY的总体摘要

database - 更新oracle中的日期格式

elasticsearch - 使用 http 输入配置 Elasticsearch、Kibana 5、Logstash

mysql - Elasticsearch使用jdbc River与mysql数据库同步

java - 错误 ORA-01000 : maximum open cursors exceeded