gpt4 book ai didi

mysql - 使用 JDBC 驱动程序从 ElasticSearch 中的 MySQL 表加载动态数据

转载 作者:行者123 更新时间:2023-11-29 17:33:07 28 4
gpt4 key购买 nike

我已经从我的elasticSearch索引中的MySQL表中获取了动态数据。为此,我使用了以下链接,但没有得到正确的结果:

我使用了以下代码:

echo '{
"type":"jdbc",
"jdbc":{

"url":"jdbc:mysql://localhost:3306/CDFL",
"user":"root",
"password":"root",
"useSSL":"false",
"sql":"SELECT * FROM event",
"index":"event",
"type":"event",
"autocommit":"true",
"metrics": {
"enabled" : true
},
"elasticsearch" : {
"cluster" : "servercluster",
"host" : "localhost",
"port" : 9300
}
}
}' | java -cp "/etc/elasticsearch/elasticsearch-jdbc-2.3.4.0/lib/*" -"Dlog4j.configurationFile=file:////etc/elasticsearch/elasticsearch-jdbc-2.3.4.0/bin/log4j2.xml" "org.xbib.tools.Runner" "org.xbib.tools.JDBCImporter"

为了获得解决方案,我使用了以下链接:

ElasticSearch how to integrate with Mysql

https://github.com/jprante/elasticsearch-jdbc

Fetching changes from table with ElasticSearch JDBC river

https://github.com/logstash-plugins/logstash-input-jdbc

最佳答案

我已经找到了这个问题的答案:在根目录中创建一个名为 event.sh 的文件,并在该文件中添加以下代码

event.sh

curl -XDELETE 'localhost:9200/event'
bin=/etc/elasticsearch/elasticsearch-jdbc-2.3.4.0/bin
lib=/etc/elasticsearch/elasticsearch-jdbc-2.3.4.0/lib
echo '{
"type":"jdbc",
"jdbc":{

"url":"jdbc:mysql://localhost:3306/CDFL",
"user":"root",
"password":"root",
"useSSL":"false",
"sql":"SELECT * FROM event",
"index":"event",
"type":"event",
"poll" : "6s",
"autocommit":"true",
"metrics": {
"enabled" : true
},
"elasticsearch" : {
"cluster" : "servercluster",
"host" : "localhost",
"port" : 9300
}
}
}' | java -cp "/etc/elasticsearch/elasticsearch-jdbc-2.3.4.0/lib/*" -"Dlog4j.configurationFile=file:////etc/elasticsearch/elasticsearch-jdbc-2.3.4.0/bin/log4j2.xml" "org.xbib.tools.Runner" "org.xbib.tools.JDBCImporter"
echo "sleeping while importer should run..."
sleep 10
curl -XGET 'localhost:9200/event/_refresh'

并在 cmd 中运行该文件,键入以下命令:

sh elasticSearch/event.sh

工作正常

关于mysql - 使用 JDBC 驱动程序从 ElasticSearch 中的 MySQL 表加载动态数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50488966/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com