Boto和底层的EMR API当前正在混合使用术语“ 集群” 和“ 工作流”
,并且不赞成使用工作流。我认为它们是同义词。
您可以通过调用该
boto.emr.connection.run_jobflow()函数来创建新集群。它将返回EMR为您生成的集群ID。
首先是所有强制性的事情:
#!/usr/bin/env pythonimport botoimport boto.emrfrom boto.emr.instance_group import InstanceGroupconn = boto.emr.connect_to_region('us-east-1')然后,我们指定实例组,包括我们要为TASK节点支付的现货价格:
instance_groups = []instance_groups.append(InstanceGroup( num_instances=1, role="MASTER", type="m1.small", market="ON_DEMAND", name="Main node"))instance_groups.append(InstanceGroup( num_instances=2, role="CORE", type="m1.small", market="ON_DEMAND", name="Worker nodes"))instance_groups.append(InstanceGroup( num_instances=2, role="TASK", type="m1.small", market="SPOT", name="My cheap spot nodes", bidprice="0.002"))
最后,我们开始一个新的集群:
cluster_id = conn.run_jobflow( "Name for my cluster", instance_groups=instance_groups, action_on_failure='TERMINATE_JOB_FLOW', keep_alive=True, enable_debugging=True, log_uri="s3://mybucket/logs/", hadoop_version=None, ami_version="2.4.9", steps=[], bootstrap_actions=[], ec2_keyname="my-ec2-key", visible_to_all_users=True, job_flow_role="EMR_EC2_DefaultRole", service_role="EMR_DefaultRole")
如果我们关心的话,我们也可以打印集群ID:
print "Starting cluster", cluster_id



