美文网首页
002Ubuntu下Hadoop集群搭建过程

002Ubuntu下Hadoop集群搭建过程

作者: 桃子味的白开水 | 来源:发表于2019-11-09 17:21 被阅读0次

    本文链接:https://blog.csdn.net/qq_41941875/article/details/98182246

    UbuntuHadoop集群搭建过程

    1、实验环境

    namnode1:192.168.80.90
    namnode2:
    datanode1:192.168.80.91
    datanode2:192.168.80.92
    datanode3:
    操作系统: ubuntu-16.04-x64
    hadoop版本: apache-hadoop-2.1.1
    jdk版本:1.8

    2、安装jdk

    安装包百度网盘分享: https://pan.baidu.com/s/1C-Kg7jmqvlGg3TAr24_qVA,下载之后上传到虚拟机中,接着开始安装jdk。

    cd /usr/lib
    sudo mkdir jvm #创建/usr/lib/jvm目录用来存放JDK文件
    cd /usr/local/hadoo  #jdk安装包的目录
    sudo tar -zxvf ./jdk-8u162-linux-x64.tar.gz -C /usr/lib/jvm  #把JDK文件解压到/usr/lib/jvm目录下
    cd /usrlib/jvm # 进入目录
    mv jdk1.8.0_162 jdk # 改名字
    
    

    设置环境变量

    cd ~
    gedit ~/.bashrc
    
    

    在文件的开头添加如下内容:

    export JAVA_HOME=/usr/lib/jvm/jdk
    export JRE_HOME=${JAVA_HOME}/jre
    export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
    export PATH=${JAVA_HOME}/bin:$PATH
    
    

    保存.bashrc文件并退出。然后,继续执行如下命令让.bashrc文件的配置立即生效:

    source ~/.bashrc
    
    

    这时,可以使用如下命令查看是否安装成功:

    java -version
    
    

    显示如下内容表使安装成功

    java version "1.8.0_162"
    Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
    Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)
    
    

    3、修改主机名字和ip映射

    下面的操作是在namenode1上进行的,对于datanode1和datanode2的操作相同。

    1】修改主机名字

    sudo vim /etc/hostname
    
    

    2】修改ip映射

    sudo vim /etc/hosts
    
    

    下面是我的主机ip映射

    127.0.0.1       localhost
    
    192.168.80.90 namenode1
    192.168.80.91 datanode1
    192.168.80.92 datanode2
    
    

    修改完成后需要重启一下,重启后在终端中才会看到机器名的变化。接下来的教程中请注意区分 namenode1节点与 datanode1节点的操作。

    配置好后需要在各个节点上执行如下命令,测试是否相互 ping 得通,如果 ping 不通,后面就无法顺利配置成功:

    需要在所有节点上完成网络配置

    如上面讲的是 namenode1节点的配置,而在其他的datanode 节点上,也要对 /etc/hostname(修改为 datanode1、datanode 2 等) 和 /etc/hosts(跟namenode1 的配置一样)这两个文件进行修改!

    ping datanode1 -c 3   # 只ping 3次,否则要按 Ctrl+c 中断
    ping datanode2 -c 3
    
    

    下面是三台虚拟机ping的结果

    root@namenode1:~# ping datanode1 -c 3
    PING datanode1 (192.168.80.91) 56(84) bytes of data.
    64 bytes from datanode1 (192.168.80.91): icmp_seq=1 ttl=64 time=0.567 ms
    64 bytes from datanode1 (192.168.80.91): icmp_seq=2 ttl=64 time=0.408 ms
    ^C
    --- datanode1 ping statistics ---
    2 packets transmitted, 2 received, 0% packet loss, time 1020ms
    rtt min/avg/max/mdev = 0.408/0.487/0.567/0.082 ms
    root@namenode1:~# ping datanode2 -c 3
    PING datanode2 (192.168.80.92) 56(84) bytes of data.
    64 bytes from datanode2 (192.168.80.92): icmp_seq=1 ttl=64 time=0.751 ms
    64 bytes from datanode2 (192.168.80.92): icmp_seq=2 ttl=64 time=0.391 ms
    ^C
    --- datanode2 ping statistics ---
    2 packets transmitted, 2 received, 0% packet loss, time 1032ms
    rtt min/avg/max/mdev = 0.391/0.571/0.751/0.180 ms
    root@namenode1:~# 
    
    
    root@datanode1:~# ping namenode1 -c 3
    PING namenode1 (192.168.80.90) 56(84) bytes of data.
    64 bytes from namenode1 (192.168.80.90): icmp_seq=1 ttl=64 time=0.341 ms
    64 bytes from namenode1 (192.168.80.90): icmp_seq=2 ttl=64 time=0.406 ms
    ^C
    --- namenode1 ping statistics ---
    2 packets transmitted, 2 received, 0% packet loss, time 1019ms
    rtt min/avg/max/mdev = 0.341/0.373/0.406/0.037 ms
    root@datanode1:~# ping datanode2 -c 3
    PING datanode2 (192.168.80.92) 56(84) bytes of data.
    64 bytes from datanode2 (192.168.80.92): icmp_seq=1 ttl=64 time=0.463 ms
    64 bytes from datanode2 (192.168.80.92): icmp_seq=2 ttl=64 time=1.09 ms
    ^C
    --- datanode2 ping statistics ---
    2 packets transmitted, 2 received, 0% packet loss, time 1008ms
    rtt min/avg/max/mdev = 0.463/0.780/1.097/0.317 ms
    root@datanode1:~# 
    
    
    root@datanode2:~# ping namenode1 -c 3
    PING namenode1 (192.168.80.90) 56(84) bytes of data.
    64 bytes from namenode1 (192.168.80.90): icmp_seq=1 ttl=64 time=1.02 ms
    ^C
    --- namenode1 ping statistics ---
    1 packets transmitted, 1 received, 0% packet loss, time 0ms
    rtt min/avg/max/mdev = 1.022/1.022/1.022/0.000 ms
    root@datanode2:~# ping datanode1 -c 3
    PING datanode1 (192.168.80.91) 56(84) bytes of data.
    64 bytes from datanode1 (192.168.80.91): icmp_seq=1 ttl=64 time=0.675 ms
    ^C
    --- datanode1 ping statistics ---
    1 packets transmitted, 1 received, 0% packet loss, time 0ms
    rtt min/avg/max/mdev = 0.675/0.675/0.675/0.000 ms
    root@datanode2:~# 
    
    

    4、SSH无密码登陆节点

    这个操作是要让 namenode1节点可以无密码 SSH 登陆到各个 datanode节点上。

    1】首先生成 namenode1节点的公匙,在 namenode1节点的终端中执行(因为改过主机名,所以还需要删掉原有的再重新生成一次):

    cd ~/.ssh               # 如果没有该目录,先执行一次ssh localhost
    rm ./id_rsa*            # 删除之前生成的公匙(如果有)
    ssh-keygen -t rsa       # 一直按回车就可以
    
    

    下面是我的操作:发现本地没有 .ssh目录,所以先执行了依次ssh localhost,发现需要输入密码,然后退出,推出后删除之前的公钥发现也没有,所以接着创建公钥。

    root@namenode1:~# cd ~/.ssh
    bash: cd: /root/.ssh: 没有那个文件或目录
    root@namenode1:~# ssh localhost
    The authenticity of host 'localhost (127.0.0.1)' can't be established.
    ECDSA key fingerprint is SHA256:fy0m26YldIm91K1K+eui/0wraIlSC/3QdFb/W8Jit34.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
    root@localhost's password: 
    Welcome to Ubuntu 16.04.4 LTS (GNU/Linux 4.13.0-36-generic x86_64)
    
     * Documentation:  https://help.ubuntu.com
     * Management:     https://landscape.canonical.com
     * Support:        https://ubuntu.com/advantage
    
    510 个可升级软件包。
    356 个安全更新。
    
    Last login: Thu Aug  1 11:05:15 2019 from 192.168.80.1
    root@namenode1:~# exit
    注销
    Connection to localhost closed.
    root@namenode1:~# cd ~/.ssh
    root@namenode1:~/.ssh# rm ./id_rsa*
    rm: 无法删除'./id_rsa*': 没有那个文件或目录
    root@namenode1:~/.ssh# ssh-keygen -t rsa
    Generating public/private rsa key pair.
    Enter file in which to save the key (/root/.ssh/id_rsa): 
    Enter passphrase (empty for no passphrase): 
    Enter same passphrase again: 
    Your identification has been saved in /root/.ssh/id_rsa.
    Your public key has been saved in /root/.ssh/id_rsa.pub.
    The key fingerprint is:
    SHA256:XFncqsW9qHNeQqMPdSczmYSbJNEUWXZQbhCSYuopL3s root@namenode1
    The key's randomart image is:
    +---[RSA 2048]----+
    |          .+=**+o|
    |          o+=+.+ |
    |         o+ooo. o|
    |       ... o++.+ |
    |       .S. o*.B..|
    |      . o .+.o.= |
    |       o  o.. .  |
    |      . E oo.o   |
    |      .+   +o    |
    +----[SHA256]-----+
    root@namenode1:~/.ssh# 
    
    

    2】让 namenode1 节点需能无密码 SSH 本机,在 namenode1 节点上执行:

    cat ./id_rsa.pub >> ./authorized_keys
    
    

    完成后可执行 ssh namenode1 验证一下(可能需要输入 yes,成功后执行 exit 返回原来的终端)

    生成公钥后:此时登陆本机不需要输入密码

    root@namenode1:~/.ssh# cat ./id_rsa.pub >> ./authorized_keys
    root@namenode1:~/.ssh# ssh namenode1
    The authenticity of host 'namenode1 (192.168.80.90)' can't be established.
    ECDSA key fingerprint is SHA256:fy0m26YldIm91K1K+eui/0wraIlSC/3QdFb/W8Jit34.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added 'namenode1,192.168.80.90' (ECDSA) to the list of known hosts.
    Welcome to Ubuntu 16.04.4 LTS (GNU/Linux 4.13.0-36-generic x86_64)
    
     * Documentation:  https://help.ubuntu.com
     * Management:     https://landscape.canonical.com
     * Support:        https://ubuntu.com/advantage
    
    510 个可升级软件包。
    356 个安全更新。
    
    Last login: Fri Aug  2 09:41:37 2019 from 127.0.0.1
    root@namenode1:~# exit
    注销
    Connection to namenode1 closed.
    root@namenode1:~/.ssh# 
    
    

    3】接着在 namenode1节点将上公匙传输到 datanode1和datanode2节点(在传输前如果不存在目录,先创建)

    scp ~/.ssh/id_rsa.pub root@datanode1:/home/hadoop/
    
    

    scp 是 secure copy 的简写,用于在 Linux 下进行远程拷贝文件,类似于 cp 命令,不过 cp 只能在本机中拷贝。执行 scp 时会要求输入 datanode 上 root 用户的密码(root),输入完成后会提示传输完毕,如下所示:

    root@namenode1:~/.ssh# scp ~/.ssh/id_rsa.pub root@datanode1:/home/hadoop/
    The authenticity of host 'datanode1 (192.168.80.91)' can't be established.
    ECDSA key fingerprint is SHA256:fy0m26YldIm91K1K+eui/0wraIlSC/3QdFb/W8Jit34.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added 'datanode1,192.168.80.91' (ECDSA) to the list of known hosts.
    root@datanode1's password: 
    id_rsa.pub                                    100%  396     0.4KB/s   00:00    
    root@namenode1:~/.ssh# scp ~/.ssh/id_rsa.pub root@datanode2:/home/hadoop/
    The authenticity of host 'datanode2 (192.168.80.92)' can't be established.
    ECDSA key fingerprint is SHA256:fy0m26YldIm91K1K+eui/0wraIlSC/3QdFb/W8Jit34.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added 'datanode2,192.168.80.92' (ECDSA) to the list of known hosts.
    root@datanode2's password: 
    id_rsa.pub                                    100%  396     0.4KB/s   00:00    
    root@namenode1:~/.ssh# 
    
    

    4】接着在 datanode 节点上,将 ssh 公匙加入授权:

    mkdir ~/.ssh       # 如果不存在该文件夹需先创建,若已存在则忽略
    cat id_rsa.pub >> ~/.ssh/authorized_keys
    rm id_rsa.pub    # 用完就可以删掉了
    
    

    下面是我的操作:(注意我的当前目录,因为当时将公钥传输到/home/hadoop目录,所以我直接切换到这个目录了,接着如果~/.ssh 目录不存在,直接mkdir ~/.ssh,然后可以开始下面的步骤)

    在datanode1上的操作
    root@datanode1:/home/hadoop# ls
    id_rsa.pub
    root@datanode1:/home/hadoop# mkdir ~/.ssh
    root@datanode1:/home/hadoop# cat id_rsa.pub >> ~/.ssh/authorized_keys
    root@datanode1:/home/hadoop# rm id_rsa.pub
    root@datanode1:/home/hadoop# 
    在datanode2上的操作
    root@datanode2:/home/hadoop# ls
    id_rsa.pub
    root@datanode2:/home/hadoop# mkdir ~/.ssh
    root@datanode2:/home/hadoop# cat id_rsa.pub >> ~/.ssh/authorized_keys
    root@datanode2:/home/hadoop# rm id_rsa.pub
    root@datanode2:/home/hadoop#
    
    

    如果有其他 datanode 节点,也要执行将 namenode1 公匙传输到 datanode 节点、在 datanode 节点上加入授权这两步。这样,在 namenode1 节点上就可以无密码 SSH 到各个 datanode 节点了,可在 namenode1 节点上执行如下命令进行检验,如下所示:

    连接datanode1:
    root@namenode1:~/.ssh# ssh datanode1
    Welcome to Ubuntu 16.04.4 LTS (GNU/Linux 4.13.0-36-generic x86_64)
    
     * Documentation:  https://help.ubuntu.com
     * Management:     https://landscape.canonical.com
     * Support:        https://ubuntu.com/advantage
    
    512 个可升级软件包。
    358 个安全更新。
    
    Last login: Thu Aug  1 11:05:15 2019 from 192.168.80.1
    root@datanode1:~# exit
    注销
    Connection to datanode1 closed.
    连接datanode2
    root@namenode1:~/.ssh# ssh datanode2
    Welcome to Ubuntu 16.04.4 LTS (GNU/Linux 4.13.0-36-generic x86_64)
    
     * Documentation:  https://help.ubuntu.com
     * Management:     https://landscape.canonical.com
     * Support:        https://ubuntu.com/advantage
    
    512 个可升级软件包。
    358 个安全更新。
    
    Last login: Thu Aug  1 11:05:15 2019 from 192.168.80.1
    root@datanode2:~# 
    
    

    5、安装Hadoop,配置PATH变量

    1】下载haddoop:https://pan.baidu.com/s/1DyiCiFyvJkgfJP95dsDF1g 百度网盘链接

    2】上传到虚拟机中。我们选择将 Hadoop 安装至 /usr/local/ 中:hadoop的安装包我在本地下载好之后,直接上传到了虚拟机的usr/local/hadoop中了。(下面命令可以根据你的安装包的目录的不同而有所改变)

    tar -zxf hadoop-2.7.1.tar.gz   # 解压安装包
    mv hadoop-2.7.1 hadoop         # 将文件夹名改为hadoop
    chown -R root ./hadoop   # 修改文件权限 
    
    

    下面是我的操作

    root@namenode1:/usr/local/hadoop# ls
    hadoop-2.7.1.tar.gz  jdk-8u162-linux-x64.tar.gz
    root@namenode1:/usr/local/hadoop# tar -zxf hadoop-2.7.1.tar.gz 
    root@namenode1:/usr/local/hadoop# ls
    hadoop-2.7.1  hadoop-2.7.1.tar.gz  jdk-8u162-linux-x64.tar.gz
    root@namenode1:/usr/local/hadoop# mv hadoop-2.7.1 hadoop
    root@namenode1:/usr/local/hadoop# chown -R root ./hadoop 
    root@namenode1:/usr/local/hadoop# 
    
    

    3】Hadoop 解压后即可使用。输入如下命令来检查 Hadoop 是否可用,成功则会显示 Hadoop 版本信息:

    由于我的目录不是特别舒服,我将之前的目录删除了,安装移出来了,重新解压了一遍操作如下:

    root@namenode1:/usr/local# rm -rf hadoop
    root@namenode1:/usr/local# tar -zxf hadoop-2.7.1.tar.gz 
    root@namenode1:/usr/local# ls
    bin     hadoop-2.7.1                lib    src
    docker  hadoop-2.7.1.tar.gz         man    windscribe-cli_1.3-19_amd64.deb
    etc     include                     sbin
    games   jdk-8u162-linux-x64.tar.gz  share
    root@namenode1:/usr/local# mv hadoop-2.7.1 hadoop
    root@namenode1:/usr/local# ls
    bin     hadoop                      lib    src
    docker  hadoop-2.7.1.tar.gz         man    windscribe-cli_1.3-19_amd64.deb
    etc     include                     sbin
    games   jdk-8u162-linux-x64.tar.gz  share
    root@namenode1:/usr/local# cd hadoop
    root@namenode1:/usr/local/hadoop# ls
    bin  include  libexec      NOTICE.txt  sbin
    etc  lib      LICENSE.txt  README.txt  share
    root@namenode1:/usr/local/hadoop# 
    
    

    4】查看hadoop版本:(在hadoop目录执行)

    ./bin/hadoop version
    
    

    结果如下:

    root@namenode1:/usr/local/hadoop# ./bin/hadoop version
    Hadoop 2.7.1
    Subversion https://git-wip-us.apache.org/repos/asf/hadoop.git -r 15ecc87ccf4a0228f35af08fc56de536e6ce657a
    Compiled by jenkins on 2015-06-29T06:04Z
    Compiled with protoc 2.5.0
    From source with checksum fc0a1a23fc1868e4d5ee7fa2b28a58a
    This command was run using /usr/local/hadoop/share/hadoop/common/hadoop-common-2.7.1.jar
    root@namenode1:/usr/local/hadoop# 
    
    

    5】上面显示已经安装好hadoop,可以配置hadoop环境变量了。这样就可以在任意目录中直接使用 hadoop、hdfs 等命令了,如果还没有配置的,需要在 namenode 节点上进行配置。首先执行 vim ~/.bashrc,加入一行:

    export PATH=$PATH:/usr/local/hadoop/bin:/usr/local/hadoop/sbin
    
    

    保存后执行 source ~/.bashrc 使配置生效。

    6、配置集群/分布式环境

    1】集群/分布式模式需要修改 /usr/local/hadoop/etc/hadoop 中的5个配置文件,更多设置项可点击查看官方说明,这里仅设置了正常启动所必须的设置项: slaves、core-site.xmlhdfs-site.xmlmapred-site.xmlyarn-site.xml

    下面的配置根据自己的情况可以自由调整。

    1, 文件 slaves,将作为 DataNode 的主机名写入该文件,每行一个,默认为 localhost,所以在伪分布式配置时,节点即作为 NameNode 也作为 DataNode。分布式配置可以保留 localhost,也可以删掉,让 namenode1 节点仅作为 NameNode 使用。本教程让 NameNode1节点仅作为 NameNode 使用,因此将文件中原来的 localhost 删除,添加如下内容:datanode1、datanode2。

    datanode1
    datanode2
    
    

    下面是我的操作

    root@namenode1:/usr/local/hadoop/etc/hadoop# gedit slaves 
    root@namenode1:/usr/local/hadoop/etc/hadoop# cat slaves 
    datanode1
    datanode2
    root@namenode1:/usr/local/hadoop/etc/hadoop#
    
    

    2, 文件 core-site.xml 改为下面的配置:

    <configuration>
            <property>
                    <name>fs.defaultFS</name>
                    <value>hdfs://namenode1:9000</value>
            </property>
            <property>
                    <name>hadoop.tmp.dir</name>
                    <value>file:/usr/local/hadoop/tmp</value>
                    <description>Abase for other temporary directories.</description>
            </property>
    </configuration>
    
    

    3, 文件 hdfs-site.xml,dfs.replication 一般设为 3,它的意思是hdfs文件块的副本的个数,这是我们设置成2。

    <configuration>
            <property>
                    <name>dfs.namenode.secondary.http-address</name>
                    <value>namenode1:50090</value>
            </property>
            <property>
                    <name>dfs.replication</name>
                    <value>2</value>
            </property>
            <property>
                    <name>dfs.namenode.name.dir</name>
                    <value>file:/usr/local/hadoop/tmp/dfs/name</value>
            </property>
            <property>
                    <name>dfs.datanode.data.dir</name>
                    <value>file:/usr/local/hadoop/tmp/dfs/data</value>
            </property>
    </configuration>
    
    

    4, 文件 mapred-site.xml (可能需要先重命名 mv mapred-site.xml.template mapred-site.xml,默认文件名为 mapred-site.xml.template),然后配置修改如下:

    <configuration>
            <property>
                    <name>mapreduce.framework.name</name>
                    <value>yarn</value>
            </property>
            <property>
                    <name>mapreduce.jobhistory.address</name>
                    <value>namenode1:10020</value>
            </property>
            <property>
                    <name>mapreduce.jobhistory.webapp.address</name>
                    <value>namenode1:19888</value>
            </property>
    </configuration>
    
    

    5, 文件 yarn-site.xml

    <configuration>
            <property>
                    <name>yarn.resourcemanager.hostname</name>
                    <value>namenode1</value>
            </property>
            <property>
                    <name>yarn.nodemanager.aux-services</name>
                    <value>mapreduce_shuffle</value>
            </property>
    </configuration>
    
    

    2】配置好后,将 namnode1上的 /usr/local/hadoop 文件夹复制到各个节点上。在 namnode1节点上执行:

    tar -zcf hadoop.namenode1.tar.gz ./hadoop   # 先压缩再复制
    scp ./hadoop.namenode1.tar.gz datanode1:/home/hadoop
    
    

    下面是我的操作

    root@namenode1:/usr/local# tar -zcf hadoop.namenode1.tar.gz ./hadoop
    root@namenode1:/usr/local# scp ./hadoop.namenode1.tar.gz datanode1:/home/hadoop
    hadoop.namenode1.tar.gz                                                    100%  202MB  67.3MB/s   00:03    
    root@namenode1:/usr/local# scp ./hadoop.namenode1.tar.gz datanode2:/home/hadoop
    hadoop.namenode1.tar.gz                                                    100%  202MB  40.4MB/s   00:05    
    root@namenode1:/usr/local# 
    
    

    3】在 datanode1节点上执行:

    rm -rf /usr/local/hadoop    # 删掉旧的(如果存在)
    tar -zxf hadoop.namenode1.tar.gz -C /usr/local
    chown -R root /usr/local/hadoop  # 修改文件权限 
    
    

    下面是我的操作

    datanode1操作:
    root@datanode1:/home/hadoop# ls
    hadoop.namenode1.tar.gz
    root@datanode1:/home/hadoop# tar -zxf hadoop.namenode1.tar.gz -C /usr/local
    root@datanode1:/home/hadoop# chown -R root /usr/local/hadoop
    root@datanode1:/home/hadoop# 
    datanode2操作:
    root@datanode2:/home/hadoop# ls
    hadoop.namenode1.tar.gz
    root@datanode2:/home/hadoop# tar -zxf hadoop.namenode1.tar.gz -C /usr/local
    root@datanode2:/home/hadoop# chown -R root /usr/local/hadoop
    root@datanode2:/home/hadoop# 
    
    

    4】同样,如果有其他 datanode节点,也要执行将 hadoop.namenode1.tar.gz 传输到 datanode节点、在 datanode节点解压文件的操作。首次启动需要先在 namenode1节点执行 NameNode 的格式化:

    hdfs namenode -format       # 首次运行需要执行初始化,之后不需要
    
    

    成功的话,会看到 “successfully formatted” 和 “Exitting with status 0” 的提示,若为 “Exitting with status 1” 则是出错。下面是我的初始化结果:

    root@namenode1:/usr/local/hadoop# hdfs namenode -format   
    19/08/02 10:48:04 INFO namenode.NameNode: STARTUP_MSG: 
    /************************************************************
    STARTUP_MSG: Starting NameNode
    STARTUP_MSG:   host = namenode1/192.168.80.90
    STARTUP_MSG:   args = [-format]
    STARTUP_MSG:   version = 2.7.1
    STARTUP_MSG:   classpath = /usr/local/hadoop/etc/hadoop:/usr/local/hadoop/share/hadoop/common/lib/commons-lang-2.6.jar:/usr/local/hadoop/share/hadoop/common/lib/api-util-1.0.0-M20.jar:/usr/local/hadoop/share/hadoop/common/lib/commons-httpclient-3.1.jar:/usr/local/hadoop/share/hadoop/common/lib/jackson-jaxrs-1.9.13.jar:/usr/local/hadoop/share/hadoop/common/lib/gson-2.2.4.jar:/usr/local/hadoop/share/hadoop/common/lib/avro-1.7.4.jar:/usr/local/hadoop/share/hadoop/common/lib/jetty-util-6.1.26.jar:/usr/local/hadoop/share/hadoop/common/lib/servlet-api-2.5.jar:/usr/local/hadoop/share/hadoop/common/lib/commons-beanutils-1.7.0.jar:/usr/local/hadoop/share/hadoop/common/lib/commons-net-3.1.jar:/usr/local/hadoop/share/hadoop/common/lib/commons-cli-1.2.jar:/usr/local/hadoop/share/hadoop/common/lib/asm-3.2.jar:/usr/local/hadoop/share/hadoop/common/lib/paranamer-2.3.jar:/usr/local/hadoop/share/hadoop/common/lib/httpcore-4.2.5.jar:/usr/local/hadoop/share/hadoop/common/lib/guava-11.0.2.jar:/usr/local/hadoop/share/hadoop/common/lib/snappy-java-1.0.4.1.jar:/usr/local/hadoop/share/hadoop/common/lib/commons-logging-1.1.3.jar:/usr/local/hadoop/share/hadoop/common/lib/jackson-xc-1.9.13.jar:/usr/local/hadoop/share/hadoop/common/lib/zookeeper-3.4.6.jar:/usr/local/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar:/usr/local/hadoop/share/hadoop/common/lib/jersey-core-1.9.jar:/usr/local/hadoop/share/hadoop/common/lib/curator-client-2.7.1.jar:/usr/local/hadoop/share/hadoop/common/lib/commons-math3-3.1.1.jar:/usr/local/hadoop/share/hadoop/common/lib/stax-api-1.0-2.jar:/usr/local/hadoop/share/hadoop/common/lib/hamcrest-core-1.3.jar:/usr/local/hadoop/share/hadoop/common/lib/commons-beanutils-core-1.8.0.jar:/usr/local/hadoop/share/hadoop/common/lib/jackson-mapper-asl-1.9.13.jar:/usr/local/hadoop/share/hadoop/common/lib/log4j-1.2.17.jar:/usr/local/hadoop/share/hadoop/common/lib/mockito-all-1.8.5.jar:/usr/local/hadoop/share/hadoop/common/lib/curator-framework-2.7.1.jar:/usr/local/hadoop/share/hadoop/common/lib/hadoop-annotations-2.7.1.jar:/usr/local/hadoop/share/hadoop/common/lib/jersey-server-1.9.jar:/usr/local/hadoop/share/hadoop/common/lib/xz-1.0.jar:/usr/local/hadoop/share/hadoop/common/lib/slf4j-api-1.7.10.jar:/usr/local/hadoop/share/hadoop/common/lib/jsch-0.1.42.jar:/usr/local/hadoop/share/hadoop/common/lib/commons-io-2.4.jar:/usr/local/hadoop/share/hadoop/common/lib/jsr305-3.0.0.jar:/usr/local/hadoop/share/hadoop/common/lib/junit-4.11.jar:/usr/local/hadoop/share/hadoop/common/lib/activation-1.1.jar:/usr/local/hadoop/share/hadoop/common/lib/hadoop-auth-2.7.1.jar:/usr/local/hadoop/share/hadoop/common/lib/jackson-core-asl-1.9.13.jar:/usr/local/hadoop/share/hadoop/common/lib/htrace-core-3.1.0-incubating.jar:/usr/local/hadoop/share/hadoop/common/lib/httpclient-4.2.5.jar:/usr/local/hadoop/share/hadoop/common/lib/protobuf-java-2.5.0.jar:/usr/local/hadoop/share/hadoop/common/lib/java-xmlbuilder-0.4.jar:/usr/local/hadoop/share/hadoop/common/lib/commons-collections-3.2.1.jar:/usr/local/hadoop/share/hadoop/common/lib/apacheds-kerberos-codec-2.0.0-M15.jar:/usr/local/hadoop/share/hadoop/common/lib/jsp-api-2.1.jar:/usr/local/hadoop/share/hadoop/common/lib/jersey-json-1.9.jar:/usr/local/hadoop/share/hadoop/common/lib/api-asn1-api-1.0.0-M20.jar:/usr/local/hadoop/share/hadoop/common/lib/commons-configuration-1.6.jar:/usr/local/hadoop/share/hadoop/common/lib/commons-compress-1.4.1.jar:/usr/local/hadoop/share/hadoop/common/lib/jets3t-0.9.0.jar:/usr/local/hadoop/share/hadoop/common/lib/commons-digester-1.8.jar:/usr/local/hadoop/share/hadoop/common/lib/jaxb-impl-2.2.3-1.jar:/usr/local/hadoop/share/hadoop/common/lib/jaxb-api-2.2.2.jar:/usr/local/hadoop/share/hadoop/common/lib/commons-codec-1.4.jar:/usr/local/hadoop/share/hadoop/common/lib/jetty-6.1.26.jar:/usr/local/hadoop/share/hadoop/common/lib/apacheds-i18n-2.0.0-M15.jar:/usr/local/hadoop/share/hadoop/common/lib/netty-3.6.2.Final.jar:/usr/local/hadoop/share/hadoop/common/lib/jettison-1.1.jar:/usr/local/hadoop/share/hadoop/common/lib/curator-recipes-2.7.1.jar:/usr/local/hadoop/share/hadoop/common/lib/xmlenc-0.52.jar:/usr/local/hadoop/share/hadoop/common/hadoop-common-2.7.1.jar:/usr/local/hadoop/share/hadoop/common/hadoop-common-2.7.1-tests.jar:/usr/local/hadoop/share/hadoop/common/hadoop-nfs-2.7.1.jar:/usr/local/hadoop/share/hadoop/hdfs:/usr/local/hadoop/share/hadoop/hdfs/lib/commons-lang-2.6.jar:/usr/local/hadoop/share/hadoop/hdfs/lib/xml-apis-1.3.04.jar:/usr/local/hadoop/share/hadoop/hdfs/lib/jetty-util-6.1.26.jar:/usr/local/hadoop/share/hadoop/hdfs/lib/servlet-api-2.5.jar:/usr/local/hadoop/share/hadoop/hdfs/lib/commons-cli-1.2.jar:/usr/local/hadoop/share/hadoop/hdfs/lib/asm-3.2.jar:/usr/local/hadoop/share/hadoop/hdfs/lib/guava-11.0.2.jar:/usr/local/hadoop/share/hadoop/hdfs/lib/commons-logging-1.1.3.jar:/usr/local/hadoop/share/hadoop/hdfs/lib/jersey-core-1.9.jar:/usr/local/hadoop/share/hadoop/hdfs/lib/jackson-mapper-asl-1.9.13.jar:/usr/local/hadoop/share/hadoop/hdfs/lib/log4j-1.2.17.jar:/usr/local/hadoop/share/hadoop/hdfs/lib/jersey-server-1.9.jar:/usr/local/hadoop/share/hadoop/hdfs/lib/commons-io-2.4.jar:/usr/local/hadoop/share/hadoop/hdfs/lib/leveldbjni-all-1.8.jar:/usr/local/hadoop/share/hadoop/hdfs/lib/jsr305-3.0.0.jar:/usr/local/hadoop/share/hadoop/hdfs/lib/jackson-core-asl-1.9.13.jar:/usr/local/hadoop/share/hadoop/hdfs/lib/htrace-core-3.1.0-incubating.jar:/usr/local/hadoop/share/hadoop/hdfs/lib/protobuf-java-2.5.0.jar:/usr/local/hadoop/share/hadoop/hdfs/lib/netty-all-4.0.23.Final.jar:/usr/local/hadoop/share/hadoop/hdfs/lib/commons-codec-1.4.jar:/usr/local/hadoop/share/hadoop/hdfs/lib/jetty-6.1.26.jar:/usr/local/hadoop/share/hadoop/hdfs/lib/commons-daemon-1.0.13.jar:/usr/local/hadoop/share/hadoop/hdfs/lib/xercesImpl-2.9.1.jar:/usr/local/hadoop/share/hadoop/hdfs/lib/netty-3.6.2.Final.jar:/usr/local/hadoop/share/hadoop/hdfs/lib/xmlenc-0.52.jar:/usr/local/hadoop/share/hadoop/hdfs/hadoop-hdfs-2.7.1.jar:/usr/local/hadoop/share/hadoop/hdfs/hadoop-hdfs-nfs-2.7.1.jar:/usr/local/hadoop/share/hadoop/hdfs/hadoop-hdfs-2.7.1-tests.jar:/usr/local/hadoop/share/hadoop/yarn/lib/commons-lang-2.6.jar:/usr/local/hadoop/share/hadoop/yarn/lib/jackson-jaxrs-1.9.13.jar:/usr/local/hadoop/share/hadoop/yarn/lib/jetty-util-6.1.26.jar:/usr/local/hadoop/share/hadoop/yarn/lib/servlet-api-2.5.jar:/usr/local/hadoop/share/hadoop/yarn/lib/jersey-client-1.9.jar:/usr/local/hadoop/share/hadoop/yarn/lib/commons-cli-1.2.jar:/usr/local/hadoop/share/hadoop/yarn/lib/asm-3.2.jar:/usr/local/hadoop/share/hadoop/yarn/lib/guava-11.0.2.jar:/usr/local/hadoop/share/hadoop/yarn/lib/commons-logging-1.1.3.jar:/usr/local/hadoop/share/hadoop/yarn/lib/jackson-xc-1.9.13.jar:/usr/local/hadoop/share/hadoop/yarn/lib/zookeeper-3.4.6.jar:/usr/local/hadoop/share/hadoop/yarn/lib/jersey-core-1.9.jar:/usr/local/hadoop/share/hadoop/yarn/lib/javax.inject-1.jar:/usr/local/hadoop/share/hadoop/yarn/lib/stax-api-1.0-2.jar:/usr/local/hadoop/share/hadoop/yarn/lib/jackson-mapper-asl-1.9.13.jar:/usr/local/hadoop/share/hadoop/yarn/lib/log4j-1.2.17.jar:/usr/local/hadoop/share/hadoop/yarn/lib/jersey-server-1.9.jar:/usr/local/hadoop/share/hadoop/yarn/lib/xz-1.0.jar:/usr/local/hadoop/share/hadoop/yarn/lib/commons-io-2.4.jar:/usr/local/hadoop/share/hadoop/yarn/lib/leveldbjni-all-1.8.jar:/usr/local/hadoop/share/hadoop/yarn/lib/jsr305-3.0.0.jar:/usr/local/hadoop/share/hadoop/yarn/lib/activation-1.1.jar:/usr/local/hadoop/share/hadoop/yarn/lib/jackson-core-asl-1.9.13.jar:/usr/local/hadoop/share/hadoop/yarn/lib/protobuf-java-2.5.0.jar:/usr/local/hadoop/share/hadoop/yarn/lib/aopalliance-1.0.jar:/usr/local/hadoop/share/hadoop/yarn/lib/commons-collections-3.2.1.jar:/usr/local/hadoop/share/hadoop/yarn/lib/jersey-json-1.9.jar:/usr/local/hadoop/share/hadoop/yarn/lib/guice-servlet-3.0.jar:/usr/local/hadoop/share/hadoop/yarn/lib/jersey-guice-1.9.jar:/usr/local/hadoop/share/hadoop/yarn/lib/commons-compress-1.4.1.jar:/usr/local/hadoop/share/hadoop/yarn/lib/jaxb-impl-2.2.3-1.jar:/usr/local/hadoop/share/hadoop/yarn/lib/jaxb-api-2.2.2.jar:/usr/local/hadoop/share/hadoop/yarn/lib/commons-codec-1.4.jar:/usr/local/hadoop/share/hadoop/yarn/lib/jetty-6.1.26.jar:/usr/local/hadoop/share/hadoop/yarn/lib/guice-3.0.jar:/usr/local/hadoop/share/hadoop/yarn/lib/zookeeper-3.4.6-tests.jar:/usr/local/hadoop/share/hadoop/yarn/lib/netty-3.6.2.Final.jar:/usr/local/hadoop/share/hadoop/yarn/lib/jettison-1.1.jar:/usr/local/hadoop/share/hadoop/yarn/hadoop-yarn-api-2.7.1.jar:/usr/local/hadoop/share/hadoop/yarn/hadoop-yarn-server-web-proxy-2.7.1.jar:/usr/local/hadoop/share/hadoop/yarn/hadoop-yarn-client-2.7.1.jar:/usr/local/hadoop/share/hadoop/yarn/hadoop-yarn-common-2.7.1.jar:/usr/local/hadoop/share/hadoop/yarn/hadoop-yarn-server-common-2.7.1.jar:/usr/local/hadoop/share/hadoop/yarn/hadoop-yarn-applications-unmanaged-am-launcher-2.7.1.jar:/usr/local/hadoop/share/hadoop/yarn/hadoop-yarn-applications-distributedshell-2.7.1.jar:/usr/local/hadoop/share/hadoop/yarn/hadoop-yarn-server-applicationhistoryservice-2.7.1.jar:/usr/local/hadoop/share/hadoop/yarn/hadoop-yarn-server-sharedcachemanager-2.7.1.jar:/usr/local/hadoop/share/hadoop/yarn/hadoop-yarn-server-tests-2.7.1.jar:/usr/local/hadoop/share/hadoop/yarn/hadoop-yarn-server-nodemanager-2.7.1.jar:/usr/local/hadoop/share/hadoop/yarn/hadoop-yarn-registry-2.7.1.jar:/usr/local/hadoop/share/hadoop/yarn/hadoop-yarn-server-resourcemanager-2.7.1.jar:/usr/local/hadoop/share/hadoop/mapreduce/lib/avro-1.7.4.jar:/usr/local/hadoop/share/hadoop/mapreduce/lib/asm-3.2.jar:/usr/local/hadoop/share/hadoop/mapreduce/lib/paranamer-2.3.jar:/usr/local/hadoop/share/hadoop/mapreduce/lib/snappy-java-1.0.4.1.jar:/usr/local/hadoop/share/hadoop/mapreduce/lib/jersey-core-1.9.jar:/usr/local/hadoop/share/hadoop/mapreduce/lib/javax.inject-1.jar:/usr/local/hadoop/share/hadoop/mapreduce/lib/hamcrest-core-1.3.jar:/usr/local/hadoop/share/hadoop/mapreduce/lib/jackson-mapper-asl-1.9.13.jar:/usr/local/hadoop/share/hadoop/mapreduce/lib/log4j-1.2.17.jar:/usr/local/hadoop/share/hadoop/mapreduce/lib/hadoop-annotations-2.7.1.jar:/usr/local/hadoop/share/hadoop/mapreduce/lib/jersey-server-1.9.jar:/usr/local/hadoop/share/hadoop/mapreduce/lib/xz-1.0.jar:/usr/local/hadoop/share/hadoop/mapreduce/lib/commons-io-2.4.jar:/usr/local/hadoop/share/hadoop/mapreduce/lib/leveldbjni-all-1.8.jar:/usr/local/hadoop/share/hadoop/mapreduce/lib/junit-4.11.jar:/usr/local/hadoop/share/hadoop/mapreduce/lib/jackson-core-asl-1.9.13.jar:/usr/local/hadoop/share/hadoop/mapreduce/lib/protobuf-java-2.5.0.jar:/usr/local/hadoop/share/hadoop/mapreduce/lib/aopalliance-1.0.jar:/usr/local/hadoop/share/hadoop/mapreduce/lib/guice-servlet-3.0.jar:/usr/local/hadoop/share/hadoop/mapreduce/lib/jersey-guice-1.9.jar:/usr/local/hadoop/share/hadoop/mapreduce/lib/commons-compress-1.4.1.jar:/usr/local/hadoop/share/hadoop/mapreduce/lib/guice-3.0.jar:/usr/local/hadoop/share/hadoop/mapreduce/lib/netty-3.6.2.Final.jar:/usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.1.jar:/usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-client-hs-2.7.1.jar:/usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-client-shuffle-2.7.1.jar:/usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-client-hs-plugins-2.7.1.jar:/usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-client-common-2.7.1.jar:/usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-client-jobclient-2.7.1.jar:/usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-client-app-2.7.1.jar:/usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-client-jobclient-2.7.1-tests.jar:/usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-client-core-2.7.1.jar:/contrib/capacity-scheduler/*.jar
    STARTUP_MSG:   build = https://git-wip-us.apache.org/repos/asf/hadoop.git -r 15ecc87ccf4a0228f35af08fc56de536e6ce657a; compiled by 'jenkins' on 2015-06-29T06:04Z
    STARTUP_MSG:   java = 1.8.0_162
    ************************************************************/
    19/08/02 10:48:04 INFO namenode.NameNode: registered UNIX signal handlers for [TERM, HUP, INT]
    19/08/02 10:48:04 INFO namenode.NameNode: createNameNode [-format]
    Formatting using clusterid: CID-ba9cbb91-7c7a-4e86-a04c-c248be36c50d
    19/08/02 10:48:05 INFO namenode.FSNamesystem: No KeyProvider found.
    19/08/02 10:48:05 INFO namenode.FSNamesystem: fsLock is fair:true
    19/08/02 10:48:05 INFO blockmanagement.DatanodeManager: dfs.block.invalidate.limit=1000
    19/08/02 10:48:05 INFO blockmanagement.DatanodeManager: dfs.namenode.datanode.registration.ip-hostname-check=true
    19/08/02 10:48:05 INFO blockmanagement.BlockManager: dfs.namenode.startup.delay.block.deletion.sec is set to 000:00:00:00.000
    19/08/02 10:48:05 INFO blockmanagement.BlockManager: The block deletion will start around 2019 八月 02 10:48:05
    19/08/02 10:48:05 INFO util.GSet: Computing capacity for map BlocksMap
    19/08/02 10:48:05 INFO util.GSet: VM type       = 64-bit
    19/08/02 10:48:05 INFO util.GSet: 2.0% max memory 889 MB = 17.8 MB
    19/08/02 10:48:05 INFO util.GSet: capacity      = 2^21 = 2097152 entries
    19/08/02 10:48:05 INFO blockmanagement.BlockManager: dfs.block.access.token.enable=false
    19/08/02 10:48:05 INFO blockmanagement.BlockManager: defaultReplication         = 2
    19/08/02 10:48:05 INFO blockmanagement.BlockManager: maxReplication             = 512
    19/08/02 10:48:05 INFO blockmanagement.BlockManager: minReplication             = 1
    19/08/02 10:48:05 INFO blockmanagement.BlockManager: maxReplicationStreams      = 2
    19/08/02 10:48:05 INFO blockmanagement.BlockManager: shouldCheckForEnoughRacks  = false
    19/08/02 10:48:05 INFO blockmanagement.BlockManager: replicationRecheckInterval = 3000
    19/08/02 10:48:05 INFO blockmanagement.BlockManager: encryptDataTransfer        = false
    19/08/02 10:48:05 INFO blockmanagement.BlockManager: maxNumBlocksToLog          = 1000
    19/08/02 10:48:05 INFO namenode.FSNamesystem: fsOwner             = root (auth:SIMPLE)
    19/08/02 10:48:05 INFO namenode.FSNamesystem: supergroup          = supergroup
    19/08/02 10:48:05 INFO namenode.FSNamesystem: isPermissionEnabled = true
    19/08/02 10:48:05 INFO namenode.FSNamesystem: HA Enabled: false
    19/08/02 10:48:05 INFO namenode.FSNamesystem: Append Enabled: true
    19/08/02 10:48:06 INFO util.GSet: Computing capacity for map INodeMap
    19/08/02 10:48:06 INFO util.GSet: VM type       = 64-bit
    19/08/02 10:48:06 INFO util.GSet: 1.0% max memory 889 MB = 8.9 MB
    19/08/02 10:48:06 INFO util.GSet: capacity      = 2^20 = 1048576 entries
    19/08/02 10:48:06 INFO namenode.FSDirectory: ACLs enabled? false
    19/08/02 10:48:06 INFO namenode.FSDirectory: XAttrs enabled? true
    19/08/02 10:48:06 INFO namenode.FSDirectory: Maximum size of an xattr: 16384
    19/08/02 10:48:06 INFO namenode.NameNode: Caching file names occuring more than 10 times
    19/08/02 10:48:06 INFO util.GSet: Computing capacity for map cachedBlocks
    19/08/02 10:48:06 INFO util.GSet: VM type       = 64-bit
    19/08/02 10:48:06 INFO util.GSet: 0.25% max memory 889 MB = 2.2 MB
    19/08/02 10:48:06 INFO util.GSet: capacity      = 2^18 = 262144 entries
    19/08/02 10:48:06 INFO namenode.FSNamesystem: dfs.namenode.safemode.threshold-pct = 0.9990000128746033
    19/08/02 10:48:06 INFO namenode.FSNamesystem: dfs.namenode.safemode.min.datanodes = 0
    19/08/02 10:48:06 INFO namenode.FSNamesystem: dfs.namenode.safemode.extension     = 30000
    19/08/02 10:48:06 INFO metrics.TopMetrics: NNTop conf: dfs.namenode.top.window.num.buckets = 10
    19/08/02 10:48:06 INFO metrics.TopMetrics: NNTop conf: dfs.namenode.top.num.users = 10
    19/08/02 10:48:06 INFO metrics.TopMetrics: NNTop conf: dfs.namenode.top.windows.minutes = 1,5,25
    19/08/02 10:48:06 INFO namenode.FSNamesystem: Retry cache on namenode is enabled
    19/08/02 10:48:06 INFO namenode.FSNamesystem: Retry cache will use 0.03 of total heap and retry cache entry expiry time is 600000 millis
    19/08/02 10:48:06 INFO util.GSet: Computing capacity for map NameNodeRetryCache
    19/08/02 10:48:06 INFO util.GSet: VM type       = 64-bit
    19/08/02 10:48:06 INFO util.GSet: 0.029999999329447746% max memory 889 MB = 273.1 KB
    19/08/02 10:48:06 INFO util.GSet: capacity      = 2^15 = 32768 entries
    19/08/02 10:48:06 INFO namenode.FSImage: Allocated new BlockPoolId: BP-1454062026-192.168.80.90-1564714086384
    19/08/02 10:48:06 INFO common.Storage: Storage directory /usr/local/hadoop/tmp/dfs/name has been successfully formatted.
    19/08/02 10:48:06 INFO namenode.NNStorageRetentionManager: Going to retain 1 images with txid >= 0
    19/08/02 10:48:06 INFO util.ExitUtil: Exiting with status 0
    19/08/02 10:48:06 INFO namenode.NameNode: SHUTDOWN_MSG: 
    /************************************************************
    SHUTDOWN_MSG: Shutting down NameNode at namenode1/192.168.80.90
    ************************************************************/
    root@namenode1:/usr/local/hadoop# 
    
    

    可以看到下面的内容,表使已经初始化成功。

    19/08/02 10:48:06 INFO common.Storage: Storage directory /usr/local/hadoop/tmp/dfs/name has been successfully formatted.
    19/08/02 10:48:06 INFO namenode.NNStorageRetentionManager: Going to retain 1 images with txid >= 0
    19/08/02 10:48:06 INFO util.ExitUtil: Exiting with status 0
    
    

    CentOS系统需要关闭防火墙

    CentOS系统默认开启了防火墙,在开启 Hadoop 集群之前,需要关闭集群中每个节点的防火墙。有防火墙会导致 ping 得通但 telnet 端口不通,从而导致 DataNode 启动了,但 Live datanodes 为 0 的情况。

    在 CentOS 6.x 中,可以通过如下命令关闭防火墙:

    sudo service iptables stop   # 关闭防火墙服务
    sudo chkconfig iptables off  # 禁止防火墙开机自启,就不用手动关闭了
    
    

    Shell 命令

    若用是 CentOS 7,需通过如下命令关闭(防火墙服务改成了 firewall):

    systemctl stop firewalld.service    # 关闭firewall
    systemctl disable firewalld.service # 禁止firewall开机启动
    
    

    5】接着可以启动 hadoop 了,启动需要在 namnode1节点上进行:

    start-dfs.sh
    start-yarn.sh
    mr-jobhistory-daemon.sh start historyserver
    
    

    下面是我的操作:

    root@namenode1:/usr/local/hadoop# start-dfs.sh
    Starting namenodes on [namenode1]
    namenode1: starting namenode, logging to /usr/local/hadoop/logs/hadoop-root-namenode-namenode1.out
    datanode2: starting datanode, logging to /usr/local/hadoop/logs/hadoop-root-datanode-datanode2.out
    datanode1: starting datanode, logging to /usr/local/hadoop/logs/hadoop-root-datanode-datanode1.out
    Starting secondary namenodes [namenode1]
    namenode1: starting secondarynamenode, logging to /usr/local/hadoop/logs/hadoop-root-secondarynamenode-namenode1.out
    root@namenode1:/usr/local/hadoop# start-yarn.sh
    starting yarn daemons
    starting resourcemanager, logging to /usr/local/hadoop/logs/yarn-root-resourcemanager-namenode1.out
    datanode1: starting nodemanager, logging to /usr/local/hadoop/logs/yarn-root-nodemanager-datanode1.out
    datanode2: starting nodemanager, logging to /usr/local/hadoop/logs/yarn-root-nodemanager-datanode2.out
    root@namenode1:/usr/local/hadoop# mr-jobhistory-daemon.sh start historyserver
    starting historyserver, logging to /usr/local/hadoop/logs/mapred-root-historyserver-namenode1.out
    root@namenode1:/usr/local/hadoop# 
    
    

    通过命令 jps 可以查看各个节点所启动的进程。正确的话,在 namenode1节点上可以看到 NameNode、ResourceManager、SecondrryNameNode、JobHistoryServer 进程,如下所示:

    root@namenode1:/usr/local/hadoop# jps
    6721 JobHistoryServer
    5940 NameNode
    6404 ResourceManager
    6777 Jps
    6220 SecondaryNameNode
    root@namenode1:/usr/local/hadoop# 
    
    

    在 datanode节点可以看到 DataNode 和 NodeManager 进程,如下所示:

    root@datanode1:/usr/local/hadoop# jps
    5429 Jps
    5253 NodeManager
    5119 DataNode
    root@datanode1:/usr/local/hadoop# 
    
    
    root@datanode2:/usr/local/hadoop# jps
    5395 Jps
    5079 DataNode
    5239 NodeManager
    root@datanode2:/usr/local/hadoop# 
    
    

    缺少任一进程都表示出错。另外还需要在 namenode1 节点上通过命令 hdfs dfsadmin -report 查看 DataNode 是否正常启动,如果 Live datanodes 不为 0 ,则说明集群启动成功。例如我这边一共有 2 个 Datanodes:

    root@namenode1:/usr/local/hadoop# hdfs dfsadmin -report
    Configured Capacity: 77872496640 (72.52 GB)
    Present Capacity: 59310374912 (55.24 GB)
    DFS Remaining: 59310325760 (55.24 GB)
    DFS Used: 49152 (48 KB)
    DFS Used%: 0.00%
    Under replicated blocks: 0
    Blocks with corrupt replicas: 0
    Missing blocks: 0
    Missing blocks (with replication factor 1): 0
    
    -------------------------------------------------
    Live datanodes (2):
    
    Name: 192.168.80.91:50010 (datanode1)
    Hostname: datanode1
    Decommission Status : Normal
    Configured Capacity: 38936248320 (36.26 GB)
    DFS Used: 24576 (24 KB)
    Non DFS Used: 9389010944 (8.74 GB)
    DFS Remaining: 29547212800 (27.52 GB)
    DFS Used%: 0.00%
    DFS Remaining%: 75.89%
    Configured Cache Capacity: 0 (0 B)
    Cache Used: 0 (0 B)
    Cache Remaining: 0 (0 B)
    Cache Used%: 100.00%
    Cache Remaining%: 0.00%
    Xceivers: 1
    Last contact: Fri Aug 02 11:00:58 CST 2019
    
    Name: 192.168.80.92:50010 (datanode2)
    Hostname: datanode2
    Decommission Status : Normal
    Configured Capacity: 38936248320 (36.26 GB)
    DFS Used: 24576 (24 KB)
    Non DFS Used: 9173110784 (8.54 GB)
    DFS Remaining: 29763112960 (27.72 GB)
    DFS Used%: 0.00%
    DFS Remaining%: 76.44%
    Configured Cache Capacity: 0 (0 B)
    Cache Used: 0 (0 B)
    Cache Remaining: 0 (0 B)
    Cache Used%: 100.00%
    Cache Remaining%: 0.00%
    Xceivers: 1
    Last contact: Fri Aug 02 11:00:58 CST 2019
    root@namenode1:/usr/local/hadoop# 
    
    

    也可以通过 Web 页面看到查看 DataNode 和 NameNode 的状态:http://namenode1:50070/。(namenode1换成ip)

    namenode1 在这里插入图片描述

    相关文章

      网友评论

          本文标题:002Ubuntu下Hadoop集群搭建过程

          本文链接:https://www.haomeiwen.com/subject/reynbctx.html