共计 2991 个字符,预计需要花费 8 分钟才能阅读完成。
更新工夫:2020-07-29。如果 hadoop 下载链接生效,则须要自行去 hadoop 官网找下链接
hadoop3.2.1 装置
1. 下载
https://mirrors.tuna.tsinghua.edu.cn/apache/hadoop/common/hadoop-3.2.1/hadoop-3.2.1.tar.gz
2. 解压
tar -zxvf hadoop-3.2.1.tar.gz
3. 重命名
mv hadoop-3.2.1 hadoop
4. 增加 JAVA_HOME 至环境变量
4.1 首先找到 JAVA_HOME,执行上面命令,其中有一项是 java_home
java -XshowSettings:properties -version
4.2 增加至环境变量
vim /etc/bashrc
# 而后在 profile 的最上面加一句:export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-3.el8_2.x86_64/jre
# 保留退出 vim,执行以下命令使环境变量立刻失效
source /etc/bashrc
5.hadoop 增加至环境变量
# vim /etc/bashrc 文件,退出如下两行
export HADOOP_HOME=/usr/share/hadoop
export PATH=$PATH:$HADOOP_HOME/bin
6. 测试 hadoop。如果显示版本号,则证实胜利运行。
hadoop version
#Hadoop 3.2.1
#Source code repository https://gitbox.apache.org/repos/asf/hadoop.git -r b3cbbb467e22ea829b3808f4b7b01d07e0bf3842
#Compiled by rohithsharmaks on 2019-09-10T15:56Z
#Compiled with protoc 2.5.0
#From source with checksum 776eaf9eee9c0ffc370bcbc1888737
#This command was run using /usr/share/hadoop/share/hadoop/common/hadoop-common-3.2.1.jar
hdfs 配置(伪分布式)
1. 创立 hadoop 用户(专门为 hadoop 筹备的用户),以下操作在 root 用户下执行
# 创立 hadoop 用户
useradd -m hadoop -s /bin/bash
#批改明码
passwd hadoop
#切换至 hadoop 用户
su hadoop
#设置 ssh 免密登录(ssh 免密登录本身,如果不设置,启动 DFS 会报错)ssh-keygen -t rsa
#将本人生成的公钥退出本人的受权,这样本人就能够免密登录本人
cd ~/.ssh
cat id_rsa.pub >> authorized_keys
chmod 600 authorized_keys # 避免其余用户看到
2. 配置 core-site.xml
vim /usr/share/hadoop/etc/hadoop/core-site.xml
#退出如下配置(其中应用 hadoop 代替了 ip 地址,后续须要在 hosts 文件内退出对应的 ip)#(存文件的门路最好写到 hadoop 用户的家目录下,防止权限问题)<configuration>
<property>
<name>hadoop.tmp.dir</name>
<value>file:/home/hadoop/tmp</value>
<description>Abase for other temporary directories.</description>
</property>
<property>
<name>fs.defaultFS</name>
<value>hdfs://hadoop:9000</value>
</property>
</configuration>
3. 配置 hdfs-site.xml
vim /usr/share/hadoop/etc/hadoop/hdfs-site.xml
#退出如下配置
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.namenode.name.dir</name>
<value>file:/home/hadoop/tmp/dfs/name</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>file:/home/hadoop/tmp/dfs/data</value>
</property>
</configuration>
4. 配置 yarn-site,xml
vim /usr/share/hadoop/etc/hadoop/yarn-site.xml
#退出如下配置
<configuration>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<property>
<name>yarn.resourcemanager.hostname</name>
<value>hadoop</value>
</property>
</configuration>
5. 配置 mapred-site.xml
vim /usr/share/hadoop/etc/hadoop/mapred-site.xml
#退出如下配置
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>
6. 批改 hosts 文件
su root
vim /etc/hosts
#最上面退出
0.0.0.0 hadoop
7. 格式化 HDFS 零碎
su hadoop
/usr/share/hadoop/bin/hdfs namenode -format
8. 启动 hadoop-DFS
/usr/share/hadoop/sbin/start-dfs.sh
#hadoop: namenode is running as process 25242. Stop it first.
#Starting datanodes
#localhost: datanode is running as process 25402. Stop it first.
#Starting secondary namenodes [hadoop]
#hadoop: secondarynamenode is running as process 25607. Stop it first.
/usr/share/hadoop/sbin/start-yarn.sh
#Starting resourcemanager
#Starting nodemanagers
9. 浏览器拜访 web 页面(Centos 留神敞开防火墙)
http://<hadoop ip>:9870 #dfs
http://<hadoop ip>:8088 #yarn
正文完