启动Hadoop

启动停止脚本在$HADOOPHOME/sbin目录下

  1. 执行启动脚本:start-all.sh
    1. [root@hadoop101 hadoop-3.2.1]# start-all.sh
    2. Starting namenodes on [hadoop101]
    3. ERROR: Attempting to operate on hdfs namenode as root
    4. ERROR: but there is no HDFS_NAMENODE_USER defined. Aborting operation.
    5. Starting datanodes
    6. ERROR: Attempting to operate on hdfs datanode as root
    7. ERROR: but there is no HDFS_DATANODE_USER defined. Aborting operation.
    8. Starting secondary namenodes [hadoop101]
    9. ERROR: Attempting to operate on hdfs secondarynamenode as root
    10. ERROR: but there is no HDFS_SECONDARYNAMENODE_USER defined. Aborting operation.
    11. Starting resourcemanager
    12. ERROR: Attempting to operate on yarn resourcemanager as root
    13. ERROR: but there is no YARN_RESOURCEMANAGER_USER defined. Aborting operation.
    14. Starting nodemanagers
    15. ERROR: Attempting to operate on yarn nodemanager as root
    16. ERROR: but there is no YARN_NODEMANAGER_USER defined. Aborting operation.
    启动失败,从错误信息中可以看出缺少hdfs、yarn的变量定义

修改start-dfs.sh、stop-dfs.sh

  1. 打开配置文件:$HADOOP_HOME/sbin/
  2. 都添加以下内容:
    HDFS_DATANODE_USER=root 
    HDFS_DATANODE_SECURE_USER=hdfs
    HDFS_NAMENODE_USER=root
    HDFS_SECONDARYNAMENODE_USER=root
    

修改start-yarn.sh、stop-yarn.sh

  1. 打开配置文件:$HADOOP_HOME/sbin/
  2. 都添加以下内容:
    YARN_RESOURCEMANAGER_USER=root
    HADOOP_SECURE_DN_USER=yarn
    YARN_NODEMANAGER_USER=root
    

重新启动Hadoop

  1. 执行启动脚本: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文件一致

  1. 浏览器输入网址:http://hadoop101:8088

image.png

  1. 浏览器输入网址:http://hadoop101:9870

image.png

停止Hadoop

  1. 执行脚本: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 上
    
  2. 查看进程结果:

    [root@hadoop101 sbin]# jps
    8838 Jps
    

    Hadoop相关的5个进程不存在