一、首先在windows环境操作虚拟机的hadoop集群,需要配置 windows的环境
1.根据自己电脑的操作系统拷贝对应的编译后的hadoop jar包到非中文路径
2.配置HADOOP_HOME环境变量 -- 然后将虚拟机hadoop的配置文件(4个)拷贝到windows部署的hadoop环境中
3.idea调试的时候指定虚拟机的参数
至此Windows的hadoop基础环境搭建完成。注意:搭建完成后一定要重启电脑,否则idea不能加载windows的hadoop环境配置。
二、使用Spark SQL操作hive第一个错误:
详细报错如下:
D:\Java\jdk1.8.0_141\bin\java.exe -DHADOOP_USER_NAME=atguigu "-javaagent:D:\ADevTool\IntelliJ IDEA 2018.3.3\lib\idea_rt.jar=52751:D:\ADevTool\IntelliJ IDEA 2018.3.3\bin" -Dfile.encoding=UTF-8 -classpath D:\Java\jdk1.8.0_141\jre\lib\charsets.jar;D:\Java\jdk1.8.0_141\jre\lib\deploy.jar;D:\Java\jdk1.8.0_141\jre\lib\ext\access-bridge-64.jar;D:\Java\jdk1.8.0_141\jre\lib\ext\cldrdata.jar;D:\Java\jdk1.8.0_141\jre\lib\ext\dnsns.jar;D:\Java\jdk1.8.0_141\jre\lib\ext\jaccess.jar;D:\Java\jdk1.8.0_141\jre\lib\ext\jfxrt.jar;D:\Java\jdk1.8.0_141\jre\lib\ext\localedata.jar;D:\Java\jdk1.8.0_141\jre\lib\ext\nashorn.jar;D:\Java\jdk1.8.0_141\jre\lib\ext\sunec.jar;D:\Java\jdk1.8.0_141\jre\lib\ext\sunjce_provider.jar;D:\Java\jdk1.8.0_141\jre\lib\ext\sunmscapi.jar;D:\Java\jdk1.8.0_141\jre\lib\ext\sunpkcs11.jar;D:\Java\jdk1.8.0_141\jre\lib\ext\zipfs.jar;D:\Java\jdk1.8.0_141\jre\lib\javaws.jar;D:\Java\jdk1.8.0_141\jre\lib\jce.jar;D:\Java\jdk1.8.0_141\jre\lib\jfr.jar;D:\Java\jdk1.8.0_141\jre\lib\jfxswt.jar;D:\Java\jdk1.8.0_141\jre\lib\jsse.jar;D:\Java\jdk1.8.0_141\jre\lib\management-agent.jar;D:\Java\jdk1.8.0_141\jre\lib\plugin.jar;D:\Java\jdk1.8.0_141\jre\lib\resources.jar;D:\Java\jdk1.8.0_141\jre\lib\rt.jar;E:\DevPrj\IdeaProject2019\gmall1205-parent-master\gmall1205-export-sale\target\classes;E:\DevPrj\IdeaProject2019\gmall1205-parent-master\gmall1205-common\target\classes;D:\localMaven\com\alibaba\fastjson\1.2.47\fastjson-1.2.47.jar;D:\localMaven\org\apache\httpcomponents\httpclient\4.5.5\httpclient-4.5.5.jar;D:\localMaven\org\apache\httpcomponents\httpcore\4.4.9\httpcore-4.4.9.jar;D:\localMaven\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;D:\localMaven\org\apache\httpcomponents\httpmime\4.3.6\httpmime-4.3.6.jar;D:\localMaven\io\searchbox\jest\2.0.4\jest-2.0.4.jar;D:\localMaven\io\searchbox\jest-common\2.0.4\jest-common-2.0.4.jar;D:\localMaven\com\google\code\gson\gson\2.8.2\gson-2.8.2.jar;D:\localMaven\org\apache\httpcomponents\httpcore-nio\4.4.4\httpcore-nio-4.4.4.jar;D:\localMaven\org\apache\httpcomponents\httpasyncclient\4.1.3\httpasyncclient-4.1.3.jar;D:\localMaven\net\java\dev\jna\jna\4.2.2\jna-4.2.2.jar;D:\localMaven\org\codehaus\janino\commons-compiler\2.7.8\commons-compiler-2.7.8.jar;D:\localMaven\org\apache\spark\spark-core_2.11\2.1.1\spark-core_2.11-2.1.1.jar;D:\localMaven\org\apache\avro\avro-mapred\1.7.7\avro-mapred-1.7.7-hadoop2.jar;D:\localMaven\org\apache\avro\avro-ipc\1.7.7\avro-ipc-1.7.7.jar;D:\localMaven\org\apache\avro\avro-ipc\1.7.7\avro-ipc-1.7.7-tests.jar;D:\localMaven\org\codehaus\jackson\jackson-core-asl\1.9.13\jackson-core-asl-1.9.13.jar;D:\localMaven\com\twitter\chill_2.11\0.8.0\chill_2.11-0.8.0.jar;D:\localMaven\com\esotericsoftware\kryo-shaded\3.0.3\kryo-shaded-3.0.3.jar;D:\localMaven\com\esotericsoftware\minlog\1.3.0\minlog-1.3.0.jar;D:\localMaven\org\objenesis\objenesis\2.1\objenesis-2.1.jar;D:\localMaven\com\twitter\chill-java\0.8.0\chill-java-0.8.0.jar;D:\localMaven\org\apache\xbean\xbean-asm5-shaded\4.4\xbean-asm5-shaded-4.4.jar;D:\localMaven\org\apache\hadoop\hadoop-client\2.2.0\hadoop-client-2.2.0.jar;D:\localMaven\org\apache\hadoop\hadoop-common\2.2.0\hadoop-common-2.2.0.jar;D:\localMaven\org\apache\commons\commons-math\2.1\commons-math-2.1.jar;D:\localMaven\xmlenc\xmlenc\0.52\xmlenc-0.52.jar;D:\localMaven\commons-configuration\commons-configuration\1.6\commons-configuration-1.6.jar;D:\localMaven\commons-collections\commons-collections\3.2.2\commons-collections-3.2.2.jar;D:\localMaven\commons-digester\commons-digester\2.1\commons-digester-2.1.jar;D:\localMaven\commons-beanutils\commons-beanutils\1.9.3\commons-beanutils-1.9.3.jar;D:\localMaven\commons-beanutils\commons-beanutils-core\1.8.0\commons-beanutils-core-1.8.0.jar;D:\localMaven\com\google\protobuf\protobuf-java\2.5.0\protobuf-java-2.5.0.jar;D:\localMaven\org\apache\hadoop\hadoop-auth\2.2.0\hadoop-auth-2.2.0.jar;D:\localMaven\org\apache\hadoop\hadoop-hdfs\2.2.0\hadoop-hdfs-2.2.0.jar;D:\localMaven\org\mortbay\jetty\jetty-util\6.1.26\jetty-util-6.1.26.jar;D:\localMaven\org\apache\hadoop\hadoop-mapreduce-client-app\2.2.0\hadoop-mapreduce-client-app-2.2.0.jar;D:\localMaven\org\apache\hadoop\hadoop-mapreduce-client-common\2.2.0\hadoop-mapreduce-client-common-2.2.0.jar;D:\localMaven\org\apache\hadoop\hadoop-yarn-client\2.2.0\hadoop-yarn-client-2.2.0.jar;D:\localMaven\com\google\inject\guice\3.0\guice-3.0.jar;D:\localMaven\javax\inject\javax.inject\1\javax.inject-1.jar;D:\localMaven\aopalliance\aopalliance\1.0\aopalliance-1.0.jar;D:\localMaven\org\apache\hadoop\hadoop-yarn-server-common\2.2.0\hadoop-yarn-server-common-2.2.0.jar;D:\localMaven\org\apache\hadoop\hadoop-mapreduce-client-shuffle\2.2.0\hadoop-mapreduce-client-shuffle-2.2.0.jar;D:\localMaven\org\apache\hadoop\hadoop-yarn-api\2.2.0\hadoop-yarn-api-2.2.0.jar;D:\localMaven\org\apache\hadoop\hadoop-mapreduce-client-core\2.2.0\hadoop-mapreduce-client-core-2.2.0.jar;D:\localMaven\org\apache\hadoop\hadoop-yarn-common\2.2.0\hadoop-yarn-common-2.2.0.jar;D:\localMaven\org\apache\hadoop\hadoop-mapreduce-client-jobclient\2.2.0\hadoop-mapreduce-client-jobclient-2.2.0.jar;D:\localMaven\org\apache\hadoop\hadoop-annotations\2.2.0\hadoop-annotations-2.2.0.jar;D:\localMaven\org\apache\spark\spark-launcher_2.11\2.1.1\spark-launcher_2.11-2.1.1.jar;D:\localMaven\org\apache\spark\spark-network-common_2.11\2.1.1\spark-network-common_2.11-2.1.1.jar;D:\localMaven\org\fusesource\leveldbjni\leveldbjni-all\1.8\leveldbjni-all-1.8.jar;D:\localMaven\com\fasterxml\jackson\core\jackson-annotations\2.8.0\jackson-annotations-2.8.0.jar;D:\localMaven\org\apache\spark\spark-network-shuffle_2.11\2.1.1\spark-network-shuffle_2.11-2.1.1.jar;D:\localMaven\org\apache\spark\spark-unsafe_2.11\2.1.1\spark-unsafe_2.11-2.1.1.jar;D:\localMaven\net\java\dev\jets3t\jets3t\0.7.1\jets3t-0.7.1.jar;D:\localMaven\org\apache\curator\curator-recipes\2.4.0\curator-recipes-2.4.0.jar;D:\localMaven\org\apache\curator\curator-framework\2.4.0\curator-framework-2.4.0.jar;D:\localMaven\org\apache\curator\curator-client\2.4.0\curator-client-2.4.0.jar;D:\localMaven\org\apache\zookeeper\zookeeper\3.4.5\zookeeper-3.4.5.jar;D:\localMaven\com\google\guava\guava\14.0.1\guava-14.0.1.jar;D:\localMaven\javax\servlet\javax.servlet-api\3.1.0\javax.servlet-api-3.1.0.jar;D:\localMaven\org\apache\commons\commons-lang3\3.5\commons-lang3-3.5.jar;D:\localMaven\org\apache\commons\commons-math3\3.4.1\commons-math3-3.4.1.jar;D:\localMaven\com\google\code\findbugs\jsr305\1.3.9\jsr305-1.3.9.jar;D:\localMaven\org\slf4j\jul-to-slf4j\1.7.22\jul-to-slf4j-1.7.22.jar;D:\localMaven\com\ning\compress-lzf\1.0.3\compress-lzf-1.0.3.jar;D:\localMaven\org\xerial\snappy\snappy-java\1.1.2.6\snappy-java-1.1.2.6.jar;D:\localMaven\net\jpountz\lz4\lz4\1.3.0\lz4-1.3.0.jar;D:\localMaven\org\roaringbitmap\RoaringBitmap\0.5.11\RoaringBitmap-0.5.11.jar;D:\localMaven\commons-net\commons-net\2.2\commons-net-2.2.jar;D:\localMaven\org\scala-lang\scala-library\2.11.8\scala-library-2.11.8.jar;D:\localMaven\org\json4s\json4s-jackson_2.11\3.2.11\json4s-jackson_2.11-3.2.11.jar;D:\localMaven\org\json4s\json4s-core_2.11\3.2.11\json4s-core_2.11-3.2.11.jar;D:\localMaven\org\json4s\json4s-ast_2.11\3.2.11\json4s-ast_2.11-3.2.11.jar;D:\localMaven\org\scala-lang\scalap\2.11.0\scalap-2.11.0.jar;D:\localMaven\org\scala-lang\scala-compiler\2.11.0\scala-compiler-2.11.0.jar;D:\localMaven\org\scala-lang\modules\scala-xml_2.11\1.0.1\scala-xml_2.11-1.0.1.jar;D:\localMaven\org\scala-lang\modules\scala-parser-combinators_2.11\1.0.1\scala-parser-combinators_2.11-1.0.1.jar;D:\localMaven\org\glassfish\jersey\core\jersey-client\2.25.1\jersey-client-2.25.1.jar;D:\localMaven\javax\ws\rs\javax.ws.rs-api\2.0.1\javax.ws.rs-api-2.0.1.jar;D:\localMaven\org\glassfish\hk2\hk2-api\2.5.0-b32\hk2-api-2.5.0-b32.jar;D:\localMaven\org\glassfish\hk2\hk2-utils\2.5.0-b32\hk2-utils-2.5.0-b32.jar;D:\localMaven\org\glassfish\hk2\external\aopalliance-repackaged\2.5.0-b32\aopalliance-repackaged-2.5.0-b32.jar;D:\localMaven\org\glassfish\hk2\external\javax.inject\2.5.0-b32\javax.inject-2.5.0-b32.jar;D:\localMaven\org\glassfish\hk2\hk2-locator\2.5.0-b32\hk2-locator-2.5.0-b32.jar;D:\localMaven\org\javassist\javassist\3.21.0-GA\javassist-3.21.0-GA.jar;D:\localMaven\org\glassfish\jersey\core\jersey-common\2.25.1\jersey-common-2.25.1.jar;D:\localMaven\javax\annotation\javax.annotation-api\1.2\javax.annotation-api-1.2.jar;D:\localMaven\org\glassfish\jersey\bundles\repackaged\jersey-guava\2.25.1\jersey-guava-2.25.1.jar;D:\localMaven\org\glassfish\hk2\osgi-resource-locator\1.0.1\osgi-resource-locator-1.0.1.jar;D:\localMaven\org\glassfish\jersey\core\jersey-server\2.25.1\jersey-server-2.25.1.jar;D:\localMaven\org\glassfish\jersey\media\jersey-media-jaxb\2.25.1\jersey-media-jaxb-2.25.1.jar;D:\localMaven\javax\validation\validation-api\1.1.0.Final\validation-api-1.1.0.Final.jar;D:\localMaven\org\glassfish\jersey\containers\jersey-container-servlet\2.25.1\jersey-container-servlet-2.25.1.jar;D:\localMaven\org\glassfish\jersey\containers\jersey-container-servlet-core\2.25.1\jersey-container-servlet-core-2.25.1.jar;D:\localMaven\io\netty\netty-all\4.0.42.Final\netty-all-4.0.42.Final.jar;D:\localMaven\io\netty\netty\3.8.0.Final\netty-3.8.0.Final.jar;D:\localMaven\com\clearspring\analytics\stream\2.7.0\stream-2.7.0.jar;D:\localMaven\io\dropwizard\metrics\metrics-core\3.1.5\metrics-core-3.1.5.jar;D:\localMaven\io\dropwizard\metrics\metrics-jvm\3.1.5\metrics-jvm-3.1.5.jar;D:\localMaven\io\dropwizard\metrics\metrics-json\3.1.5\metrics-json-3.1.5.jar;D:\localMaven\io\dropwizard\metrics\metrics-graphite\3.1.5\metrics-graphite-3.1.5.jar;D:\localMaven\com\fasterxml\jackson\core\jackson-databind\2.8.10\jackson-databind-2.8.10.jar;D:\localMaven\com\fasterxml\jackson\core\jackson-core\2.8.10\jackson-core-2.8.10.jar;D:\localMaven\com\fasterxml\jackson\module\jackson-module-scala_2.11\2.8.10\jackson-module-scala_2.11-2.8.10.jar;D:\localMaven\org\scala-lang\scala-reflect\2.11.8\scala-reflect-2.11.8.jar;D:\localMaven\com\fasterxml\jackson\module\jackson-module-paranamer\2.8.10\jackson-module-paranamer-2.8.10.jar;D:\localMaven\org\apache\ivy\ivy\2.4.0\ivy-2.4.0.jar;D:\localMaven\oro\oro\2.0.8\oro-2.0.8.jar;D:\localMaven\net\razorvine\pyrolite\4.13\pyrolite-4.13.jar;D:\localMaven\net\sf\py4j\py4j\0.10.4\py4j-0.10.4.jar;D:\localMaven\org\apache\spark\spark-tags_2.11\2.1.1\spark-tags_2.11-2.1.1.jar;D:\localMaven\org\apache\commons\commons-crypto\1.0.0\commons-crypto-1.0.0.jar;D:\localMaven\org\spark-project\spark\unused\1.0.0\unused-1.0.0.jar;D:\localMaven\org\apache\spark\spark-hive_2.11\2.1.1\spark-hive_2.11-2.1.1.jar;D:\localMaven\com\twitter\parquet-hadoop-bundle\1.6.0\parquet-hadoop-bundle-1.6.0.jar;D:\localMaven\org\spark-project\hive\hive-exec\1.2.1.spark2\hive-exec-1.2.1.spark2.jar;D:\localMaven\commons-io\commons-io\2.4\commons-io-2.4.jar;D:\localMaven\commons-lang\commons-lang\2.6\commons-lang-2.6.jar;D:\localMaven\javolution\javolution\5.5.1\javolution-5.5.1.jar;D:\localMaven\log4j\apache-log4j-extras\1.2.17\apache-log4j-extras-1.2.17.jar;D:\localMaven\org\antlr\antlr-runtime\3.4\antlr-runtime-3.4.jar;D:\localMaven\org\antlr\stringtemplate\3.2.1\stringtemplate-3.2.1.jar;D:\localMaven\antlr\antlr\2.7.7\antlr-2.7.7.jar;D:\localMaven\org\antlr\ST4\4.0.4\ST4-4.0.4.jar;D:\localMaven\org\apache\commons\commons-compress\1.4.1\commons-compress-1.4.1.jar;D:\localMaven\org\tukaani\xz\1.0\xz-1.0.jar;D:\localMaven\com\googlecode\javaewah\JavaEWAH\0.3.2\JavaEWAH-0.3.2.jar;D:\localMaven\org\iq80\snappy\snappy\0.2\snappy-0.2.jar;D:\localMaven\stax\stax-api\1.0.1\stax-api-1.0.1.jar;D:\localMaven\net\sf\opencsv\opencsv\2.3\opencsv-2.3.jar;D:\localMaven\org\spark-project\hive\hive-metastore\1.2.1.spark2\hive-metastore-1.2.1.spark2.jar;D:\localMaven\com\jolbox\bonecp\0.8.0.RELEASE\bonecp-0.8.0.RELEASE.jar;D:\localMaven\commons-cli\commons-cli\1.2\commons-cli-1.2.jar;D:\localMaven\org\apache\derby\derby\10.13.1.1\derby-10.13.1.1.jar;D:\localMaven\org\datanucleus\datanucleus-api-jdo\3.2.6\datanucleus-api-jdo-3.2.6.jar;D:\localMaven\org\datanucleus\datanucleus-rdbms\3.2.9\datanucleus-rdbms-3.2.9.jar;D:\localMaven\commons-pool\commons-pool\1.6\commons-pool-1.6.jar;D:\localMaven\commons-dbcp\commons-dbcp\1.4\commons-dbcp-1.4.jar;D:\localMaven\javax\jdo\jdo-api\3.0.1\jdo-api-3.0.1.jar;D:\localMaven\javax\transaction\jta\1.1\jta-1.1.jar;D:\localMaven\org\apache\avro\avro\1.7.7\avro-1.7.7.jar;D:\localMaven\com\thoughtworks\paranamer\paranamer\2.3\paranamer-2.3.jar;D:\localMaven\commons-httpclient\commons-httpclient\3.1\commons-httpclient-3.1.jar;D:\localMaven\org\apache\calcite\calcite-avatica\1.2.0-incubating\calcite-avatica-1.2.0-incubating.jar;D:\localMaven\org\apache\calcite\calcite-core\1.2.0-incubating\calcite-core-1.2.0-incubating.jar;D:\localMaven\org\apache\calcite\calcite-linq4j\1.2.0-incubating\calcite-linq4j-1.2.0-incubating.jar;D:\localMaven\net\hydromatic\eigenbase-properties\1.1.5\eigenbase-properties-1.1.5.jar;D:\localMaven\org\codehaus\jackson\jackson-mapper-asl\1.9.13\jackson-mapper-asl-1.9.13.jar;D:\localMaven\commons-codec\commons-codec\1.10\commons-codec-1.10.jar;D:\localMaven\joda-time\joda-time\2.9.9\joda-time-2.9.9.jar;D:\localMaven\org\jodd\jodd-core\3.5.2\jodd-core-3.5.2.jar;D:\localMaven\org\datanucleus\datanucleus-core\3.2.10\datanucleus-core-3.2.10.jar;D:\localMaven\org\apache\thrift\libthrift\0.9.3\libthrift-0.9.3.jar;D:\localMaven\org\apache\thrift\libfb303\0.9.3\libfb303-0.9.3.jar;D:\localMaven\org\apache\spark\spark-sql_2.11\2.1.1\spark-sql_2.11-2.1.1.jar;D:\localMaven\com\univocity\univocity-parsers\2.2.1\univocity-parsers-2.2.1.jar;D:\localMaven\org\apache\spark\spark-sketch_2.11\2.1.1\spark-sketch_2.11-2.1.1.jar;D:\localMaven\org\apache\spark\spark-catalyst_2.11\2.1.1\spark-catalyst_2.11-2.1.1.jar;D:\localMaven\org\codehaus\janino\janino\2.7.8\janino-2.7.8.jar;D:\localMaven\org\antlr\antlr4-runtime\4.5.3\antlr4-runtime-4.5.3.jar;D:\localMaven\org\apache\parquet\parquet-column\1.8.1\parquet-column-1.8.1.jar;D:\localMaven\org\apache\parquet\parquet-common\1.8.1\parquet-common-1.8.1.jar;D:\localMaven\org\apache\parquet\parquet-encoding\1.8.1\parquet-encoding-1.8.1.jar;D:\localMaven\org\apache\parquet\parquet-hadoop\1.8.1\parquet-hadoop-1.8.1.jar;D:\localMaven\org\apache\parquet\parquet-format\2.3.0-incubating\parquet-format-2.3.0-incubating.jar;D:\localMaven\org\apache\parquet\parquet-jackson\1.8.1\parquet-jackson-1.8.1.jar;D:\localMaven\mysql\mysql-connector-java\5.1.44\mysql-connector-java-5.1.44.jar;D:\localMaven\org\slf4j\jcl-over-slf4j\1.7.22\jcl-over-slf4j-1.7.22.jar;D:\localMaven\org\slf4j\slf4j-api\1.7.22\slf4j-api-1.7.22.jar;D:\localMaven\org\slf4j\slf4j-log4j12\1.7.22\slf4j-log4j12-1.7.22.jar;D:\localMaven\log4j\log4j\1.2.17\log4j-1.2.17.jar;D:\ADevTool\scala-2.11.8\lib\scala-actors-2.11.0.jar;D:\ADevTool\scala-2.11.8\lib\scala-actors-migration_2.11-1.1.0.jar;D:\ADevTool\scala-2.11.8\lib\scala-library.jar;D:\ADevTool\scala-2.11.8\lib\scala-parser-combinators_2.11-1.0.4.jar;D:\ADevTool\scala-2.11.8\lib\scala-reflect.jar;D:\ADevTool\scala-2.11.8\lib\scala-swing_2.11-1.0.2.jar;D:\ADevTool\scala-2.11.8\lib\scala-xml_2.11-1.0.4.jar com.atguigu.gmall1205.exportsale.app.ExportSaleApp |
这个错误巨坑:导致的原因是hadoop的windows本地环境的配置更新了一些参数,没有重启电脑,重启后这个问题就解决。
三:解决上面的问题后还有一个报错:错误还是指向上一个位置,但是错误信息不一样,报错信息和权限有关
报错:
具体报错:
Exception in thread "main" java.lang.IllegalArgumentException: Error while instantiating 'org.apache.spark.sql.hive.HiveSessionState': |
解决办法:
很多帖子说是目录访问权限问题,需要给目录授权,然而授权后还是报错。hadoop fs -chmod 777 /tmp/hive
经过多次尝试,在idea环境中的hive-site.xml文件中添加一下配置后问题解决了
<property> |
因为直接通过命令行默认hive-site.xml中的/tmp/hive就是在HDFS上的路径,但是在IDEA中则默认为系统的文件系统路径,所以会存在找不到文件或者目录的情况,需要指定 hdfs://hadoop102:9000/tmp/hive