Installing ElasticSearch with River JDBC on RedHat/CentOS

  • Post author:
  • Post category:RedHat

1. Install OpenJDK if it doesn’t already exist. Here we are running as root, so sudo is not required.

> yum install java-1.7.0-openjdk.x86_64

2. Install ElasticSearch using yum. The latest ElasticSearch version is 1.4 at the time of this writing.

> rpm --import https://packages.elasticsearch.org/GPG-KEY-elasticsearch
> vi /etc/yum.repos.d/elasticsearch.repo

# contents of elasticsearch.repo
[elasticsearch-1.4]
name=Elasticsearch repository for 1.4.x packages
baseurl=http://packages.elasticsearch.org/elasticsearch/1.4/centos
gpgcheck=1
gpgkey=http://packages.elasticsearch.org/GPG-KEY-elasticsearch
enabled=1

> yum install elasticsearch

3. Start ElasticSearch as a service, and tail the log.

> chkconfig --add elasticsearch
> service elasticsearch start
> tail -f /var/log/elasticsearch/elasticsearch.log

4. Install River JDBC. We are using the latest Rivers JDBC version, which is 1.4.0.8 at the time of this writing.

> cd /usr/share/elasticsearch
> bin/plugin --install jdbc --url http://xbib.org/repository/org/xbib/elasticsearch/plugin/elasticsearch-river-jdbc/1.4.0.8/elasticsearch-river-jdbc-1.4.0.8-plugin.zip
cd plugins/jdbc/
> wget {url-to-jdbc-jar}/ojdbc6.jar
> service elasticsearch restart

5. Configure River. Do the initial, oneshot data load from Oracle. Replace the variables which are surrounded by {}. If you are unfamiliar with ElasticSearch indexes and types, they are similar to relational databases and tables.

PUT
    {
        "type" : "jdbc",
        "jdbc" : {
            "url" : "jdbc:oracle:thin:@//{IP}:1521/{SERVICE}",
            "user" : "{USERNAME}",
            "password" : "{PASSWORD}",
            "sql" : [{
                "statement" : "{QUERY}"
            }],
            "index" : "{INDEX}",
            "type" :  "{TYPE}"
        }
    }

6. Load new or updated data every 10 minutes.

PUT
    {
        "type" : "jdbc",
        "schedule" : "0 */10 * * * ?",
        "jdbc" : {
            "url" : "jdbc:oracle:thin:@//{IP}:1521/{SERVICE}",
            "user" : "{USERNAME}",
            "password" : "{PASSWORD}",
            "sql" : [{
                "statement" : "{QUERY where created_on > ? or modified_on > ?}",
                "parameter" : [ "$river.state.last_active_begin", "$river.state.last_active_begin" ]
            }],
            "index" : "{INDEX}",
            "type" :  "{TYPE}"
        }
    }

This Post Has One Comment

  1. Prashant

    I am trying to install this. But I am facing one issue in step 4.

    I installed jdbc plugin using below command. Only version is 1.7.0.1.
    bin/plugin –install jdbc –url http://xbib.org/repository/org/xbib/elasticsearch/importer/elasticsearch-jdbc/1.7.0.1/elasticsearch-jdbc-1.7.0.1-dist.zip

    But i did not find ojdbc6.jar in /plugins/jdbc folder. I found elasticsearch-jdbc-1.7.0.1-uberjar.jar in lib directory.

    When i execute following command
    # wget /plugins/jdbc/lib/elasticsearch-jdbc-1.7.0.1-uberjar.jar

    Am i missing anything? I am very new guy in the world of computer programming. And I have given this assignment to complete.

    Can you please help me out in this?

    Thanks

Comments are closed.