-
Notifications
You must be signed in to change notification settings - Fork 1
/
04-iceberg-job.sh
executable file
·69 lines (62 loc) · 2.86 KB
/
04-iceberg-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
68
69
#! /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/iceberg.py \
${S3blogbucket}/eks-emr-spark/iceberg.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-iceberg-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/iceberg.py",
"entryPointArguments": ["'${S3blogbucket}'"],
"sparkSubmitParameters": "--jars local:///usr/share/aws/iceberg/lib/iceberg-spark3-runtime.jar --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": "org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions",
"spark.sql.catalog.glue_catalog": "org.apache.iceberg.spark.SparkCatalog",
"spark.sql.catalog.glue_catalog.catalog-impl": "org.apache.iceberg.aws.glue.GlueCatalog",
"spark.sql.catalog.glue_catalog.io-impl": "org.apache.iceberg.aws.s3.S3FileIO",
"spark.sql.catalog.glue_catalog.lock-impl": "org.apache.iceberg.aws.glue.DynamoLockManager",
"spark.sql.catalog.glue_catalog.lock.table": "myIcebergLockTable",
"spark.sql.catalog.glue_catalog.warehouse": "'${S3blogbucket}'/example-prefix/",
"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": "iceberg"
},
"s3MonitoringConfiguration": {
"logUri": "'"$S3blogbucket"'/eks-emr-spark/logs/"
}
}
}'