赞
踩
1.
2.将Spark的包下载下来,并将它解压到虚拟机上,放在/usr/local/路径下
解压命令:
tar -xzvf Spark-2.4.8-bin-hadoop2.7.tgz -C /usr/local
3.修改Spark配置文件
(1) 从当前路径切换到Spark配置文件路径:
cd /usr/local/spark-2.4.8-bin-hadoop2.7/conf
(2) 拷贝 spark-env.sh.template:
cp spark-env.sh.template spark-env.sh
得到一个 spark-env.sh文件;
(3) 修改spark-env.sh,在该文件第二行空白地方添加:
source /etc/profile
;
(4) 拷贝slaves.template:
cp slaves.template slaves
得到一个slaves文件;
(5) 将slaves内容改为虚拟机的主机名。
4.启动Spark
切换路径: cd /usr/local/spark-2.4.8-bin-hadoop2.7/sbin
启动命令: ./start-all.sh
5.
验证Spark是否部署成功,至此完成了平台搭建(Hadoop+Spark)
切换路径:cd /usr/local/spark-2.4.8-bin-hadoop2.7/bin
验证:./run-example SparkPi
1.新建一个类
public class Shop { // 电商商品数据 // 产品名 private String Username; // 浏览量(PV) private String pv; // 访客数(UV) private String uv; // 登录时间 private String time; // 交易金额 private Integer cash; public Shop(String username, String pv, String uv, String time, Integer cash) { Username = username; this.pv = pv; this.uv = uv; this.time = time; this.cash = cash; } public String getUsername() { return Username; } public void setUsername(String username) { Username = username; } public String getPv() { return pv; } public void setPv(String pv) { this.pv = pv; } public String getUv() { return uv; } public void setUv(String uv) { this.uv = uv; } public String getTime() { return time; } public void setTime(String time) { this.time = time; } public Integer getCash() { return cash; } public void setCash(Integer cash) { this.cash = cash; } }
2.创建一个方法
import java.io.Serializable; import java.util.List; public class ShopCanData implements Serializable { // 产品名 private String Username; // 浏览量(PV) private String pv; // 访客数(UV) private String uv; // 登录时间 private String time; // 交易金额 private Integer cash; //退货码 private List<Integer> returnList; public String getUsername() { return Username; } public void setUsername(String username) { Username = username; } public String getPv() { return pv; } public void setPv(String pv) { this.pv = pv; } public String getUv() { return uv; } public void setUv(String uv) { this.uv = uv; } public String getTime() { return time; } public void setTime(String time) { this.time = time; } public Integer getCash() { return cash; } public void setCash(Integer cash) { this.cash = cash;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。