• Spark Shell及Spark2.2和Spark1.6的对比


    2019-12-12  09:37:43

    Spark Shell

    Spark-shell是Spark自带的交互式Shell程序,方便用户进行交互式编程,可以在命令下编写Scala程序执行Spark

    Spark-shell多用于测试 Spark-Shell启动有两种模式 local模式和Cluster模式

    Local模式:

    ps: 必须进入到Spark安装目录中bin目录下
    spark-shell 
    启动的就是本地模式,local模式仅在本机启动一个SparkSubmit进程,没有集群建立联系,虽然进程中有SparkSubmit但是不会被提交到集群
    

    Cluster模式:

    必须进入到Spark安装目录中bin目录下
    spark-shell 
    --master spark://hadoop01:7077 
    --executor-memory  512M 
    --total-executor-cores 1
    ps: --master必须有的一条命令  后面的两条是可以没有的
    

      

    退出Shell:

    1.使用 :quit  退出shell
    2.使用 ctrl+c 退出shell  
    ps:使用ctrl+c 退出shell 可能会出现 后台占用端口的情况
       查看监听端口  netstat -apn | grep 4040  只要有这个端口占用的进程就杀死
    

     

     Spark2.2shell和Spark1.6shell的对比

    1)Spark2.2

     2)Spark1.6

     说明:Spark2.X版本shell中有两个内置对象

    SparkContext  ——> 变量名:sc

    SparkSession  ——>变量名:spark

    SparkSession不能单独拿出来解释,2.x之后spark将SQLContext和HiveContext进行整合提供一种全新的创建方式SparkSession

    Spark1.6版本shell中有两个内置对象

    SparkContext  ——>变量名:sc

    SQLContext  ——>变量名:sqlcontext

     

     

     

  • 相关阅读:
    yii2 页面渲染方法解析
    JavaScript 编码小技巧
    Ansible Playbooks入门介绍
    CentOS 7 源码安装Ansible 2.x
    GitLab 安装与入门
    SpringBoot 悲观锁 与 乐观锁
    SpringBoot 事务隔离性和传播性
    SpringBoot 定义通过字段验证
    SpringBoot 密码MD5加密
    SpringBoot MockMVC
  • 原文地址:https://www.cnblogs.com/yumengfei/p/12027506.html
Copyright © 2020-2023  润新知