我已经编写了一个sparkR代码,并想知道我是否可以使用EMR集群上的submit或sparkR提交它。
我尝试过几种方法,例如: sparkR、mySparkRScript.r或sparkR --不保存mySparkScript.r等等。但每次我都犯了错误:
Error in sparkR.sparkContext(master, appName, sparkHome, sparkConfigMap, :
JVM is not ready after 10 seconds样本代码:
#Set the path for the R libraries you would like to use.
#You may need to modify this if you have custom R libraries.
.libPaths(c(.libPaths(), '/usr/lib/spark/R/lib'))
#Set the SPARK_HOME environment variable to the location on EMR
Sys.setenv(SPARK_HOME = '/usr/lib/spark')
#Load the SparkR library into R
library(SparkR, lib.loc = c(file.path(Sys.getenv("SPARK_HOME"), "R", "lib")))
#Initiate a Spark context and identify where the master node is located.
#local is used here because the RStudio server
#was installed on the master node
sc <- sparkR.session(master = "local[*]", sparkEnvir = list(spark.driver.memory="2g"))
sqlContext <- sparkRSQL.init(sc)注意:我可以通过直接粘贴或使用资料来源(“mySparkRScript.R”)运行我的代码。
参考:
发布于 2018-01-09 17:51:56
我可以通过Rscript运行这个程序。有几件事你需要做,这可能是一个有点过程密集。如果你愿意试一试,我建议:
Rscript执行该文件。将这个shell脚本与R代码文件放在同一个S3桶中(为了简单起见)。这个shell文件的内容的示例如下所示:
#!/bin/bash aws s3 cp S3://path/to//R/file/from/s3 3.R--NameOfTheFileToRun.R脚本--step插入到集群创建调用中,使用Amazon提供的自定义JAR运行器运行复制和执行R代码的shell脚本AWS命令的示例可能如下所示(在我的示例中,我正在使用Amazon上的instead 1区域,并在cluster...just中的每个工作人员上抛出一个100‘m的磁盘,将您的区域放置在任何您看到' us-east-1’的位置,然后选择您想要的任何大小的磁盘)
aws emr create-cluster --name "MY COOL SPARKR OR SPARKLYR CLUSTER WITH AN RSCRIPT TO RUN SOME R CODE" --release-label emr-5.8.0 --applications Name=Spark Name=Ganglia Name=Hadoop --instance-groups InstanceGroupType=MASTER,InstanceCount=1,InstanceType=m4.xlarge 'InstanceGroupType=CORE,InstanceCount=2,InstanceType=m4.2xlarge,EbsConfiguration={EbsOptimized=true,EbsBlockDeviceConfigs=[{VolumeSpecification={VolumeType=gp2,SizeInGB=100}},{VolumeSpecification={VolumeType=io1,SizeInGB=100,Iops=100},VolumesPerInstance=1}]}' --log-uri s3://path/to/EMR/sparkr_logs --bootstrap-action Path=s3://path/to/EMR/sparkr_bootstrap/rstudio_sparkr_emr5lyr-proc.sh,Args=['--user','cool_dude','--user-pw','top_secret','--shiny','true','--sparkr','true','sparklyr','true'] --ec2-attributes KeyName=mykeyfilename,InstanceProfile=EMR_EC2_DefaultRole,AdditionalMasterSecurityGroups="sg-abc123",SubnetId="subnet-abc123" --service-role EMR_DefaultRole --scale-down-behavior TERMINATE_AT_TASK_COMPLETION --auto-terminate --region us-east-1 --steps Type=CUSTOM_JAR,Name=CustomJAR,ActionOnFailure=CONTINUE,Jar=s3://us-east-1.elasticmapreduce/libs/script-runner/script-runner.jar,Args=["s3://path/to/the/shell/file/from/step4.sh"]祝好运!干杯,内特
https://stackoverflow.com/questions/47198617
复制相似问题