title: How to change mapreduce temporary working directory /tmp to other folder
body: <p>I am using hive and I want to change the mapreduce temporary working directory from /tmp to some other directory. I tried everything which could I find on internet but nothing is working. I can see by du -h command that /tmp is filling up during the mapreduce task. Please somebody help me to change the directory.</p>
  
  <p>core-site.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;?xml-stylesheet type="text/xsl" href="configuration.xsl"?&gt;
   &lt;configuration&gt;
     &lt;property&gt;
        &lt;name&gt;fs.default.name&lt;/name&gt;
        &lt;value&gt;hdfs://localhost:9000&lt;/value&gt;
     &lt;/property&gt;
    &lt;property&gt;
       &lt;name&gt;hadoop.tmp.dir&lt;/name&gt;
       &lt;value&gt;/data/bd/tmp/hadoop-${user.name}&lt;/value&gt;
    &lt;/property&gt;
     &lt;property&gt;
        &lt;name&gt;dfs.journalnode.edits.dir&lt;/name&gt;
        &lt;value&gt;/data/bd/tmp/hadoop/dfs/journalnode/&lt;/value&gt;
     &lt;/property&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>mapred-site.xml</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;?xml-stylesheet type="text/xsl" href="configuration.xsl"?&gt;
  &lt;!-- Put site-specific property overrides in this file. --&gt;
  &lt;configuration&gt;
     &lt;property&gt;
        &lt;name&gt;mapreduce.framework.name&lt;/name&gt;
        &lt;value&gt;yarn&lt;/value&gt;
     &lt;/property&gt;
     &lt;property&gt;
        &lt;name&gt;mapreduce.cluster.local.dir&lt;/name&gt;
        &lt;value&gt;/data/bd/tmp/mapred/local&lt;/value&gt;
     &lt;/property&gt;
     &lt;property&gt;
        &lt;name&gt;mapreduce.task.tmp.dir&lt;/name&gt;
        &lt;value&gt;/data/bd/tmp&lt;/value&gt;
     &lt;/property&gt;
     &lt;property&gt;
        &lt;name&gt;mapreduce.cluster.temp.dir&lt;/name&gt;
        &lt;value&gt;/data/bd/tmp/mapred/temp&lt;/value&gt;
     &lt;/property&gt;
     &lt;property&gt;
        &lt;name&gt;yarn.app.mapreduce.am.env&lt;/name&gt;
        &lt;value&gt;HADOOP_MAPRED_HOME=${HADOOP_HOME}&lt;/value&gt;
     &lt;/property&gt;
     &lt;property&gt;
        &lt;name&gt;mapreduce.map.env&lt;/name&gt;
        &lt;value&gt;HADOOP_MAPRED_HOME=${HADOOP_HOME}&lt;/value&gt;
     &lt;/property&gt;
     &lt;property&gt;
        &lt;name&gt;mapreduce.reduce.env&lt;/name&gt;
        &lt;value&gt;HADOOP_MAPRED_HOME=${HADOOP_HOME}&lt;/value&gt;
     &lt;/property&gt;
     &lt;property&gt;
        &lt;name&gt;mapreduce.map.memory.mb&lt;/name&gt;
        &lt;value&gt;2048&lt;/value&gt;
     &lt;/property&gt;
     &lt;property&gt;
        &lt;name&gt;mapreduce.reduce.memory.mb&lt;/name&gt;
        &lt;value&gt;4096&lt;/value&gt;
     &lt;/property&gt;
     &lt;property&gt;
        &lt;name&gt;yarn.app.mapreduce.am.staging-dir&lt;/name&gt;
        &lt;value&gt;/data/bd/tmp/hadoop-yarn/staging&lt;/value&gt;
     &lt;/property&gt;
     &lt;property&gt;
        &lt;name&gt;mapreduce.jobtracker.system.dir&lt;/name&gt;
        &lt;value&gt;/data/bd/tmp/mapred/system&lt;/value&gt;
     &lt;/property&gt;
     &lt;property&gt;
        &lt;name&gt;mapreduce.jobtracker.staging.root.dir&lt;/name&gt;
        &lt;value&gt;/data/bd/tmp/mapred/staging&lt;/value&gt;
     &lt;/property&gt;
     &lt;property&gt;
        &lt;name&gt;mapreduce.map.output.compress&lt;/name&gt;
        &lt;value&gt;true&lt;/value&gt;
     &lt;/property&gt;
     &lt;property&gt;
        &lt;name&gt;mapreduce.map.output.compress.codec&lt;/name&gt;
        &lt;value&gt;org.apache.hadoop.io.compress.GzipCodec&lt;/value&gt;
     &lt;/property&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>yarn-site.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;configuration&gt;
     &lt;property&gt;
        &lt;name&gt;yarn.nodemanager.aux-services&lt;/name&gt;
        &lt;value&gt;mapreduce_shuffle&lt;/value&gt;
     &lt;/property&gt;
     &lt;property&gt;
        &lt;name&gt;yarn.nodemanager.aux-services.mapreduce_shuffle.class&lt;/name&gt;
        &lt;value&gt;org.apache.hadoop.mapred.ShuffleHandler&lt;/value&gt;
     &lt;/property&gt;
     &lt;property&gt;
        &lt;name&gt;yarn.application.classpath&lt;/name&gt;
        &lt;value&gt;$HADOOP_CONF_DIR,$HADOOP_COMMON_HOME/share/hadoop/common/*,$HADOOP_COMMON_HOME/share/hadoop/common/lib/*,$HADOOP_HDFS_HOME/share/hadoop/hdfs/*,$HADOOP_HDFS_HOME/share/hadoop/hdfs/lib/*,$HADOOP_MAPRED_HOME/share/hadoop/mapreduce/*,$HADOOP_MAPRED_HOME/share/hadoop/mapreduce/lib/*,
      $HADOOP_YARN_HOME/share/hadoop/yarn/*,$HADOOP_YARN_HOME/share/hadoop/yarn/lib/*&lt;/value&gt;
     &lt;/property&gt;
     &lt;property&gt;
        &lt;name&gt;yarn.nodemanager.vmem-check-enabled&lt;/name&gt;
        &lt;value&gt;false&lt;/value&gt;
        &lt;description&gt;Whether virtual memory limits will be enforced for containers&lt;/description&gt;
     &lt;/property&gt;
     &lt;property&gt;
        &lt;name&gt;yarn.nodemanager.vmem-pmem-ratio&lt;/name&gt;
        &lt;value&gt;4&lt;/value&gt;
        &lt;description&gt;Ratio between virtual memory to physical memory when setting memory limits for containers&lt;/description&gt;
     &lt;/property&gt;
     &lt;property&gt;
        &lt;name&gt;yarn.nodemanager.remote-app-log-dir&lt;/name&gt;
        &lt;value&gt;/data/bd/tmp/logs&lt;/value&gt;
        &lt;description&gt;The staging dir used while submitting jobs&lt;/description&gt;
     &lt;/property&gt;
     &lt;property&gt;
        &lt;name&gt;yarn.timeline-service.entity-group-fs-store.active-dir&lt;/name&gt;
        &lt;value&gt;/data/bd/tmp/entity-file-history/active&lt;/value&gt;
        &lt;description&gt;HDFS path to store active application’s timeline data&lt;/description&gt;
     &lt;/property&gt;
     &lt;property&gt;
        &lt;name&gt;yarn.timeline-service.entity-group-fs-store.done-dir&lt;/name&gt;
        &lt;value&gt;/data/bd/tmp/entity-file-history/done/&lt;/value&gt;
        &lt;description&gt;HDFS path to store done application’s timeline data&lt;/description&gt;
     &lt;/property&gt;
     &lt;property&gt;
        &lt;name&gt;yarn.nodemanager.local-dirs&lt;/name&gt;
        &lt;value&gt;/data/bd/tmp/hadoop-ubuntu/nm-local-dir&lt;/value&gt;
        &lt;description&gt;List of directories to store localized files&lt;/description&gt;
     &lt;/property&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>hive-site.xml</p>
  
  <pre><code>&lt;configuration&gt;
      &lt;property&gt;
          &lt;name&gt;javax.jdo.option.ConnectionURL&lt;/name&gt;
          &lt;value&gt;jdbc:mysql://localhost/metastore?createDatabaseIfNotExist=true&lt;/value&gt;
          &lt;description&gt;metadata is stored in a MySQL server&lt;/description&gt;
      &lt;/property&gt;
      &lt;property&gt;
          &lt;name&gt;javax.jdo.option.ConnectionDriverName&lt;/name&gt;
          &lt;value&gt;com.mysql.jdbc.Driver&lt;/value&gt;
          &lt;description&gt;MySQL JDBC driver class&lt;/description&gt;
      &lt;/property&gt;
      &lt;property&gt;
          &lt;name&gt;javax.jdo.option.ConnectionUserName&lt;/name&gt;
          &lt;value&gt;hive&lt;/value&gt;
          &lt;description&gt;user name for connecting to mysql server&lt;/description&gt;
      &lt;/property&gt;
      &lt;property&gt;
          &lt;name&gt;javax.jdo.option.ConnectionPassword&lt;/name&gt;
          &lt;value&gt;hive&lt;/value&gt;
          &lt;description&gt;password for connecting to mysql server&lt;/description&gt;
      &lt;/property&gt;
      &lt;property&gt;
          &lt;name&gt;hive.exec.parallel&lt;/name&gt;
          &lt;value&gt;true&lt;/value&gt;
          &lt;description&gt;Whether to execute jobs in parallel&lt;/description&gt;
      &lt;/property&gt;
      &lt;property&gt;
          &lt;name&gt;hive.exec.parallel.thread.number&lt;/name&gt;
          &lt;value&gt;8&lt;/value&gt;
          &lt;description&gt;How many jobs at most can be executed in parallel&lt;/description&gt;
      &lt;/property&gt;
      &lt;property&gt;
          &lt;name&gt;hive.cbo.enable&lt;/name&gt;
          &lt;value&gt;true&lt;/value&gt;
          &lt;description&gt;Flag to control enabling Cost Based Optimizations using Calcite framework.&lt;/description&gt;
      &lt;/property&gt;
      &lt;property&gt;
          &lt;name&gt;hive.compute.query.using.stats&lt;/name&gt;
          &lt;value&gt;true&lt;/value&gt;
          &lt;description&gt;
        When set to true Hive will answer a few queries like count(1) purely using stats
        stored in metastore. For basic stats collection turn on the config hive.stats.autogather to true.
        For more advanced stats collection need to run analyze table queries.
      &lt;/description&gt;
      &lt;/property&gt;
      &lt;property&gt;
          &lt;name&gt;hive.stats.fetch.partition.stats&lt;/name&gt;
          &lt;value&gt;true&lt;/value&gt;
          &lt;description&gt;
        Annotation of operator tree with statistics information requires partition level basic
        statistics like number of rows, data size and file size. Partition statistics are fetched from
        metastore. Fetching partition statistics for each needed partition can be expensive when the
        number of partitions is high. This flag can be used to disable fetching of partition statistics
        from metastore. When this flag is disabled, Hive will make calls to filesystem to get file sizes
        and will estimate the number of rows from row schema.
      &lt;/description&gt;
      &lt;/property&gt;
      &lt;property&gt;
          &lt;name&gt;hive.stats.fetch.column.stats&lt;/name&gt;
          &lt;value&gt;true&lt;/value&gt;
          &lt;description&gt;
        Annotation of operator tree with statistics information requires column statistics.
        Column statistics are fetched from metastore. Fetching column statistics for each needed column
        can be expensive when the number of columns is high. This flag can be used to disable fetching
        of column statistics from metastore.
      &lt;/description&gt;
      &lt;/property&gt;
      &lt;property&gt;
          &lt;name&gt;hive.stats.autogather&lt;/name&gt;
          &lt;value&gt;true&lt;/value&gt;
          &lt;description&gt;A flag to gather statistics automatically during the INSERT OVERWRITE command.&lt;/description&gt;
      &lt;/property&gt;
      &lt;property&gt;
          &lt;name&gt;hive.stats.dbclass&lt;/name&gt;
          &lt;value&gt;fs&lt;/value&gt;
          &lt;description&gt;
        Expects one of the pattern in [jdbc(:.*), hbase, counter, custom, fs].
        The storage that stores temporary Hive statistics. In filesystem based statistics collection ('fs'), 
        each task writes statistics it has collected in a file on the filesystem, which will be aggregated 
        after the job has finished. Supported values are fs (filesystem), jdbc:database (where database 
        can be derby, mysql, etc.), hbase, counter, and custom as defined in StatsSetupConst.java.
      &lt;/description&gt;
      &lt;/property&gt;
      &lt;property&gt;
          &lt;name&gt;hive.exec.scratchdir&lt;/name&gt;
          &lt;value&gt;/data/bd/tmp&lt;/value&gt;
          &lt;description&gt;Scratch space for Hive jobs&lt;/description&gt;
      &lt;/property&gt;
      &lt;property&gt;
          &lt;name&gt;hive.service.metrics.file.location&lt;/name&gt;
          &lt;value&gt;/data/bd/tmp/report.json&lt;/value&gt;
          &lt;description&gt;For metric class org.apache.hadoop.hive.common.metrics.metrics2.CodahaleMetrics JSON_FILE reporter, the location of local JSON metrics file.  This file will get overwritten at every interval.&lt;/description&gt;
      &lt;/property&gt;
      &lt;property&gt;
          &lt;name&gt;hive.query.results.cache.directory&lt;/name&gt;
          &lt;value&gt;/data/bd/tmp/hive/_resultscache_&lt;/value&gt;
          &lt;description&gt;unknown&lt;/description&gt;
      &lt;/property&gt;
      &lt;property&gt;
          &lt;name&gt;hive.llap.io.allocator.mmap.path&lt;/name&gt;
          &lt;value&gt;/data/bd/tmp&lt;/value&gt;
          &lt;description&gt;unknown&lt;/description&gt;
      &lt;/property&gt;
      &lt;property&gt;
          &lt;name&gt;hive.hbase.snapshot.restoredir&lt;/name&gt;
          &lt;value&gt;/data/bd/tmp&lt;/value&gt;
          &lt;description&gt;unknown&lt;/description&gt;
      &lt;/property&gt;
      &lt;property&gt;
          &lt;name&gt;hive.druid.working.directory&lt;/name&gt;
          &lt;value&gt;/data/bd/tmp//workingDirectory&lt;/value&gt;
          &lt;description&gt;unknown&lt;/description&gt;
      &lt;/property&gt;
      &lt;property&gt;
          &lt;name&gt;hive.querylog.location&lt;/name&gt;
          &lt;value&gt;/data/bd/tmp&lt;/value&gt;
          &lt;description&gt;logs hive&lt;/description&gt;
      &lt;/property&gt;
  &lt;/configuration&gt;
  </code></pre>