上传数据到阿里云对象存储
登录管理控制台,进入阿里云对象存储产品界面,创建bucket并上传测试文件:
创建阿里云对象存储 Source
进入BSC编辑作业界面,创建bos source table, sql代码如下
CREATE table source_table_bos( stringtype STRING, longtype LONG) with( type = '阿里云对象存储', 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 intosink_table_es(stringtype, longtype) outputmode appendselect stringtype, longtypefrom source_table_bos;
保存作业并发布运行作业