vi /etc/hosts

添加节点dns信息

192.168.209.157 node1

192.168.209.158 node2

192.168.209.159 node3

vi /etc/profile

添加运行目录

export HADOOP_HOME=/home/hadoop/hadoop-3.1.0

exportPATH=$PATH:$HADOOP_HOME/bin

复制到各节点过去

scp /etc/profile node2:/etc/profile

scp /etc/profile node3:/etc/profile

在各节点执行

source /etc/profile

刷新配置

fecc27bd57344cf9ab99ccd6fa2cc932

274c8bcfdfbf4d138c617d3afd44a404

然后把key复制到不同节点

ssh-copy-id node1

ssh-copy-id node2

ssh-copy-id node3

mkdir tmp创建临时目录

7f33523f67564eb0a38cda7bbddc0c1b

创建data和name 在/home/hadoop/hadoop-3.1.0

e32a7977e37e4d98b833d70c049eb4a4

vi /home/hadoop/hadoop-3.1.0/etc/hadoop/core-site.xml

<configuration>

<!-- 指定HDFS老大(namenode)的通信地址 -->

<property>

<name>fs.defaultFS</name>

<value>hdfs://node1:50070</value>

</property>

<!-- 指定hadoop运行时产生文件的存储路径 -->

<property>

<name>hadoop.tmp.dir</name>

<value>/home/hadoop/hadoop-3.1.0/tmp</value>

</property>

</configuration>

vi /home/hadoop/hadoop-3.1.0/etc/hadoop/hdfs-site.xml

<configuration> <!-- 设置namenode的http通讯地址 --> <property> <name>dfs.namenode.http-address</name> <value>node1:50070</value> </property> <!-- 设置secondarynamenode的http通讯地址 --> <property> <name>dfs.namenode.secondary.http-address</name> <value>node2:50090</value> </property> <!-- 设置namenode存放的路径 --> <property> <name>dfs.namenode.name.dir</name> <value>/home/hadoop/hadoop-3.1.0/name</value> </property> <!-- 设置hdfs副本数量 --> <property> <name>dfs.replication</name> <value>2</value> </property> <!-- 设置datanode存放的路径 --> <property> <name>dfs.datanode.data.dir</name> <value>/home/hadoop/hadoop-3.1.0/data</value> </property> </configuration>

vi /home/hadoop/hadoop-3.1.0/etc/hadoop/mapred-site.xml

<configuration>

<property> <name>mapreduce.framework.name</name> <value>yarn</value> </property>

</configuration>

vi /home/hadoop/hadoop-3.1.0/etc/hadoop/yarn-site.xml

<configuration> <!-- 设置 resourcemanager 在哪个节点--> <property> <name>yarn.resourcemanager.hostname</name> <value>master</value> </property> <!-- reducer取数据的方式是mapreduce_shuffle --> <property> <name>yarn.nodemanager.aux-services</name> <value>mapreduce_shuffle</value> </property> <property> <name>yarn.nodemanager.aux-services.mapreduce.shuffle.class</name> <value>org.apache.hadoop.mapred.ShuffleHandler</value> </property> </configuration>

开始启动了

./bin/hdfs namenode -format

d2d79bfb9e3e4188be01adbfc8319372

没找到java,容我修个错误

找一下包的位置

rpm -qal | grep jdk

c597dbdf45ec43129044817c05b6e259

vi /etc/profile

加入java 环境配置信息

export JAVA_HOME=/usr/java/jdk1.8.0_162 export PATH=$JAVA_HOME/bin:$PATH

export HADOOP_HOME=/home/hadoop/hadoop-3.1.0

exportPATH=$PATH:$HADOOP_HOME/bin

41d1ec02e0e84eff92b2c9efdd7d70f9

刷新下配置source /etc/profile

再次格式化下

./bin/hdfs namenode -format

83d43228493643ccb38463c78cc6551e

dcde415a10ce4e45810b11267b14af25

启动失败鸟

5223664b81d6416f9e9e6dfd25decfb1

容我修个错误

SHUTDOWN_MSG: Shutting down NameNode at java.net.UnknownHostException: hadoop-1: hadoop-1: Name or service not known

本机名字是hadoop-1,和配置中的node1有差,所以nmtui改hostname先

再次格式化

c6082f3a442d4d438ca1d46525f72e39

启动dfs

./sbin/start-dfs.sh

出错鸟

Starting namenodes on [node1]node1: ERROR: JAVA_HOME is not set and could not be found.

我明明已经设了javahome了,再次看下日志,有黑字

vi ./etc/hadoop/hadoop-env.sh

export JAVA_HOME=/usr/java/jdk1.8.0_162

f249515ee0b646b08b9d1f1cf9c19e9c

再次启动dfs

8ed671630a7c44e5b81bc8eeba6e358e

aadab5cd45e94e5d8cfc4c3da19d2b7f

e5a4479165ce46febf6b7ea174f3923c

3台都没有报错

启动yarm

./sbin/start-yarn.sh

9be6ef55d229438cb172e6b6f67f1454

60f701f9f2594c139f95ada47651da2c

node1 启动的组件

48b66979248e4694a2a81e03ddcbb85b

node2 组件

21f3b7283f04401d8b39db9de1b16336

node3 组件

90af00e45fd04b5497029a86e8859732

sbin目录中有全部启动命令

.sbin/start-all.sh

.sbin/stop-all.sh