[Solved] Hive Run SQL error: mapreduce failed to initiate a task

When running sql in hive, mapreduce fails to launch the task, check the log that APPmaster cannot find the hadoop path.
Solution:
Add the following codes in mapred-site.xml, the error will be solved.

<configuration>
<property>
  <name>yarn.app.mapreduce.am.env</name>
  <value>HADOOP_MAPRED_HOME=/opt/apps/hadoop-3.1.1</value>
</property>
<property>
  <name>mapreduce.map.env</name>
  <value>HADOOP_MAPRED_HOME=/opt/apps/hadoop-3.1.1</value>
</property>
<property>
  <name>mapreduce.reduce.env</name>
  <value>HADOOP_MAPRED_HOME=/opt/apps/hadoop-3.1.1</value>
</property>
 
</configuration>

Read More: