单机运行 spark-shell错误

本文记录了在安装Spark过程中遇到的问题及解决方案,特别是针对spark-shell启动时出现的警告和错误信息。通过检查和修改/etc/hosts文件中的主机名绑定地址,最终成功解决了Spark无法绑定随机空闲端口的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

安装spark,spark-shell遇到错误

Using Spark’s default log4j profile: org/apache/spark/log4j-defaults.properties
Setting default log level to “WARN”.
To adjust logging level use sc.setLogLevel(newLevel). For SparkR, use setLogLevel(newLevel).
17/12/18 08:40:12 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform… using builtin-java classes where applicable
17/12/18 08:40:13 WARN Utils: Service ‘sparkDriver’ could not bind on a random free port. You may check whether configuring an appropriate binding address.
17/12/18 08:40:13 WARN Utils: Service ‘sparkDriver’ could not bind on a random free port. You may check whether configuring an appropriate binding address.
17/12/18 08:40:13 WARN Utils: Service ‘sparkDriver’ could not bind on a random free port. You may check whether configuring an appropriate binding address.
17/12/18 08:40:13 WARN Utils: Service ‘sparkDriver’ could not bind on a random free port. You may check whether configuring an appropriate binding address.
17/12/18 08:40:13 WARN Utils: Service ‘sparkDriver’ could not bind on a random free port. You may check whether configuring an appropriate binding address.
17/12/18 08:40:13 WARN Utils: Service ‘sparkDriver’ could not bind on a random free port. You may check whether configuring an appropriate binding address.
17/12/18 08:40:13 WARN Utils: Service ‘sparkDriver’ could not bind on a random free port. You may check whether configuring an appropriate binding address.
17/12/18 08:40:13 WARN Utils: Service ‘sparkDriver’ could not bind on a random free port. You may check whether configuring an appropriate binding address.
17/12/18 08:40:13 WARN Utils: Service ‘sparkDriver’ could not bind on a random free port. You may check whether configuring an appropriate binding address.
17/12/18 08:40:13 WARN Utils: Service ‘sparkDriver’ could not bind on a random free port. You may check whether configuring an appropriate binding address.
17/12/18 08:40:13 WARN Utils: Service ‘sparkDriver’ could not bind on a random free port. You may check whether configuring an appropriate binding address.
17/12/18 08:40:13 WARN Utils: Service ‘sparkDriver’ could not bind on a random free port. You may check whether configuring an appropriate binding address.
17/12/18 08:40:13 WARN Utils: Service ‘sparkDriver’ could not bind on a random free port. You may check whether configuring an appropriate binding address.
17/12/18 08:40:13 WARN Utils: Service ‘sparkDriver’ could not bind on a random free port. You may check whether configuring an appropriate binding address.
17/12/18 08:40:13 WARN Utils: Service ‘sparkDriver’ could not bind on a random free port. You may check whether configuring an appropriate binding address.
17/12/18 08:40:13 WARN Utils: Service ‘sparkDriver’ could not bind on a random free port. You may check whether configuring an appropriate binding address.
17/12/18 08:40:13 ERROR SparkContext: Error initializing SparkContext.
java.net.BindException: Cannot assign requested address: Service ‘sparkDriver’ failed after 16 retries (on a random free port)! Consider explicitly setting the appropriate binding address for the service ‘sparkDriver’ (for example spark.driver.bindAddress for SparkDriver) to the correct binding address.
.
.
.
Welcome to
__
/ / _ _/ /__
\ \/ \/ _ `/ _/ ‘/
// ./_,// //_\ version 2.2.1
/_/
Using Scala version 2.11.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_151)
Type in expressions to have them evaluated.
Type :help for more information
scala>

原因:
host文件绑定地址错误
解决:
修改 /etc/hosts文件
添加或配置正确地址
原hosts文件

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

查看本机hostname及地址
修改hosts文件

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
10.64.42.108 ls-dj-test-3

重新运行 spark-shell 成功

本教程为官方授权出品如今大数据已经成了各大互联网公司工作的重点方向,而推荐系统可以说就是大数据最好的落地应用之一,已经为企业带来了可观的用户流量和销售额。特别是对于电商,好的推荐系统可以大大提升电商企业的销售业绩。国内外的知名电商,如亚马逊、淘宝、京东等公司,都在推荐系统领域投入了大量研发力量,也在大量招收相关的专业人才。量身定制打造的电商推荐系统项目,就是以经过修改的中文亚马逊电商数据集作为依托,并以某电商网站真实的业务架构作为基础来实现的,其中包含了离线推荐与实时推荐体系,综合利用了协同过滤算法以及基于内容的推荐方法来提供混合推荐。具体实现的模块主要有:基于统计的离线推荐、基于隐语义模型的离线推荐、基于自定义模型的实时推荐,以及基于内容的、和基于Item-CF的离线相似推荐。整个项目具有很强的实操性和综合性,对已有的大数据和机器学习相关知识是一个系统性的梳理和整合,通过学习,同学们可以深入了解推荐系统在电商企业中的实际应用,可以为有志于增加大数据项目经验的开发人员、特别是对电商业务领域感兴趣的求职人员,提供更好的学习平台。适合人群:1.有一定的 Java、Scala 基础,希望了解大数据应用方向的编程人员2.有 Java、Scala 开发经验,了解大数据相关知识,希望增加项目经验的开发人员3.有电商领域开发经验,希望拓展电商业务场景、丰富经验的开发人员4.有较好的数学基础,希望学br习机器学习和推荐系统相关算法的求职人员
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值