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
    


    
                                        
    
  • 相关阅读:
    滑动窗口法学习
    209. Minimum Size Subarray Sum
    485. Max Consecutive Ones
    27. Remove Element
    167. Two Sum II
    561. Array Partition I
    344. Reverse String
    14. 最长公共前缀
    layui上传文件时出现 请求上传接口出错
    Linux-5.13将初步支持苹果M1 Soc
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13350286.html
Copyright © 2011-2022 走看看