Posted on 2012-04-15 16:37
zljpp 閱讀(183)
評論(0) 編輯 收藏
Hadoop添加節點的方法
自己實際添加節點過程:
1. 先在slave上配置好環境,包括ssh,jdk,相關config,lib,bin等的拷貝;
2. 將新的datanode的host加到集群namenode及其他datanode中去;
3. 將新的datanode的ip加到master的conf/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也可以在有mr job的cluster上運行,默認dfs.balance.bandwidthPerSec很低,為1M/s。在沒有mr job時,可以提高該設置加快負載均衡時間。
其他備注:
1. 必須確保slave的firewall已關閉;
2. 確保新的slave的ip已經添加到master及其他slaves的/etc/hosts中,反之也要將master及其他slave的ip添加到新的slave的/etc/hosts中
hadoop 學習借鑒
1. 解決hadoop OutOfMemoryError問題:
<property>
<name>mapred.child.java.opts</name>
<value>-Xmx800M -server</value>
</property>
With the right JVM size in your hadoop-site.xml , you will have to copy this
to all mapred nodes and restart the cluster.
或者:hadoop jar jarfile [main class] -D mapred.child.java.opts=-Xmx800M
2. Hadoop java.io.IOException: Job failed! at org.apache.hadoop.mapred.JobClient.runJob(JobClient.java:1232) while indexing.
when i use nutch1.0,get this error:
Hadoop java.io.IOException: Job failed! at org.apache.hadoop.mapred.JobClient.runJob(JobClient.java:1232) while indexing.
這個也很好解決:
可以刪除conf/log4j.properties,然后可以看到詳細的錯誤報告
我這兒出現的是out of memory
解決辦法是在給運行主類org.apache.nutch.crawl.Crawl加上參數:-Xms64m -Xmx512m
你的或許不是這個問題,但是能看到詳細的錯誤報告問題就好解決了
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/all output
2. 程序中調用:
public void configure(JobConf conf) {
metadata = new NcdcStationMetadata();
try {
metadata.initialize(new File("stations-fixed-width.txt"));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
另外一種間接的使用方法:在hadoop-0.19.0中好像沒有
調用addCacheFile()或者addCacheArchive()添加文件,
使用getLocalCacheFiles() 或 getLocalCacheArchives() 獲得文件