{"id":1116,"date":"2019-05-28T13:25:18","date_gmt":"2019-05-28T05:25:18","guid":{"rendered":"https:\/\/199604.com\/?p=1116"},"modified":"2019-07-13T11:23:43","modified_gmt":"2019-07-13T03:23:43","slug":"sqoop%e5%85%a5hdfs%e5%87%ba%e7%8e%b0no-primary-key-could-be-found-forxx%e7%9a%84%e9%97%ae%e9%a2%98%e8%ae%b0%e5%bd%95","status":"publish","type":"post","link":"https:\/\/199604.com\/1116","title":{"rendered":"sqoop\u5165hdfs\u51fa\u73b0No primary key could be found forXX\u7684\u95ee\u9898\u8bb0\u5f55"},"content":{"rendered":"<p>\u5982\u679c\u4f7f\u7528\u8fc7sqoop\u5de5\u5177\uff0c\u628a\u5173\u7cfb\u578b\u6570\u636e\u5e93(ORACLE\/Mysql)\u7684\u6570\u636e\u5bfc\u5165\u5230hdfs\u65f6\uff0c\u5e94\u8be5\u4e5f\u4f1a\u51fa\u73b0\u4e00\u4e9b\u95ee\u9898..\u5982\u679c\u8fd8\u4e0d\u77e5\u9053\u7684\u8bdd\uff0c\u53ef\u4ee5\u5148\u5230https:\/\/199604.com\/1102( sqoop\u7684\u7b80\u5355\u7528\u6cd5)\uff0c\u6211\u8fd9\u7bc7\u6587\u7ae0\u7b80\u5355\u5165\u95e8\u3002<\/p>\n<hr \/>\n<p>\u6700\u8fd1\uff0c\u51fa\u73b0\u6700\u591a\u7684\u95ee\u9898\uff0c\u5e94\u8be5\u662f\u62a5\u8fd9\u4e2a\u9519&#8211;&gt;<\/p>\n<p>ERROR tool.ImportTool: Error during import: No primary key could be found for table IOT_DIG_CAT_COUNT_BAK_1904. Please specify one with &#8211;split-by or perform a sequential import with &#8216;-m 1&#8217;.<\/p>\n<p>\u4ece\u62a5\u9519\u7684\u4fe1\u606f\u63d0\u793a\u53ef\u4ee5\u770b\u51fa\uff0c\u4ed6\u8868\u793a\u60a8\u8fd9\u4e2a\u8868\u627e\u4e0d\u5230\u4e3b\u952e\uff0c\u9700\u8981\u6211\u4eec\u4f7f\u7528\u628a&#8211;split-by\u6216\u8005\u628a\u53c2\u6570-m\u8bbe\u7f6e\u4e3a1\u3002<\/p>\n<p>\u00a0\u4ece\u8fd9\u4e2a\u62a5\u9519\u7684\u4fe1\u606f\u91cc\uff0c\u5176\u5b9e\u4e5f\u53ef\u4ee5\u6df1\u5165\u804a\u4e00\u4e0b\uff0c\u5c31\u662f &#8211;split-by\u4e0e-m\u7684\u5173\u7cfb(\u5c0f\u767d\u5f00\u53d1\u4e5f\u53ef\u4ee5\u662f\u5783\u573e\u5f00\u53d1\uff0c\u6211\u5199\u7684\u4f60\u4eec\u6700\u597d\u522b\u4fe1)\uff1a<\/p>\n<p>1.split-by \u6839\u636e\u4e0d\u540c\u7684\u53c2\u6570\u7c7b\u578b\u6709\u4e0d\u540c\u7684\u5207\u5206\u65b9\u6cd5\uff0c\u5982int\u578b\uff0cSqoop\u4f1a\u53d6\u6700\u5927\u548c\u6700\u5c0fsplit-by \u5b57\u6bb5\u503c\uff0c\u7136\u540e\u6839\u636e\u4f20\u5165\u7684-m\uff08&#8211;num-mappers\uff09\u6765\u786e\u5b9a\u5212\u5206\u51e0\u4e2a\u533a\u57df\u3002\u6bd4\u5982select max(id),min(id) from\u5f97\u5230\u7684max(id)\u548cmin(id)\u5206\u522b\u4e3a1000\u548c1,\u800c\u8fd9\u65f6&#8211;num-mappers\uff08-m\uff09\u4e3a2\u7684\u8bdd\uff0c\u7a0b\u5e8f\u5c31\u4f1a\u5206\u6210\u4e24\u4e2amap\u7684\u533a\u57df\uff0c\uff081,500\uff09\uff0c\uff08501-1000\uff09\uff0c\u540c\u65f6\u4e5f\u4f1a\u5206\u62102\u4e2asql\u7ed92\u4e2amap\u53bb\u8fdb\u884c\u5bfc\u5165\u64cd\u4f5c\uff0c\u5176\u5b9e\u5c31\u662f\u5206\u9875\u67e5\u8be2&#8230;sql\u7c7b\u4f3c select xxx\u5b57\u6bb5 from queryTableName wher id &gt;=1 and id &lt;=500,\u540e\u9762\u7684sql\u7701\u7565..\u7136\u540e\u4f60-m\u76842\u4e2amap\u5c31\u53bb\u6267\u884c\u8fd9\u4e24\u4e2asql\u3002<\/p>\n<p>2.\u8fd9\u4e2a\u95ee\u9898\uff0c\u5e94\u8be5\u4e5f\u5f88\u5e38\u89c1\uff0c\u56e0\u4e3a\u6211\u5148\u5728\u516c\u53f8\uff0c\u5f88\u591a\u8868\u90fd\u662f\u65e0\u4e3b\u952e\u7684\uff0c\u6240\u4ee5\u6709\u65f6\u5019split-by \u5b57\u6bb5\u4e0d\u662fint(number)\u7c7b\u578b\uff0c\u6211\u89e3\u51b3\u7684\u529e\u6cd5\u5c31\u662f\u6700\u65e0\u5948\u7684\u529e\u6cd5\u4e86\uff0c\u53ea\u80fd\u7528\u4e00\u4e2amap \u53bb\u6267\u884c\uff0csplit-by\u4e0d\u8bbe\u7f6e\u3002\u65f6\u95f4\u6548\u7387\u5c31\u6162\u4e86\u4e0b\u6765\u5427\u3002ps\uff1a\u5f53-m \u8bbe\u7f6e\u7684\u503c\u5927\u4e8e1\u65f6\uff0csplit-by\u5fc5\u987b\u8bbe\u7f6e\u5b57\u6bb5<\/p>\n<p>3.\u5982\u679csplit-by \u8bbe\u7f6e\u7684\u5b57\u6bb5\u662fint(number)\u7c7b\u578b\uff0c\u4f46\u662f\u5462\uff0c\u4f60\u7684\u6570\u5b57\u4e0d\u662f\u8fde\u7eed\u7684..\u8fd9\u79cd\u60c5\u51b5\u6709\u53ef\u80fd\u4f1a\u9020\u6210 \u4e00\u4e9bmap\u6267\u884c\u6570\u91cf\u6bd4\u8f83\u591a\uff0c\u4e00\u4e9b\u6bd4\u8f83\u5c11\uff0c\u4ece\u800c\u9020\u6210\u4e86\u67d0\u4e9bmap\u6d88\u8017\u65f6\u95f4\u975e\u5e38\u4e45\uff0c\u4e00\u4e9b\u9a6c\u4e0a\u6267\u884c\u5b8c\u7684\u60c5\u51b5\uff0c\u9020\u6210\u6570\u636e\u503e\u659c\u6709\u53ef\u80fd\u62a5\u9519&#8230;<\/p>\n<p>\u597d\u4e86\uff0c\u6839\u636e\u8fd9\u4e2a\u89e3\u91ca\uff0c\u5e94\u8be5\u90fd\u77e5\u9053\uff0c\u62a5\u8fd9\u4e2a\u9519\uff0c\u600e\u4e48\u89e3\u51b3\u4e86\u5427&#8230;end\uff0c\u7761\u4e2a\u6f02\u4eae\u7684\u5348\u4f11&#8230;<\/p>\n<hr \/>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='http:\/\/qn.199604.com\/wp-content\/uploads\/2017\/07\/zhifubao.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large\" data-original=\"http:\/\/qn.199604.com\/wp-content\/uploads\/2017\/07\/zhifubao.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" width=\"318\" height=\"406\" \/><\/div><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='http:\/\/qn.199604.com\/wp-content\/uploads\/2017\/07\/weixin.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large\" data-original=\"http:\/\/qn.199604.com\/wp-content\/uploads\/2017\/07\/weixin.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" width=\"268\" height=\"291\" \/><\/div><\/p>\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u679c\u4f7f\u7528\u8fc7sqoop\u5de5\u5177\uff0c\u628a\u5173\u7cfb\u578b\u6570\u636e\u5e93(ORACLE\/Mysql)\u7684\u6570\u636e\u5bfc\u5165\u5230hdfs\u65f6\uff0c\u5e94\u8be5\u4e5f\u4f1a\u51fa\u73b0\u4e00\u4e9b\u95ee [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[177,198,199],"class_list":["post-1116","post","type-post","status-publish","format-standard","hentry","category-2","tag-hadoop","tag-sqoop","tag-199"],"_links":{"self":[{"href":"https:\/\/199604.com\/wp-json\/wp\/v2\/posts\/1116","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/199604.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/199604.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/199604.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/199604.com\/wp-json\/wp\/v2\/comments?post=1116"}],"version-history":[{"count":5,"href":"https:\/\/199604.com\/wp-json\/wp\/v2\/posts\/1116\/revisions"}],"predecessor-version":[{"id":1197,"href":"https:\/\/199604.com\/wp-json\/wp\/v2\/posts\/1116\/revisions\/1197"}],"wp:attachment":[{"href":"https:\/\/199604.com\/wp-json\/wp\/v2\/media?parent=1116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/199604.com\/wp-json\/wp\/v2\/categories?post=1116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/199604.com\/wp-json\/wp\/v2\/tags?post=1116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}