2014-04-19 41 views
5

需要在amazon EMR bootstrap動作上安裝一些軟件包和二進制文件,但我找不到任何使用它的示例。如何在代碼中的amazon EMR bootstrap動作上安裝自定義包?

基本上,我想安裝python包,並指定每個hadoop節點使用此包來處理s3桶中的項目,這裏是一個示例frpm boto。

     name='Image to grayscale using SimpleCV python package', 
         mapper='s3n://elasticmapreduce/samples/imageGrayScale.py', 
         reducer='aggregate', 
         input='s3n://elasticmapreduce/samples/input', 
         output='s3n://<my output bucket>/output' 

我需要使它使用SimpleCV python包,但不知道在哪裏指定此。如果沒有安裝,如何安裝?有沒有辦法避免等待安裝完成,是否有可能將其安裝在某處並引用python包?

+0

聽說過「boto」嗎? – emeth

+0

是的,這就是我從 – KJW

回答

6

有一個類boto.emr.bootstrap_action.BootstrapAction爲引導行動。

將其定義如下。大部分代碼來自boto example page

import boto.emr 
from boto.emr.bootstrap_action import BootstrapAction 

action = BootstrapAction(name="Bootstrap to add SimpleCV", 
         path="s3n://<my bucket uri>/bootstrap-simplecv.sh") 

conn = boto.emr.connect_to_region('us-west-2') 
jobid = conn.run_jobflow(name='My jobflow', 
         log_uri='s3://<my log uri>/jobflow_logs', 
         steps=[step], # step defined elsewhere 
         bootstrap_actions=[action]) 

而且您需要定義引導操作。如果你需要Python的另一個版本,那麼是的,這將節省時間在同一臺計算機上進行預編譯,tar,將其放入S3存儲桶,然後在引導過程中解壓縮它。

#!/bin/sh 
# filename: bootstrap-simplecv.sh (save it in an S3 bucket) 
set -e -x 

sudo apt-get install python-setuptools 
sudo easy_install pip 
sudo pip install -U SimpleCV 

我想你可以讓EMR實例從博託內部旋轉,這樣引導只會在你的會話中第一次出現。在註銷之前請注意關閉它們,以免讓帳單感到意外。

+0

獲得示例代碼的地方,特別是sudo apt-get命令幫助我手動完成。 –

相關問題