{"id":36546,"date":"2023-07-08T02:08:20","date_gmt":"2023-10-11T07:06:53","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%ae%89%e8%a3%85apache-hive%e7%9a%84%e6%ad%a5%e9%aa%a4\/"},"modified":"2024-04-30T12:32:30","modified_gmt":"2024-04-30T04:32:30","slug":"%e5%ae%89%e8%a3%85apache-hive%e7%9a%84%e6%ad%a5%e9%aa%a4","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%ae%89%e8%a3%85apache-hive%e7%9a%84%e6%ad%a5%e9%aa%a4\/","title":{"rendered":"\u5b89\u88c5Apache Hive\u7684\u6b65\u9aa4"},"content":{"rendered":"<h2>\u6982\u8981 &#8211; \u6982\u8ff0<\/h2>\n<p>Apache Hadoop\u548cHive\u7684\u5b89\u88c5\u6b65\u9aa4\u5982\u4e0b\uff0c\u5c06\u5206\u522b\u5728\u4e0d\u540c\u7684\u6587\u7ae0\u4e2d\u8fdb\u884c\u8bf4\u660e\u3002<\/p>\n<h2>\u76ee\u5f55<\/h2>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\u5b89\u88c5Apache Hadoop\u7684\u6b65\u9aa4<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\u5b89\u88c5Apache Hive\u7684\u6b65\u9aa4<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\u5c1d\u8bd5\u5728Hadoop\u4e0a\u8fdb\u884cWordCount\u4efb\u52a1<\/ol>\n<h2>Apache Hive\u7684\u5b89\u88c5\u6b65\u9aa4<\/h2>\n<p>\u4ee5\u4e0b\u662fApache Hadoop\u7684\u5b89\u88c5\u6b65\u9aa4\u7684\u7ee7\u7eed\u3002<\/p>\n<p>Hive \u662f\u7528\u4e8e\u65b9\u4fbf\u5730\u4f7f\u7528 Hadoop \u6570\u636e\u7684\u8f6f\u4ef6\uff0c\u5b83\u652f\u6301\u7c7b\u4f3c SQL \u7684 HiveQL \u8bed\u6cd5\u6765\u64cd\u4f5c\u6570\u636e\u3002<br \/>\n\u4ee5\u4e0b\u662f\u5728\u4f2a\u72ec\u7acb\u6a21\u5f0f\uff08\u672c\u5730\u6a21\u5f0f\uff09\u4e0b\u642d\u5efa\u7684\u6b65\u9aa4\u3002<\/p>\n<h2>\u73af\u5883<\/h2>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">CentOS 7.1<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Hadoop 2.8.0<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">MariaDB 5.5.52<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">java 1.8.0<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Hive 2.3.0<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">HBase 1.3.1<\/ul>\n<p>\u5728\u6b64\u9875\u9762\u4e2d\uff0c\u5c06\u8fdb\u884c\u7c97\u4f53\u5b57\u7684\u5b89\u88c5\u3002<\/p>\n<h2>\u8bbe\u7f6eApache Hive<\/h2>\n<p>\u8bf7\u4ece\u4ee5\u4e0b\u9875\u9762\u4e0b\u8f7d\u5e76\u89e3\u538bApache Hive\u3002<\/p>\n<p>Apache\u4e0b\u8f7d\u955c\u50cf-\u8702\u5de2<\/p>\n<pre class=\"post-pre\"><code>$ wget http:\/\/ftp.jaist.ac.jp\/pub\/apache\/hive\/hive-2.3.0\/apache-hive-2.3.0-bin.tar.gz\r\n$ tar zxfv apache-hive-2.3.0-bin.tar.gz\r\n<\/code><\/pre>\n<p>\u5c06HIVE_HOME\u8bbe\u7f6e\u4e3a\u73af\u5883\u53d8\u91cf\u3002<\/p>\n<pre class=\"post-pre\"><code>$ echo \"export HIVE_HOME=\/home\/`whoami`\/apache-hive-2.3.0-bin\" &gt;&gt; ~\/.bashrc\r\n$ source ~\/.bashrc\r\n<\/code><\/pre>\n<h2>HBase\u7684\u5b89\u88c5<\/h2>\n<p>\u8fd9\u662f\u4e00\u4e2a\u5efa\u7acb\u5728Hadoop\u4e0a\u7684NoSQL\u6570\u636e\u5e93\u3002<\/p>\n<p>\u5982\u679c\u4f7f\u7528apache-hive-2.1.1\u30012.3.0\uff0c\u6ca1\u6709\u5b89\u88c5HBase\uff0c\u6267\u884chive\u547d\u4ee4\u65f6\u5c06\u4f1a\u51fa\u73b0\u4ee5\u4e0b\u9519\u8bef\u3002\u503c\u5f97\u4e00\u63d0\u7684\u662f\uff0c\u57281.2.2\u7248\u672c\u4e2d\u5c06\u4e0d\u4f1a\u51fa\u73b0\u6b64\u9519\u8bef\u3002\u56e0\u6b64\uff0c\u5982\u679c\u8981\u5b89\u88c52.1.1\u4ee5\u4e0a\u7684\u7248\u672c\uff0c\u4e5f\u9700\u8981\u5b89\u88c5HBase\u3002<\/p>\n<h4>\u9519\u8bef\u5185\u5bb9<\/h4>\n<pre class=\"post-pre\"><code>$ $HIVE_HOME\/bin\/hive -H\r\n\r\nwhich: no hbase in (\/usr\/local\/bin:\/usr\/bin:\/usr\/local\/sbin:\/usr\/sbin:\/home\/vagrant\/.local\/bin:\/home\/vagrant\/bin)\r\n<\/code><\/pre>\n<p>\u8bf7\u4ece\u4ee5\u4e0b\u7f51\u9875\u4e0b\u8f7d\u5e76\u89e3\u538bApache HBase\uff1a<br \/>\nhttp:\/\/ftp.jaist.ac.jp\/pub\/apache\/hbase\/<\/p>\n<pre class=\"post-pre\"><code>$ wget http:\/\/ftp.jaist.ac.jp\/pub\/apache\/hbase\/1.3.1\/hbase-1.3.1-bin.tar.gz\r\n$ tar zxfv hbase-1.3.1-bin.tar.gz\r\n<\/code><\/pre>\n<h3>\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf<\/h3>\n<p>\u5c06HBASE_HOME\u8bbe\u4e3a\u73af\u5883\u53d8\u91cf\u3002<\/p>\n<pre class=\"post-pre\"><code>$ echo 'export HBASE_HOME=\/home\/`whoami`\/hbase-1.3.1' &gt;&gt; ~\/.bashrc\r\n$ echo 'export PATH=\"$HBASE_HOME\/bin:$PATH\"' &gt;&gt; ~\/.bashrc\r\n$ source ~\/.bashrc\r\n<\/code><\/pre>\n<h3>\u8bf7\u786e\u8ba4\u5b89\u88c5<\/h3>\n<pre class=\"post-pre\"><code>$ $HBASE_HOME\/bin\/hbase version\r\n<\/code><\/pre>\n<h3>\u4fee\u6539hbase-site.xml\u6587\u4ef6<\/h3>\n<p>\u7f16\u8f91$HBASE_HOME\/conf\/hbase-site.xml\u6587\u4ef6\uff0c\u6307\u5b9aHBase\u548cZooKeeper\u6570\u636e\u5199\u5165\u7684\u76ee\u5f55\u3002\u7531\u4e8e\u662f\u4f2a\u5206\u5e03\u6a21\u5f0f\uff0c\u6240\u4ee5\u6307\u5b9a\u672c\u5730\u76ee\u5f55\u3002\u65e0\u9700\u63d0\u524d\u521b\u5efa\u76ee\u5f55\u3002<br \/>\n\u5982\u679c\u4e0d\u6307\u5b9a\u76ee\u5f55\uff0c\u5219\u9ed8\u8ba4\u5728\/tmp\/hbase-root\u4e0b\u521b\u5efa\u3002<br \/>\n\u53c2\u8003\uff1ahttp:\/\/www.task-notes.com\/entry\/20160211\/1455179303<\/p>\n<pre class=\"post-pre\"><code>$ vi $HBASE_HOME\/conf\/hbase-site.xml\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code><span class=\"nt\">&lt;configuration&gt;<\/span>\r\n  <span class=\"nt\">&lt;property&gt;<\/span>\r\n    <span class=\"nt\">&lt;name&gt;<\/span>hbase.rootdir<span class=\"nt\">&lt;\/name&gt;<\/span>\r\n    <span class=\"nt\">&lt;value&gt;<\/span>file:\/\/\/opt\/hbase<span class=\"nt\">&lt;\/value&gt;<\/span>\r\n  <span class=\"nt\">&lt;\/property&gt;<\/span>\r\n  <span class=\"nt\">&lt;property&gt;<\/span>\r\n    <span class=\"nt\">&lt;name&gt;<\/span>hbase.zookeeper.property.dataDir<span class=\"nt\">&lt;\/name&gt;<\/span>\r\n    <span class=\"nt\">&lt;value&gt;<\/span>\/opt\/zookeeper<span class=\"nt\">&lt;\/value&gt;<\/span>\r\n  <span class=\"nt\">&lt;\/property&gt;<\/span>\r\n<span class=\"nt\">&lt;\/configuration&gt;<\/span>\r\n<\/code><\/pre>\n<h3>\u542f\u52a8HBase\u3002<\/h3>\n<pre class=\"post-pre\"><code>$ $HBASE_HOME\/bin\/start-hbase.sh\r\n<\/code><\/pre>\n<h3>\u786e\u8ba4\u80fd\u5426\u8fdb\u5165HBase Shell\u3002<\/h3>\n<pre class=\"post-pre\"><code>$ $HBASE_HOME\/bin\/hbase shell\r\n\r\nhbase(main):001:0&gt; exit\r\n<\/code><\/pre>\n<h2>\u7c7b\u8def\u5f84\u4e2d\u5305\u542b\u4e86\u591a\u4e2aSLF4J\u7ed1\u5b9a\u3002<\/h2>\n<p>\u5982\u679c\u4f7f\u7528apache-hive-2.1.1\u30012.3.0\uff0c\u5728\u6267\u884chive\u547d\u4ee4\u65f6\u4f1a\u51fa\u73b0\u4ee5\u4e0b\u9519\u8bef\u3002\u57281.2.2\u7248\u672c\u4e2d\u6ca1\u6709\u8fd9\u4e2a\u9519\u8bef\u3002<br \/>\n\u56e0\u6b64\uff0c\u5982\u679c\u8981\u4f7f\u75282.1.1\u4ee5\u4e0a\u7684\u7248\u672c\uff0c\u9700\u8981\u8fdb\u884c\u4ee5\u4e0b\u5904\u7406\u3002<\/p>\n<h3>\u9519\u8bef\u5185\u5bb9<\/h3>\n<p>(chinese translation of &#8220;\u30a8\u30e9\u30fc\u5185\u5bb9&#8221;)<\/p>\n<pre class=\"post-pre\"><code>$ $HIVE_HOME\/bin\/hive -H\r\n\r\nSLF4J: Class path contains multiple SLF4J bindings.\r\nSLF4J: Found binding in [jar:file:\/home\/vagrant\/apache-hive-2.3.0-bin\/lib\/log4j-slf4j-impl-2.6.2.jar!\/org\/slf4j\/impl\/StaticLoggerBinder.class]\r\nSLF4J: Found binding in [jar:file:\/home\/vagrant\/hadoop-2.8.0\/share\/hadoop\/common\/lib\/slf4j-log4j12-1.7.10.jar!\/org\/slf4j\/impl\/StaticLoggerBinder.class]\r\nSLF4J: See http:\/\/www.slf4j.org\/codes.html#multiple_bindings for an explanation.\r\nSLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]\r\n<\/code><\/pre>\n<p>\u7c7b\u8def\u5f84\u4e2d\u5305\u542b\u591a\u4e2aSLF4J\u7ed1\u5b9a\u3002<\/p>\n<p>\u53c2\u8003\u6765\u6e90\uff1ahttps:\/\/stackoverflow.com\/questions\/27050820\/running-hive-0-12-with-error-of-slf4j\u3002<\/p>\n<p>\u8bf7\u53c2\u8003\u4ee5\u4e0b\u94fe\u63a5\uff1ahttps:\/\/stackoverflow.com\/questions\/27050820\/running-hive-0-12-with-error-of-slf4j\u3002<\/p>\n<blockquote><p>\u4f60\u9700\u8981\u5220\u9664Hadoop\u548cHive\u4e4b\u95f4\u7684\u8fd9\u4e9bjar\u6587\u4ef6\u7ed1\u5b9a\u3002<\/p>\n<p>rm lib\/hive-jdbc-2.0.0-standalone.jar<br \/>\nrm lib\/log4j-slf4j-impl-2.4.1.jar<\/p><\/blockquote>\n<p>\u56e0\u6b64\uff0c\u4f1a\u641c\u5bfb\u76f8\u5173\u7684\u6587\u4ef6\u3002<\/p>\n<pre class=\"post-pre\"><code>$ find .\/ -name '*hive-jdbc-*-standalone.jar'\r\n.\/apache-hive-2.3.0-bin\/jdbc\/hive-jdbc-2.3.0-standalone.jar\r\n\r\n$ find .\/ -name '*log4j-slf4j-impl-*.jar'\r\n.\/apache-hive-2.3.0-bin\/lib\/log4j-slf4j-impl-2.6.2.jar\r\n<\/code><\/pre>\n<p>\u5220\u9664\u8fd9\u4e24\u4e2a\u6587\u4ef6\u3002<\/p>\n<pre class=\"post-pre\"><code>$ rm -f .\/apache-hive-2.3.0-bin\/jdbc\/hive-jdbc-2.3.0-standalone.jar\r\n$ rm -f .\/apache-hive-2.3.0-bin\/lib\/log4j-slf4j-impl-2.6.2.jar\r\n<\/code><\/pre>\n<p>\u901a\u8fc7\u6267\u884c\u8fd9\u4e2aHive\u547d\u4ee4\uff0c\u9519\u8bef\u6d88\u5931\u4e86\uff01<\/p>\n<pre class=\"post-pre\"><code>$ $HIVE_HOME\/bin\/hive -H\r\nusage: hive\r\n -d,--define &lt;key=value&gt;          Variable substitution to apply to Hive\r\n                                  commands. e.g. -d A=B or --define A=B\r\n    --database &lt;databasename&gt;     Specify the database to use\r\n -e &lt;quoted-query-string&gt;         SQL from command line\r\n -f &lt;filename&gt;                    SQL from files\r\n -H,--help                        Print help information\r\n    --hiveconf &lt;property=value&gt;   Use value for given property\r\n    --hivevar &lt;key=value&gt;         Variable substitution to apply to Hive\r\n                                  commands. e.g. --hivevar A=B\r\n -i &lt;filename&gt;                    Initialization SQL file\r\n -S,--silent                      Silent mode in interactive shell\r\n -v,--verbose                     Verbose mode (echo executed SQL to the\r\n                                  console)\r\n<\/code><\/pre>\n<p>Hive\u7684\u5b89\u88c5\u73b0\u5df2\u5b8c\u6210\u3002<\/p>\n<h2>JDBC\u9a45\u52d5\u7a0b\u5f0f\u7684\u914d\u7f6e<\/h2>\n<p>\u4ecemysql\u7684\u7f51\u7ad9\u4e0a\u4e0b\u8f7d\u5e76\u89e3\u538bjdbc\u9a71\u52a8\u7a0b\u5e8f\u3002<br \/>\n\u4e0b\u8f7d\u94fe\u63a5\uff1ahttp:\/\/dev.mysql.com\/downloads\/connector\/j\/\u3002<\/p>\n<pre class=\"post-pre\"><code>$ wget https:\/\/dev.mysql.com\/get\/Downloads\/Connector-J\/mysql-connector-java-5.1.42.tar.gz\r\n$ tar zxfv mysql-connector-java-5.1.42.tar.gz\r\n<\/code><\/pre>\n<p>\u5c06mysql-connector-java-5.1.42-bin.jar\u6587\u4ef6\u653e\u7f6e\u5728$HIVE_HOME\/lib\/\u76ee\u5f55\u4e0b\u3002<\/p>\n<pre class=\"post-pre\"><code>$ cp mysql-connector-java-5.1.42\/mysql-connector-java-5.1.42-bin.jar $HIVE_HOME\/lib\/ \r\n<\/code><\/pre>\n<h2>\u5143\u6570\u636e\u5b58\u50a8\u8bbe\u5b9a<\/h2>\n<p>\u5c06hive-site.xml\u6587\u4ef6\u6309\u7167\u4ee5\u4e0b\u65b9\u5f0f\u8fdb\u884c\u4fee\u6539\u3002<\/p>\n<pre class=\"post-pre\"><code>$ vi $HIVE_HOME\/conf\/hive-site.xml\r\n<\/code><\/pre>\n<p>\u8bf7\u5c06\u203bDB\u5bc6\u7801\u203b\u8bbe\u7f6e\u4e3a\u5728MariaDB\u4e2d\u8bbe\u7f6e\u7684hive&#8217;@&#8217;localhost\u7684\u5bc6\u7801\u3002<\/p>\n<pre class=\"post-pre\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?&gt;\r\n&lt;?xml-stylesheet type=\"text\/xsl\" href=\"configuration.xsl\"?&gt;\r\n&lt;configuration&gt;\r\n  &lt;property&gt;\r\n    &lt;name&gt;javax.jdo.option.ConnectionURL&lt;\/name&gt;\r\n    &lt;value&gt;&lt;![CDATA[jdbc:mysql:\/\/localhost\/hive_metastore?autoReconnect=true&amp;useSSL=false]]&gt;&lt;\/value&gt;\r\n  &lt;\/property&gt;\r\n  &lt;property&gt;\r\n    &lt;name&gt;javax.jdo.option.ConnectionDriverName&lt;\/name&gt;\r\n    &lt;value&gt;com.mysql.jdbc.Driver&lt;\/value&gt;\r\n  &lt;\/property&gt;\r\n  &lt;property&gt;\r\n    &lt;name&gt;javax.jdo.option.ConnectionUserName&lt;\/name&gt;\r\n    &lt;value&gt;hive&lt;\/value&gt;\r\n  &lt;\/property&gt;\r\n  &lt;property&gt;\r\n    &lt;name&gt;javax.jdo.option.ConnectionPassword&lt;\/name&gt;\r\n    &lt;value&gt;\u203bDB\u30d1\u30b9\u30ef\u30fc\u30c9\u203b&lt;\/value&gt;\r\n  &lt;\/property&gt;\r\n  &lt;property&gt;\r\n    &lt;name&gt;datanucleus.fixedDatastore&lt;\/name&gt;\r\n    &lt;value&gt;false&lt;\/value&gt;\r\n  &lt;\/property&gt;\r\n  &lt;property&gt;\r\n      &lt;name&gt;hive.exec.local.scratchdir&lt;\/name&gt;\r\n      &lt;value&gt;\/tmp\/hive&lt;\/value&gt;\r\n  &lt;\/property&gt;\r\n  &lt;property&gt;\r\n    &lt;name&gt;hive.downloaded.resources.dir&lt;\/name&gt;\r\n    &lt;value&gt;\/tmp\/hive&lt;\/value&gt;\r\n  &lt;\/property&gt;\r\n  &lt;property&gt;\r\n    &lt;name&gt;hive.querylog.location&lt;\/name&gt;\r\n    &lt;value&gt;\/tmp\/hive&lt;\/value&gt;\r\n  &lt;\/property&gt;\r\n  &lt;property&gt;\r\n    &lt;name&gt;hive.server2.enable.doAs&lt;\/name&gt;\r\n    &lt;value&gt;false&lt;\/value&gt;\r\n  &lt;\/property&gt;\r\n&lt;\/configuration&gt;\r\n<\/code><\/pre>\n<p>\u521d\u59cb\u5316metastore\u3002<\/p>\n<pre class=\"post-pre\"><code>$ $HIVE_HOME\/bin\/schematool -dbType mysql -initSchema\r\n<\/code><\/pre>\n<h2>\u901a\u8fc7Hive\u547d\u4ee4\u8fdb\u884c\u8fde\u63a5<\/h2>\n<p>\u6211\u5c06\u68c0\u67e5Hive\u662f\u5426\u6b63\u5e38\u8fd0\u884c\u3002\u5982\u679c\u63d0\u793a\u51fa\u73b0\uff0c\u90a3\u5c31\u6ca1\u95ee\u9898\u3002<\/p>\n<pre class=\"post-pre\"><code>$ $HIVE_HOME\/bin\/hive\r\n\r\nLogging initialized using configuration in jar:file:\/home\/vagrant\/apache-hive-2.3.0-bin\/lib\/hive-common-2.3.0.jar!\/hive-log4j2.properties Async: true\r\nHive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.\r\nhive&gt; exit\r\n<\/code><\/pre>\n<h2>\u4f7f\u7528beeline\u8fde\u63a5\u5230hiveserver2\u5e76\u542f\u52a8\u3002<\/h2>\n<p>\u542f\u52a8HiveServer2\u3002<\/p>\n<pre class=\"post-pre\"><code>$ $HIVE_HOME\/bin\/hiveserver2\r\n2017-07-19 06:51:11: Starting HiveServer2\r\n<\/code><\/pre>\n<p>\u5728hive\u670d\u52a12\u542f\u52a8\u7684\u60c5\u51b5\u4e0b\uff0c\u901a\u8fc7beeline\u786e\u8ba4\u53ef\u4ee5\u8fde\u63a5\u3002<\/p>\n<pre class=\"post-pre\"><code>$ $HIVE_HOME\/bin\/beeline -u jdbc:hive2:\/\/localhost:10000\/default -n `whoami`\r\nConnecting to jdbc:hive2:\/\/localhost:10000\/default\r\nConnected to: Apache Hive (version 2.3.0)\r\nDriver: Hive JDBC (version 2.3.0)\r\nTransaction isolation: TRANSACTION_REPEATABLE_READ\r\nBeeline version 2.3.0 by Apache Hive\r\n0: jdbc:hive2:\/\/localhost:10000\/default&gt; !exit\r\n<\/code><\/pre>\n<h2>\u9a8c\u8bc1Hive\u7684\u8fd0\u884c<\/h2>\n<p>\u6211\u5011\u5c07\u4f7f\u7528HiveQL\u5be6\u969b\u4e0a\u5132\u5b58\u8cc7\u6599\u3002<\/p>\n<h3>\u51c6\u5907\u6837\u672c\u6570\u636e<\/h3>\n<p>\u6211\u51c6\u5907\u4e86\u5982\u4e0b\u7684CSV\u6587\u4ef6\uff1asample.csv\u3002<\/p>\n<pre class=\"post-pre\"><code>\u308a\u3093\u3054,100\r\n\u30d0\u30ca\u30ca,340\r\n\u307f\u304b\u3093,200\r\n\u3044\u3061\u3058\u304f,400\r\n<\/code><\/pre>\n<h3>\u521b\u5efa\u6570\u636e\u5e93\u548c\u8868<\/h3>\n<p>\u6211\u4f1a\u521b\u5efa\u4e00\u4e2a\u540d\u4e3atestdb\u7684\u6570\u636e\u5e93\uff0c\u5e76\u5728\u5176\u4e2d\u521b\u5efa\u4e00\u4e2a\u540d\u4e3aitems\u7684\u8868\u3002<\/p>\n<pre class=\"post-pre\"><code>hive&gt; create database testdb;\r\nhive&gt; use testdb;\r\nhive&gt; create table items(name string,price int) row format delimited fields terminated by ',';\r\nhive&gt; desc items;\r\nOK\r\nname                    string\r\nprice                   int\r\nTime taken: 0.173 seconds, Fetched: 2 row(s)\r\n<\/code><\/pre>\n<p>\u5c06CSV\u6570\u636e\u63d2\u5165\u8868\u683c\u3002<\/p>\n<pre class=\"post-pre\"><code>hive&gt; load data local inpath \"\/home\/vagrant\/sample.csv\" into table items;\r\nLoading data to table testdb.items\r\nOK\r\nTime taken: 1.585 seconds\r\n<\/code><\/pre>\n<p>\u6211\u8981\u68c0\u67e5\u4e00\u4e0b\u684c\u5b50\u91cc\u9762\u7684\u4e1c\u897f\u3002<\/p>\n<pre class=\"post-pre\"><code>hive&gt; select * from items;\r\nOK\r\n\u308a\u3093\u3054   100\r\n\u30d0\u30ca\u30ca   340\r\n\u307f\u304b\u3093   200\r\n\u3044\u3061\u3058\u304f    400\r\nTime taken: 0.339 seconds, Fetched: 4 row(s)\r\n<\/code><\/pre>\n<h3>\u5c06\u5904\u7406\u7ed3\u679c\u8f93\u51fa\u5230\u6587\u4ef6\u4e2d<\/h3>\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u4f7f\u7528insert\u8bed\u53e5\u6307\u5b9a\u8f93\u51fa\u4f4d\u7f6e\uff0c\u7136\u540e\u6267\u884cselect\u8bed\u53e5\u5c06\u8868\u4e2d\u5185\u5bb9\u8f93\u51fa\u5230\u6587\u4ef6\u4e2d\u3002<\/p>\n<pre class=\"post-pre\"><code>hive&gt; insert overwrite directory '\/output\/'\r\n    &gt; select * from sales;\r\n<\/code><\/pre>\n<p>\u5728\u51fa\u529b\u76ee\u5f55\u4e0b\u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3aoutput\u7684\u6587\u4ef6\u5939\uff0c\u5e76\u5728\u5176\u4e2d\u751f\u6210\u4e86\u4e00\u4e2a\u540d\u4e3a000000_0\u7684\u6587\u4ef6\u3002<\/p>\n<pre class=\"post-pre\"><code>$ $HADOOP_HOME\/bin\/hadoop fs -ls \/output\r\nFound 1 items\r\n-rwxr-xr-x   1 vagrant supergroup         59 2017-07-28 03:26 \/output\/000000_0\r\n<\/code><\/pre>\n<p>\u6211\u4f1a\u68c0\u67e5\u6587\u4ef6\u7684\u5185\u5bb9\u3002<\/p>\n<pre class=\"post-pre\"><code>$ $HADOOP_HOME\/bin\/hadoop fs -cat \/output\/000000_0\r\n\u308a\u3093\u3054100\r\n\u30d0\u30ca\u30ca340\r\n\u307f\u304b\u3093200\r\n\u3044\u3061\u3058\u304f400\r\n<\/code><\/pre>\n<h3>\u66f4\u65b0\uff0c\u5220\u9664<\/h3>\n<p>HiveQL\u4e2d\u4e0d\u5b58\u5728Update\u548cDelete\u64cd\u4f5c\u3002<\/p>\n<h2>\u8bf7\u53c2\u8003<\/h2>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Hadoop(\u30cf\u30c9\u30a5\u30fc\u30d7)\u3068\u306f\uff1f\uff1a\u30d3\u30c3\u30b0\u30c7\u30fc\u30bf\u51e6\u7406\u3092\u652f\u3048\u308b\u300c\u57fa\u76e4\u300d<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Hive\u3068\u306f\uff1f\uff1aHadoop\u4e0a\u3067\u7a3c\u52d5\u3059\u308b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30de\u30cd\u30fc\u30b8\u30e1\u30f3\u30c8\u30b7\u30b9\u30c6\u30e0(DBMS)<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">CentOS7 Apache Hadoop \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">CentOS\u3067Hadoop\u3068Hive\u3092\u8a66\u3057\u3066\u307f\u308b\uff082015\u5e74\u79cb\u7de8\uff09<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">CentOS7\u3078\u306e\u64ec\u4f3c\u5206\u6563\u30e2\u30fc\u30c9\u3067\u306ehadoop\u53ca\u3073\u3001hive\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u624b\u9806<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Hadoop\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3068\u5b9f\u884c\u65b9\u6cd5\uff08\u30b9\u30bf\u30f3\u30c9\u30a2\u30ed\u30f3\u30e2\u30fc\u30c9\uff09<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Hive\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3068\u5b9f\u884c\u65b9\u6cd5<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">HBase\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3068\u5b9f\u884c\u65b9\u6cd5\uff08\u30b9\u30bf\u30f3\u30c9\u30a2\u30ed\u30f3\u30e2\u30fc\u30c9\uff09<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981 &#8211; \u6982\u8ff0 Apache Hadoop\u548cHive\u7684\u5b89\u88c5\u6b65\u9aa4\u5982\u4e0b\uff0c\u5c06\u5206\u522b\u5728\u4e0d\u540c\u7684\u6587\u7ae0\u4e2d\u8fdb\u884c\u8bf4\u660e\u3002 [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-36546","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u5b89\u88c5Apache Hive\u7684\u6b65\u9aa4 - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/\u5b89\u88c5apache-hive\u7684\u6b65\u9aa4\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u5b89\u88c5Apache Hive\u7684\u6b65\u9aa4\" \/>\n<meta property=\"og:description\" content=\"\u6982\u8981 &#8211; \u6982\u8ff0 Apache Hadoop\u548cHive\u7684\u5b89\u88c5\u6b65\u9aa4\u5982\u4e0b\uff0c\u5c06\u5206\u522b\u5728\u4e0d\u540c\u7684\u6587\u7ae0\u4e2d\u8fdb\u884c\u8bf4\u660e\u3002 [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/\u5b89\u88c5apache-hive\u7684\u6b65\u9aa4\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-10-11T07:06:53+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-30T04:32:30+00:00\" \/>\n<meta name=\"author\" content=\"\u6e05, \u626c\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u6e05, \u626c\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%ae%89%e8%a3%85apache-hive%e7%9a%84%e6%ad%a5%e9%aa%a4\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%ae%89%e8%a3%85apache-hive%e7%9a%84%e6%ad%a5%e9%aa%a4\/\",\"name\":\"\u5b89\u88c5Apache Hive\u7684\u6b65\u9aa4 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2023-10-11T07:06:53+00:00\",\"dateModified\":\"2024-04-30T04:32:30+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/cb5556d2501da73d864cac945e8d9461\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%ae%89%e8%a3%85apache-hive%e7%9a%84%e6%ad%a5%e9%aa%a4\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%ae%89%e8%a3%85apache-hive%e7%9a%84%e6%ad%a5%e9%aa%a4\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%ae%89%e8%a3%85apache-hive%e7%9a%84%e6%ad%a5%e9%aa%a4\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u5b89\u88c5Apache Hive\u7684\u6b65\u9aa4\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/cb5556d2501da73d864cac945e8d9461\",\"name\":\"\u6e05, \u626c\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/32a4239de8ff29adace466261d309424a1e5fe9f7e3036bf89fe03f2e3dbe717?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/32a4239de8ff29adace466261d309424a1e5fe9f7e3036bf89fe03f2e3dbe717?s=96&d=mm&r=g\",\"caption\":\"\u6e05, \u626c\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/qingyang\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%ae%89%e8%a3%85apache-hive%e7%9a%84%e6%ad%a5%e9%aa%a4\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"\u5b89\u88c5Apache Hive\u7684\u6b65\u9aa4 - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/\u5b89\u88c5apache-hive\u7684\u6b65\u9aa4\/","og_locale":"zh_CN","og_type":"article","og_title":"\u5b89\u88c5Apache Hive\u7684\u6b65\u9aa4","og_description":"\u6982\u8981 &#8211; \u6982\u8ff0 Apache Hadoop\u548cHive\u7684\u5b89\u88c5\u6b65\u9aa4\u5982\u4e0b\uff0c\u5c06\u5206\u522b\u5728\u4e0d\u540c\u7684\u6587\u7ae0\u4e2d\u8fdb\u884c\u8bf4\u660e\u3002 [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/\u5b89\u88c5apache-hive\u7684\u6b65\u9aa4\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-10-11T07:06:53+00:00","article_modified_time":"2024-04-30T04:32:30+00:00","author":"\u6e05, \u626c","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u6e05, \u626c","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"6 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%ae%89%e8%a3%85apache-hive%e7%9a%84%e6%ad%a5%e9%aa%a4\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%ae%89%e8%a3%85apache-hive%e7%9a%84%e6%ad%a5%e9%aa%a4\/","name":"\u5b89\u88c5Apache Hive\u7684\u6b65\u9aa4 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2023-10-11T07:06:53+00:00","dateModified":"2024-04-30T04:32:30+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/cb5556d2501da73d864cac945e8d9461"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%ae%89%e8%a3%85apache-hive%e7%9a%84%e6%ad%a5%e9%aa%a4\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/%e5%ae%89%e8%a3%85apache-hive%e7%9a%84%e6%ad%a5%e9%aa%a4\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%ae%89%e8%a3%85apache-hive%e7%9a%84%e6%ad%a5%e9%aa%a4\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"\u5b89\u88c5Apache Hive\u7684\u6b65\u9aa4"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/cb5556d2501da73d864cac945e8d9461","name":"\u6e05, \u626c","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/32a4239de8ff29adace466261d309424a1e5fe9f7e3036bf89fe03f2e3dbe717?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/32a4239de8ff29adace466261d309424a1e5fe9f7e3036bf89fe03f2e3dbe717?s=96&d=mm&r=g","caption":"\u6e05, \u626c"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/qingyang\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%ae%89%e8%a3%85apache-hive%e7%9a%84%e6%ad%a5%e9%aa%a4\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/36546","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=36546"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/36546\/revisions"}],"predecessor-version":[{"id":91930,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/36546\/revisions\/91930"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=36546"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=36546"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=36546"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}