elasticsearch,bigdata,query-performance,Mysql,elasticsearch,Bigdata,Query Performance" /> elasticsearch,bigdata,query-performance,Mysql,elasticsearch,Bigdata,Query Performance" />

使用logstash从MySQL向elasticsearch导入大量数据

使用logstash从MySQL向elasticsearch导入大量数据,mysql,elasticsearch,bigdata,query-performance,Mysql,elasticsearch,Bigdata,Query Performance,我正在寻找一种加速MySQL数据的解决方案,但在尝试索引之后,我没有找到加速MySQL计数(*)数据的解决方案。因此,我使用elasticsearch以获得更好的性能。我在MySQL中有大约300万条记录,我想用join导入所有记录,所以我使用PHP elasticsearch插件导入数据,但这也需要很长时间。然后我使用logstash并创建一个脚本来读取数据,但它也不起作用。我整个晚上都在运行我的系统,然后logstash将只插入600000条记录。那么解决这个问题的办法是什么呢?我是否需要提

我正在寻找一种加速MySQL数据的解决方案,但在尝试索引之后,我没有找到加速MySQL计数(*)数据的解决方案。因此,我使用elasticsearch以获得更好的性能。我在MySQL中有大约300万条记录,我想用join导入所有记录,所以我使用PHP elasticsearch插件导入数据,但这也需要很长时间。然后我使用logstash并创建一个脚本来读取数据,但它也不起作用。我整个晚上都在运行我的系统,然后logstash将只插入600000条记录。那么解决这个问题的办法是什么呢?我是否需要提高MySQL性能以导入elasticsearch,或者需要任何其他方式将大数据导入elasticsearch

检查我的脚本也

input {
  jdbc { 
    jdbc_connection_string => "jdbc:mysql://172.17.0.3:3306/repairs_db"
    # The user we wish to execute our statement as
    jdbc_user => "root"
    jdbc_password => ""
    jdbc_page_size => 50000 
    jdbc_paging_enabled => true
    # The path to our downloaded jdbc driver
    jdbc_driver_library => "/home/mysql-connector-java-5.1.46/mysql-connector-java-5.1.46.jar"
    jdbc_driver_class => "com.mysql.jdbc.Driver"
    # our query
    statement => "SELECT r.id,r.brand_id,r.product_brand,r.product_description,r.store_id,r.product_group,r.product_id,r.itm_product_group_desc,r.first_name,r.last_name,r.status,r.damaged,r.is_extended_warranty,r.is_floor_stock,r.is_inhome,r.callcentre,r.is_bsp_case,r.created,r.updated,r.is_sandbox_mode,pro.itm_descriptor,st.name as store_name,rp.name as repairer_name from requests r JOIN products pro ON r.product_id = pro.id JOIN stores st ON r.store_id = st.id JOIN repairers rp ON r.repairer_id = rp.id"
    }
  }
output {
  stdout { codec => json_lines }
  elasticsearch {
  "hosts" => "172.17.0.3:9200"
  "index" => "req-migrate"
  "document_type" => "data"
  }
}

请建议我将数据加载到elasticsearch中。在这种情况下,我们也可以使用MySQL吗?

为什么这个问题要用PHP标记?您能很好地快速执行SQL查询吗?因为带偏移量的数据限制工作正常。但是对于分页,比如我想要所有记录的总计数,这需要时间。SQL查询的结果对于日志存储来说可能太大了吗?也许您必须增加输入和输出之间的队列大小。请提供您试图优化的
选项的示例。此外,每次加载到Elasticsearch时,这些查询将运行多少次?