设为首页 收藏本站
查看: 554|回复: 0

[经验分享] Apache Spark 2.3 运行在Kubernete实战

[复制链接]

尚未签到

发表于 2018-11-26 12:34:47 | 显示全部楼层 |阅读模式

  • 下载源代码,并解压
    下载地址

tar -zxvf v2.3.2.tar.gz

  • 编译

cd spark-2.3.2
build/mvn install -DskipTests
build/mvn compile -Pkubernetes -pl resource-managers/kubernetes/core -am -DskipTests
build/mvn install -Pkubernetes -pl resource-managers/kubernetes/core -am -DskipTests
[root@compile spark-2.3.2]# ls assembly/target/scala-2.11/jars/ -la|grep spark-kub*
-rw-r--r-- 1 root root   381120 Sep 26 09:56 spark-kubernetes_2.11-2.3.2.jar
dev/make-distribution.sh --tgz -Phadoop-2.7 -Pkubernetes
  构建支持R语言和hive的tar

./dev/make-distribution.sh --name inspur-spark --pip --r --tgz -Psparkr -Phadoop-2.7 -Phive -Phive-thriftserver -Pkubernetes
  出错:

++ echo 'Cannot find '\''R_HOME'\''. Please specify '\''R_HOME'\'' or make sure R is properly installed.'
Cannot find 'R_HOME'. Please specify 'R_HOME' or make sure R is properly installed.
  此次我们只测试Spark running on kubernetes,因此暂时不需要解决此问题。


  • 构建Docker Image
    ./bin/docker-image-tool.sh -r bigdata.registry.com:5000 -t 2.3.2 build
    ./bin/docker-image-tool.sh -r bigdata.registry.com:5000 -t 2.3.2 push
      由于本地的私有harbor中创建了仓库insight
    因此,执行如下命令push Image:

    docker tag bigdata.registry.com:5000/spark:2.3.2 bigdata.registry.com:5000/insight/spark:2.3.2
    docker push  bigdata.registry.com:5000/insight/spark:2.3.2
  • 将examples.jar上传至httpd服务中
    [root@compile spark-2.3.2]# ll dist/examples/jars/spark-examples_2.11-2.3.2.jar
    -rw-r--r-- 1 root root 1997551 Sep 26 09:56 dist/examples/jars/spark-examples_2.11-2.3.2.jar
    [root@compile spark-2.3.2]# cp dist/examples/jars/spark-examples_2.11-2.3.2.jar /opt/mnt/www/html/spark/
    [root@compile spark-2.3.2]# ll /opt/mnt/www/html/spark/
    -rw-r--r-- 1 root root  1997551 Sep 26 10:26 spark-examples_2.11-2.3.2.jar
  • 准备kubernetes环境,即授权
    kubectl create serviceaccount spark -nspark
    kubectl create clusterrolebinding spark-role --clusterrole=edit --serviceaccount=spark:spark --namespace=spark
      --seriveaccount=spark:spark 前一个spark是指namespace, 后一个spark是指serviceaccount

  • 测试
    bin/spark-submit \
    --master k8s://http://10.221.129.20:8080 \
    --deploy-mode cluster \
    --name spark-pi \
    --class org.apache.spark.examples.SparkPi \
    --conf spark.executor.instances=1 \
    --conf spark.kubernetes.container.image=bigdata.registry.com:5000/insight/spark:2.3.2 \
    --conf spark.kubernetes.namespace=spark \
    --conf spark.kubernetes.authenticate.driver.serviceAccountName=spark \
    http://10.221.129.22/spark/spark-examples_2.11-2.3.2.jar
    DSC0000.png
    运行日志:


      2018-09-26 10:27:54 WARN  Utils:66 - Kubernetes master URL uses HTTP instead of HTTPS.
    2018-09-26 10:28:25 WARN  Config:347 - Error reading service account token from: [/var/run/secrets/kubernetes.io/serviceaccount/token]. Ignoring.
    2018-09-26 10:28:27 INFO  LoggingPodStatusWatcherImpl:54 - State changed, new state:
    pod name: spark-pi-7b0ffe8a4023370a872acdd679f024b1-driver
    namespace: default
    labels: spark-app-selector -> spark-74d52904a3794e8986895a12322c5cd9, spark-role -> driver
    pod uid: d9bce33c-c133-11e8-b988-fa163e609d06
    creation time: 2018-09-26T02:28:27Z
    service account name: default
    volumes: spark-init-properties, download-jars-volume, download-files-volume, default-token-7mnhw
    node name: N/A
    start time: N/A
    container images: N/A
    phase: Pending
    status: []
    2018-09-26 10:28:27 INFO  LoggingPodStatusWatcherImpl:54 - State changed, new state:
    pod name: spark-pi-7b0ffe8a4023370a872acdd679f024b1-driver
    namespace: default
    labels: spark-app-selector -> spark-74d52904a3794e8986895a12322c5cd9, spark-role -> driver
    pod uid: d9bce33c-c133-11e8-b988-fa163e609d06
    creation time: 2018-09-26T02:28:27Z
    service account name: default
    volumes: spark-init-properties, download-jars-volume, download-files-volume, default-token-7mnhw
    node name: master2
    start time: N/A
    container images: N/A
    phase: Pending
    status: []
    2018-09-26 10:28:27 INFO  LoggingPodStatusWatcherImpl:54 - State changed, new state:
    pod name: spark-pi-7b0ffe8a4023370a872acdd679f024b1-driver
    namespace: default
    labels: spark-app-selector -> spark-74d52904a3794e8986895a12322c5cd9, spark-role -> driver
    pod uid: d9bce33c-c133-11e8-b988-fa163e609d06
    creation time: 2018-09-26T02:28:27Z
    service account name: default
    volumes: spark-init-properties, download-jars-volume, download-files-volume, default-token-7mnhw
    node name: master2
    start time: 2018-09-26T02:28:27Z
    container images: bigdata.registry.com:5000/insight/spark:2.3.2
    phase: Pending
    status: [ContainerStatus(containerID=null, image=bigdata.registry.com:5000/insight/spark:2.3.2, imageID=, lastState=ContainerState(running=null, terminated=null, waiting=null, additionalProperties={}), name=spark-kubernetes-driver, ready=false, restartCount=0, state=ContainerState(running=null, terminated=null, waiting=ContainerStateWaiting(message=null, reason=PodInitializing, additionalProperties={}), additionalProperties={}), additionalProperties={})]
    2018-09-26 10:28:28 INFO  Client:54 - Waiting for application spark-pi to finish...
    2018-09-26 10:28:51 INFO  LoggingPodStatusWatcherImpl:54 - State changed, new state:
    pod name: spark-pi-7b0ffe8a4023370a872acdd679f024b1-driver
    namespace: default
    labels: spark-app-selector -> spark-74d52904a3794e8986895a12322c5cd9, spark-role -> driver
    pod uid: d9bce33c-c133-11e8-b988-fa163e609d06
    creation time: 2018-09-26T02:28:27Z
    service account name: default
    volumes: spark-init-properties, download-jars-volume, download-files-volume, default-token-7mnhw
    node name: master2
    start time: 2018-09-26T02:28:27Z
    container images: bigdata.registry.com:5000/insight/spark:2.3.2
    phase: Pending
    status: [ContainerStatus(containerID=null, image=bigdata.registry.com:5000/insight/spark:2.3.2, imageID=, lastState=ContainerState(running=null, terminated=null, waiting=null, additionalProperties={}), name=spark-kubernetes-driver, ready=false, restartCount=0, state=ContainerState(running=null, terminated=null, waiting=ContainerStateWaiting(message=null, reason=PodInitializing, additionalProperties={}), additionalProperties={}), additionalProperties={})]
    2018-09-26 10:28:56 INFO  LoggingPodStatusWatcherImpl:54 - State changed, new state:
    pod name: spark-pi-7b0ffe8a4023370a872acdd679f024b1-driver
    namespace: default
    labels: spark-app-selector -> spark-74d52904a3794e8986895a12322c5cd9, spark-role -> driver
    pod uid: d9bce33c-c133-11e8-b988-fa163e609d06
    creation time: 2018-09-26T02:28:27Z
    service account name: default
    volumes: spark-init-properties, download-jars-volume, download-files-volume, default-token-7mnhw
    node name: master2
    start time: 2018-09-26T02:28:27Z
    container images: bigdata.registry.com:5000/insight/spark:2.3.2
    phase: Pending
    status: [ContainerStatus(containerID=null, image=bigdata.registry.com:5000/insight/spark:2.3.2, imageID=, lastState=ContainerState(running=null, terminated=null, waiting=null, additionalProperties={}), name=spark-kubernetes-driver, ready=false, restartCount=0, state=ContainerState(running=null, terminated=null, waiting=ContainerStateWaiting(message=null, reason=PodInitializing, additionalProperties={}), additionalProperties={}), additionalProperties={})]
    2018-09-26 10:28:57 INFO  LoggingPodStatusWatcherImpl:54 - State changed, new state:
    pod name: spark-pi-7b0ffe8a4023370a872acdd679f024b1-driver
    namespace: default
    labels: spark-app-selector -> spark-74d52904a3794e8986895a12322c5cd9, spark-role -> driver
    pod uid: d9bce33c-c133-11e8-b988-fa163e609d06
    creation time: 2018-09-26T02:28:27Z
    service account name: default
    volumes: spark-init-properties, download-jars-volume, download-files-volume, default-token-7mnhw
    node name: master2
    start time: 2018-09-26T02:28:27Z
    container images: bigdata.registry.com:5000/insight/spark:2.3.2
    phase: Running
    status: [ContainerStatus(containerID=docker://3abe8f7ac19d2f52ed3ba84e32e076268ae0dfde83ff0a75b2359924d3bac412, image=bigdata.registry.com:5000/insight/spark:2.3.2, imageID=docker-pullable://bigdata.registry.com:5000/insight/spark@sha256:0bfd1a27778f97a1ec620446b599d9f1fda882e8c3945a04ce8435356a40efe8, lastState=ContainerState(running=null, terminated=null, waiting=null, additionalProperties={}), name=spark-kubernetes-driver, ready=true, restartCount=0, state=ContainerState(running=ContainerStateRunning(startedAt=Time(time=2018-09-26T02:28:57Z, additionalProperties={}), additionalProperties={}), terminated=null, waiting=null, additionalProperties={}), additionalProperties={})]
    2018-09-26 10:29:05 INFO  LoggingPodStatusWatcherImpl:54 - State changed, new state:
    pod name: spark-pi-7b0ffe8a4023370a872acdd679f024b1-driver
    namespace: default
    labels: spark-app-selector -> spark-74d52904a3794e8986895a12322c5cd9, spark-role -> driver
    pod uid: d9bce33c-c133-11e8-b988-fa163e609d06
    creation time: 2018-09-26T02:28:27Z
    service account name: default
    volumes: spark-init-properties, download-jars-volume, download-files-volume, default-token-7mnhw
    node name: master2
    start time: 2018-09-26T02:28:27Z
    container images: bigdata.registry.com:5000/insight/spark:2.3.2
    phase: Failed
    status: [ContainerStatus(containerID=docker://3abe8f7ac19d2f52ed3ba84e32e076268ae0dfde83ff0a75b2359924d3bac412, image=bigdata.registry.com:5000/insight/spark:2.3.2, imageID=docker-pullable://bigdata.registry.com:5000/insight/spark@sha256:0bfd1a27778f97a1ec620446b599d9f1fda882e8c3945a04ce8435356a40efe8, lastState=ContainerState(running=null, terminated=null, waiting=null, additionalProperties={}), name=spark-kubernetes-driver, ready=false, restartCount=0, state=ContainerState(running=null, terminated=ContainerStateTerminated(containerID=docker://3abe8f7ac19d2f52ed3ba84e32e076268ae0dfde83ff0a75b2359924d3bac412, exitCode=1, finishedAt=Time(time=2018-09-26T02:29:04Z, additionalProperties={}), message=null, reason=Error, signal=null, startedAt=Time(time=2018-09-26T02:28:57Z, additionalProperties={}), additionalProperties={}), waiting=null, additionalProperties={}), additionalProperties={})]
    2018-09-26 10:29:05 INFO  LoggingPodStatusWatcherImpl:54 - Container final statuses:
    Container name: spark-kubernetes-driver
    Container image: bigdata.registry.com:5000/insight/spark:2.3.2
    Container state: Terminated
    Exit code: 1
    2018-09-26 10:29:05 INFO  Client:54 - Application spark-pi finished.
    2018-09-26 10:29:05 INFO  ShutdownHookManager:54 - Shutdown hook called
    2018-09-26 10:29:05 INFO  ShutdownHookManager:54 - Deleting directory /tmp/spark-53c85221-619e-41c6-8b94-80b950852b7e


  编码提交:

val args = Array(  //10.110.25.114 //10.221.129.20
"--master","k8s://http://10.221.129.20:8080",
"--deploy-mode", "cluster",
"--name","spark-pi",
"--class", "org.apache.spark.examples.SparkPi",
"--conf", "spark.kubernetes.container.image=bigdata.registry.com:5000/insight/spark:2.3.2",
"--conf","spark.kubernetes.container.image.pullPolicy=Always",
"--conf", "spark.kubernetes.namespace=spark",
"--conf","spark.executor.instances=1",
"--conf", "spark.kubernetes.authenticate.driver.serviceAccountName=spark",
"http://10.221.129.22/spark/spark-examples_2.11-2.3.2.jar",
"1000"
)
for (arg

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-639844-1-1.html 上篇帖子: Apache完全安装指南 下篇帖子: 隐藏apache版本号
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表