{"id":36445,"date":"2023-04-15T15:18:32","date_gmt":"2023-10-25T14:22:01","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8homebrew%e5%9c%a8macos%e4%b8%8a%e5%ae%89%e8%a3%85apache-hadoop-3%e5%92%8capache-hive-3\/"},"modified":"2024-04-29T23:39:19","modified_gmt":"2024-04-29T15:39:19","slug":"%e4%bd%bf%e7%94%a8homebrew%e5%9c%a8macos%e4%b8%8a%e5%ae%89%e8%a3%85apache-hadoop-3%e5%92%8capache-hive-3","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8homebrew%e5%9c%a8macos%e4%b8%8a%e5%ae%89%e8%a3%85apache-hadoop-3%e5%92%8capache-hive-3\/","title":{"rendered":"\u4f7f\u7528Homebrew\u5728macOS\u4e0a\u5b89\u88c5Apache Hadoop 3\u548cApache Hive 3"},"content":{"rendered":"<h2>\u6982\u8981<\/h2>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">macOS 1\u53f0\u306b Homebrew \u3067 Apache Hadoop \u3068 Apache Hive \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3001\u30b7\u30f3\u30b0\u30eb\u30ce\u30fc\u30c9\u3067\u7591\u4f3c\u5206\u6563\u30e2\u30fc\u30c9\u306e\u30af\u30e9\u30b9\u30bf\u30fc\u3092\u69cb\u7bc9\u3059\u308b<\/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\u5206\u6563\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0 HDFS (Hadoop Distributed File System) \u3092\u4f7f\u7528\u3059\u308b<\/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\">Apache Hive \u304b\u3089 HiveQL \u3067\u30c6\u30fc\u30d6\u30eb\u4f5c\u6210\u30fb\u30c7\u30fc\u30bf\u8ffd\u52a0\u30fb\u30c7\u30fc\u30bf\u53c2\u7167\u3059\u308b<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\u4eca\u56de\u306e\u74b0\u5883: macOS Catalina + Java 8 (AdoptOpenJDK 1.8.0_265) + Apache Hadoop 3.3.0 + Apache Hive 3.1.2<\/ul>\n<h2>\u5b89\u88c5Java 8<\/h2>\n<p>\u5982\u679c\u60a8\u5c1a\u672a\u5b89\u88c5Java 8\uff0c\u8bf7\u4f7f\u7528Homebrew\u6216\u5176\u4ed6\u65b9\u5f0f\u8fdb\u884c\u5b89\u88c5\uff0c\u5e76\u9a8c\u8bc1JAVA_HOME\u6240\u5e94\u8bbe\u5b9a\u7684\u76ee\u5f55\u4f4d\u7f6e\u3002<\/p>\n<pre class=\"post-pre\"><code>$ brew tap AdoptOpenJDK\/openjdk\r\n\r\n$ brew cask install adoptopenjdk8\r\n\r\n$ \/usr\/libexec\/java_home -v 1.8\r\n\/Library\/Java\/JavaVirtualMachines\/adoptopenjdk-8.jdk\/Contents\/Home\r\n<\/code><\/pre>\n<p>\u7531\u4e8eApache Hive\u4e0d\u652f\u6301Java 9\u53ca\u66f4\u9ad8\u7248\u672c\uff0c\u56e0\u6b64\u8bf7\u6ce8\u610f\uff0c\u5982\u679c\u4f7f\u7528Java 9\u53ca\u66f4\u9ad8\u7248\u672c\uff0c\u5c06\u4f1a\u51fa\u73b0\u4ee5\u4e0b\u9519\u8bef\u3002<\/p>\n<pre class=\"post-pre\"><code>Exception in thread \"main\" java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')\r\n  at org.apache.hadoop.hive.ql.session.SessionState.&lt;init&gt;(SessionState.java:413)\r\n  at org.apache.hadoop.hive.ql.session.SessionState.&lt;init&gt;(SessionState.java:389)\r\n  at org.apache.hadoop.hive.cli.CliSessionState.&lt;init&gt;(CliSessionState.java:60)\r\n  at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:705)\r\n  at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:683)\r\n  at java.base\/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n  at java.base\/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n  at java.base\/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n  at java.base\/java.lang.reflect.Method.invoke(Method.java:564)\r\n  at org.apache.hadoop.util.RunJar.run(RunJar.java:323)\r\n  at org.apache.hadoop.util.RunJar.main(RunJar.java:236)\r\n<\/code><\/pre>\n<h2>\u5b89\u88c5Apache Hadoop\u548cApache Hive\u3002<\/h2>\n<p>\u5728\u81ea\u5bb6\u917f\u9020\u4e2d\u5b89\u88c5 Apache Hive \u4f1a\u81ea\u52a8\u5b89\u88c5\u4f9d\u8d56\u5173\u7cfb\u7684 Apache Hadoop\u3002<\/p>\n<pre class=\"post-pre\"><code>$ brew install hive\r\n<\/code><\/pre>\n<p>\u786e\u8ba4Hadoop\u7684\u7248\u672c\u3002<\/p>\n<pre class=\"post-pre\"><code>$ hadoop version\r\nHadoop 3.3.0\r\nSource code repository https:\/\/gitbox.apache.org\/repos\/asf\/hadoop.git -r aa96f1871bfd858f9bac59cf2a81ec470da649af\r\nCompiled by brahma on 2020-07-06T18:44Z\r\nCompiled with protoc 3.7.1\r\nFrom source with checksum 5dc29b802d6ccd77b262ef9d04d19c4\r\nThis command was run using \/usr\/local\/Cellar\/hadoop\/3.3.0\/libexec\/share\/hadoop\/common\/hadoop-common-3.3.0.jar\r\n<\/code><\/pre>\n<p>\u68c0\u67e5 Hive \u7248\u672c\u3002<\/p>\n<pre class=\"post-pre\"><code>$ hive --version\r\nSLF4J: Class path contains multiple SLF4J bindings.\r\nSLF4J: Found binding in [jar:file:\/usr\/local\/Cellar\/hive\/3.1.2_1\/libexec\/lib\/log4j-slf4j-impl-2.10.0.jar!\/org\/slf4j\/impl\/StaticLoggerBinder.class]\r\nSLF4J: Found binding in [jar:file:\/usr\/local\/Cellar\/hadoop\/3.3.0\/libexec\/share\/hadoop\/common\/lib\/slf4j-log4j12-1.7.25.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\nHive 3.1.2\r\nGit git:\/\/HW13934\/Users\/gates\/tmp\/hive-branch-3.1\/hive -r 8190d2be7b7165effa62bd21b7d60ef81fb0e4af\r\nCompiled by gates on Thu Aug 22 15:01:18 PDT 2019\r\nFrom source with checksum 0492c08f784b188c349f6afb1d8d9847\r\n<\/code><\/pre>\n<h2>\u5047\u8bbe\u8bbe\u7f6e\u4e3a\u5206\u5e03\u5f0f\u6a21\u5f0f<\/h2>\n<p>\u8a2d\u5b9a\u6a94\u6848\u4f4d\u65bc \/usr\/local\/Cellar\/hadoop\/3.3.0\/libexec\/etc\/hadoop \u4e2d\u3002<br \/>\n\u8acb\u6309\u7167\u4ee5\u4e0b\u65b9\u5f0f\u4fee\u6539 core-site.xml \u548c hdfs-site.xml\u3002<\/p>\n<h3>\u6838\u5fc3\u914d\u7f6e\u6587\u4ef6.xml<\/h3>\n<pre class=\"post-pre\"><code><span class=\"cp\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;<\/span>\r\n<span class=\"cp\">&lt;?xml-stylesheet type=\"text\/xsl\" href=\"configuration.xsl\"?&gt;<\/span>\r\n<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>fs.defaultFS<span class=\"nt\">&lt;\/name&gt;<\/span>\r\n    <span class=\"nt\">&lt;value&gt;<\/span>hdfs:\/\/localhost:9000<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>hdfs-site.xml \u6587\u4ef6<\/h3>\n<pre class=\"post-pre\"><code><span class=\"cp\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;<\/span>\r\n<span class=\"cp\">&lt;?xml-stylesheet type=\"text\/xsl\" href=\"configuration.xsl\"?&gt;<\/span>\r\n<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>dfs.replication<span class=\"nt\">&lt;\/name&gt;<\/span>\r\n    <span class=\"nt\">&lt;value&gt;<\/span>1<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<h2>\u4fee\u6539hadoop.tmp.dir<\/h2>\n<p>\u5728Hadoop\u4e2d\u4f7f\u7528\u7684\u6570\u636e\u5b58\u50a8\u76ee\u5f55\u9ed8\u8ba4\u4e3a\/tmp\/hadoop-${user.name}\uff0c\u56e0\u6b64\u5728macOS\u91cd\u65b0\u542f\u52a8\u7b49\u60c5\u51b5\u4e0b\uff0c\u6570\u636e\u4f1a\u4e22\u5931\u3002<\/p>\n<p>\u6839\u636e\u9700\u8981\uff0c\u53ef\u4ee5\u901a\u8fc7\u5728core-site.xml\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5173\u4e8ehadoop.tmp.dir\u7684\u914d\u7f6e\u6765\u6307\u5b9a\u5b58\u50a8\u6570\u636e\u7684\u76ee\u5f55\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nt\">&lt;property&gt;<\/span>\r\n  <span class=\"nt\">&lt;name&gt;<\/span>hadoop.tmp.dir<span class=\"nt\">&lt;\/name&gt;<\/span>\r\n  <span class=\"nt\">&lt;value&gt;<\/span>\/Users\/foo\/hadoop<span class=\"nt\">&lt;\/value&gt;<\/span>\r\n<span class=\"nt\">&lt;\/property&gt;<\/span>\r\n<\/code><\/pre>\n<h2>\u8bbe\u7f6e JAVA_HOME<\/h2>\n<p>\u5728 \/usr\/local\/Cellar\/hadoop\/3.3.0\/libexec\/etc\/hadoop \u76ee\u5f55\u4e0b\u7684 hadoop-env.sh \u6587\u4ef6\u4e2d\u5199\u5165 JAVA_HOME\u3002\u6307\u5b9a\u7684 JAVA_HOME JVM \u8fd8\u4f1a\u88ab Apache Hive \u4f7f\u7528\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f\u6307\u5b9a\u901a\u8fc7Homebrew\u5b89\u88c5\u7684AdoptOpenJDK 8\u7684JAVA_HOME\u7684\u793a\u4f8b\u3002<\/p>\n<pre class=\"post-pre\"><code>export JAVA_HOME=\"\/Library\/Java\/JavaVirtualMachines\/adoptopenjdk-8.jdk\/Contents\/Home\"\r\n<\/code><\/pre>\n<h2>\u5141\u8bb8\u8fdc\u7a0b\u767b\u5f55<\/h2>\n<p>\u5728macOS\u4e2d\uff0c\u9700\u8981\u52fe\u9009\u201c\u7cfb\u7edf\u504f\u597d\u8bbe\u7f6e\u201d\u2192\u201c\u5171\u4eab\u201d\u4e2d\u7684\u201c\u8fdc\u7a0b\u767b\u5f55\u201d\u9009\u9879\u5e76\u5141\u8bb8\u8bbf\u95ee\u3002<\/p>\n<p>\u5982\u679c\u6ca1\u6709\u5141\u8bb8\u8fdc\u7a0b\u767b\u5f55\uff0c\u5219\u5728Hadoop\u542f\u52a8\u65f6\u4f1a\u51fa\u73b0\u4ee5\u4e0b\u9519\u8bef\u3002<\/p>\n<pre class=\"post-pre\"><code>$ \/usr\/local\/Cellar\/hadoop\/3.3.0\/sbin\/start-dfs.sh\r\nStarting namenodes on [localhost]\r\nlocalhost: ssh: connect to host localhost port 22: Connection refused\r\nStarting datanodes\r\nlocalhost: ssh: connect to host localhost port 22: Connection refused\r\nStarting secondary namenodes [mymacos.local]\r\nmymacos.local: ssh: connect to host mymacos.local port 22: Connection refused\r\n<\/code><\/pre>\n<h2>\u6ca1\u6709\u8bbe\u7f6e\u5bc6\u7801\u7684SSH\u914d\u7f6e<\/h2>\n<p>\u521b\u5efa\u6ca1\u6709\u5bc6\u7801\u7684\u5bc6\u94a5\u5bf9\uff0c\u5e76\u5c06\u5176\u6dfb\u52a0\u5230\u5141\u8bb8SSH\u8fde\u63a5\u7684\u5217\u8868\u4e2d\u3002<\/p>\n<pre class=\"post-pre\"><code>$ ssh-keygen -t rsa -P '' -f ~\/.ssh\/id_rsa\r\n$ cat ~\/.ssh\/id_rsa.pub &gt;&gt; ~\/.ssh\/authorized_keys\r\n$ chmod 0600 ~\/.ssh\/authorized_keys\r\n<\/code><\/pre>\n<p>\u5982\u679c\u5df2\u7ecf\u5b58\u5728 ~\/.ssh\/id_rsa \u6587\u4ef6\u5e76\u4e14\u4e0d\u60f3\u8986\u76d6\u5b83\uff0c\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528\u4efb\u610f\u6587\u4ef6\u540d\u521b\u5efa\u3002<br \/>\n\u4f8b\u5982\uff0c\u53ef\u4ee5\u6307\u5b9a\u6587\u4ef6\u540d\u4e3a id_rsa_for_my_hadoop\u3002<\/p>\n<pre class=\"post-pre\"><code>$ ssh-keygen -t rsa -P '' -f ~\/.ssh\/id_rsa_for_my_hadoop\r\n$ cat ~\/.ssh\/id_rsa_for_my_hadoop.pub &gt;&gt; ~\/.ssh\/authorized_keys\r\n$ chmod 0600 ~\/.ssh\/authorized_keys\r\n<\/code><\/pre>\n<p>\u5982\u679c\u4f7f\u7528\u4efb\u610f\u7684\u6587\u4ef6\u540d\u8fdb\u884c\u521b\u5efa\uff0c\u53ef\u4ee5\u5728\u73af\u5883\u53d8\u91cfHADOOP_SSH_OPTS\u4e2d\u63cf\u8ff0Hadoop\u5728\u4f7f\u7528ssh\u65f6\u6307\u5b9a\u7684\u9009\u9879\uff0c\u4ee5\u4f7f\u7528\u79c1\u94a5\u7684\u8def\u5f84\u3002HADOOP_SSH_OPTS\u5e94\u5728hadoop-env.sh\u4e2d\u8fdb\u884c\u8bbe\u7f6e\u3002<\/p>\n<pre class=\"post-pre\"><code>$ export HADOOP_SSH_OPTS=\"-i ~\/.ssh\/id_rsa_for_my_hadoop\"\r\n<\/code><\/pre>\n<p>\u5982\u679c\u65e0\u6cd5\u4f7f\u7528\u672c\u5730\u4e3b\u673a\u8fdb\u884c\u65e0\u5bc6\u7801\u8bbf\u95ee\u7684SSH\u8fde\u63a5\uff0c\u5219\u5728\u542f\u52a8Hadoop\u65f6\u53ef\u80fd\u4f1a\u51fa\u73b0\u4ee5\u4e0b\u9519\u8bef\u3002<\/p>\n<pre class=\"post-pre\"><code>$ \/usr\/local\/Cellar\/hadoop\/3.3.0\/sbin\/start-dfs.sh\r\nStarting namenodes on [localhost]\r\nlocalhost: Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.\r\nlocalhost: foo@localhost: Permission denied (publickey,password,keyboard-interactive).\r\nStarting datanodes\r\nlocalhost: foo@localhost: Permission denied (publickey,password,keyboard-interactive).\r\nStarting secondary namenodes [mymacos.local]\r\nmymacos.local: Warning: Permanently added 'mymacos.local' (ECDSA) to the list of known hosts.\r\nmymacos.local: foo@mymacos.local: Permission denied (publickey,password,keyboard-interactive).\r\n<\/code><\/pre>\n<h2>\u6587\u4ef6\u7cfb\u7edf\u7684\u683c\u5f0f\u5316<\/h2>\n<p>\u5728Hadoop\u4e2d\uff0c\u4f7f\u7528HDFS\uff08Hadoop\u5206\u5e03\u5f0f\u6587\u4ef6\u7cfb\u7edf\uff09\u6765\u683c\u5f0f\u5316\u73af\u5883\u3002<\/p>\n<pre class=\"post-pre\"><code>$ hdfs namenode -format\r\n<\/code><\/pre>\n<h2>Hadoop \u7684\u542f\u52a8<\/h2>\n<p>\u542f\u52a8\u7ba1\u7406HDFS\u7684NameNode\uff08\u5143\u6570\u636e\uff09\u548cDataNode\uff08\u6570\u636e\u5b9e\u4f53\uff09\u3002<\/p>\n<pre class=\"post-pre\"><code>$ \/usr\/local\/Cellar\/hadoop\/3.3.0\/sbin\/start-dfs.sh\r\n<\/code><\/pre>\n<p>&#8220;\u8b66\u544a\uff1autil.NativeCodeLoader\uff1a\u65e0\u6cd5\u4e3a\u60a8\u7684\u5e73\u53f0\u52a0\u8f7d\u672c\u5730Hadoop\u5e93&#8230; \u5728\u9002\u7528\u7684\u60c5\u51b5\u4e0b\u4f7f\u7528\u5185\u7f6eJava\u7c7b\u3002&#8221; \u8fd9\u4e2a\u8b66\u544a\u4f1a\u51fa\u73b0\uff0c\u4f46\u662f\u7531\u4e8e\u8fd9\u4e2a\u672c\u5730\u5e93\u4e0d\u652f\u6301macOS\uff0c\u6240\u4ee5\u53ef\u4ee5\u5ffd\u7565\u3002<\/p>\n<p>Apache Hadoop 3.3.0 &#8211; \u672c\u5730\u5e93\u6307\u5357<\/p>\n<blockquote><p>\u539f\u751fhadoop\u5e93\u4ec5\u9002\u7528\u4e8e*nix\u5e73\u53f0\u3002\u8be5\u5e93\u65e0\u6cd5\u4e0eCygwin\u6216Mac OS X\u5e73\u53f0\u914d\u5408\u4f7f\u7528\u3002<\/p><\/blockquote>\n<h2>\u521b\u5efa\u7528\u4e8eHive\u7684\u76ee\u5f55<\/h2>\n<p>\u5728HDFS\u4e0a\u521b\u5efa\u7528\u4e8eHive\u7684\u76ee\u5f55\u3002<\/p>\n<pre class=\"post-pre\"><code>$ hadoop fs -mkdir \/tmp\r\n$ hadoop fs -mkdir \/user\r\n$ hadoop fs -mkdir \/user\/hive\r\n$ hadoop fs -mkdir \/user\/hive\/warehouse\r\n$ hadoop fs -chmod g+w \/tmp\r\n$ hadoop fs -chmod g+w \/user\/hive\/warehouse\r\n<\/code><\/pre>\n<h2>\u521b\u5efaMetaStore<\/h2>\n<p>\u521b\u5efa\u4e00\u4e2a\u7528\u4e8e\u7ba1\u7406Hive\u76f8\u5173\u4fe1\u606f\u7684\u5143\u6570\u636e\u5b58\u50a8\u3002<\/p>\n<pre class=\"post-pre\"><code>$ schematool -initSchema -dbType derby\r\n(\u4e2d\u7565)\r\nMetastore connection URL:  jdbc:derby:;databaseName=metastore_db;create=true\r\nMetastore Connection Driver :  org.apache.derby.jdbc.EmbeddedDriver\r\nMetastore connection User:   APP\r\nStarting metastore schema initialization to 3.1.0\r\nInitialization script hive-schema-3.1.0.derby.sql\r\n(\u4e2d\u7565)\r\nInitialization script completed\r\nschemaTool completed\r\n<\/code><\/pre>\n<h2>\u542f\u52a8Hive CLI<\/h2>\n<p>\u4ee5\u4ea4\u4e92\u6a21\u5f0f\u542f\u52a8Hive CLI\u3002<\/p>\n<pre class=\"post-pre\"><code>$ hive\r\n<\/code><\/pre>\n<h2>\u521b\u5efa\u6570\u636e\u5e93<\/h2>\n<p>\u521b\u5efa\u6570\u636e\u5e93<\/p>\n<pre class=\"post-pre\"><code>hive&gt; create database foo_database;\r\nOK\r\nTime taken: 0.696 seconds\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>hive&gt; show databases;\r\nOK\r\ndefault\r\nfoo_database\r\nTime taken: 0.159 seconds, Fetched: 2 row(s)\r\n<\/code><\/pre>\n<h2>\u521b\u5efa\u8868\u683c<\/h2>\n<p>\u7528CREATE TABLE\u547d\u4ee4\u521b\u5efa\u8868\u683c\u3002<br \/>\n\u5c06\u6570\u636e\u4ee5\u9017\u53f7\u5206\u9694\u7684\u5f62\u5f0f\u6307\u5b9a\u4e3a\u5217\uff0c\u5e76\u4ee5\u6362\u884c\u5206\u9694\u7684\u5f62\u5f0f\u6307\u5b9a\u4e3a\u884c\u4f5c\u4e3a\u6570\u636e\u7684\u683c\u5f0f\u3002<\/p>\n<pre class=\"post-pre\"><code>hive&gt; create table foo_database.foo_table(\r\n    &gt;   id int,\r\n    &gt;   name string,\r\n    &gt;   updated_at timestamp)\r\n    &gt; row format delimited\r\n    &gt; fields terminated by ','\r\n    &gt; lines terminated by '\\n';\r\nOK\r\nTime taken: 0.887 seconds\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>hive&gt; show tables from foo_database;\r\nOK\r\nfoo_table\r\nTime taken: 0.058 seconds, Fetched: 1 row(s)\r\n<\/code><\/pre>\n<p>\u5728\u9000\u51faHive CLI\u65f6\uff0c\u8f93\u5165exit;\u3002<\/p>\n<pre class=\"post-pre\"><code>hive&gt; exit;\r\n<\/code><\/pre>\n<h2>\u52a0\u8f7d\u6570\u636e<\/h2>\n<p>\u51c6\u5907\u4e00\u4e2a\u6309\u9017\u53f7\u5206\u9694\u5217\uff0c\u6309\u6362\u884c\u7b26\u5206\u9694\u8bb0\u5f55\u7684CSV\u6587\u4ef6\uff0c\u5e76\u5c06\u5176\u653e\u7f6e\u5728\u8def\u5f84 \/Users\/foo\/data.csv \u4e0b\u3002\u6587\u4ef6\u5185\u5bb9\u5982\u4e0b\u6240\u793a\u3002<\/p>\n<pre class=\"post-pre\"><code>100,Alice,2020-02-29 00:00:00.000000001\r\n200,\u30dc\u30d6,1999-12-31 23:59:59\r\n<\/code><\/pre>\n<p>\u4f7f\u7528load data\u51fd\u6570\uff0c\u901a\u8fc7\u6307\u5b9aCSV\u6587\u4ef6\u7684\u8def\u5f84\u5c06\u6587\u4ef6\u52a0\u8f7d\u5230\u8868\u4e2d\u3002<\/p>\n<pre class=\"post-pre\"><code>hive&gt; LOAD DATA LOCAL INPATH 'file:\/Users\/foo\/data.csv' OVERWRITE INTO TABLE foo_database.foo_table;\r\nLoading data to table foo_database.foo_table\r\nOK\r\nTime taken: 1.307 seconds\r\n<\/code><\/pre>\n<h2>\u6570\u636e\u7684\u67e5\u8be2 de<\/h2>\n<p>\u5728\u6267\u884c\u67e5\u8be2\u65f6\u8bbe\u7f6e\u8f93\u51fa\u5217\u540d\u3002<\/p>\n<pre class=\"post-pre\"><code>hive&gt; set hive.cli.print.header=true;\r\n<\/code><\/pre>\n<p>\u4f7f\u7528select\u8bed\u53e5\u83b7\u53d6\u8bb0\u5f55\u5e76\u8fdb\u884c\u663e\u793a\u3002<\/p>\n<pre class=\"post-pre\"><code>hive&gt; select * from foo_database.foo_table;\r\nOK\r\nfoo_table.id    foo_table.name  foo_table.updated_at\r\n100     Alice   2020-02-29 00:00:00.000000001\r\n200     \u30dc\u30d6     1999-12-31 23:59:59\r\nTime taken: 0.131 seconds, Fetched: 2 row(s)\r\n<\/code><\/pre>\n<h2>\u505c\u6b62 Hadoop<\/h2>\n<pre class=\"post-pre\"><code>$ \/usr\/local\/Cellar\/hadoop\/3.3.0\/sbin\/stop-dfs.sh\r\n<\/code><\/pre>\n<h2>\u53c2\u8003\u6587\u732e<\/h2>\n<h3>\u5bb6\u917f<\/h3>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">hadoop \u2014 Homebrew Formulae<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">hive \u2014 Homebrew Formulae<\/ul>\n<h3>Apache Hadoop \u8f6f\u4ef6\u6846\u67b6<\/h3>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Hadoop \u2013 Apache Hadoop 3.3.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\">Apache Hadoop 3.3.0 \u2013 Hadoop: Setting up a Single Node Cluster.<\/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\">core-default.xml<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">hdfs-default.xml<\/ul>\n<h3>\u963f\u5e15\u5947\u5927\u8702\u5de2<\/h3>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Apache Hive TM<\/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\">GettingStarted &#8211; Apache Hive &#8211; Apache Software Foundation<\/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\">Configuration Properties &#8211; Apache Hive &#8211; Apache Software Foundation<\/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\">LanguageManual DML &#8211; Apache Hive &#8211; Apache Software Foundation<\/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\">LanguageManual Types &#8211; Apache Hive &#8211; Apache Software Foundation<\/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\">CSV\u3001TSV\u3001\u304a\u3088\u3073\u30ab\u30b9\u30bf\u30e0\u533a\u5207\u308a\u30d5\u30a1\u30a4\u30eb\u306e LazySimpleSerDe &#8211; Amazon Athena<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">Hadoop\uff0bHive\u691c\u8a3c\u74b0\u5883\u3092\u69cb\u7bc9\u3057\u3066\u307f\u308b (1\/3)\uff1aHive\u2015\u2015RDB\u4f7f\u3044\u306e\u305f\u3081\u306eHadoop\u30ac\u30a4\u30c9\uff08\u524d\u7de8\uff09 &#8211; \uff20IT<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981 macOS 1\u53f0\u306b Homebrew \u3067 Apache Hadoop \u3068 Apache Hive \u3092\u30a4\u30f3 [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-36445","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>\u4f7f\u7528Homebrew\u5728macOS\u4e0a\u5b89\u88c5Apache Hadoop 3\u548cApache Hive 3 - 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\/\u4f7f\u7528homebrew\u5728macos\u4e0a\u5b89\u88c5apache-hadoop-3\u548capache-hive-3\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4f7f\u7528Homebrew\u5728macOS\u4e0a\u5b89\u88c5Apache Hadoop 3\u548cApache Hive 3\" \/>\n<meta property=\"og:description\" content=\"\u6982\u8981 macOS 1\u53f0\u306b Homebrew \u3067 Apache Hadoop \u3068 Apache Hive \u3092\u30a4\u30f3 [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/\u4f7f\u7528homebrew\u5728macos\u4e0a\u5b89\u88c5apache-hadoop-3\u548capache-hive-3\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-10-25T14:22:01+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-29T15:39:19+00:00\" \/>\n<meta name=\"author\" content=\"\u5b87, \u534e\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u5b87, \u534e\" \/>\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\/%e4%bd%bf%e7%94%a8homebrew%e5%9c%a8macos%e4%b8%8a%e5%ae%89%e8%a3%85apache-hadoop-3%e5%92%8capache-hive-3\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8homebrew%e5%9c%a8macos%e4%b8%8a%e5%ae%89%e8%a3%85apache-hadoop-3%e5%92%8capache-hive-3\/\",\"name\":\"\u4f7f\u7528Homebrew\u5728macOS\u4e0a\u5b89\u88c5Apache Hadoop 3\u548cApache Hive 3 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2023-10-25T14:22:01+00:00\",\"dateModified\":\"2024-04-29T15:39:19+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8homebrew%e5%9c%a8macos%e4%b8%8a%e5%ae%89%e8%a3%85apache-hadoop-3%e5%92%8capache-hive-3\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8homebrew%e5%9c%a8macos%e4%b8%8a%e5%ae%89%e8%a3%85apache-hadoop-3%e5%92%8capache-hive-3\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8homebrew%e5%9c%a8macos%e4%b8%8a%e5%ae%89%e8%a3%85apache-hadoop-3%e5%92%8capache-hive-3\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4f7f\u7528Homebrew\u5728macOS\u4e0a\u5b89\u88c5Apache Hadoop 3\u548cApache Hive 3\"}]},{\"@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\/513018e4e121d3add1b7c5de8be21458\",\"name\":\"\u5b87, \u534e\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g\",\"caption\":\"\u5b87, \u534e\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/yuhua\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8homebrew%e5%9c%a8macos%e4%b8%8a%e5%ae%89%e8%a3%85apache-hadoop-3%e5%92%8capache-hive-3\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"\u4f7f\u7528Homebrew\u5728macOS\u4e0a\u5b89\u88c5Apache Hadoop 3\u548cApache Hive 3 - 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\/\u4f7f\u7528homebrew\u5728macos\u4e0a\u5b89\u88c5apache-hadoop-3\u548capache-hive-3\/","og_locale":"zh_CN","og_type":"article","og_title":"\u4f7f\u7528Homebrew\u5728macOS\u4e0a\u5b89\u88c5Apache Hadoop 3\u548cApache Hive 3","og_description":"\u6982\u8981 macOS 1\u53f0\u306b Homebrew \u3067 Apache Hadoop \u3068 Apache Hive \u3092\u30a4\u30f3 [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/\u4f7f\u7528homebrew\u5728macos\u4e0a\u5b89\u88c5apache-hadoop-3\u548capache-hive-3\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-10-25T14:22:01+00:00","article_modified_time":"2024-04-29T15:39:19+00:00","author":"\u5b87, \u534e","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u5b87, \u534e","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"6 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8homebrew%e5%9c%a8macos%e4%b8%8a%e5%ae%89%e8%a3%85apache-hadoop-3%e5%92%8capache-hive-3\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8homebrew%e5%9c%a8macos%e4%b8%8a%e5%ae%89%e8%a3%85apache-hadoop-3%e5%92%8capache-hive-3\/","name":"\u4f7f\u7528Homebrew\u5728macOS\u4e0a\u5b89\u88c5Apache Hadoop 3\u548cApache Hive 3 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2023-10-25T14:22:01+00:00","dateModified":"2024-04-29T15:39:19+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8homebrew%e5%9c%a8macos%e4%b8%8a%e5%ae%89%e8%a3%85apache-hadoop-3%e5%92%8capache-hive-3\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8homebrew%e5%9c%a8macos%e4%b8%8a%e5%ae%89%e8%a3%85apache-hadoop-3%e5%92%8capache-hive-3\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8homebrew%e5%9c%a8macos%e4%b8%8a%e5%ae%89%e8%a3%85apache-hadoop-3%e5%92%8capache-hive-3\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"\u4f7f\u7528Homebrew\u5728macOS\u4e0a\u5b89\u88c5Apache Hadoop 3\u548cApache Hive 3"}]},{"@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\/513018e4e121d3add1b7c5de8be21458","name":"\u5b87, \u534e","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g","caption":"\u5b87, \u534e"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/yuhua\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8homebrew%e5%9c%a8macos%e4%b8%8a%e5%ae%89%e8%a3%85apache-hadoop-3%e5%92%8capache-hive-3\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/36445","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\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=36445"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/36445\/revisions"}],"predecessor-version":[{"id":88342,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/36445\/revisions\/88342"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=36445"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=36445"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=36445"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}