hadoop修改hadoop.tmp.dir

4 篇文章 0 订阅
1 篇文章 0 订阅

hadoop.tmp.dir的目录默认指向的是:/tmp/hadoop-${USERNAME}

这样会有个问题,系统重启时会自动删除/tmp目录下的文件,导致你之前对hadoop做的很多

操作都被删除了,需要重新再来,比如你想hdfs导入的文件会都被删除。

这是你需要修改 ${hadoop_home}/etc/hadoop/core-site.xml文件,添加一个名字为"hadoop.tmp.dir"

的property,内容如下:


<property>
        <name>hadoop.tmp.dir</name>
        <value>/opt/hadoopDir/tmp/data</value>
</property>


添加完hadoop.tmp.dir后的core-site.xml文件内容大致如下:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License. See accompanying LICENSE file.
-->

<!-- Put site-specific property overrides in this file. -->

<configuration>

<property>
        <name>fs.defaultFS</name>
        <value>hdfs://localhost:9000</value>
</property>

<property>
        <name>hadoop.tmp.dir</name>
        <value>/opt/hadoopDir/tmp/data</value>
</property>

<property>
        <name>io.native.lib.available</name>
        <value>false</value>
        <description>Controls whether to use native libraries for bz2 and zlib
                compression codecs or not. The property does not control any other native
                libraries.
        </description>
</property>

</configuration>

之后就是关闭hadoop,执行hdfs namenode -format,然后重新启动的过程了,不过这时有个

问题,就是你的hadoop可能运行了很久,执行stop-dfs.sh的时候提示不能关闭namenode、

datanode等,这时可能是你的java进程的状态文件被删除了。这时们就只能使用ps fax命令查

看hadoop进程,然后手动kill掉未被关闭的进程。


这个问题主要是因为java的进程状态文件是保存在“/tmp/hsperfdata_$USER”下的,而Linux的

/tmp目录可能会被某些流失文件夹工具删除,比如:

1、tmpwatch

2、tmpreaper

我查看了自己的机器是有一个tmpwatch的工具,这时我们需要执行该工具在清除/tmp目录时不

要清除我们的/tmp/hsperfdata_$USER目录,进入root权限,然后vi /etc/cron.daily/tmpwatch:

[root@localhost tmp]# vi /etc/cron.daily/tmpwatch

#! /bin/sh
flags=-umc
/usr/sbin/tmpwatch "$flags" -x /tmp/.X11-unix -x /tmp/.XIM-unix \
        -x /tmp/.font-unix -x /tmp/.ICE-unix -x /tmp/.Test-unix \
        -X '/tmp/hsperfdata_*' 10d /tmp
/usr/sbin/tmpwatch "$flags" 30d /var/tmp
for d in /var/{cache/man,catman}/{cat?,X11R6/cat?,local/cat?}; do
    if [ -d "$d" ]; then
        /usr/sbin/tmpwatch "$flags" -X '/tmp/hsperfdata_*' -f 30d "$d"
    fi
done

增加上面的红色部分代码,然后保存退出,这以后tmpwatch就不会删除java的临时目录了。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值