CN110825722A - 基于logstash的批量数据导入方法 - Google Patents

基于logstash的批量数据导入方法 Download PDF

Info

Publication number
CN110825722A
CN110825722A CN201911081379.2A CN201911081379A CN110825722A CN 110825722 A CN110825722 A CN 110825722A CN 201911081379 A CN201911081379 A CN 201911081379A CN 110825722 A CN110825722 A CN 110825722A
Authority
CN
China
Prior art keywords
data
import
mysql
logstash
index table
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201911081379.2A
Other languages
English (en)
Inventor
张章松
郑仁海
马杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Electric Fufu Mdt Infotech Ltd
Original Assignee
China Electric Fufu Mdt Infotech Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Electric Fufu Mdt Infotech Ltd filed Critical China Electric Fufu Mdt Infotech Ltd
Priority to CN201911081379.2A priority Critical patent/CN110825722A/zh
Publication of CN110825722A publication Critical patent/CN110825722A/zh
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages

Abstract

本发明公开基于LOGSTASH的批量数据导入方法,Logstash加载mysql数据库的连接驱动包,根据创建好的Elasticsearch的索引表结构,拼写需导入的mysql数据的sql查询语句,该sql语句中的字段名称与Elasticsearch的索引表的字段一样;根据机器性能调整内存参数,mysql数据查询完成后放在内存中,所以内存参数关系到一次性导入数据的数据量,运行logstash实现数据的导入。本发明以mysql数据库为准,一次性导入的数据量根据机器性能可以达到几千万条,解决了Elasticsearch数据的初始化已经需要频繁导入删除大批量数据的问题。

Description

基于LOGSTASH的批量数据导入方法
技术领域
本发明涉及大数据技术领域,尤其涉及基于LOGSTASH的批量数据导入方法。
背景技术
目前越来越多的系统需要实现快速检索功能,如何在大量数据的基础上快速检索出所要信息,是一个难题。数据量可能是几十亿级别,单单靠传统的数据库或者文档检索,根本解决不了该问题。ElasticSearch是一个基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口。它可以方便、快速的匹配检索的关键词,特点为检索速度快、数据量大、匹配度高。Logstash主要就是解决如何将数据库中已有的数据导入到ElasticSearch系统中,它的特点主要体现在,导入速度快、可以自定义连接数据库、自定义索引表结构等。Logstash缺点是没有提供java或者c的开放接口,只能人工操作,而且对机器的性能要求较高,机器性能影响Elasticsearch数据的导入速度。
发明内容
本发明的目的在于提供基于LOGSTASH的批量数据导入方法。
本发明采用的技术方案是:
基于LOGSTASH的批量数据导入方法,其包括以下步骤:
步骤1、根据项目要求确定表结构并创建Elasticsearch索引表,同时下载mysql数据连接驱动包;
步骤2、创建并更新Logstash的配置文件S,其具体步骤为:
步骤2-1、根据需求确定需从mysql数据库导入的数据;
步骤2-2、基于Elasticsearch索引表结构创建查询导入数据的mysql查询语句,且查询语句的字段名和字段个数与Elasticsearch索引表结构一样;
步骤2-3、为查询到不同类型的数据分别关联映射至对应类型的Elasticsearch索引表;
步骤2-4、基于步骤2-1至2-3的操作同步更新配置文件S;
步骤3、根据机器性能调整logstash的内存参数;
步骤4、logstash调用配置文件S进行数据的批量导入;
步骤5、导入结束后快读检索Elasticsearch的数据完成批量导入。
进一步地,步骤2-1中确定需导入的数据前先连接mysql并引用驱动包。
进一步地,步骤2中将配置文件S的任务设为定时任务。
本发明采用以上技术方案,以mysql数据库为准,实现数据从mysql导入到Elasticsearch系统中。Logstash要处理的是,加载mysql数据库的连接驱动包,然后根据创建好的Elasticsearch的索引表结构,拼写需要查询的mysql数据的sql语句,该sql语句中的字段名称必须与Elasticsearch的索引表的字段一样,否则会出现问题。这里导入的数据量以sql语句查询的结果为准。根据机器性能调整内存参数,由于本身mysql数据查询完成后放在内存中,所以内存参数关系到一次性导入数据的数据量,运行logstash实现数据的导入。
附图说明
以下结合附图和具体实施方式对本发明做进一步详细说明;
图1为本发明基于LOGSTASH的批量数据导入方法的流程示意图。
具体实施方式
如图1所示,本发明公开了基于LOGSTASH的批量数据导入方法,其包括以下步骤:
步骤1、根据项目要求确定表结构并创建Elasticsearch索引表,同时下载mysql数据连接驱动包;
步骤2、创建并更新Logstash的配置文件S,其具体步骤为:
步骤2-1、根据需求确定需从mysql数据库导入的数据;
步骤2-2、基于Elasticsearch索引表结构创建查询导入数据的mysql查询语句,且查询语句的字段名和字段个数与Elasticsearch索引表结构一样;
步骤2-3、为查询到不同类型的数据分别关联映射至对应类型的Elasticsearch索引表;
步骤2-4、基于步骤2-1至2-3的操作同步更新配置文件S;
步骤3、根据机器性能调整logstash的内存参数;
步骤4、logstash调用配置文件S进行数据的批量导入;
步骤5、导入结束后快读检索Elasticsearch的数据完成批量导入。
进一步地,步骤2-1中确定需导入的数据前先连接mysql并引用驱动包。
进一步地,步骤2中将配置文件S的任务设为定时任务。
本发明采用以上技术方案,以mysql数据库为准,实现数据从mysql导入到Elasticsearch系统中。Logstash要处理的是,加载mysql数据库的连接驱动包,然后根据创建好的Elasticsearch的索引表结构,拼写需要查询的mysql数据的sql语句,该sql语句中的字段名称必须与Elasticsearch的索引表的字段一样,否则会出现问题。这里导入的数据量以sql语句查询的结果为准。根据机器性能调整内存参数,由于本身mysql数据查询完成后放在内存中,所以内存参数关系到一次性导入数据的数据量,运行logstash实现数据的导入。本发明由于Logstash导入速度快,查询语句自由,一次性导入的数据量根据机器性能可以达到几千万条,解决了Elasticsearch数据的初始化已经需要频繁导入删除大批量数据的问题。

