博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
玩转Hadoop的几个小技巧
阅读量:4112 次
发布时间:2019-05-25

本文共 3238 字,大约阅读时间需要 10 分钟。

Hadoop添加节点的方法 

自己实际添加节点过程:
1.
先在slave上配置好环境,包括sshjdk,相关configlibbin等的拷贝;
2.
将新的datanodehost加到集群namenode及其他datanode中去;
3.
将新的datanodeip加到masterconf/slaves中;
4.
重启cluster,cluster中看到新的datanode节点;
5.
运行bin/start-balancer.sh,这个会很耗时间
备注:
1.
如果不balance,那么cluster会把新的数据都存放在新的node上,这样会降低mr的工作效率;
2.
也可调用bin/start-balancer.sh命令执行,也可加参数 -threshold 5
   threshold
是平衡阈值,默认是10%,值越低各节点越平衡,但消耗时间也更长。
3. balancer
也可以在有mrjobcluster上运行,默认dfs.balance.bandwidthPerSec很低,为1M/s。在没有mr job时,可以提高该设置加快负载均衡时间。
其他备注: 
1.
必须确保slavefirewall已关闭;
2.
确保新的slaveip已经添加到master及其他slaves/etc/hosts中,反之也要将master及其他slaveip添加到新的slave/etc/hosts
mapper
reducer个数 
url
地址: 

较好的建议:

The right number of reduces seems to be 0.95 or 1.75 multiplied by (<no. ofnodes> * mapred.tasktracker.reduce.tasks.maximum).increasing the number ofreduces increases the framework overhead, but increases load balancing andlowers the cost of failures. 
<property>
  <name>mapred.tasktracker.reduce.tasks.maximum</name>
  <value>2</value>
  <description>The maximum number of reduce tasks that will berun
  simultaneously by a task tracker.
  </description>
</property>

单个node新加硬盘 

1.修改需要新加硬盘的nodedfs.data.dir,用逗号分隔新、旧文件目录
2.
重启dfs
同步hadoop 代码 
hadoop-env.sh
# host:path where hadoop code should be rsync'd from.  Unset bydefault.
# export HADOOP_MASTER=master:/home/$USER/src/hadoop
用命令合并HDFS小文件 
hadoop fs -getmerge <src> <dest>
重启reduce job方法 
Introduced recovery of jobs when JobTracker restarts. This facility is off bydefault.
Introduced config parameters "mapred.jobtracker.restart.recover","mapred.jobtracker.job.history.block.size", and"mapred.jobtracker.job.history.buffer.size".
还未验证过。
HDFS
退服节点的方法 
目前版本的dfsadmin的帮助信息是没写清楚的,已经file了一个bug了,正确的方法如下:
1.
dfs.hosts 置为当前的slaves,文件名用完整路径,注意,列表中的节点主机名要用大名,即 uname -n 可以得到的那个。
2.
slaves 中要被退服的节点的全名列表放在另一个文件里,如 slaves.ex,使用 dfs.host.exclude 参数指向这个文件的完整路径
3.
运行命令bin/hadoop dfsadmin -refreshNodes
4. web
界面或bin/hadoop dfsadmin -report 可以看到退服节点的状态是 Decomission in progress,直到需要复制的数据复制完成为止
5.
完成之后,从slaves 里(指dfs.hosts 指向的文件)去掉已经退服的节点
附带说一下 -refreshNodes 命令的另外三种用途: 
2.
添加允许的节点到列表中(添加主机名到 dfs.hosts 里来)
3.
直接去掉节点,不做数据副本备份(在 dfs.hosts 里去掉主机名)
4.
退服的逆操作——停止 exclude 里面和 dfs.hosts 里面都有的,正在进行 decomission 的节点的退服,也就是把 Decomission inprogress 的节点重新变为Normal (在 web 界面叫 in service)
distribute cache
使用 
类似一个全局变量,但是由于这个变量较大,所以不能设置在config文件中,转而使用distribute cache
具体使用方法:(详见《the definitive guide,P240)
1.
在命令行调用时:调用-files,引入需要查询的文件(可以是local file, HDFS file(使用hdfs://xxx?)), 或者 -archives (JAR,ZIP, tar)
% hadoop jar job.jar MaxTemperatureByStationNameUsingDistributedCacheFile \
  -files input/ncdc/metadata/stations-fixed-width.txt input/ncdc/alloutput
2.
程序中调用:
   public void configure(JobConf conf) {
      metadata = new NcdcStationMetadata();
      try {
        metadata.initialize(newFile("stations-fixed-width.txt"));
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
   }
另外一种间接的使用方法:在hadoop-0.19.0中好像没有
调用addCacheFile()或者addCacheArchive()添加文件,
使用getLocalCacheFiles() getLocalCacheArchives() 获得文件
hadoop
job显示web 
There are web-based interfaces to both the JobTracker (MapReduce master) andNameNode (HDFS master) which display status pages about the state of the entiresystem. By default, these are located at [WWW] and[WWW]  . 
hadoop
监控 
OnlyXP(52388483) 131702
nagios作告警,ganglia作监控图表即可

 

转载地址:http://zjrsi.baihongyu.com/

你可能感兴趣的文章
百度产品经理群面
查看>>
去哪儿一面+平安科技二面+hr面+贝贝一面+二面产品面经
查看>>
element ui 弹窗在IE11中关闭时闪现问题修复
查看>>
vue 遍历对象并动态绑定在下拉列表中
查看>>
Vue动态生成el-checkbox点击无法选中的解决方法
查看>>
python __future__
查看>>
MySQL Tricks1
查看>>
python 变量作用域问题(经典坑)
查看>>
pytorch
查看>>
pytorch(二)
查看>>
pytorch(三)
查看>>
pytorch(四)
查看>>
pytorch(5)
查看>>
pytorch(6)
查看>>
ubuntu相关
查看>>
C++ 调用json
查看>>
nano中设置脚本开机自启动
查看>>
动态库调动态库
查看>>
Kubernetes集群搭建之CNI-Flanneld部署篇
查看>>
k8s web终端连接工具
查看>>