Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Apache Hive on YARN

DZone's Guide to

Apache Hive on YARN

Using Apache Hive on YARN enables Hadoop to support more varied processing approaches and a broader array of applications. Learn how to do it in this article!

· Big Data Zone
Free Resource

Learn best practices according to DataOps. Download the free O'Reilly eBook on building a modern Big Data platform.

YARN is a software rewrite that decouples MapReduce’s resource management and scheduling capabilities from the data processing component, enabling Hadoop to support more varied processing approaches and a broader array of applications. For example, Hadoop clusters can now run interactive querying and streaming data applications simultaneously with MapReduce batch jobs. In this blog, we will use Apache YARN on Apache Hive. Let's get started!

Add the file yarn-site.xml inside your /usr/local/hadoop/etc/hadoop folder with the following content:

<configuration>
	<property>
		<name>yarn.app.mapreduce.am.resource.mb</name>
		<value>1024</value>
	</property>
	<property>
		<name>yarn.app.mapreduce.am.command-opts</name>
		<value>-Xmx768m</value>
	</property>
	<property>
		<name>mapreduce.framework.name</name>
		<value>yarn</value>
		<description>Execution framework.</description>
	</property>
	<property>
		<name>mapreduce.map.cpu.vcores</name>
		<value>1</value>
		<description>The number of virtual cores required for each map task.</description>
	</property>
	<property>
		<name>mapreduce.reduce.cpu.vcores</name>
		<value>1</value>
		<description>The number of virtual cores required for each map task.</description>
	</property>
	<property>
		<name>yarn.nodemanager.aux-services</name>
		<value>mapreduce_shuffle</value>
	</property>
	<property>
		<name>yarn.nodemanager.aux-services.mapreduce_shuffle.class</name>
		<value>org.apache.hadoop.mapred.ShuffleHandler</value>
	</property>
	<property>
		<name>mapreduce.map.memory.mb</name>
		<value>1024</value>
		<description>Larger resource limit for maps.</description>
	</property>
	<property>
		<name>mapreduce.map.java.opts</name>
		<value>-Xmx768m</value>
		<description>Heap-size for child jvms of maps.</description>
	</property>
	<property>
		<name>mapreduce.reduce.memory.mb</name>
		<value>1024</value>
		<description>Larger resource limit for reduces.</description>
	</property>
	<property>
		<name>mapreduce.reduce.java.opts</name>
		<value>-Xmx768m</value>
		<description>Heap-size for child jvms of reduces.</description>
	</property>
	<property>
		<name>mapreduce.jobtracker.address</name>
		<value>jobtracker.alexjf.net:8021</value>
	</property>
</configuration>

First, start the DFS with the following command:dfs.png

Next, start the YARN Resource Manager with the command yarn resourcemanager startdfs1.png

Then, start the YARN Node Manager with the command yarn nodemanager start:dfs2.pngdf3

Start your Hive CLI and fire an insert into the query since it is a MapReduce query:dfs4.png

Now, why does this job fail? There are two ways to see the application logs. One is by typing command yarn logs -applicationId <applicationId>:df8.png

...and the other is through navigating to job rankings specified by the YARN UI job tracking URL.dfs5.png

From the error message, you can see that you’re using more virtual memory than your current limit of 1.0 gb. This can be resolved in two ways; one is by increasing the memory of yarn.app.mapreduce.am.resource.mb to a higher value such as 4096. The other is specifying this when starting Hive fires your query:

dfs6

Now, even if you navigate to the YARN UI, the query is successful.dfs7That's it! I hope that this blog is helpful for for those starting with Apache Hive and YARN.

Find the perfect platform for a scalable self-service model to manage Big Data workloads in the Cloud. Download the free O'Reilly eBook to learn more.

Topics:
big data ,tutorial ,apache hive ,yarn

Published at DZone with permission of Anubhav Tarar, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}