使用BSC将BOS中的数据导入Es
更新时间:2022-12-01
介绍
本文主要介绍通过 BSC【百度流式计算服务】将数据从BOS【百度对象存储系统】中导入到Es中。
上传数据到BOS
登录管理控制台,进入BOS产品界面,创建bucket并上传测试文件:
测试文件的内容如下:
编辑BSC 作业
创建BOS Source
进入BSC编辑作业界面,创建bos source table, sql代码如下
Plain Text
1CREATE table source_table_bos(
2 stringtype STRING,
3 longtype LONG
4) with(
5 type = 'BOS',
6 path = 'bos://es-sink-test/test',
7 encode = 'json'
8);
其中path为上图中红框中指定的bos路径,并在路径前增加"bos://"前缀。
创建Es Sink Table
sql代码如下
Plain Text
1create table sink_table_es(
2 stringtype String,
3 longtype Long
4)with(
5 type = 'ES',
6 es.net.http.auth.user = 'superuser',
7 es.net.http.auth.pass = 'bbs_2016',
8 es.resource = 'bsc_test_2/doc_type',
9 es.clusterId = '296245916518715392',
10 es.region = 'bd',
11 es.port = '8200',
12 es.version = '6.5.3'
13);
其中:
- es.resource对应es的索引与类型,es会在bsc写入数据时自动创建指定索引
- es.clusterId对应es的集群ID
- es.region 表示 Es服务所在的地区的代码,可以参考 Es服务区域代码 中查询区域与代码的对应关系。
编写导入语句
sql语句如下:
Plain Text
1insert into
2 sink_table_es(stringtype, longtype) outputmode append
3select
4 stringtype,
5 longtype
6from
7 source_table_bos;
8
保存作业并发布运行作业