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