{"id":277386,"date":"2021-01-13T08:26:28","date_gmt":"2021-01-13T00:26:28","guid":{"rendered":"http:\/\/4563.org\/?p=277386"},"modified":"2021-01-13T08:26:28","modified_gmt":"2021-01-13T00:26:28","slug":"nebula-exchange-%e5%b7%a5%e5%85%b7-hive-%e6%95%b0%e6%8d%ae%e5%af%bc%e5%85%a5%e7%9a%84%e8%b8%a9%e5%9d%91%e4%b9%8b%e6%97%85","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=277386","title":{"rendered":"Nebula Exchange \u5de5\u5177 Hive \u6570\u636e\u5bfc\u5165\u7684\u8e29\u5751\u4e4b\u65c5"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  Nebula Exchange \u5de5\u5177 Hive \u6570\u636e\u5bfc\u5165\u7684\u8e29\u5751\u4e4b\u65c5               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : NebulaGraph <\/span>  <span><i><\/i> 1<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p><img decoding=\"async\" loading=\"lazy\" referrerpolicy=\"no-referrer\" rel=\"noreferrer\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2021\/01\/20210114_5fffa920d6290.png\" alt=\"Nebula Exchange \u5de5\u5177 Hive \u6570\u636e\u5bfc\u5165\u7684\u8e29\u5751\u4e4b\u65c5\" \/><\/p>\n<p>\u6458\u8981\uff1a\u672c\u6587\u7531\u793e\u533a\u7528\u6237 xrfinbj \u8d21\u732e\uff0c\u4e3b\u8981\u4ecb\u7ecd Exchange \u5de5\u5177\u4ece Hive \u6570\u4ed3\u5bfc\u5165\u6570\u636e\u5230 Nebula Graph \u7684\u6d41\u7a0b\u53ca\u76f8\u5173\u7684\u6ce8\u610f\u4e8b\u9879\u3002<\/p>\n<h2>1 \u80cc\u666f<\/h2>\n<p>\u516c\u53f8\u5185\u90e8\u6709\u4f7f\u7528\u56fe\u6570\u636e\u5e93\u7684\u573a\u666f\uff0c\u5185\u90e8\u901a\u8fc7\u6280\u672f\u9009\u578b\u786e\u5b9a\u4e86 Nebula Graph \u56fe\u6570\u636e\u5e93\uff0c\u8fd8\u9700\u8981\u9a8c\u8bc1 Nebula Graph \u6570\u636e\u5e93\u5728\u5b9e\u9645\u4e1a\u52a1\u573a\u666f\u4e0b\u7684\u67e5\u8be2\u6027\u80fd\u3002\u6240\u4ee5\u6025\u8feb\u7684\u9700\u8981\u5bfc\u5165\u6570\u636e\u5230 Nebula Graph \u5e76\u9a8c\u8bc1\u3002\u5728\u8fd9\u4e2a\u8fc7\u7a0b\u4e2d\u53d1\u73b0\u901a\u8fc7 Exchange \u5de5\u5177\u4ece hive \u6570\u4ed3\u5bfc\u5165\u6570\u636e\u5230 Nebula Graph \u6587\u6863\u4e0d\u662f\u5f88\u5168\uff0c\u6240\u4ee5\u628a\u8fd9\u4e2a\u6d41\u7a0b\u4e2d\u8e29\u5230\u7684\u5751\u8bb0\u5f55\u4e0b\u6765\uff0c\u56de\u9988\u793e\u533a\uff0c\u907f\u514d\u540e\u4eba\u8d70\u5f2f\u8def\u3002<\/p>\n<p>\u672c\u6587\u4e3b\u8981\u57fa\u4e8e\u6211\u4e4b\u524d\u53d1\u5728\u8bba\u575b\u7684 2 \u7bc7\u5e16\u5b50\uff1a<\/p>\n<ul>\n<li>exchange \u5982\u4f55\u5bfc\u5165 hive \u6570\u636e\u95ee\u9898<\/li>\n<li>exchange \u6267\u884c\u4ece hive \u5bfc\u5165\u6570\u636e\u62a5\u9519<\/li>\n<\/ul>\n<h2>2 \u73af\u5883\u4fe1\u606f<\/h2>\n<ul>\n<li>Nebula Graph \u7248\u672c\uff1anebula:nightly<\/li>\n<li>\u90e8\u7f72\u65b9\u5f0f\uff08\u5206\u5e03\u5f0f \/ \u5355\u673a \/ Docker \/ DBaaS \uff09\uff1aMac \u7535\u8111 Docker \u90e8\u7f72<\/li>\n<li> \u786c\u4ef6\u4fe1\u606f\n<ul>\n<li>\u78c1\u76d8\uff08 SSD \/ HDD \uff09\uff1aMac \u7535\u8111 SSD<\/li>\n<li>CPU \u3001\u5185\u5b58\u4fe1\u606f\uff1a16 G<\/li>\n<\/ul>\n<\/li>\n<li> \u6570\u4ed3\u73af\u5883\uff08 Mac \u7535\u8111\u642d\u5efa\u7684\u672c\u5730\u6570\u4ed3\uff09\uff1a\n<ul>\n<li>Hive 3.1.2<\/li>\n<li>Hadoop 3.2.1<\/li>\n<\/ul>\n<\/li>\n<li>Exchange \u5de5\u5177\uff1ahttps:\/\/github.com\/vesoft-inc\/nebula-java\/tree\/v1.0\/tools\/exchange<\/li>\n<\/ul>\n<p>\u7f16\u8bd1\u540e\u751f\u6210 jar \u5305 <\/p>\n<ul>\n<li>Spark spark-2.4.7-bin-hadoop2.7 (conf \u76ee\u5f55\u4e0b\u914d\u7f6e Hadoop 3.2.1 \u5bf9\u5e94\u7684 core-site.xml \uff0chdfs-site.xml \uff0chive-site.xml \u8bbe\u7f6e spark-env.sh) Scala code runner version 2.13.3 &#8212; Copyright 2002-2020, LAMP\/EPFL and Lightbend, Inc.<\/li>\n<\/ul>\n<h3>3 \u914d\u7f6e<\/h3>\n<h3>1 Nebula Graph DDL<\/h3>\n<pre><code>CREATE SPACE test_hive(partition_num=10, replica_factor=1); --\u521b\u5efa\u56fe\u7a7a\u95f4\uff0c\u672c\u793a\u4f8b\u4e2d\u5047\u8bbe\u53ea\u9700\u8981\u4e00\u4e2a\u526f\u672c USE test_hive; --\u9009\u62e9\u56fe\u7a7a\u95f4 test CREATE TAG tagA(idInt int, idString string, tboolean bool, tdouble double); -- \u521b\u5efa\u6807\u7b7e tagA CREATE TAG tagB(idInt int, idString string, tboolean bool, tdouble double); -- \u521b\u5efa\u6807\u7b7e tagB CREATE EDGE edgeAB(idInt int, idString string, tboolean bool, tdouble double); -- \u521b\u5efa\u8fb9\u7c7b\u578b edgeAB <\/code><\/pre>\n<h3>2 Hive DDL<\/h3>\n<pre><code>CREATE TABLE `tagA`(                                   `id` bigint,                                         `idInt` int,                                `idString` string,                                     `tboolean` boolean,                                     `tdouble` double) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\u000001' LINES TERMINATED BY 'n'; insert into tagA select 1,1,'str1',true,11.11; insert into tagA select 2,2,\"str2\",false,22.22;  CREATE TABLE `tagB`(                                   `id` bigint,                                         `idInt` int,                                `idString` string,                                     `tboolean` boolean,                                     `tdouble` double) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\u000001' LINES TERMINATED BY 'n'; insert into tagB select 3,3,\"str 3\",true,33.33; insert into tagB select 4,4,\"str 4\",false,44.44;  CREATE TABLE `edgeAB`(                                   `id_source` bigint,                                         `id_dst` bigint,             `idInt` int,                                `idString` string,                                     `tboolean` boolean,                                     `tdouble` double) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\u000001' LINES TERMINATED BY 'n'; insert into edgeAB select 1,3,5,\"edge 1\",true,55.55; insert into edgeAB select 2,4,6,\"edge 2\",false,66.66; <\/code><\/pre>\n<h3>3 \u6211\u7684\u6700\u65b0 nebula_application.conf \u6587\u4ef6<\/h3>\n<p>\u6ce8\u610f\u770b exec \u3001fields \u3001nebula.fields \u3001vertex \u3001source \u3001target \u5b57\u6bb5\u6620\u5c04<\/p>\n<pre><code>{   # Spark relation config   spark: {     app: {       name: Spark Writer     }      driver: {       cores: 1       maxResultSize: 1G     }      cores {       max: 4     }   }    # Nebula Graph relation config   nebula: {     address:{       graph: [\"192.168.1.110:3699\"]       meta: [\"192.168.1.110:45500\"]     }     user: user     pswd: password     space: test_hive      connection {       timeout: 3000       retry: 3     }      execution {       retry: 3     }      error: {       max: 32       output: \/tmp\/error     }     rate: {       limit: 1024       timeout: 1000     }   }    # Processing tags   tags: [     # Loading from Hive     {       name: tagA       type: {         source: hive         sink: client       }       exec: \"select id,idint,idstring,tboolean,tdouble from nebula.taga\"       fields: [id,idstring,tboolean,tdouble]       nebula.fields: [idInt,idString,tboolean,tdouble]       vertex: id       batch: 256       partition: 10     }     {       name: tagB       type: {         source: hive         sink: client       }       exec: \"select id,idint,idstring,tboolean,tdouble from nebula.tagb\"       fields: [id,idstring,tboolean,tdouble]       nebula.fields: [idInt,idString,tboolean,tdouble]       vertex: id       batch: 256       partition: 10     }   ]    # Processing edges   edges: [     # Loading from Hive     {       name: edgeAB       type: {         source: hive         sink: client       }       exec: \"select id_source,id_dst,idint,idstring,tboolean,tdouble from nebula.edgeab\"       fields: [id_source,idstring,tboolean,tdouble]       nebula.fields: [idInt,idString,tboolean,tdouble]       source: id_source       target: id_dst       batch: 256       partition: 10     }   ] }  <\/code><\/pre>\n<h2>4 \u6267\u884c\u5bfc\u5165<\/h2>\n<h3>4.1 \u786e\u4fdd nebula \u670d\u52a1\u542f\u52a8<\/h3>\n<h3>4.2 \u786e\u4fdd Hive \u8868\u548c\u6570\u636e\u5c31\u7eea<\/h3>\n<h3>4.3 \u6267\u884c spark-sql cli \u67e5\u770b Hive \u8868\u4ee5\u53ca\u6570\u636e\u662f\u5426\u6b63\u5e38\u4ee5\u786e\u4fdd Spark \u73af\u5883\u6ca1\u95ee\u9898<\/h3>\n<p><img decoding=\"async\" loading=\"lazy\" referrerpolicy=\"no-referrer\" rel=\"noreferrer\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2021\/01\/20210114_5fffa925ed719.jpg\" alt=\"Nebula Exchange \u5de5\u5177 Hive \u6570\u636e\u5bfc\u5165\u7684\u8e29\u5751\u4e4b\u65c5\" \/><\/p>\n<h3>4.4 \u4e00\u5207\u914d\u7f6e\u5de5\u4f5c\u5c31\u7eea\u540e\uff0c\u6267\u884c Spark \u547d\u4ee4\uff1a<\/h3>\n<pre><code>spark-submit --class com.vesoft.nebula.tools.importer.Exchange --master \u201clocal[4]\u201d \/xxx\/exchange-1.0.1.jar -c \/xxx\/nebula_application.conf -h <\/code><\/pre>\n<h3>4.5 \u5bfc\u5165\u6210\u529f\u540e \u53ef\u4ee5\u501f\u52a9 db_dump \u5de5\u5177\u67e5\u770b\u5bfc\u5165\u6570\u636e\u91cf \u9a8c\u8bc1\u6b63\u786e\u6027<\/h3>\n<pre><code>.\/db_dump --mode=stat --space=xxx --db_path=\/home\/xxx\/data\/storage0\/nebula   --limit 20000000 <\/code><\/pre>\n<h2>5 \u8e29\u5751\u4ee5\u53ca\u8bf4\u660e<\/h2>\n<ul>\n<li>\u7b2c\u4e00\u4e2a\u5751\u5c31\u662f spark-submit \u547d\u4ee4\u6ca1\u6709\u52a0 -h \u53c2\u6570<\/li>\n<li>Nebula Graph \u4e2d tagName \u662f\u5927\u5c0f\u5199\u654f\u611f\u7684\uff0ctags \u7684\u914d\u7f6e\u4e2d name \u914d\u7f6e\u7684\u5e94\u8be5\u662f Nebula Graph \u7684 tag \u540d<\/li>\n<li>Hive \u7684 int \u548c Nebula Graph \u7684 int \u4e0d\u4e00\u81f4\uff0cHive \u91cc\u9762\u7684 bigint \u5bf9\u5e94 Nebula Graph \u7684 int<\/li>\n<\/ul>\n<h3>\u5176\u4ed6\u8bf4\u660e\uff1a<\/h3>\n<ul>\n<li>\u7531\u4e8e Nebula Graph \u5e95\u5c42\u5b58\u50a8\u662f kv\uff0c\u91cd\u590d\u63d2\u5165\u5176\u5b9e\u662f\u8986\u76d6\uff0cupdate \u64cd\u4f5c\u7528 insert \u66ff\u4ee3\u6027\u80fd\u4f1a\u9ad8\u4e9b<\/li>\n<li>\u6587\u6863\u91cc\u9762\u4e0d\u5168\u7684\u5730\u65b9\u53ef\u80fd\u6682\u65f6\u53ea\u6709\u4e00\u8fb9\u770b\u6e90\u7801\u89e3\u51b3\uff0c\u4e00\u8fb9\u53bb\u8bba\u575b\u95ee\uff08\u5f00\u53d1\u540c\u5b66\u4e5f\u4e0d\u5bb9\u6613\u53c8\u8981\u7d27\u5f20\u7684\u5f00\u53d1\u53c8\u8981\u56de\u7b54\u7528\u6237\u7684\u7591\u95ee\uff09<\/li>\n<li>\u5bfc\u5165\u6570\u636e\u3001Compact \u4ee5\u53ca\u64cd\u4f5c\u5efa\u8bae\uff1ahttps:\/\/docs.nebula-graph.com.cn\/manual-CN\/3.build-develop-and-administration\/5.storage-service-administration\/compact\/<\/li>\n<li> \u6211\u5df2\u7ecf\u9a8c\u8bc1\u5982\u4e0b\u4e24\u4e2a\u573a\u666f:\n<ul>\n<li>\u7528 Spark 2.4 \u4ece Hive 2 \uff08 Hadoop 2 \uff09\u4e2d\u5bfc\u5165\u6570\u636e\u5230 Nebula Graph <\/li>\n<li>\u7528 Spark 2.4 \u4ece Hive3 \uff08 Hadoop 3 \uff09\u4e2d\u5bfc\u5165\u6570\u636e\u5230 Nebula Graph <\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u8bf4\u660e\uff1aExchange \u76ee\u524d\u8fd8\u4e0d\u652f\u6301 Spark 3\uff0c\u7f16\u8bd1\u540e\u8fd0\u884c\u62a5\u9519\uff0c\u6240\u4ee5\u6ca1\u6cd5\u9a8c\u8bc1 Spark 3 \u73af\u5883<\/p>\n<h3>\u8fd8\u6709\u4e00\u4e9b\u7591\u95ee<\/h3>\n<ul>\n<li>nebula_application.conf \u6587\u4ef6\u7684\u53c2\u6570 batch \u548c rate.limit \u5e94\u8be5\u5982\u4f55\u8bbe\u7f6e\uff1f\u53c2\u6570\u5982\u4f55\u6289\u62e9\uff1f<\/li>\n<li>Exchange \u5de5\u5177 Hive \u6570\u636e\u5bfc\u5165\u539f\u7406\uff08 Spark \u8fd9\u5757\u6211\u4e5f\u662f\u6700\u8fd1\u73b0\u5b66\u73b0\u7528\uff09<\/li>\n<\/ul>\n<h2>6 Exchange \u6e90\u7801 Debug<\/h2>\n<p>Spark Debug \u90e8\u5206\u53c2\u8003\u535a\u5ba2\uff1ahttps:\/\/dzone.com\/articles\/how-to-attach-a-debugger-to-apache-spark<\/p>\n<p>\u901a\u8fc7 Exchange \u6e90\u7801\u7684\u5b66\u4e60\u548c Debug \u80fd\u52a0\u6df1\u5bf9 Exchange \u539f\u7406\u7684\u7406\u89e3\uff0c\u540c\u65f6\u4e5f\u80fd\u53d1\u73b0\u4e00\u4e9b\u6587\u6863\u63cf\u8ff0\u4e0d\u6e05\u6670\u7684\u5730\u65b9\uff0c\u6bd4\u5982 \u5bfc\u5165 SST \u6587\u4ef6 \u548c Download and Ingest \u53ea\u6709\u7ed3\u5408\u6e90\u7801\u770b\u624d\u80fd\u53d1\u73b0\u6587\u6863\u63cf\u8ff0\u4e0d\u6e05\u6670\u903b\u8f91\u4e0d\u4e25\u8c28\u7684\u95ee\u9898\u3002<\/p>\n<p>\u901a\u8fc7\u6e90\u7801 Debug \u4e5f\u80fd\u53d1\u73b0\u4e00\u4e9b\u7b80\u5355\u7684\u53c2\u6570\u914d\u7f6e\u95ee\u9898\u3002<\/p>\n<p>\u8fdb\u5165\u6b63\u9898\uff1a<\/p>\n<p>\u6b65\u9aa4\u4e00\uff1a<\/p>\n<pre><code>export SPARK_SUBMIT_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=4000 <\/code><\/pre>\n<p>\u6b65\u9aa4\u4e8c\uff1a<\/p>\n<pre><code>spark-submit --class com.vesoft.nebula.tools.importer.Exchange --master \u201clocal\u201d \/xxx\/exchange-1.1.0.jar -c \/xxx\/nebula_application.conf -h Listening for transport dt_socket at address: 4000 <\/code><\/pre>\n<p>\u6b65\u9aa4\u4e09\uff1aIDEA \u914d\u7f6e<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" referrerpolicy=\"no-referrer\" rel=\"noreferrer\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2021\/01\/20210114_5fffa92c1cca4.png\" alt=\"Nebula Exchange \u5de5\u5177 Hive \u6570\u636e\u5bfc\u5165\u7684\u8e29\u5751\u4e4b\u65c5\" \/> <\/p>\n<p>\u6b65\u9aa4\u56db\uff1a\u5728 IDEA \u91cc\u9762\u70b9\u51fb Debug<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" referrerpolicy=\"no-referrer\" rel=\"noreferrer\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2021\/01\/20210114_5fffa931d726c.png\" alt=\"Nebula Exchange \u5de5\u5177 Hive \u6570\u636e\u5bfc\u5165\u7684\u8e29\u5751\u4e4b\u65c5\" \/> <\/p>\n<h2>7 \u5efa\u8bae\u4e0e\u611f\u8c22<\/h2>\n<p>\u611f\u8c22 vesoft \u63d0\u4f9b\u4e86\u5b87\u5b99\u6027\u80fd\u6700\u5f3a\u7684 Nebula Graph \u56fe\u6570\u636e\u5e93\uff0c\u80fd\u89e3\u51b3\u4e1a\u52a1\u4e2d\u5f88\u591a\u5b9e\u9645\u95ee\u9898\uff0c\u4e2d\u9014\u8fd9\u70b9\u75db\u4e0d\u7b97\u4ec0\u4e48\uff08\u770b\u4e4b\u524d\u7684\u5206\u4eab\uff0c360 \u6570\u79d1\u4ed6\u4eec\u90a3\u4e2a\u75db\u624d\u662f\u771f\u75db\uff09\u3002\u4e2d\u9014\u9047\u5230\u7684\u95ee\u9898\u90fd\u6709\u5e78\u5f97\u5230\u793e\u533a\u53ca\u65f6\u7684\u53cd\u9988\u89e3\u7b54\uff0c\u518d\u6b21\u611f\u8c22<\/p>\n<p><strong>\u5f88\u671f\u5f85 Exchange \u652f\u6301 Nebula Graph 2.0<\/strong><\/p>\n<h2>\u53c2\u8003\u8d44\u6599<\/h2>\n<ul>\n<li>exchange \u548c Spark Writer \u4ec0\u4e48\u5173\u7cfb\uff1f<\/li>\n<li>Spark Writer \u624b\u518c<\/li>\n<li>Spark Writer \u624b\u518c<\/li>\n<\/ul>\n<p>\u559c\u6b22\u8fd9\u7bc7\u6587\u7ae0\uff1f\u6765\u6765\u6765\uff0c\u7ed9\u6211\u4eec\u7684 GitHub \u70b9\u4e2a star \u8868\u9f13\u52b1\u5566~~       <\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>0<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>Nebula Exchange \u5de5&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/277386"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=277386"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/277386\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=277386"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=277386"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=277386"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}