-
Notifications
You must be signed in to change notification settings - Fork 1
/
06-delta-job.sh
executable file
·67 lines (60 loc) · 2.73 KB
/
06-delta-job.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#! /bin/bash
export AWS_REGION=cn-northwest-1
export CLUSTER_NAME=eks-emr-example
export AWS_ACCOUNT_ID="$(aws sts get-caller-identity --query Account --output text)"
export S3blogbucket=s3://emr-eks-spark-${AWS_REGION}-${AWS_ACCOUNT_ID}
# aws s3 mb $S3blogbucket --region $AWS_REGION
aws s3 cp resources/delta.py \
${S3blogbucket}/eks-emr-spark/delta.py
# aws s3 cp resources/spark_driver_podtemplate.yaml \
# ${S3blogbucket}/eks-emr-spark/spark_driver_podtemplate.yaml
# aws s3 cp resources/spark_executor_podtemplate.yaml \
# ${S3blogbucket}/eks-emr-spark/spark_executor_podtemplate.yaml
export VIRTUAL_CLUSTER_ID=$(aws emr-containers list-virtual-clusters \
--query "virtualClusters[?state=='RUNNING'].id" \
--region $AWS_REGION \
--output text)
export EMR_ROLE_ARN=$(aws iam get-role \
--role-name EMRContainers-JobExecutionRole \
--query Role.Arn \
--region $AWS_REGION \
--output text)
aws emr-containers start-job-run \
--virtual-cluster-id $VIRTUAL_CLUSTER_ID \
--name spark-delta-eks-emr \
--execution-role-arn $EMR_ROLE_ARN \
--release-label emr-6.8.0-latest \
--region $AWS_REGION \
--job-driver '{
"sparkSubmitJobDriver": {
"entryPoint": "'${S3blogbucket}'/eks-emr-spark/delta.py",
"entryPointArguments": ["'${S3blogbucket}'", "'${AWS_REGION}'"],
"sparkSubmitParameters": "--conf spark.executor.instances=6 --conf spark.executor.memory=1G --conf spark.executor.cores=1 --conf spark.driver.cores=2"
}
}' \
--configuration-overrides '{
"applicationConfiguration": [
{
"classification": "spark-defaults",
"properties": {
"spark.driver.memory":"1G",
"spark.sql.extensions": "io.delta.sql.DeltaSparkSessionExtension",
"spark.sql.catalog.spark_catalog":"org.apache.spark.sql.delta.catalog.DeltaCatalog",
"spark.serializer":"org.apache.spark.serializer.KryoSerializer",
"spark.hadoop.hive.metastore.client.factory.class":"com.amazonaws.glue.catalog.metastore.AWSGlueDataCatalogHiveClientFactory",
"spark.jars": "https://repo1.maven.org/maven2/io/delta/delta-core_2.12/2.1.0/delta-core_2.12-2.1.0.jar,https://repo1.maven.org/maven2/io/delta/delta-storage/2.1.0/delta-storage-2.1.0.jar",
"spark.kubernetes.driver.podTemplateFile":"'${S3blogbucket}'/eks-emr-spark/spark_driver_podtemplate.yaml",
"spark.kubernetes.executor.podTemplateFile":"'${S3blogbucket}'/eks-emr-spark/spark_executor_podtemplate.yaml"
}
}
],
"monitoringConfiguration": {
"cloudWatchMonitoringConfiguration": {
"logGroupName": "/emr-on-eks/emreksblog",
"logStreamNamePrefix": "delta"
},
"s3MonitoringConfiguration": {
"logUri": "'"$S3blogbucket"'/eks-emr-spark/logs/"
}
}
}'