• <small id='HSoZk'></small><noframes id='HSoZk'>

      <tfoot id='HSoZk'></tfoot>
    1. <i id='HSoZk'><tr id='HSoZk'><dt id='HSoZk'><q id='HSoZk'><span id='HSoZk'><b id='HSoZk'><form id='HSoZk'><ins id='HSoZk'></ins><ul id='HSoZk'></ul><sub id='HSoZk'></sub></form><legend id='HSoZk'></legend><bdo id='HSoZk'><pre id='HSoZk'><center id='HSoZk'></center></pre></bdo></b><th id='HSoZk'></th></span></q></dt></tr></i><div id='HSoZk'><tfoot id='HSoZk'></tfoot><dl id='HSoZk'><fieldset id='HSoZk'></fieldset></dl></div>
      1. <legend id='HSoZk'><style id='HSoZk'><dir id='HSoZk'><q id='HSoZk'></q></dir></style></legend>

        • <bdo id='HSoZk'></bdo><ul id='HSoZk'></ul>

        如何将 ElasticSearch 与 MySQL 集成?

        How to integrate ElasticSearch with MySQL?(如何将 ElasticSearch 与 MySQL 集成?)
        <i id='WZ6jS'><tr id='WZ6jS'><dt id='WZ6jS'><q id='WZ6jS'><span id='WZ6jS'><b id='WZ6jS'><form id='WZ6jS'><ins id='WZ6jS'></ins><ul id='WZ6jS'></ul><sub id='WZ6jS'></sub></form><legend id='WZ6jS'></legend><bdo id='WZ6jS'><pre id='WZ6jS'><center id='WZ6jS'></center></pre></bdo></b><th id='WZ6jS'></th></span></q></dt></tr></i><div id='WZ6jS'><tfoot id='WZ6jS'></tfoot><dl id='WZ6jS'><fieldset id='WZ6jS'></fieldset></dl></div>

          <small id='WZ6jS'></small><noframes id='WZ6jS'>

          <legend id='WZ6jS'><style id='WZ6jS'><dir id='WZ6jS'><q id='WZ6jS'></q></dir></style></legend>
            <tbody id='WZ6jS'></tbody>

                • <bdo id='WZ6jS'></bdo><ul id='WZ6jS'></ul>
                • <tfoot id='WZ6jS'></tfoot>

                  本文介绍了如何将 ElasticSearch 与 MySQL 集成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在我的一个项目中,我计划将 ElasticSearch 与 MySQL 结合使用.我已经成功安装了 ElasticSearch.我可以单独管理 ES 中的索引.但我不知道如何在 MySQL 中实现相同的功能.

                  In one of my project, I am planning to use ElasticSearch with MySQL. I have successfully installed ElasticSearch. I am able to manage index in ES separately. but I don't know how to implement the same with MySQL.

                  我已经阅读了一些文档,但我有点困惑,没有一个清晰的想法.

                  I have read a couple of documents but I am a bit confused and not having a clear idea.

                  推荐答案

                  我终于找到了答案.分享我的发现.

                  Finally i was able to find the answer. sharing my findings.

                  要在 Mysql 中使用 ElasticSearch,您需要 Java 数据库连接 (JDBC) 导入器.使用 JDBC 驱动程序,您可以将 mysql 数据同步到 elasticsearch.

                  To use ElasticSearch with Mysql you will require The Java Database Connection (JDBC) importer. with JDBC drivers you can sync your mysql data into elasticsearch.

                  我使用的是 ubuntu 14.04 LTS,您需要安装 Java8 才能运行用 Java 编写的 elasticsearch

                  I am using ubuntu 14.04 LTS and you will require to install Java8 to run elasticsearch as it is written in Java

                  以下是安装ElasticSearch 2.2.0和ElasticSearch-jdbc 2.2.0的步骤,请注意两个版本必须相同

                  following are steps to install ElasticSearch 2.2.0 and ElasticSearch-jdbc 2.2.0 and please note both the versions has to be same

                  安装Java8后.....如下安装elasticsearch 2.2.0

                  after installing Java8 ..... install elasticsearch 2.2.0 as follows

                  # cd /opt
                  
                  # wget https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/deb/elasticsearch/2.2.0/elasticsearch-2.2.0.deb
                  
                  # sudo dpkg -i elasticsearch-2.2.0.deb
                  

                  此安装过程会将 Elasticsearch 安装在/usr/share/elasticsearch/中,其配置文件将放置在/etc/elasticsearch 中.

                  This installation procedure will install Elasticsearch in /usr/share/elasticsearch/ whose configuration files will be placed in /etc/elasticsearch .

                  现在让我们在配置文件中做一些基本的配置.这里/etc/elasticsearch/elasticsearch.yml 是我们的配置文件您可以通过

                  Now lets do some basic configuration in config file. here /etc/elasticsearch/elasticsearch.yml is our config file you can open file to change by

                  nano /etc/elasticsearch/elasticsearch.yml
                  

                  并更改集群名称和节点名称

                  and change cluster name and node name

                  例如:

                  # ---------------------------------- Cluster -----------------------------------
                  #
                  # Use a descriptive name for your cluster:
                  #
                   cluster.name: servercluster
                  #
                  # ------------------------------------ Node ------------------------------------
                  #
                  # Use a descriptive name for the node:
                  #
                   node.name: vps.server.com
                  #
                  # Add custom attributes to the node:
                  #
                  # node.rack: r1
                  

                  现在保存文件并启动elasticsearch

                  Now save the file and start elasticsearch

                   /etc/init.d/elasticsearch start
                  

                  测试ES安装或不运行以下

                  to test ES installed or not run following

                   curl -XGET 'http://localhost:9200/?pretty'
                  

                  如果你得到关注,那么你的elasticsearch现在已经安装:)

                  If you get following then your elasticsearch is installed now :)

                  {
                    "name" : "vps.server.com",
                    "cluster_name" : "servercluster",
                    "version" : {
                      "number" : "2.2.0",
                      "build_hash" : "8ff36d139e16f8720f2947ef62c8167a888992fe",
                      "build_timestamp" : "2016-01-27T13:32:39Z",
                      "build_snapshot" : false,
                      "lucene_version" : "5.4.1"
                    },
                    "tagline" : "You Know, for Search"
                  }
                  

                  现在让我们安装 elasticsearch-JDBC

                  http://xbib.org/repository/org/xbib/elasticsearch/importer 下载/elasticsearch-jdbc/2.3.3.1/elasticsearch-jdbc-2.3.3.1-dist.zip 并将其解压到/etc/elasticsearch/并在那里创建logs"文件夹(日志路径应该是/etc/elasticsearch/logs)

                  download it from http://xbib.org/repository/org/xbib/elasticsearch/importer/elasticsearch-jdbc/2.3.3.1/elasticsearch-jdbc-2.3.3.1-dist.zip and extract the same in /etc/elasticsearch/ and create "logs" folder also there ( path of logs should be /etc/elasticsearch/logs)

                  我在 mysql 中创建了一个名为ElasticSearchDatabase"的数据库,并在名为test"的中创建了一个数据库,其中包含字段 id、name 和 email

                  I have one database created in mysql having name "ElasticSearchDatabase" and inside that table named "test" with fields id,name and email

                  cd /etc/elasticsearch
                  

                  并运行以下

                  echo '{
                  "type":"jdbc",
                  "jdbc":{
                  
                  "url":"jdbc:mysql://localhost:3306/ElasticSearchDatabase",
                  "user":"root",
                  "password":"",
                  "sql":"SELECT id as _id, id, name,email FROM test",
                  "index":"users",
                  "type":"users",
                  "autocommit":"true",
                  "metrics": {
                              "enabled" : true
                          },
                          "elasticsearch" : {
                               "cluster" : "servercluster",
                               "host" : "localhost",
                               "port" : 9300 
                          } 
                  }
                  }' | java -cp "/etc/elasticsearch/elasticsearch-jdbc-2.2.0.0/lib/*" -"Dlog4j.configurationFile=file:////etc/elasticsearch/elasticsearch-jdbc-2.2.0.0/bin/log4j2.xml" "org.xbib.tools.Runner" "org.xbib.tools.JDBCImporter"
                  

                  现在检查是否在ES中导入mysql数据

                  now check if mysql data imported in ES or not

                  curl -XGET http://localhost:9200/users/_search/?pretty
                  

                  如果一切顺利,你将可以看到你所有的 json 格式的 mysql 数据如果有任何错误,您将能够在/etc/elasticsearch/logs/jdbc.log 文件中看到它们

                  If all goes well, you will be able to see all your mysql data in json format and if any error is there you will be able to see them in /etc/elasticsearch/logs/jdbc.log file

                  注意:

                  在旧版本的 ES ... 插件中使用了 Elasticsearch-river-jdbc,但在最新版本中已完全弃用,因此请勿使用.

                  In older versions of ES ... plugin Elasticsearch-river-jdbc was used which is completely deprecated in latest version so do not use it.

                  我希望我能节省你的时间 :)

                  I hope i could save your time :)

                  如果有任何进一步的想法,我们将不胜感激

                  Any further thoughts are appreciated

                  参考网址:https://github.com/jprante/elasticsearch-jdbc

                  这篇关于如何将 ElasticSearch 与 MySQL 集成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to update a record using sequelize for node?(如何使用节点的 sequelize 更新记录?)
                  How to provide a mysql database connection in single file in nodejs(如何在 nodejs 中的单个文件中提供 mysql 数据库连接)
                  Looping Over Result Sets in MySQL(在 MySQL 中循环结果集)
                  Writing an SQL query to SELECT item from the following table(编写 SQL 查询以从下表中选择项目)
                  Converting MySQL code to Access: GROUP_CONCAT and a triple JOIN(将 MySQL 代码转换为 Access:GROUP_CONCAT 和三重 JOIN)
                  How can I convert an MDB (Access) file to MySQL (or plain SQL file)?(如何将 MDB (Access) 文件转换为 MySQL(或普通 SQL 文件)?)
                      <bdo id='TLrd2'></bdo><ul id='TLrd2'></ul>

                      • <legend id='TLrd2'><style id='TLrd2'><dir id='TLrd2'><q id='TLrd2'></q></dir></style></legend>

                      • <small id='TLrd2'></small><noframes id='TLrd2'>

                        <i id='TLrd2'><tr id='TLrd2'><dt id='TLrd2'><q id='TLrd2'><span id='TLrd2'><b id='TLrd2'><form id='TLrd2'><ins id='TLrd2'></ins><ul id='TLrd2'></ul><sub id='TLrd2'></sub></form><legend id='TLrd2'></legend><bdo id='TLrd2'><pre id='TLrd2'><center id='TLrd2'></center></pre></bdo></b><th id='TLrd2'></th></span></q></dt></tr></i><div id='TLrd2'><tfoot id='TLrd2'></tfoot><dl id='TLrd2'><fieldset id='TLrd2'></fieldset></dl></div>
                          <tbody id='TLrd2'></tbody>

                            <tfoot id='TLrd2'></tfoot>