搭建Hadoop
1、配置网络
在终端中输入
1
$ nmtui
更改网络设置。配置好网络后使用
1
$ service network restart
与宿主机互ping,如果互ping成功,就算完成
2、关闭防火墙
1 | $ systemctl status firewalld |
3、安装配置JDK
创建文件夹(为了方便所有文件均改名)
1 | $ mkdir /opt/programs |
4、安装Java
1 | $ rpm -qa |grep openjdk |
出现如下信息
java-1.7.0-openjdk-headless-1.7.0.261-2.6.22.2.el7_8.x86_64
java-1.8.0-openjdk-headless-1.8.0.262.b10-1.el7.x86_64
java-1.8.0-openjdk-1.8.0.262.b10-1.el7.x86_64
java-1.7.0-openjdk-1.7.0.261-2.6.22.2.el7_8.x86_64
输入以下命令
1 | $ rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.261-2.6.22.2.el7_8.x86_64 |
再次查询
# rpm -qa |grep openjdk
新建文件夹
# mkdir /opt/programs
# tar -zxvf jdk-8u211-linux-x64.tar.gz -C /opt/programs/
切换到/opt/programs/
# cd /opt/programs/
重命名为jdk
# mv jdk1.8.0_211 jdk
修改profile文件
# vim /etc/profile
添加以下语句
export JAVA_HOME=/opt/programs/jdk
export PATH=$PATH:$JAVA_HOME/bin
# source /etc/profile
6、修改host文件
# vim /etc/hosts
192.168.165.11 hadoop0
SSH登录
# ssh-keygen
然后无脑回车
复制
# ssh-copy-id hadoop0
然后输入yes,并输入密码
7、配置Hadoop
下载链接:https://archive.apache.org/dist/hadoop/core/hadoop-2.7.6/hadoop-2.7.6.tar.gz
解压Hadoop
# tar -zxvf hadoop-2.7.6.tar.gz -C /opt/programs/
重命名为hadoop
# mv hadoop-2.7.6 hadoop
修改配置文件
# cd /opt/programs/hadoop/etc/hadoop
地址:https://github.com/9ju92002/hadoop/raw/main/hadoop%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6.zip
修改profile文件
# vim /etc/profile
export HADOOP_HOME=/opt/programs/hadoop
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
# source /etc/profile
# hdfs namenode -format
出现以下信息,说明格式化成功
INFO common.Storage: Storage directory /opt/programs/hadoop/tmp/dfs/name has been successfully formatted.
依次执行命令
start-dfs.sh
start-yarn.sh