惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Attack and Defense Labs
Attack and Defense Labs
T
Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
H
Hackread – Cybersecurity News, Data Breaches, AI and More
I
Intezer
C
Cyber Attacks, Cyber Crime and Cyber Security
The Register - Security
The Register - Security
量子位
Security Latest
Security Latest
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
大猫的无限游戏
大猫的无限游戏
小众软件
小众软件
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
C
CXSECURITY Database RSS Feed - CXSecurity.com
MyScale Blog
MyScale Blog
J
Java Code Geeks
Apple Machine Learning Research
Apple Machine Learning Research
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
Spread Privacy
Spread Privacy
Jina AI
Jina AI
博客园 - 【当耐特】
P
Palo Alto Networks Blog
Last Week in AI
Last Week in AI
SecWiki News
SecWiki News
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
G
GRAHAM CLULEY
宝玉的分享
宝玉的分享
Hacker News - Newest:
Hacker News - Newest: "LLM"
T
The Blog of Author Tim Ferriss
V
Vulnerabilities – Threatpost
有赞技术团队
有赞技术团队
T
Tor Project blog
H
Hacker News: Front Page
A
Arctic Wolf
NISL@THU
NISL@THU
A
About on SuperTechFans
云风的 BLOG
云风的 BLOG
Engineering at Meta
Engineering at Meta
V
V2EX
N
News and Events Feed by Topic
Webroot Blog
Webroot Blog
Know Your Adversary
Know Your Adversary
P
Privacy International News Feed
I
InfoQ
D
Docker
L
LINUX DO - 最新话题
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
U
Unit 42

博客园 - 学海无涯

在CentOS上安装和部署Shiny Server Hibernate实体生成JSON的问题及解决 CentOS 6主机上的RStudio Server安装步骤 Oracle用户密码过期后重置SYS用户密码 在CentOS中将/var等已有目录挂载到新添加的硬盘 CentOS中的常用命令 Java在Web项目中读取properties文件 Druid连接池初探 安装和配置CentOS时钟同步服务 在CentOS中安装中文支持 在CentOS 6.x中支持exfat格式的U盘(移动硬盘) CentOS常见问题 CentOS MySQL 配置 显示远程网站上的图片 【转载】我们什么时候结婚 纪念新生命诞生 真爱的四个阶段 【转贴词解】富士山下 与寂寞有染,与爱情无关
在CentOS上安装并运行SparkR
学海无涯 · 2015-04-10 · via 博客园 - 学海无涯

环境配置——

  • 操作系统:CentOS 6.5
  • JDK版本:1.7.0_67
  • Hadoop集群版本:CDH 5.3.0

安装过程——

1、安装R

2、安装curl-devel(非常重要!否则无法进行RCurl包的安装,进而无法安装devtools

yum install -y curl-devel

3、设置必要的环境变量(非常重要!这里必须设置成Hadoop环境对应的版本和Yarn对应的版本,否则用Spark与Hadoop HDFS数据通信会报Hadoop 连接器版本不匹配

vi + /etc/profile

...
export USE_YARN=1
export SPARK_VERSION=1.1.0
export SPARK_YARN_VERSION=2.5.0-cdh5.3.0
export SPARK_HADOOP_VERSION=2.5.0-cdh5.3.0

4、进入R命令行,安装R包(最后一步安装SparkR时,需要安装很多依赖包,过程很漫长,可能需要重试多次才能成功)

install.packages("RCurl")
install.packages("devtools")
library(devtools)
install_github("amplab-extras/SparkR-pkg", subdir="pkg")

5、大功告成,安装完毕!现在用SparkR读取HDFS中的文件:

library(SparkR)
sc <- sparkR.init(master = "local", "RwordCount")
lines <- textFile(sc, "hdfs://quickstart.cloudera:8020/test/test.txt")
words <- flatMap(lines, function(line) {
    strsplit(line, " ")[[1]]
})
wordCount <- lapply(words, function(word) {
    list(word, 1L)
})
counts <- reduceByKey(wordCount, "+", 2L)
output <- collect(counts)
for (count in output) {
    cat(count[[1]], ": ", count[[2]], "\n")
}

参考资料: