2015-09-05 25 views
0

我在我的程序中有一個長時間的迭代,我想緩存和檢查點每隔幾次迭代(這種技術建議在網上削減長沿襲),所以我不會有StackOverflowError,通過這樣做Spark無效的檢查點目錄

for (i <- 2 to 100) { 
     //cache and checkpoint ever 30 iterations 
     if (i % 30 == 0) { 
     graph.cache 
     graph.checkpoint 
     //I use numEdges in order to start the transformation I need 
     graph.numEdges 
     } 
     //graphs are stored to a list 
     //here I use the graph of previous iteration to this iteration 
     //and perform a transformation 
} 

。我將這樣

val sc = new SparkContext(conf) 
sc.setCheckpointDir("checkpoints/") 

檢查點目錄然而,當我終於運行我的程序我得到一個異常

Exception in thread "main" org.apache.spark.SparkException: Invalid checkpoint directory 

我使用3臺計算機,每臺計算機都安裝了Ubuntu 14.04,而且我還在每臺計算機上使用hadoop 2.4或更高版本的Spark 1.4.1的預建版本。

回答

3

如果您已經在節點集羣上設置了HDFS,則可以在位於目錄HADOOP_HOME/etc/hadoop的「core-site.xml」中找到您的hdfs地址。對我來說,核心的site.xml被設置爲:

<configuration> 
     <property> 
      <name>fs.default.name</name> 
      <value>hdfs://master:9000</value> 
     </property> 
</configuration> 

然後您可以創建HDFS上一個目錄來保存個R dd檢查點文件,讓我們命名這個目錄RddChekPoint,通過Hadoop的HDFS殼:

$ hadoop fs -mkdir /RddCheckPoint 

如果使用pyspark,SparkContext由sc = SparkContext(conf)初始化後,您可以通過

sc.setCheckpointDir("hdfs://master:9000/RddCheckPoint")

設置檢查點目錄當dd爲設置檢查點,在HDFS目錄RddCheckPoint,你可以看到檢查點文件都保存在這裏,來看看:

$ hadoop fs -ls /RddCheckPoint 
1

檢查點目錄需要是一個HDFS兼容目錄(從scala文檔「HDFS兼容的目錄中檢查點數據將被可靠地存儲,注意這必須是像HDFS一樣的容錯文件系統」)。因此,如果您在這些節點上安裝了HDFS,請將它指向「hdfs:// [yourcheckpointdirectory]」。

+0

是否有任何其他方式或者我需要對我的節點HDFS設置?此外「hdfs:// [whatDoIputHere]」,如果我有hdfs安裝什麼目錄我確切地使用? –

+0

你不需要HDFS(它需要HDFS兼容,但也有其他的可能性)。如果你有HDFS設置,它應該是一個沒有任何重要內容的目錄。 – Holden