Claims (3)

1.基于LOGSTASH的批量数据导入方法,其特征在于:其包括以下步骤:
步骤1、根据项目要求确定表结构并创建Elasticsearch索引表,同时下载mysql数据连接驱动包;
步骤2、创建并更新Logstash的配置文件S,其具体步骤为:
步骤2-1、根据需求确定需从mysql数据库导入的数据;
步骤2-2、基于Elasticsearch索引表结构创建查询导入数据的mysql查询语句,且查询语句的字段名和字段个数与Elasticsearch索引表结构一样;
步骤2-3、为查询到不同类型的数据分别关联映射至对应类型的Elasticsearch索引表;
步骤2-4、基于步骤2-1至2-3的操作同步更新配置文件S;
步骤3、根据机器性能调整logstash的内存参数;
步骤4、logstash调用配置文件S进行数据的批量导入;
步骤5、导入结束后快读检索Elasticsearch的数据完成批量导入。
2.根据权利要求1所述的基于LOGSTASH的批量数据导入方法,其特征在于:步骤2中将配置文件S的任务设为定时任务。
3.根据权利要求1所述的基于LOGSTASH的批量数据导入方法,其特征在于:步骤2-1中确定需导入的数据前先连接mysql并引用驱动包。
CN201911081379.2A 2019-11-07 2019-11-07 基于logstash的批量数据导入方法 Pending CN110825722A (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911081379.2A CN110825722A (zh) 2019-11-07 2019-11-07 基于logstash的批量数据导入方法

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911081379.2A CN110825722A (zh) 2019-11-07 2019-11-07 基于logstash的批量数据导入方法

Publications (1)

Publication Number Publication Date
CN110825722A true CN110825722A (zh) 2020-02-21

Family

ID=69553477

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911081379.2A Pending CN110825722A (zh) 2019-11-07 2019-11-07 基于logstash的批量数据导入方法

Country Status (1)

Country Link
CN (1) CN110825722A (zh)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100262631A1 (en) * 2009-04-14 2010-10-14 Sun Microsystems, Inc. Mapping Information Stored In a LDAP Tree Structure to a Relational Database Structure
CN102915377A (zh) * 2012-11-14 2013-02-06 深圳市宏电技术股份有限公司 数据库转换或同步方法及系统
CN107368593A (zh) * 2017-07-25 2017-11-21 万帮充电设备有限公司 数据导入方法、装置及服务器
CN108614877A (zh) * 2018-04-27 2018-10-02 携程商旅信息服务(上海)有限公司 基于令牌桶的数据复制过程的监控方法及系统

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100262631A1 (en) * 2009-04-14 2010-10-14 Sun Microsystems, Inc. Mapping Information Stored In a LDAP Tree Structure to a Relational Database Structure
CN102915377A (zh) * 2012-11-14 2013-02-06 深圳市宏电技术股份有限公司 数据库转换或同步方法及系统
CN107368593A (zh) * 2017-07-25 2017-11-21 万帮充电设备有限公司 数据导入方法、装置及服务器
CN108614877A (zh) * 2018-04-27 2018-10-02 携程商旅信息服务(上海)有限公司 基于令牌桶的数据复制过程的监控方法及系统

Similar Documents

Publication Publication Date Title
US8682859B2 (en) Transferring records between tables using a change transaction log
CN103390020B (zh) 在数据库中存储数据的方法和系统
EP0617814B1 (en) Open office directory database views
US8037075B2 (en) Pattern index
US20060212264A1 (en) Apparatus and method for monitoring usage of components in a database index
US9594794B2 (en) Restoring records using a change transaction log
CN102054007B (zh) 一种检索方法及检索装置
CN103440245A (zh) 数据库系统的行列混合存储方法
CN107783985B (zh) 一种分布式数据库查询方法、装置及管理系统
CN112685446B (zh) 通过Elasticsearch数据库的复杂SQL查询方法、装置、处理器及存储介质
US9418154B2 (en) Push-model based index updating
WO2008147736A1 (en) User-defined relevance ranking for search
CN102027471A (zh) 改进的搜索引擎
US9594784B2 (en) Push-model based index deletion
CN103914462B (zh) 一种数据存储和查询方法以及装置
CN110941641B (zh) 一种跨多个数据库进行数据搜索的方法
US20090063397A1 (en) Method and system for disjunctive single index access
CN113918605A (zh) 数据查询方法、装置、设备以及计算机存储介质
Cioloca et al. Increasing database performance using indexes
CN110825722A (zh) 基于logstash的批量数据导入方法
CN111858581A (zh) 一种分页查询的方法、装置、存储介质和电子设备
CN109241098B (zh) 一种分布式数据库的查询优化方法
CN113127717A (zh) 一种密钥检索方法和系统
RU2656721C1 (ru) Способ организации хранения частично совпадающих больших объектов
US20130268510A1 (en) Special form of presentation of search results

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20200221

RJ01 Rejection of invention patent application after publication