{"id":1317,"date":"2022-03-04T23:53:50","date_gmt":"2022-03-04T15:53:50","guid":{"rendered":"http:\/\/www.eait.co\/?p=1317"},"modified":"2022-06-13T10:20:11","modified_gmt":"2022-06-13T02:20:11","slug":"hive%e5%ae%89%e8%a3%85%e9%83%a8%e7%bd%b2%e5%92%8c%e7%9b%b8%e5%85%b3%e6%93%8d%e4%bd%9c","status":"publish","type":"post","link":"https:\/\/notes.coremix.net\/?p=1317","title":{"rendered":"Hive\u5b89\u88c5\u90e8\u7f72\u548c\u76f8\u5173\u64cd\u4f5c"},"content":{"rendered":"<h1>Hive\u5b89\u88c5\u73af\u5883\u51c6\u5907<\/h1>\n<h2>2.1 Hive\u5b89\u88c5\u5730\u5740<\/h2>\n<p>1\uff09Hive\u5b98\u7f51\u5730\u5740\uff1a<\/p>\n<p>http:\/\/hive.apache.org\/<\/p>\n<p>2\uff09\u6587\u6863\u67e5\u770b\u5730\u5740\uff1a<\/p>\n<p>https:\/\/cwiki.apache.org\/confluence\/display\/Hive\/GettingStarted<\/p>\n<p>3\uff09\u4e0b\u8f7d\u5730\u5740\uff1a<\/p>\n<p>http:\/\/archive.apache.org\/dist\/hive\/<\/p>\n<p>4\uff09github\u5730\u5740\uff1a<\/p>\n<p>https:\/\/github.com\/apache\/hive<\/p>\n<h2>2.2 Hive\u5b89\u88c5\u90e8\u7f72<\/h2>\n<p>1\uff09Hive\u5b89\u88c5\u53ca\u914d\u7f6e<\/p>\n<p>\uff081\uff09\u4f7f\u7528rz\u547d\u4ee4\u4e0a\u4f20<\/p>\n<p>\uff082\uff09\u89e3\u538b\u5230\u6267\u884c\u76ee\u5f55<\/p>\n<p>tar -zxvf apache-hive-1.2.1-bin.tar.gz -C \/opt\/module\/<\/p>\n<p>\uff083\uff09\u4fee\u6539\u540d\u79f0\u4e3ahive<\/p>\n<p>mv apache-hive-1.2.1-bin\/ hive<\/p>\n<p>\uff084\uff09\u4fee\u6539\/opt\/module\/hive\/conf\u76ee\u5f55\u4e0b\u7684hive-env.sh.template\u540d\u79f0\u4e3ahive-env.sh<\/p>\n<p>mv hive-env.sh.template hive-env.sh<\/p>\n<p>\uff085\uff09\u914d\u7f6ehive-env.sh\u6587\u4ef6<\/p>\n<p>\uff08a\uff09\u914d\u7f6eHADOOP_HOME\u8def\u5f84<\/p>\n<p>export HADOOP_HOME=\/opt\/module\/hadoop-2.8.4<\/p>\n<p>\uff08b\uff09\u914d\u7f6eHIVE_CONF_DIR\u8def\u5f84<\/p>\n<p>export HIVE_CONF_DIR=\/opt\/module\/hive\/conf<\/p>\n<p>\u6ce8\uff1aHive\u7684log\u9ed8\u8ba4\u5b58\u653e\u5728\/tmp\/root\/hive.log\u76ee\u5f55\u4e0b\uff08\u5f53\u524d\u7528\u6237\u540d\u4e0b\uff09\u3002<\/p>\n<p>\uff081\uff09\u4fee\u6539hive\u7684log\u5b58\u653e\u65e5\u5fd7\u5230\/opt\/module\/hive\/logs\uff08\u521b\u5efalogs\u6587\u4ef6\u5939\uff09<\/p>\n<p>\uff082\uff09\u4fee\u6539conf\/hive-log4j.properties.template\u6587\u4ef6\u540d\u79f0\u4e3ahive-log4j.properties<\/p>\n<p>mv hive-log4j.properties.template hive-log4j.properties<\/p>\n<p>\uff083\uff09\u5728hive-log4j.properties\u6587\u4ef6\u4e2d\u4fee\u6539log\u5b58\u653e\u4f4d\u7f6e<\/p>\n<p>hive.log.dir=\/opt\/module\/hive\/logs<\/p>\n<p>2\uff09Hadoop\u96c6\u7fa4\u914d\u7f6e<\/p>\n<p>\uff081\uff09\u5fc5\u987b\u542f\u52a8hdfs\u548cyarn\u00a0 \u00a0\u53ef\u76f4\u63a5\u7528start-all.sh<\/p>\n<p>sbin\/start-dfs.sh<\/p>\n<p>sbin\/start-yarn.sh<\/p>\n<p>\uff082\uff09\u5728HDFS\u4e0a\u521b\u5efa\/tmp\u548c\/user\/hive\/warehouse\u4e24\u4e2a\u76ee\u5f55\u5e76\u4fee\u6539\u4ed6\u4eec\u7684\u540c\u7ec4\u6743\u9650\u53ef\u5199<\/p>\n<p>bin\/hadoop fs -mkdir \/tmp<\/p>\n<p>bin\/hadoop fs -mkdir -p \/user\/hive\/warehouse<\/p>\n<p><span style=\"color: #ff0000;\">\u00a0 \u00a0 \u00a0 \u00a0 \u6743\u9650\u76f8\u5173\uff1a<\/span><\/p>\n<p>bin\/hadoop fs -chmod g+w \/tmp<\/p>\n<p>bin\/hadoop fs -chmod g+w \/user\/hive\/warehouse<\/p>\n<h2>2.3 MySql\u5b89\u88c5(\u7565)<\/h2>\n<h3>2.4 Hive\u5143\u6570\u636e\u914d\u7f6e\u5230MySql<\/h3>\n<h3>2.4.1 \u9a71\u52a8\u62f7\u8d1d1.27\u53ca\u4ee5\u4e0a<\/h3>\n<p>1\uff09\u4e0a\u4f20mysql-connector-java-5.1.27-bin.jar\u5230\/opt\/module\/hive\/lib\/<\/p>\n<p>mysql-connector-java-5.1.38.jar\u00a0 \uff08\u6b64\u5904\u7528\u8fd9\u4e2a\u7248\u672c\uff0c\u6216\u8005\u76f4\u63a5rz\u4e0a\u4f20\uff09<\/p>\n<p>cp mysql-connector-java-5.1.27-bin.jar \/opt\/module\/hive\/lib\/<\/p>\n<h3>2.4.2 \u914d\u7f6eMetastore\u5230MySql<\/h3>\n<p>1\uff09\u5728\/opt\/module\/hive\/conf\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2ahive-site.xml<\/p>\n<p>touch \/opt\/module\/hive\/conf\/hive-site.xml<\/p>\n<p>2\uff09\u6839\u636e\u5b98\u65b9\u6587\u6863\u914d\u7f6e\u53c2\u6570\uff0c\u62f7\u8d1d\u6570\u636e\u5230hive-site.xml\u6587\u4ef6\u4e2d\u3002<\/p>\n<p><span style=\"color: #ff0000;\">\u00a0 \u00a0 \u00a0 8.x\u52a0cj\uff0ccom.mysql.cj.jdbc.Driver<\/span><\/p>\n<p><a href=\"https:\/\/cwiki.apache.org\/confluence\/display\/Hive\/AdminManual+MetastoreAdmin\">https:\/\/cwiki.apache.org\/confluence\/display\/Hive\/AdminManual+MetastoreAdmin<\/a><\/p>\n<p>&nbsp;<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;?xml version=&quot;1.0&quot;?&gt;\r\n&lt;?xml-stylesheet type=&quot;text\/xsl&quot; href=&quot;configuration.xsl&quot;?&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;jdbc:mysql:\/\/bigdata166:3306\/metastore?createDatabaseIfNotExist=true&lt;\/value&gt;\r\n          &lt;description&gt;JDBC connect string for a JDBC metastore&lt;\/description&gt;\r\n        &lt;\/property&gt;\r\n\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;description&gt;Driver class name for a JDBC metastore&lt;\/description&gt;\r\n        &lt;\/property&gt;\r\n\r\n        &lt;property&gt;\r\n          &lt;name&gt;javax.jdo.option.ConnectionUserName&lt;\/name&gt;\r\n          &lt;value&gt;root&lt;\/value&gt;\r\n          &lt;description&gt;username to use against metastore database&lt;\/description&gt;\r\n        &lt;\/property&gt;\r\n\r\n        &lt;property&gt;\r\n          &lt;name&gt;javax.jdo.option.ConnectionPassword&lt;\/name&gt;\r\n          &lt;value&gt;000000&lt;\/value&gt;\r\n          &lt;description&gt;password to use against metastore database&lt;\/description&gt;\r\n        &lt;\/property&gt;\r\n        &lt;property&gt;\r\n                &lt;name&gt;hive.metastore.warehouse.dir&lt;\/name&gt;\r\n                &lt;value&gt;\/user\/hive\/warehouse&lt;\/value&gt;\r\n                &lt;description&gt;location of default database for the warehouse&lt;\/description&gt;\r\n        &lt;\/property&gt;\r\n        &lt;property&gt;\r\n                &lt;name&gt;hive.cli.print.header&lt;\/name&gt;\r\n                &lt;value&gt;true&lt;\/value&gt;\r\n        &lt;\/property&gt;\r\n\r\n        &lt;property&gt;\r\n                &lt;name&gt;hive.cli.print.current.db&lt;\/name&gt;\r\n                &lt;value&gt;true&lt;\/value&gt;\r\n        &lt;\/property&gt;\r\n&lt;\/configuration&gt;\r\n\r\n<\/pre>\n<p>&nbsp;<\/p>\n<ul>\n<li>\u914d\u7f6e\u5b8c\u6bd5\u540e\uff0c\u5982\u679c\u542f\u52a8hive\u5f02\u5e38\uff0c\u53ef\u4ee5\u91cd\u65b0\u542f\u52a8\u865a\u62df\u673a\u3002\uff08\u91cd\u542f\u540e\uff0c\u522b\u5fd8\u4e86\u542f\u52a8hadoop\u96c6\u7fa4\uff09<\/li>\n<li><span style=\"color: #ff0000;\">\u5728hive\u7684bin\u76ee\u5f55\u4e0b\u6267\u884c.\/schematool -dbType mysql -initSchema<\/span><\/li>\n<\/ul>\n<p>3\uff09Hive\u57fa\u672c\u64cd\u4f5c(\u6d4b\u8bd5\uff0c\u7701\u5f97\u624b\u6572\u4e86)<\/p>\n<p>\uff081\uff09\u542f\u52a8hive<\/p>\n<p>[root@bigdata166hive]$ bin\/hive<\/p>\n<p>\uff082\uff09\u67e5\u770b\u6570\u636e\u5e93<\/p>\n<p>hive&gt;show databases;<\/p>\n<p>\uff083\uff09\u6253\u5f00\u9ed8\u8ba4\u6570\u636e\u5e93<\/p>\n<p>hive&gt;use default;<\/p>\n<p>\uff084\uff09\u663e\u793adefault\u6570\u636e\u5e93\u4e2d\u7684\u8868<\/p>\n<p>hive&gt;show tables;<\/p>\n<p>\uff085\uff09\u521b\u5efa\u4e00\u5f20\u8868<\/p>\n<p>hive&gt; create table student(id int, name string) ;<\/p>\n<p>\uff086\uff09\u663e\u793a\u6570\u636e\u5e93\u4e2d\u6709\u51e0\u5f20\u8868<\/p>\n<p>hive&gt;show tables;<\/p>\n<p>\uff087\uff09\u67e5\u770b\u8868\u7684\u7ed3\u6784<\/p>\n<p>hive&gt;desc student;<\/p>\n<p>\uff088\uff09\u5411\u8868\u4e2d\u63d2\u5165\u6570\u636e<\/p>\n<p>hive&gt; insert into student values(1001,&#8221;ss1&#8243;);<\/p>\n<p>\uff089\uff09\u67e5\u8be2\u8868\u4e2d\u6570\u636e<\/p>\n<p>hive&gt; select * from student;<\/p>\n<p>\uff0810\uff09\u9000\u51fahive<\/p>\n<p>hive&gt; quit;<\/p>\n<p><span style=\"color: #ff0000;\">\u6ce8\uff1a\u914d\u7f6e\u5b8cmysql\u4f5c\u4e3aHive\u7684\u5143\u6570\u636e\u5e93\u540e\uff0c\u624d\u53ef\u4ee5\u4f7f\u7528\u591a\u4e2axshell\u5ba2\u6237\u7aef\u6253\u5f00hive\u64cd\u4f5c\u3002<\/span><\/p>\n<h2>2.5 \u5c06\u672c\u5730\u6587\u4ef6\u5bfc\u5165Hive\u6848\u4f8b<\/h2>\n<p><strong>\u9700\u6c42<\/strong>\uff1a\u5c06\u672c\u5730\/opt\/module\/datas\/student.txt\u8fd9\u4e2a\u76ee\u5f55\u4e0b\u7684\u6570\u636e\u5bfc\u5165\u5230hive\u7684student(id int, name string)\u8868\u4e2d\u3002<\/p>\n<p>1\uff09\u6570\u636e\u51c6\u5907\uff1a\u5728\/opt\/module\/datas\/student.txt\u8fd9\u4e2a\u76ee\u5f55\u4e0b\u51c6\u5907\u6570\u636e<\/p>\n<p>\uff081\uff09\u6570\u636e\u51c6\u5907 \u00a0mkdir \/opt\/module\/datas<\/p>\n<p>\uff082\uff09\u521b\u5efa\u6587\u672c\u00a0 touch \/opt\/module\/datas\/student.txt<\/p>\n<p>vi student.txt<\/p>\n<p>1001\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 zhangshan<\/p>\n<p>1002\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 lishi<\/p>\n<p>1003\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 zhaoliu<\/p>\n<p><span style=\"color: #ff0000;\">\u6ce8\u610f\u4ee5tab\uff08\u2018\\t\u2019\uff09\u952e\u95f4\u9694\u3002<\/span><\/p>\n<p>2\uff09Hive\u5b9e\u9645\u64cd\u4f5c<\/p>\n<p>\uff081\uff09\u542f\u52a8hive<\/p>\n<p>bin\/hive<\/p>\n<p><del>\uff082\uff09\u663e\u793a\u6570\u636e\u5e93<\/del><\/p>\n<p><del>hive&gt;show databases;<\/del><\/p>\n<p>\uff083\uff09\u4f7f\u7528default\u6570\u636e\u5e93<\/p>\n<p><span style=\"color: #ff0000;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hive&gt;use default; \uff08\u7528\u8fd9\u79cd\u65b9\u6cd5\u6587\u4ef6\u5939\u4e0b\u6709\u6587\u4ef6\u5939\uff0c\u800c\u4e0d\u662fxxx.db\uff09<\/span><\/p>\n<p><del>\uff084\uff09\u663e\u793adefault\u6570\u636e\u5e93\u4e2d\u7684\u8868<\/del><\/p>\n<p><del>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hive&gt;show tables;<\/del><\/p>\n<p><del>\uff085\uff09\u5220\u9664\u5df2\u521b\u5efa\u7684student\u8868<\/del><\/p>\n<p><del>hive&gt; drop table student;<\/del><\/p>\n<p>\uff086\uff09\u521b\u5efastudent\u8868, \u5e76\u58f0\u660e\u6587\u4ef6\u5206\u9694\u7b26\u2019\\t\u2019<\/p>\n<p>hive&gt; create table student1(id int, name string) <span style=\"color: #ff0000;\">ROW FORMAT DELIMITED FIELDS TERMINATED BY &#8216;\\t&#8217;;<\/span><\/p>\n<p>\uff087\uff09\u52a0\u8f7d\/opt\/module\/datas\/student.txt \u6587\u4ef6\u5230student\u6570\u636e\u5e93\u8868\u4e2d\u3002(\u4e0d\u52a0local\u662fhdfs\u8def\u5f84)<\/p>\n<p>hive&gt; load data local inpath &#8216;\/opt\/module\/datas\/student.txt&#8217; into table student1;<\/p>\n<p>\uff088\uff09Hive\u67e5\u8be2\u7ed3\u679c<\/p>\n<p>hive&gt; select * from student;<\/p>\n<p>OK<\/p>\n<p>1001\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 zhangshan<\/p>\n<p>1002\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 lishi<\/p>\n<p>1003\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 zhaoliu<\/p>\n<p>Time taken: 0.266 seconds, Fetched: 3 row(s)<\/p>\n<p>\uff089\uff09\u5e2e\u52a9\u547d\u4ee4<\/p>\n<p>[root@bigdata166hive]$ <span style=\"color: #ff0000;\">bin\/hive -help<\/span><\/p>\n<h2>2.6 Hive\u5e38\u7528\u4ea4\u4e92\u547d\u4ee4<\/h2>\n<p>1\uff09\u201c-e\u201d\u4e0d\u8fdb\u5165hive\u7684\u4ea4\u4e92\u7a97\u53e3\u6267\u884csql\u8bed\u53e5<\/p>\n<p>[root@bigdata166hive]$ <span style=\"color: #ff0000;\">bin\/hive -e &#8220;select id from student;&#8221;<\/span><\/p>\n<p>2\uff09\u201c-f\u201d\u6267\u884c\u811a\u672c\u4e2dsql\u8bed\u53e5<\/p>\n<p>\uff081\uff09\u5728\/opt\/module\/datas\u76ee\u5f55\u4e0b\u521b\u5efahivef.sql\u6587\u4ef6<\/p>\n<p>[root@bigdata166datas]$ touch hivef.sql<\/p>\n<p>\u6587\u4ef6\u4e2d\u5199\u5165\u6b63\u786e\u7684sql\u8bed\u53e5<\/p>\n<p>select *from student;<\/p>\n<p>\uff082\uff09\u6267\u884c\u6587\u4ef6\u4e2d\u7684sql\u8bed\u53e5<\/p>\n<p>[root@bigdata166hive]$ <span style=\"color: #ff0000;\">bin\/hive -f \/opt\/module\/datas\/hivef.sql<\/span><\/p>\n<p>\uff083\uff09\u6267\u884c\u6587\u4ef6\u4e2d\u7684sql\u8bed\u53e5\u5e76\u5c06\u7ed3\u679c\u5199\u5165\u6587\u4ef6\u4e2d(\u6ce8\uff1a\u53ef\u80fd\u542b\u6709\u5176\u4ed6\u7684\u8868\u4fe1\u606f\uff0c\u5982\u8868\u5934)<\/p>\n<p>[root@bigdata166hive]$ <span style=\"color: #ff0000;\">bin\/hive -f \/opt\/module\/datas\/hivef.sql\u00a0 &gt; \/opt\/module\/datas\/hive_result.txt<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>student.id\u00a0\u00a0\u00a0\u00a0\u00a0 student.name<\/p>\n<p>1001\u00a0\u00a0\u00a0 zhangshan<\/p>\n<p>1002\u00a0\u00a0\u00a0 lishi<\/p>\n<p>1003\u00a0\u00a0\u00a0 zhaoliu<\/p>\n<h2>2.7 Hive\u5176\u4ed6\u547d\u4ee4\u64cd\u4f5c<\/h2>\n<p>1\uff09\u9000\u51fahive\u7a97\u53e3\uff1a<\/p>\n<p>hive(default)&gt;exit; exit:\u5148\u9690\u6027\u63d0\u4ea4\u6570\u636e\uff0c\u518d\u9000\u51fa\uff1b<\/p>\n<p>hive(default)&gt;quit; quit:\u4e0d\u63d0\u4ea4\u6570\u636e\uff0c\u9000\u51fa\uff1b<\/p>\n<p>\u5728\u65b0\u7248\u4e2d\u6ca1\u533a\u522b\u4e86\uff0c\u5728\u4ee5\u524d\u7684\u7248\u672c\u662f\u6709\u7684\uff1a<\/p>\n<p>2\uff09\u5728hive cli\u547d\u4ee4\u7a97\u53e3\u4e2d\u5982\u4f55\u67e5\u770bhdfs\u6587\u4ef6\u7cfb\u7edf\uff08<span style=\"color: #ff0000;\">\u77ac\u95f4\u51fa\u6765<\/span>\uff09<\/p>\n<p>hive(default)&gt;<span style=\"color: #ff0000;\">dfs -ls \/;<\/span><\/p>\n<p>3\uff09\u5728hive cli\u547d\u4ee4\u7a97\u53e3\u4e2d\u5982\u4f55\u67e5\u770bhdfs\u672c\u5730\u7cfb\u7edf<\/p>\n<p>hive(default)&gt;<span style=\"color: #ff0000;\">! ls \/opt\/module\/datas;<\/span><\/p>\n<p>4\uff09\u67e5\u770b\u5728hive\u4e2d\u8f93\u5165\u7684\u6240\u6709\u5386\u53f2\u547d\u4ee4<\/p>\n<p>\uff081\uff09\u8fdb\u5165\u5230\u5f53\u524d\u7528\u6237\u7684\u6839\u76ee\u5f55\/root\u6216\/home\/root<\/p>\n<p>\uff082\uff09\u67e5\u770b. hivehistory\u6587\u4ef6<\/p>\n<p><span style=\"color: #ff0000;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0cat .hivehistory<\/span><\/p>\n<h2>2.8 \u53c2\u6570\u914d\u7f6e\u65b9\u5f0f<\/h2>\n<p>1\uff09\u67e5\u770b\u5f53\u524d\u6240\u6709\u7684\u914d\u7f6e\u4fe1\u606f<\/p>\n<p>hive&gt;set;<\/p>\n<p>2\uff09\u53c2\u6570\u7684\u914d\u7f6e\u4e09\u79cd\u65b9\u5f0f<\/p>\n<p>\uff081\uff09\u914d\u7f6e\u6587\u4ef6\u65b9\u5f0f<\/p>\n<p>\u9ed8\u8ba4\u914d\u7f6e\u6587\u4ef6\uff1ahive-default.xml<\/p>\n<p>\u7528\u6237\u81ea\u5b9a\u4e49\u914d\u7f6e\u6587\u4ef6\uff1ahive-site.xml<\/p>\n<p>\u6ce8\u610f\uff1a\u7528\u6237\u81ea\u5b9a\u4e49\u914d\u7f6e\u4f1a\u8986\u76d6\u9ed8\u8ba4\u914d\u7f6e\u3002\u53e6\u5916\uff0cHive\u4e5f\u4f1a\u8bfb\u5165Hadoop\u7684\u914d\u7f6e\uff0c\u56e0\u4e3aHive\u662f\u4f5c\u4e3aHadoop\u7684\u5ba2\u6237\u7aef\u542f\u52a8\u7684\uff0cHive\u7684\u914d\u7f6e\u4f1a\u8986\u76d6Hadoop\u7684\u914d\u7f6e\u3002\u914d\u7f6e\u6587\u4ef6\u7684\u8bbe\u5b9a\u5bf9\u672c\u673a\u542f\u52a8\u7684\u6240\u6709Hive\u8fdb\u7a0b\u90fd\u6709\u6548\u3002<\/p>\n<p>\uff082\uff09\u547d\u4ee4\u884c\u53c2\u6570\u65b9\u5f0f<\/p>\n<p>\u542f\u52a8Hive\u65f6\uff0c\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u6dfb\u52a0-hiveconf param=value\u6765\u8bbe\u5b9a\u53c2\u6570\u3002<\/p>\n<p>\u4f8b\u5982\uff1a<\/p>\n<p>[root@bigdata167 hive]$ bin\/hive -hiveconf mapred.reduce.tasks=10;<\/p>\n<p>\u6ce8\u610f\uff1a\u4ec5\u5bf9\u672c\u6b21hive\u542f\u52a8\u6709\u6548<\/p>\n<p>\u67e5\u770b\u53c2\u6570\u8bbe\u7f6e\uff1a<\/p>\n<p>hive (default)&gt; set mapred.reduce.tasks;<\/p>\n<p>\u663e\u793a\u4e3a\uff1amapred.reduce.tasks=10<\/p>\n<p>\u9ed8\u8ba4mapred.reduce.tasks=-1<\/p>\n<p>\uff083\uff09\u53c2\u6570\u58f0\u660e\u65b9\u5f0f<\/p>\n<p>\u53ef\u4ee5\u5728HQL\u4e2d\u4f7f\u7528SET\u5173\u952e\u5b57\u8bbe\u5b9a\u53c2\u6570<\/p>\n<p>\u4f8b\u5982\uff1a<\/p>\n<p>hive (default)&gt; set mapred.reduce.tasks=10;<\/p>\n<p>\u6ce8\u610f\uff1a\u4ec5\u5bf9\u672c\u6b21hive\u542f\u52a8\u6709\u6548\u3002<\/p>\n<p>\u67e5\u770b\u53c2\u6570\u8bbe\u7f6e<\/p>\n<p>hive (default)&gt; set mapred.reduce.tasks;<\/p>\n<p>\u4e0a\u8ff0\u4e09\u79cd\u8bbe\u5b9a\u65b9\u5f0f\u7684\u4f18\u5148\u7ea7\u4f9d\u6b21\u9012\u589e\u3002\u5373\u914d\u7f6e\u6587\u4ef6&lt;\u547d\u4ee4\u884c\u53c2\u6570&lt;\u53c2\u6570\u58f0\u660e\u3002\u6ce8\u610f\u67d0\u4e9b\u7cfb\u7edf\u7ea7\u7684\u53c2\u6570\uff0c\u4f8b\u5982log4j\u76f8\u5173\u7684\u8bbe\u5b9a\uff0c\u5fc5\u987b\u7528\u524d\u4e24\u79cd\u65b9\u5f0f\u8bbe\u5b9a\uff0c\u56e0\u4e3a\u90a3\u4e9b\u53c2\u6570\u7684\u8bfb\u53d6\u5728\u4f1a\u8bdd\u5efa\u7acb\u4ee5\u524d\u5df2\u7ecf\u5b8c\u6210\u4e86\u3002<\/p>\n<p><strong>\u5c0f\u5751\uff1a<\/strong><\/p>\n<p>\u603b\u662f\u63d0\u793aMySQL SSl\u95ee\u9898\uff0c\u4e5f\u61d2\u5f97\u767e\u5ea6\u4e86\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"952\" height=\"265\" class=\"alignnone wp-image-1318 size-full\" src=\"http:\/\/www.eait.co\/wp-content\/uploads\/2022\/03\/Pasted.png\" srcset=\"https:\/\/notes.coremix.net\/wp-content\/uploads\/2022\/03\/Pasted.png 952w, https:\/\/notes.coremix.net\/wp-content\/uploads\/2022\/03\/Pasted-300x84.png 300w, https:\/\/notes.coremix.net\/wp-content\/uploads\/2022\/03\/Pasted-768x214.png 768w\" sizes=\"auto, (max-width: 952px) 100vw, 952px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hive\u5b89\u88c5\u73af\u5883\u51c6\u5907 2.1 Hive\u5b89\u88c5\u5730\u5740 1\uff09Hive\u5b98\u7f51\u5730\u5740\uff1a http:\/\/hive.apache. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1317","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts\/1317","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1317"}],"version-history":[{"count":4,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts\/1317\/revisions"}],"predecessor-version":[{"id":1424,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts\/1317\/revisions\/1424"}],"wp:attachment":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1317"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1317"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1317"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}