1

My objective is to extract data from MySQL database using elasticsearch on Centos7.

I followed this link:ElasticSearch how to integrate with Mysql.

  • Database named ElasticSearchDatabase created
    • "test" the table name
  • Java 8 is installed.
  • Elasticsearch 6.2.4 is installed.
  • Elasticsearch-jdbc-2.3.4.1-dist.zip is unzipped under /etc/elasticsearch
  • "logs" folder is created under /etc/elasticsearch

I got this result when I have executing :

curl -XGET 'http://localhost:9200/?pretty'

{
  "name" : "vps.server.com",
  "cluster_name" : "my-application",
  "cluster_uuid" : "ICqEEr1VQHK8mZ82x7J_YQ",
  "version" : {
    "number" : "6.2.4",
    "build_hash" : "ccec39f",
    "build_date" : "2018-04-12T20:37:28.497551Z",
    "build_snapshot" : false,
    "lucene_version" : "7.2.1",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"

Then I have putted :

echo '{                                               
"type":"jdbc",
"jdbc":{

"url":"jdbc:mysql://localhost:3306/ElasticSearchDatabase",
"user":"root",
"password":"root",
"sql":"SELECT id as _id, id, name,email FROM test",
"index":"users",
"type":"users",
"autocommit":"true",
"metrics": {
            "enabled" : true
        },
        "elasticsearch" : {
             "cluster" : "my-application",
             "host" : "localhost",
             "port" : 9300 
        } 
}
}' | java -cp "/etc/elasticsearch/elasticsearch-jdbc-2.3.4.1/lib/*" - 
 "Dlog4j.configurationFile=file:////etc/elasticsearch/elasticsearch-jdbc- 
  2.3.4.1/bin/log4j2.xml" "org.xbib.tools.Runner" 
 "org.xbib.tools.JDBCImporter"

To get the result that I want I have executed this cmd:

curl -XGET http://localhost:9200/users/_search/?pretty

This is the result that I have got:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "index_not_found_exception",
        "reason" : "no such index",
        "resource.type" : "index_or_alias",
        "resource.id" : "users",
        "index_uuid" : "_na_",
        "index" : "users"
      }
    ],
    "type" : "index_not_found_exception",
    "reason" : "no such index",
    "resource.type" : "index_or_alias",
    "resource.id" : "users",
    "index_uuid" : "_na_",
    "index" : "users"
  },
  "status" : 404
}

Any one have an idea about this error. Thank you for your help.

3
  • Have you checked that the index has been created successfully? Commented Aug 6, 2018 at 15:11
  • Thank you for your question, yes it's about the index, so i checked about it and after that all worked fine for me , it's just about the configuration file. Commented Aug 7, 2018 at 8:02
  • first.. check your database's name is ElasticSearchDatabase and check also for database''s user and password. then check this path(/etc/elasticsearch/elasticsearch-jdbc-2.3.4.1/lib/) is really exist. Commented Dec 10, 2018 at 10:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.