启动Hadoop
启动停止脚本在$HADOOPHOME/sbin目录下
- 执行启动脚本:start-all.sh
启动失败,从错误信息中可以看出缺少hdfs、yarn的变量定义[root@hadoop101 hadoop-3.2.1]# start-all.sh
Starting namenodes on [hadoop101]
ERROR: Attempting to operate on hdfs namenode as root
ERROR: but there is no HDFS_NAMENODE_USER defined. Aborting operation.
Starting datanodes
ERROR: Attempting to operate on hdfs datanode as root
ERROR: but there is no HDFS_DATANODE_USER defined. Aborting operation.
Starting secondary namenodes [hadoop101]
ERROR: Attempting to operate on hdfs secondarynamenode as root
ERROR: but there is no HDFS_SECONDARYNAMENODE_USER defined. Aborting operation.
Starting resourcemanager
ERROR: Attempting to operate on yarn resourcemanager as root
ERROR: but there is no YARN_RESOURCEMANAGER_USER defined. Aborting operation.
Starting nodemanagers
ERROR: Attempting to operate on yarn nodemanager as root
ERROR: but there is no YARN_NODEMANAGER_USER defined. Aborting operation.
修改start-dfs.sh、stop-dfs.sh
- 打开配置文件:$HADOOP_HOME/sbin/
- 都添加以下内容:
HDFS_DATANODE_USER=root HDFS_DATANODE_SECURE_USER=hdfs HDFS_NAMENODE_USER=root HDFS_SECONDARYNAMENODE_USER=root
修改start-yarn.sh、stop-yarn.sh
- 打开配置文件:$HADOOP_HOME/sbin/
- 都添加以下内容:
YARN_RESOURCEMANAGER_USER=root HADOOP_SECURE_DN_USER=yarn YARN_NODEMANAGER_USER=root
重新启动Hadoop
- 执行启动脚本:start-all.sh ```shell [root@hadoop101 sbin]# start-all.sh Starting namenodes on [hadoop101] 上一次登录:六 1月 11 23:54:37 CST 2020pts/1 上 Starting datanodes 上一次登录:六 1月 11 23:54:57 CST 2020pts/1 上 Starting secondary namenodes [hadoop101] 上一次登录:六 1月 11 23:55:00 CST 2020pts/1 上 Starting resourcemanager 上一次登录:六 1月 11 23:55:15 CST 2020pts/1 上 Starting nodemanagers 上一次登录:六 1月 11 23:55:23 CST 2020pts/1 上
2. 查看进程结果
```shell
[root@hadoop101 sbin]# jps
6818 NameNode
7363 ResourceManager
6935 DataNode
7517 NodeManager
7597 Jps
7134 SecondaryNameNode
启动成功后存在以下5个进程则表示启动成功:
- NameNode
- ResourceManager
- DataNode
- NodeManager
- SecondaryNameNode
网页验证测试
如果是通过本地Window系统访问Linux虚拟机,通过主机名访问也需要在Window系统上配置hosts
修改文件:C:\Windows\System32\drivers\etc\hosts 内容与CentOS中的hosts文件一致
- 浏览器输入网址:http://hadoop101:8088
- 浏览器输入网址:http://hadoop101:9870
停止Hadoop
执行脚本:stop-all.sh
[root@hadoop101 sbin]# stop-all.sh Stopping namenodes on [hadoop101] 上一次登录:六 1月 11 23:55:26 CST 2020pts/1 上 Stopping datanodes 上一次登录:日 1月 12 00:10:54 CST 2020pts/1 上 Stopping secondary namenodes [hadoop101] 上一次登录:日 1月 12 00:10:55 CST 2020pts/1 上 Stopping nodemanagers 上一次登录:日 1月 12 00:11:08 CST 2020pts/1 上 Stopping resourcemanager 上一次登录:日 1月 12 00:11:12 CST 2020pts/1 上
查看进程结果:
[root@hadoop101 sbin]# jps 8838 Jps
Hadoop相关的5个进程不存在