赞
踩
Spark是一个开源的大数据处理框架,它提供了一个快速、通用和易于使用的计算引擎。
Spark最初由美国加州伯克利大学AMP实验室于2009年开发,是基于内存计算的大数据并行计算框架,可用于构建大型的、低延迟的数据分析应用程序。具体来说,Spark的优势包括:
速度快:Spark能够快速进行数据读取、处理和写入操作,特别是针对机器学习等需要频繁访问数据集的任务,其速度远超传统的MapReduce框架。
易用性:支持多种编程语言(如Scala、Java、Python和R),用户可以选择自己熟悉的语言进行编程。
多场景适用:Spark不仅可以处理批处理任务,还支持实时流处理、交互式查询、机器学习和图处理等多种计算场景。
兼容性好:Spark可以很好地与Hadoop生态系统中的其他组件集成,如HDFS、Hive等,保护用户现有的投资。
可扩展性:可以轻松地在各种规模的集群上运行,从几台服务器到成千上万台。
容错性高:通过RDD的分布式存储和计算,即使部分节点失败,也能保证整体运算继续进行。
node1 | 192.168.24.10 | 255.255.255.0 |
node2 | 192.168.24.20 | 255.255.255.0 |
node3 | 192.168.24.30 | 255.255.255.0 |
systemctl stop firewalld.service //关闭防火墙
systemctl disable firewalld.service //开机自动关闭防火
vim /etc/hosts
把下面的内容添加到上面的文本中
192.168.24.10 node1
192.168.24.20 node2
192.168.24.30 node3
1.生成密钥对。
[root@node1 ~]# ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: SHA256:CeXoVNQnWmbOe7UNye40vXoggf1gj4T+8un1zKlGMIQ root@node1 The key's randomart image is: +---[RSA 2048]----+ | .+.. | | = E*.. | | + .B=o . . | | o ..+oO = | | . S o.Oo = | | ..o.== o| | ..o+...| | . .o.=o.| | ++.o+= | +----[SHA256]-----+
2.将生成的密钥对传至另外的服务器
[root@node1 ~]# ssh-copy-id node1
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host 'node1 (192.168.24.10)' can't be established.
ECDSA key fingerprint is SHA256:ufToEoIJNhqd8EfasQVqky7Hk5Gu+kWQVM//ix+a/cQ.
ECDSA key fingerprint is MD5:06:13:b0:6f:dc:dd:a1:b1:48:69:b3:c1:b2:b5:c2:f7.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@node1's password: //密码
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'node1'"
and check to make sure that only the key(s) you wanted were added.
[root@node1 ~]# ssh-copy-id node2
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host 'node2 (192.168.24.20)' can't be established.
ECDSA key fingerprint is SHA256:2qW6nePm+mRHnu/T5A48W/5MIFVDYeWrfDkdd6/eibY.
ECDSA key fingerprint is MD5:e3:08:61:31:ae:59:38:2b:23:b0:98:2a:5a:ca:17:31.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@node2's password: //密码
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'node2'"
and check to make sure that only the key(s) you wanted were added.
[root@node1 ~]# ssh-copy-id node3
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host 'node3 (192.168.24.30)' can't be established.
ECDSA key fingerprint is SHA256:KkFcVD96RB3Tqt32upX4sgUZbTyqPL9QB9l/wQpvTsk.
ECDSA key fingerprint is MD5:5c:67:a5:6f:73:9f:4d:a0:85:7f:ee:c3:f4:2f:a3:f5.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@node3's password: //密码
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'node3'"
and check to make sure that only the key(s) you wanted were added.
1.用Xftp上传压缩包。
tar -xvf jdk1.8.0_111.tar.gz -C /opt/
2.配置环境变量。
vim /etc/profile
把下面的内容添加到上面的文本中
export JAVA_HOME=/opt/jdk1.8.0_111
export PATH=$JAVA_HOME/bin:$PATH
在让环境变量生效
source /etc/profile
3.检查jdk是否安装成功。
[root@node1 ~]# jps 3860 Jps [root@node1 ~]# javac 用法: javac <options> <source files> 其中, 可能的选项包括: -g 生成所有调试信息 -g:none 不生成任何调试信息 -g:{lines,vars,source} 只生成某些调试信息 -nowarn 不生成任何警告 -verbose 输出有关编译器正在执行的操作的消息 -deprecation 输出使用已过时的 API 的源位置 -classpath <路径> 指定查找用户类文件和注释处理程序的位置 -cp <路径> 指定查找用户类文件和注释处理程序的位置 -sourcepath <路径> 指定查找输入源文件的位置 -bootclasspath <路径> 覆盖引导类文件的位置 -extdirs <目录> 覆盖所安装扩展的位置 -endorseddirs <目录> 覆盖签名的标准路径的位置 -proc:{none,only} 控制是否执行注释处理和/或编译。 -processor <class1>[,<class2>,<class3>...] 要运行的注释处理程序的名称; 绕过默认的搜索进程 -processorpath <路径> 指定查找注释处理程序的位置 -parameters 生成元数据以用于方法参数的反射 -d <目录> 指定放置生成的类文件的位置 -s <目录> 指定放置生成的源文件的位置 -h <目录> 指定放置生成的本机标头文件的位置 -implicit:{none,class} 指定是否为隐式引用文件生成类文件 -encoding <编码> 指定源文件使用的字符编码 -source <发行版> 提供与指定发行版的源兼容性 -target <发行版> 生成特定 VM 版本的类文件 -profile <配置文件> 请确保使用的 API 在指定的配置文件中可用 -version 版本信息 -help 输出标准选项的提要 -A关键字[=值] 传递给注释处理程序的选项 -X 输出非标准选项的提要 -J<标记> 直接将 <标记> 传递给运行时系统 -Werror 出现警告时终止编译 @<文件名> 从文件读取选项和文件名
4.把node1的文件传给其他的虚拟机。
5.把环境变量的文件传给其他的虚拟机。
[root@node1 conf]# scp -r /etc/profile node2:/etc/
profile 100% 1985 44.3KB/s 00:00
[root@node1 conf]# scp -r /etc/profile node3:/etc/
profile 100% 1985 33.8KB/s 00:00
[root@node1 conf]#
使node1,node2的环境变量生效。
[root@node2 ~]# source /etc/profile
[root@node3 ~]# source /etc/profile
[root@node1 ~]# scp -r /opt/jdk1.8.0_111/ node2:/opt/
[root@node1 ~]# scp -r /opt/jdk1.8.0_111/ node2:/opt/
tar -xvf spark-3.5.1-bin-hadoop3.tgz -C /opt/
vim /etc/profile
把下面的内容添加到上面的文本中
export SPARK_HOME=/opt/spark-3.5.1-bin-hadoop3
export PATH=$SPARK_HOME/bin:$SPARK_HOME/sbin:$PATH
在让环境变量生效
source /etc/profile
切到这个文件的conf目录下
cd /opt/spark-3.5.1-bin-hadoop3/conf/
mv spark-env.sh.template spark-env.sh
mv workers.template workers
vim spark-env.sh
把下面的内容添加到上面的文本中。
export JAVA_HOME=/opt/jdk1.8.0_111
SPARK_MASTER_HOST=node1
SPARK_MASTER_PORT=7077
vim workers
在里面添加下面的内容,并且删除掉localhost。
node1
node2
node3
[root@node1 conf]# scp -r /etc/profile node2:/etc/
profile 100% 1985 44.3KB/s 00:00
[root@node1 conf]# scp -r /etc/profile node3:/etc/
profile 100% 1985 33.8KB/s 00:00
[root@node1 conf]#
使node1,node2的环境变量生效。
[root@node2 ~]# source /etc/profile
[root@node3 ~]# source /etc/profile
[root@node1 conf]# scp -r /opt/spark-3.5.1-bin-hadoop3/ node2:/opt/
[root@node1 ~]# scp -r /opt/spark-3.5.1-bin-hadoop3/ node3:/opt/
切到spark这个压缩包目录下。
cd /opt/spark-3.5.1-bin-hadoop3/
1.启动集群。
2.查看集群是否启动成功。
以上就是今天要讲的内容,本文仅仅简单介绍了spark的搭建。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。