安装伪分布式hadoop
安装 JAVA 环境
步骤一:下载 JDK 安装包(jdk-8u152-linuxx64.tar.gz)
[root@master ~]# rpm -qa | grep java
卸载相关服务,键入命令 rpm –e –-nodeps 删除的包
[root@master ~]# rpm -qa | grep java
[root@master ~]# java --version
bash: java: 未找到命令
步骤三:安装 JDK
安装命令如下,将安装包解压到/usr/local/src 目录下,将安装包放在了root目录下
[root@master ~]# tar -zxvf jdk-8u152-linux-x64.tar.gz -C /usr/local/src/
[root@master ~]# ls /usr/local/src/
jdk1.8.0_152
步骤四:设置 JAVA 环境变量
[root@master ~]# vi /etc/profile
在文件的最后增加如下两行:
export JAVA_HOME=/usr/local/src/jdk1.8.0_152
export PATH=$PATH:$JAVA_HOME/bin
执行 source 使设置生效:
[root@master ~]# source /etc/profile
检查 JAVA 是否可用。
[root@master ~]# echo $JAVA_HOME /usr/local/src/jdk1.8.0_152
[root@master ~]# java -version
java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)
能够正常显示 Java 版本则说明 JDK 安装并配置成功。
实现免密登陆
步骤一:创建ssh秘钥,输入如下命令,生成公私密钥
[root@master ~]# ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
步骤二:将master公钥id_dsa复制到master进行公钥认证,实现本机免密登陆,测试完exit退出
[root@master ~]# ssh-copy-id -i /root/.ssh/id_dsa.pub master
[root@master ~]# ssh master
[root@master ~]# exit
Hadoop环境的安装与配置
步骤一:将/root/runajian下的hadoop-2.7.7.tar.gz压缩包解压到/opt目录下,并将解压文件改名为hadoop
步骤二:修改环境变量
[root@master ~]# vim /etc/profile
export HADOOP_HOME=/opt/hadoop
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
[root@master ~]# source /etc/profile
步骤三:编辑/opt/hadoop/etc/hadoop/hadoop-env.sh文件
[root@master ~]# vi /opt/hadoop/etc/hadoop/hadoop-env.sh
修改配置文件为jdk的安装路径:
export JAVA_HOME=/usr/local/src/jdk1.8.0_152
步骤四:编辑/opt/hadoop/etc/hadoop/core-site.xml文件
[root@master ~]# vi /opt/hadoop/etc/hadoop/core-site.xml
修改配置文件为:
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://master</value>
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>/opt/hadoop/tmp</value>
</property>
</configuration>
步骤五:编辑/opt/hadoop/etc/hadoop/hdfs-site.xml文件
[root@master ~]# vi /opt/hadoop/etc/hadoop/hdfs-site.xml
修改配置文件:
<configuration>
<property>
<name>dfs.replication</name>
<value>3</value>
</property>
</configuration>
步骤六:
复制/opt/hadoop/etc/hadoop/mapred-site.xml.tmplate 名为mapred-site.xml
[root@master ~]# cp /opt/hadoop/etc/hadoop/mapred-site.xml.template /opt/hadoop/etc/hadoop/mapred-site.xml
编辑/opt/hadoop/etc/hadoop/mapred-site.xml文件
[root@master ~]# vi /opt/hadoop/etc/hadoop/mapred-site.xml
修改配置为:
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>
步骤七:编辑/opt/hadoop/etc/hadoop/yarn-site.xml文件
[root@master ~]# vi /opt/hadoop/etc/hadoop/yarn-site.xml
修改配置为:
<configuration>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
</configuration>
步骤八:编辑/opt/hadoop/etc/hadoop/slaves文件
[root@master ~]# vim /opt/hadoop/etc/hadoop/slaves
步骤九: 格式化hdfs
[root@master ~]# hdfs namenode -format
步骤十:启动集群 jps查看,登录网页
[root@master ~]# start-all.sh
[root@master ~]# jps
在浏览器的地址栏输入http://master:50070,进入页面可以查看NameNode和DataNode 信息
安装伪分布式spark
步骤一:安装命令如下,将安装包解压到/usr/local目录下,将安装包放在了root目录下
[root@master ~]# tar -zxf spark-3.2.1-bin-hadoop2.7.tgz -C /usr/local/
步骤二:复制和重命名后得到spark-env.sh,打开spark-env.sh添加内容
root@master ~]# cd /usr/local/spark-3.2.1-bin-hadoop2.7/conf/
[root@master conf]# ls
fairscheduler.xml.template metrics.properties.template spark-env.sh.template
log4j.properties.template spark-defaults.conf.template workers.template
[root@master conf]# cp spark-env.sh.template spark-env.sh
[root@master conf]# vi spark-env.sh
export JAVA_HOME=/usr/local/src/jdk1.8.0_152
export HADOOP_HOME=/opt/hadoop
export HADOOP_CONF_DIR=/opt/hadoop/etc/hadoop
export SPARK_MASTER_IP=master
export SPART_LOCAL_IP=master
[root@master src]# ls
jdk1.8.0_152
[root@master src]# cd /usr/local/spark-3.2.1-bin-hadoop2.7/conf/
[root@master conf]# vi spark-env.sh
[root@master conf]# cd /usr/local/spark-2.0.0-bin-hadoop2.6/sbin/
-bash: cd: /usr/local/spark-2.0.0-bin-hadoop2.6/sbin/: No such file or directory
[root@master conf]# cd /usr/local/spark-3.2.1-bin-hadoop2.7/sbin/
[root@master sbin]# ./start-all.sh
starting org.apache.spark.deploy.master.Master, logging to /usr/local/spark-3.2.1-bin-hadoop2.7/logs/spark-root-org.apache.spark.deploy.master.Master-1-master.out
localhost: Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
localhost: starting org.apache.spark.deploy.worker.Worker, logging to /usr/local/spark-3.2.1-bin-hadoop2.7/logs/spark-root-org.apache.spark.deploy.worker.Worker-1-master.out
[root@master sbin]# jps
4784 NodeManager
4436 SecondaryNameNode
4581 ResourceManager
5367 Jps
5242 Master
4219 NameNode
4316 DataNode
5309 Worker
步骤四:启动spark-ahell
步骤五:查看网页http://master:8080
安装伪分布式scala
步骤一:安装命令如下,将安装包解压到/usr/local目录下,将安装包放在了root目录下
[root@master ~]# tar -zxf scala-2.11.8.tgz -C /usr/local
步骤二:配置scala环境变量,重新加载配置文件,运行scala
[root@master ~]# vim /etc/profile
export SCALA_HOME=/usr/local/scala-2.11.8
export PATH=$PATH:$SCALA_HOME/bin
[root@master ~]# source /etc/profile
[root@master ~]# scala