• 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
    


    
                                        
    
  • 相关阅读:
    【Java】Java网络编程
    (4.47)sql server 中的 values 构造临时表
    阿里时序数据库 telegraf+influxdb+grafana for sqlserver input plugin
    全景互动制作工具
    湖南师范大学的案例
    git观点
    js-cookie对cookie的操作
    hsf的意义在于什么
    Prettier看这一篇就行了
    关于微前端的观点
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13350286.html
Copyright © 2020-2023  润新知