Hive 执行sql报 code2 错误
INFO : Query ID = root_20201015210009_fc36f3cc-2533-4857-af24-79474f803ad9
INFO : Total jobs = 1
INFO : Starting task [Stage-5:MAPREDLOCAL] in serial mode
INFO : Execution completed successfully
INFO : MapredLocal task succeeded
INFO : Launching Job 1 out of 1
INFO : Starting task [Stage-2:MAPRED] in serial mode
INFO : Number of reduce tasks not specified. Estimated from input data size: 1
INFO : In order to change the average load for a reducer (in bytes):
INFO : set hive.exec.reducers.bytes.per.reducer=<number>
INFO : In order to limit the maximum number of reducers:
INFO : set hive.exec.reducers.max=<number>
INFO : In order to set a constant number of reducers:
INFO : set mapreduce.job.reduces=<number>
INFO : number of splits:1
INFO : Submitting tokens for job: job_local1956915029_0021
INFO : Executing with tokens: []
INFO : The url to track the job: http://localhost:8080/
INFO : Job running in-process (local Hadoop)
INFO : 2020-10-15 21:00:22,533 Stage-2 map = 0%, reduce = 0%
ERROR : Ended Job = job_local1956915029_0021 with errors
ERROR : FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask
INFO : MapReduce Jobs Launched:
INFO : Stage-Stage-2: HDFS Read: 0 HDFS Write: 0 FAIL
INFO : Total MapReduce CPU Time Spent: 0 msec
INFO : Completed executing command(queryId=root_20201015210009_fc36f3cc-2533-4857-af24-79474f803ad9); Time taken: 12.769 seconds
INFO : Concurrency mode is disabled, not creating a lock manager
Error: Error while processing statement: FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask (state=08S01,code=2)
出现错误的原因可能有两个
1.集群时间不同步
1.1同步集群时间
- 所有机器安装 ntpdate
yum -y install ntpdate
- 集群所有机器同时执行 ntpdate time.nist.gov 同步时间
2.MapReduce Job程序内存溢出
- 元数据服务配置
在hive-site.xml中添加元数据服务配置
<property>
<name>hive.metastore.local</name>
<value>false</value>
<description>controls whether to connect to remove metastore server or open a new metastore server in Hive Client JVM</description>
</property>
<property>
<name>hive.metastore.uris</name>
<value>thrift://linux01:9083</value>
</property>
2.启动元数据服务
hive --service metastore 监听的端口是 9083
- 修改 MR 内存
vi /opt/apps/hadoop-3.1.1/etc/hadoop/hadoop-env.sh
修改内容
export HADOOP_CLIENT_OPTS="-Xmx1g ${HADOOP_CLIENT_OPTS}"