{"id":61573,"date":"2024-10-13T12:06:15","date_gmt":"2024-10-13T04:06:15","guid":{"rendered":"https:\/\/server.hk\/cnblog\/61573\/"},"modified":"2024-10-13T12:06:15","modified_gmt":"2024-10-13T04:06:15","slug":"hive%ef%bc%9a%e9%96%8b%e5%95%9f%e5%a4%a7%e6%95%b8%e6%93%9a%e6%8c%96%e6%8e%98%e7%9a%84%e6%95%b8%e6%93%9a%e5%ba%ab%e5%88%87%e5%85%a5%e4%b9%8b%e8%b7%af-hive%e5%88%87%e5%85%a5%e6%95%b8%e6%93%9a%e5%ba%ab","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/61573\/","title":{"rendered":"Hive\uff1a\u958b\u555f\u5927\u6578\u64da\u6316\u6398\u7684\u6578\u64da\u5eab\u5207\u5165\u4e4b\u8def (hive\u5207\u5165\u6578\u64da\u5eab)"},"content":{"rendered":"<h1 id=\"hive%ef%bc%9a%e9%96%8b%e5%95%9f%e5%a4%a7%e6%95%b8%e6%93%9a%e6%8c%96%e6%8e%98%e7%9a%84%e6%95%b8%e6%93%9a%e5%ba%ab%e5%88%87%e5%85%a5%e4%b9%8b%e8%b7%af-spFQyLVQoE\">Hive\uff1a\u958b\u555f\u5927\u6578\u64da\u6316\u6398\u7684\u6578\u64da\u5eab\u5207\u5165\u4e4b\u8def<\/h1>\n<p>\u5728\u7576\u4eca\u6578\u64da\u9a45\u52d5\u7684\u6642\u4ee3\uff0c\u5927\u6578\u64da\u7684\u8655\u7406\u548c\u5206\u6790\u5df2\u6210\u70ba\u4f01\u696d\u6210\u529f\u7684\u95dc\u9375\u3002Apache Hive \u4f5c\u70ba\u4e00\u500b\u6578\u64da\u5009\u5eab\u57fa\u790e\u8a2d\u65bd\uff0c\u70ba\u5927\u6578\u64da\u7684\u67e5\u8a62\u548c\u5206\u6790\u63d0\u4f9b\u4e86\u4e00\u500b\u9ad8\u6548\u7684\u89e3\u6c7a\u65b9\u6848\u3002\u672c\u6587\u5c07\u6df1\u5165\u63a2\u8a0e Hive \u7684\u57fa\u672c\u6982\u5ff5\u3001\u67b6\u69cb\u53ca\u5176\u5728\u5927\u6578\u64da\u6316\u6398\u4e2d\u7684\u61c9\u7528\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%af-hive%ef%bc%9f-spFQyLVQoE\">\u4ec0\u9ebc\u662f Hive\uff1f<\/h2>\n<p>Hive \u662f\u4e00\u500b\u57fa\u65bc Hadoop \u7684\u6578\u64da\u5009\u5eab\u5de5\u5177\uff0c\u4e3b\u8981\u7528\u65bc\u6578\u64da\u7684\u67e5\u8a62\u548c\u5206\u6790\u3002\u5b83\u63d0\u4f9b\u4e86\u4e00\u7a2e\u985e\u4f3c SQL \u7684\u67e5\u8a62\u8a9e\u8a00\uff0c\u7a31\u70ba HiveQL\uff0c\u4f7f\u5f97\u7528\u6236\u80fd\u5920\u8f15\u9b06\u5730\u9032\u884c\u6578\u64da\u64cd\u4f5c\uff0c\u800c\u7121\u9700\u6df1\u5165\u4e86\u89e3\u5e95\u5c64\u7684 MapReduce \u7de8\u7a0b\u6a21\u578b\u3002\u9019\u4f7f\u5f97 Hive \u6210\u70ba\u6578\u64da\u5206\u6790\u5e2b\u548c\u5546\u696d\u667a\u80fd\u5c08\u5bb6\u7684\u7406\u60f3\u9078\u64c7\u3002<\/p>\n<h2 id=\"hive-%e7%9a%84%e6%9e%b6%e6%a7%8b-spFQyLVQoE\">Hive \u7684\u67b6\u69cb<\/h2>\n<p>Hive \u7684\u67b6\u69cb\u4e3b\u8981\u7531\u4ee5\u4e0b\u5e7e\u500b\u7d44\u4ef6\u7d44\u6210\uff1a<\/p>\n<ul>\n<li><strong>Hive Metastore\uff1a<\/strong>\u5b58\u5132 Hive \u7684\u5143\u6578\u64da\uff0c\u5305\u62ec\u8868\u7d50\u69cb\u3001\u6578\u64da\u985e\u578b\u548c\u5206\u5340\u4fe1\u606f\u7b49\u3002<\/li>\n<li><strong>Hive Driver\uff1a<\/strong>\u8ca0\u8cac\u63a5\u6536 HiveQL \u67e5\u8a62\u4e26\u5c07\u5176\u8f49\u63db\u70ba MapReduce \u4efb\u52d9\u3002<\/li>\n<li><strong>Execution Engine\uff1a<\/strong>\u57f7\u884c\u8f49\u63db\u5f8c\u7684 MapReduce \u4efb\u52d9\uff0c\u4e26\u8fd4\u56de\u7d50\u679c\u3002<\/li>\n<li><strong>Hive CLI \u548c Web UI\uff1a<\/strong>\u63d0\u4f9b\u7528\u6236\u754c\u9762\uff0c\u4f7f\u7528\u6236\u80fd\u5920\u65b9\u4fbf\u5730\u57f7\u884c\u67e5\u8a62\u548c\u67e5\u770b\u7d50\u679c\u3002<\/li>\n<\/ul>\n<h2 id=\"hive-%e7%9a%84%e5%84%aa%e5%8b%a2-spFQyLVQoE\">Hive \u7684\u512a\u52e2<\/h2>\n<p>Hive \u63d0\u4f9b\u4e86\u591a\u7a2e\u512a\u52e2\uff0c\u4f7f\u5176\u6210\u70ba\u5927\u6578\u64da\u5206\u6790\u7684\u71b1\u9580\u9078\u64c7\uff1a<\/p>\n<ul>\n<li><strong>\u6613\u65bc\u4f7f\u7528\uff1a<\/strong>HiveQL \u7684\u8a9e\u6cd5\u985e\u4f3c\u65bc SQL\uff0c\u5c0d\u65bc\u719f\u6089 SQL \u7684\u7528\u6236\u4f86\u8aaa\uff0c\u5b78\u7fd2\u6210\u672c\u4f4e\u3002<\/li>\n<li><strong>\u64f4\u5c55\u6027\uff1a<\/strong>\u57fa\u65bc Hadoop \u7684\u67b6\u69cb\u4f7f\u5f97 Hive \u80fd\u5920\u8655\u7406 PB \u7d1a\u5225\u7684\u6578\u64da\u3002<\/li>\n<li><strong>\u9748\u6d3b\u6027\uff1a<\/strong>\u652f\u6301\u591a\u7a2e\u6578\u64da\u683c\u5f0f\uff0c\u5982\u6587\u672c\u3001ORC\u3001Parquet \u7b49\uff0c\u65b9\u4fbf\u7528\u6236\u6839\u64da\u9700\u6c42\u9078\u64c7\u3002<\/li>\n<\/ul>\n<h2 id=\"hive-%e7%9a%84%e6%87%89%e7%94%a8%e5%a0%b4%e6%99%af-spFQyLVQoE\">Hive \u7684\u61c9\u7528\u5834\u666f<\/h2>\n<p>Hive \u5728\u591a\u500b\u9818\u57df\u4e2d\u5f97\u5230\u4e86\u5ee3\u6cdb\u61c9\u7528\uff0c\u5305\u62ec\uff1a<\/p>\n<ul>\n<li><strong>\u5546\u696d\u667a\u80fd\uff1a<\/strong>\u4f01\u696d\u53ef\u4ee5\u5229\u7528 Hive \u9032\u884c\u6578\u64da\u5206\u6790\uff0c\u751f\u6210\u5831\u544a\uff0c\u5e6b\u52a9\u6c7a\u7b56\u3002<\/li>\n<li><strong>\u6578\u64da\u6316\u6398\uff1a<\/strong>\u901a\u904e Hive\uff0c\u6578\u64da\u79d1\u5b78\u5bb6\u53ef\u4ee5\u8f15\u9b06\u5730\u9032\u884c\u6578\u64da\u6e05\u6d17\u548c\u7279\u5fb5\u5de5\u7a0b\uff0c\u70ba\u6a5f\u5668\u5b78\u7fd2\u6a21\u578b\u63d0\u4f9b\u652f\u6301\u3002<\/li>\n<li><strong>\u65e5\u8a8c\u5206\u6790\uff1a<\/strong>Hive \u53ef\u4ee5\u7528\u65bc\u5206\u6790\u4f3a\u670d\u5668\u65e5\u8a8c\uff0c\u5e6b\u52a9\u4f01\u696d\u4e86\u89e3\u7528\u6236\u884c\u70ba\u548c\u7cfb\u7d71\u6027\u80fd\u3002<\/li>\n<\/ul>\n<h2 id=\"hive-%e7%9a%84%e5%9f%ba%e6%9c%ac%e6%93%8d%e4%bd%9c%e7%a4%ba%e4%be%8b-spFQyLVQoE\">Hive \u7684\u57fa\u672c\u64cd\u4f5c\u793a\u4f8b<\/h2>\n<p>\u4ee5\u4e0b\u662f\u4e00\u500b\u7c21\u55ae\u7684 Hive \u64cd\u4f5c\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u5275\u5efa\u8868\u683c\u4e26\u57f7\u884c\u67e5\u8a62\uff1a<\/p>\n<pre><code>-- \u5275\u5efa\u4e00\u500b\u8868\u683c\nCREATE TABLE IF NOT EXISTS users (\n    user_id INT,\n    user_name STRING,\n    user_age INT\n) ROW FORMAT DELIMITED\nFIELDS TERMINATED BY ',' \nSTORED AS TEXTFILE;\n\n-- \u52a0\u8f09\u6578\u64da\nLOAD DATA LOCAL INPATH '\/path\/to\/users.csv' INTO TABLE users;\n\n-- \u67e5\u8a62\u6578\u64da\nSELECT * FROM users WHERE user_age &gt; 30;\n<\/code><\/pre>\n<h2 id=\"%e7%b8%bd%e7%b5%90-spFQyLVQoE\">\u7e3d\u7d50<\/h2>\n<p>Hive \u4f5c\u70ba\u4e00\u500b\u5f37\u5927\u7684\u5927\u6578\u64da\u8655\u7406\u5de5\u5177\uff0c\u70ba\u4f01\u696d\u63d0\u4f9b\u4e86\u9ad8\u6548\u7684\u6578\u64da\u5206\u6790\u89e3\u6c7a\u65b9\u6848\u3002\u7121\u8ad6\u662f\u5728\u5546\u696d\u667a\u80fd\u3001\u6578\u64da\u6316\u6398\u9084\u662f\u65e5\u8a8c\u5206\u6790\u65b9\u9762\uff0cHive \u90fd\u5c55\u73fe\u4e86\u5176\u5353\u8d8a\u7684\u6027\u80fd\u548c\u9748\u6d3b\u6027\u3002\u96a8\u8457\u5927\u6578\u64da\u6280\u8853\u7684\u767c\u5c55\uff0cHive \u5c07\u7e7c\u7e8c\u5728\u6578\u64da\u5206\u6790\u9818\u57df\u4e2d\u626e\u6f14\u91cd\u8981\u89d2\u8272\u3002<\/p>\n<p>\u5982\u679c\u60a8\u5c0d\u65bc\u5927\u6578\u64da\u8655\u7406\u548c\u5206\u6790\u6709\u8208\u8da3\uff0c\u4e26\u5e0c\u671b\u5c0b\u627e\u5408\u9069\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\uff0cServer.HK \u63d0\u4f9b\u591a\u7a2e\u9078\u64c7\uff0c\u52a9\u60a8\u8f15\u9b06\u642d\u5efa\u5927\u6578\u64da\u74b0\u5883\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22Hive\u5982\u4f55\u6210\u70ba\u5927\u6578\u64da\u6316\u6398\u7684\u95dc\u9375\u5de5\u5177\uff0c\u7c21\u5316\u6578\u64da\u5eab\u64cd\u4f5c\uff0c\u63d0\u5347\u5206\u6790\u6548\u7387\uff0c\u52a9\u529b\u4f01\u696d\u6d1e\u5bdf\u6578\u64da\u50f9\u503c\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-61573","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/61573","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=61573"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/61573\/revisions"}],"predecessor-version":[{"id":61574,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/61573\/revisions\/61574"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=61573"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=61573"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=61573"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}