Elasticsearch數(shù)據(jù)遷移至MaxCompute
本文為您介紹如何通過(guò)DataWorks數(shù)據(jù)同步功能,遷移阿里云Elasticsearch集群上的數(shù)據(jù)至MaxCompute。
前提條件
已開(kāi)通MaxCompute服務(wù)。
開(kāi)通指導(dǎo),詳情請(qǐng)參見(jiàn)開(kāi)通MaxCompute。
已開(kāi)通DataWorks服務(wù)。
開(kāi)通指導(dǎo),詳情請(qǐng)參見(jiàn)開(kāi)通DataWorks服務(wù)。
在DataWorks上已完成創(chuàng)建業(yè)務(wù)流程。
本例使用DataWorks簡(jiǎn)單模式,詳情請(qǐng)參見(jiàn)創(chuàng)建業(yè)務(wù)流程。
已搭建阿里云Elasticsearch集群。
進(jìn)行數(shù)據(jù)遷移前,您需要保證自己的阿里云Elasticsearch集群環(huán)境正常。搭建阿里云Elasticsearch集群的詳細(xì)過(guò)程,請(qǐng)參見(jiàn)快速入門。
本示例中阿里云Elasticsearch的具體配置如下:
地域:華東2(上海)
可用區(qū):上海可用區(qū)B
版本:5.5.3 with Commercial Feature
背景信息
Elasticsearch是一個(gè)基于Lucene的搜索服務(wù)器,它提供了一個(gè)多用戶分布式的全文搜索引擎。Elasticsearch是遵從Apache開(kāi)源條款的一款開(kāi)源產(chǎn)品,是當(dāng)前主流的企業(yè)級(jí)搜索引擎。
阿里云Elasticsearch提供Elasticsearch 5.5.3 with Commercial Feature、6.3.2 with Commercial Feature、6.7.0 with Commercial Feature及商業(yè)插件X-pack服務(wù),致力于數(shù)據(jù)分析、數(shù)據(jù)搜索等場(chǎng)景服務(wù)。在開(kāi)源Elasticsearch基礎(chǔ)上提供企業(yè)級(jí)權(quán)限管控、安全監(jiān)控告警、自動(dòng)報(bào)表生成等功能。
操作步驟
在Elasticsearch上創(chuàng)建源表。詳情請(qǐng)參見(jiàn)通過(guò)DataWorks將MaxCompute數(shù)據(jù)同步至Elasticsearch。
在MaxCompute上創(chuàng)建目標(biāo)表。
登錄DataWorks控制臺(tái),單擊左側(cè)導(dǎo)航欄的 ,在下拉框中選擇對(duì)應(yīng)工作空間后單擊進(jìn)入數(shù)據(jù)開(kāi)發(fā)。
在數(shù)據(jù)開(kāi)發(fā)頁(yè)面,右鍵單擊目標(biāo)工作流程,選擇 。
在彈出的新建表對(duì)話框中,填寫名稱,并單擊新建。
說(shuō)明如果綁定多個(gè)實(shí)例,則需要選擇MaxCompute引擎實(shí)例。
在表的編輯頁(yè)面,單擊DDL。
在DDL對(duì)話框,輸入如下建表語(yǔ)句,單擊生成表結(jié)構(gòu)。
create table elastic2mc_bankdata ( age string, job string, marital string, education string, default string, housing string, loan string, contact string, month string, day of week string );
單擊提交到生產(chǎn)環(huán)境。
同步數(shù)據(jù)。
進(jìn)入數(shù)據(jù)開(kāi)發(fā)頁(yè)面,右鍵單擊指定業(yè)務(wù)流程,選擇 。
在新建節(jié)點(diǎn)對(duì)話框中,輸入名稱,并單擊確認(rèn)。
在頂部菜單欄上,單擊圖標(biāo)。
在腳本模式下,單擊頂部菜單欄上的圖標(biāo)。
在導(dǎo)入模板對(duì)話框中選擇來(lái)源類型、數(shù)據(jù)源、目標(biāo)類型及數(shù)據(jù)源,并單擊確定。
配置腳本。
示例代碼如下。代碼釋義請(qǐng)參見(jiàn)Elasticsearch Reader。
{ "type": "job", "steps": [ { "stepType": "elasticsearch", "parameter": { "retryCount": 3, "column": [ "age", "job", "marital", "education", "default", "housing", "loan", "contact", "month", "day_of_week", "duration", "campaign", "pdays", "previous", "poutcome", "emp_var_rate", "cons_price_idx", "cons_conf_idx", "euribor3m", "nr_employed", "y" ], "scroll": "1m", "index": "es_index", "pageSize": 1, "sort": { "age": "asc" }, "type": "elasticsearch", "connTimeOut": 1000, "retrySleepTime": 1000, "endpoint": "http://es-cn-xxxx.xxxx.xxxx.xxxx.com:9200", "password": "xxxx", "search": { "match_all": {} }, "readTimeOut": 5000, "username": "xxxx" }, "name": "Reader", "category": "reader" }, { "stepType": "odps", "parameter": { "partition": "", "truncate": true, "compress": false, "datasource": "odps_first", "column": [ "age", "job", "marital", "education", "default", "housing", "loan", "contact", "month", "day_of_week", "duration", "campaign", "pdays", "previous", "poutcome", "emp_var_rate", "cons_price_idx", "cons_conf_idx", "euribor3m", "nr_employed", "y" ], "emptyAsNull": false, "table": "elastic2mc_bankdata" }, "name": "Writer", "category": "writer" } ], "version": "2.0", "order": { "hops": [ { "from": "Reader", "to": "Writer" } ] }, "setting": { "errorLimit": { "record": "0" }, "speed": { "throttle": false, "concurrent": 1, "dmu": 1 } } }
說(shuō)明您可以在創(chuàng)建的阿里云Elasticsearch集群的基本信息中,查看公網(wǎng)地址和公網(wǎng)端口信息。
單擊圖標(biāo)運(yùn)行代碼。
您可以在運(yùn)行日志查看運(yùn)行結(jié)果。
查看結(jié)果。
右鍵單擊業(yè)務(wù)流程,選擇 。
在新建節(jié)點(diǎn)對(duì)話框中輸入節(jié)點(diǎn)名稱,并單擊確認(rèn)。
在ODPS SQL節(jié)點(diǎn)編輯頁(yè)面輸入如下語(yǔ)句。
SELECT * FROM elastic2mc_bankdata;
單擊圖標(biāo)運(yùn)行代碼。
您可以在運(yùn)行日志查看運(yùn)行結(jié)果。