使用BSC将BOS中的数据导入Es
所有文档
menu

Elasticsearch BES

使用BSC将BOS中的数据导入Es

产品详情自助选购

介绍

本文主要介绍通过 BSC【百度流式计算服务】将数据从BOS【百度对象存储系统】中导入到Es中。

上传数据到BOS

登录管理控制台,进入BOS产品界面,创建bucket并上传测试文件:

image5-1.png

测试文件的内容如下:

image5-2.png

编辑BSC 作业

创建BOS Source

进入BSC编辑作业界面,创建bos source table, sql代码如下

CREATE table source_table_bos(
    stringtype STRING,
    longtype LONG
) with(
    type = 'BOS',
    path = 'bos://es-sink-test/test',
    encode = 'json'
);

其中path为上图中红框中指定的bos路径,并在路径前增加"bos://"前缀。

创建Es Sink Table

sql代码如下

create table sink_table_es(
    stringtype String,
    longtype Long
)with(
    type = 'ES',
    es.net.http.auth.user = 'superuser',
    es.net.http.auth.pass = 'bbs_2016',
    es.resource = 'bsc_test_2/doc_type',
    es.clusterId = '296245916518715392',
    es.region = 'bd',
    es.port = '8200',
    es.version = '6.5.3'
);

其中:

  • es.resource对应es的索引与类型,es会在bsc写入数据时自动创建指定索引
  • es.clusterId对应es的集群ID
  • es.region 表示 Es服务所在的地区的代码,可以参考 Es服务区域代码 中查询区域与代码的对应关系。

编写导入语句

sql语句如下:

insert into
	sink_table_es(stringtype, longtype) outputmode append
select
    stringtype,
    longtype
from
    source_table_bos;
    

保存作业并发布运行作业

查看Es中的数据

image5-3.png

上一篇
ELK
下一篇
使用BSC将Kafka中的数据导入Es