zoukankan      html  css  js  c++  java
  • mysql 增量导入到elasticsearch

    <pre name="code" class="html">zjtest7-redis:/odbc_es# cat /odbc_es/run_mysql.sh
    . ~/.bash_profile
    cd /root/check
    v_date=`date +%Y-%m-%d '--date=1 days ago'`
    echo $v_date
    sed -i s/v_date/$v_date/g mysql_import_es.sh
    sh ./mysql_import_es.sh
    cp -r -f .mysql_import_es.sh mysql_import_es.sh
    zjtest7-redis:/odbc_es# cat mysql_import_es.sh
    . ~/.bash_profile
    bin=/usr/local/elasticsearch-jdbc-2.3.4.0/bin
    lib=/usr/local/elasticsearch-jdbc-2.3.4.0/lib
    echo '{
        "elasticsearch.autodiscover":true,
         "elasticsearch.cluster":"es_cluster",
        "type" : "jdbc",
        "jdbc" : {
            "url" : "jdbc:mysql://192.168.32.218:3306/zjzc",
            "user" : "root",
            "password" : "1234567",
            "sql" : "select * from Client  where registerTime>="v_date 00:00:00" and registerTime<="v_date 23:59:59"",
           "elasticsearch" : {
                 "cluster" : "es_cluster",
                 "host" : "192.168.32.80",
                 "port" : 9300
            },
          "index" : "logstash-client-v_date", 
            "type" : "Client"
        }
    }' | java 
           -cp "${lib}/*" 
           -Dlog4j.configurationFile=${bin}/log4j2.xml 
           org.xbib.tools.Runner 
           org.xbib.tools.JDBCImporter
    zjtest7-redis:/odbc_es# cat ~/.bashrc 
    # .bashrc
    
    # User specific aliases and functions
    
    alias rm='rm -i'
    #alias cp='cp -i'
    alias mv='mv -i'
    
    # Source global definitions
    if [ -f /etc/bashrc ]; then
    	. /etc/bashrc
    fi
    


    
       
    
    
  • 相关阅读:
    程序员的基本修养之二
    jQuery学习之二
    面向对象程序的设计模式
    Mysql的复杂语句
    养成良好的做事风格
    前端模板学习bootstrap
    23. Merge k Sorted Lists
    953. Verifying an Alien Dictionary
    Daily Coding Problem: Problem #541
    396. Rotate Function
  • 原文地址:https://www.cnblogs.com/zhaoyangjian724/p/6199231.html
Copyright © 2011-2022 走看看