CN110825722A - 基于logstash的批量数据导入方法 - Google Patents
基于logstash的批量数据导入方法 Download PDFInfo
- 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
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/22—Indexing; Data structures therefor; Storage structures
- G06F16/2228—Indexing structures
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/21—Design, administration or maintenance of databases
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/242—Query formulation
- G06F16/2433—Query languages
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Mathematical Physics (AREA)
- Computational Linguistics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本发明公开基于LOGSTASH的批量数据导入方法,Logstash加载mysql数据库的连接驱动包,根据创建好的Elasticsearch的索引表结构,拼写需导入的mysql数据的sql查询语句,该sql语句中的字段名称与Elasticsearch的索引表的字段一样;根据机器性能调整内存参数,mysql数据查询完成后放在内存中,所以内存参数关系到一次性导入数据的数据量,运行logstash实现数据的导入。本发明以mysql数据库为准,一次性导入的数据量根据机器性能可以达到几千万条,解决了Elasticsearch数据的初始化已经需要频繁导入删除大批量数据的问题。
Description
技术领域
本发明涉及大数据技术领域,尤其涉及基于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并引用驱动包。
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)
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 | 携程商旅信息服务(上海)有限公司 | 基于令牌桶的数据复制过程的监控方法及*** |
-
2019
- 2019-11-07 CN CN201911081379.2A patent/CN110825722A/zh active Pending
Patent Citations (4)
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 | |
CN104536959B (zh) | 一种Hadoop存取海量小文件的优化方法 | |
CA2121483C (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) | 一种分布式数据库查询方法、装置及管理*** | |
CN111400323B (zh) | 数据检索方法、***、设备及存储介质 | |
EP2766828A1 (en) | Presenting search results based upon subject-versions | |
US9418154B2 (en) | Push-model based index updating | |
EP2156331A1 (en) | User-defined relevance ranking for search | |
CN102027471A (zh) | 改进的搜索引擎 | |
CN106503195A (zh) | 一种基于搜索引擎的翻译词库检索方法及*** | |
CN112685446A (zh) | 通过Elasticsearch数据库的复杂SQL查询方法、装置、处理器及存储介质 | |
CN108319608A (zh) | 访问日志存储查询的方法、装置及*** | |
US20090106324A1 (en) | Push-model based index deletion | |
CN110941641B (zh) | 一种跨多个数据库进行数据搜索的方法 | |
CN113626464B (zh) | 基于ClickHouse数据库内存数据的查询支持方法及*** | |
US20090063397A1 (en) | Method and system for disjunctive single index access | |
CN101493824A (zh) | 数据库的数据检索方法和装置 | |
CN110825722A (zh) | 基于logstash的批量数据导入方法 | |
CN111858581A (zh) | 一种分页查询的方法、装置、存储介质和电子设备 | |
CN113986591A (zh) | 基于值日志的数据库闪回查询方法、***、存储介质及设备 |
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 |