Apache Hadoop 2.9.2 完全分布式部署

            Apache Hadoop 2.9.2 完全分布式部署(HDFS)

                                     作者:尹正杰

版权声明:原创作品,谢绝转载!否则将追究法律责任。

 

 

一.环境准备

1>.操作平台

[root@node101.yinzhengjie.org.cn ~]# cat /etc/redhat-release 
CentOS Linux release 7.6.1810 (Core) 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# uname -r
3.10.0-957.el7.x86_64
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# uname -m
x86_64
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# free -h
              total        used        free      shared  buff/cache   available
Mem:           7.0G        311M        6.1G        9.4M        587M        6.6G
Swap:          2.0G          0B        2.0G
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# df -h
Filesystem                    Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root   50G  4.5G   43G  10% /                    
devtmpfs                      3.9G     0  3.9G   0% /dev
tmpfs                         3.9G     0  3.9G   0% /dev/shm
tmpfs                         3.9G  9.3M  3.9G   1% /run
tmpfs                         3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/sda1                     477M  147M  301M  33% /boot
/dev/mapper/VolGroup-lv_home   12G   41M   11G   1% /home
Home                          234G  188G   47G  81% /media/psf/Home
tmpfs                         782M   20K  782M   1% /run/user/42
tmpfs                         782M     0  782M   0% /run/user/0
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# cat /etc/hosts | grep yinzhengjie          #注意,这里的主机映射咱们必须的配置,因为我们在配置文件指定的都是主机名称哟~当然你用DNS进行解析的话也是可以的!我这里就直接用本地解析啦!
172.30.1.101 node101.yinzhengjie.org.cn
172.30.1.102 node102.yinzhengjie.org.cn
172.30.1.103 node103.yinzhengjie.org.cn
[root@node101.yinzhengjie.org.cn ~]#

2>.节点角色分配

3>.登陆Apache官方网站(http://hadoop.apache.org/

4>.选择要下载的Hadoop版本

5>.下载Hadoop软件

[root@node101.yinzhengjie.org.cn ~/Downloads]# wget http://mirror.bit.edu.cn/apache/hadoop/common/hadoop-2.9.2/hadoop-2.9.2.tar.gz
--2019-04-11 11:59:02--  http://mirror.bit.edu.cn/apache/hadoop/common/hadoop-2.9.2/hadoop-2.9.2.tar.gz
Resolving mirror.bit.edu.cn (mirror.bit.edu.cn)... 202.204.80.77, 2001:da8:204:2001:250:56ff:fea1:22
Connecting to mirror.bit.edu.cn (mirror.bit.edu.cn)|202.204.80.77|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 366447449 (349M) [application/octet-stream]
Saving to: ‘hadoop-2.9.2.tar.gz’

100%[================================================================================================================================================================================================>] 366,447,449 1.32MB/s   in 3m 13s 

2019-04-11 12:02:14 (1.82 MB/s) - ‘hadoop-2.9.2.tar.gz’ saved [366447449/366447449]

[root@node101.yinzhengjie.org.cn ~/Downloads]# 
[root@node101.yinzhengjie.org.cn ~/Downloads]# wget http://mirror.bit.edu.cn/apache/hadoop/common/hadoop-2.9.2/hadoop-2.9.2.tar.gz

6>.禁用firewalld和selinux(记住,每个节点都需要操作,否则可能访问不了web UI哟!)

[root@node101.yinzhengjie.org.cn ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2019-04-11 10:31:41 CST; 7h ago
     Docs: man:firewalld(1)
 Main PID: 4059 (firewalld)
    Tasks: 2
   CGroup: /system.slice/firewalld.service
           └─4059 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

Apr 11 10:31:41 node101.yinzhengjie.org.cn systemd[1]: Starting firewalld - dynamic firewall daemon...
Apr 11 10:31:41 node101.yinzhengjie.org.cn systemd[1]: Started firewalld - dynamic firewall daemon.
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# systemctl status firewalld
[root@node101.yinzhengjie.org.cn ~]# systemctl disable firewalld 
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# systemctl disable firewalld
[root@node101.yinzhengjie.org.cn ~]# systemctl stop firewalld   
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# systemctl status firewalld  
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)

Apr 11 10:31:41 node101.yinzhengjie.org.cn systemd[1]: Starting firewalld - dynamic firewall daemon...
Apr 11 10:31:41 node101.yinzhengjie.org.cn systemd[1]: Started firewalld - dynamic firewall daemon.
Apr 11 18:22:25 node101.yinzhengjie.org.cn systemd[1]: Stopping firewalld - dynamic firewall daemon...
Apr 11 18:22:26 node101.yinzhengjie.org.cn systemd[1]: Stopped firewalld - dynamic firewall daemon.
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# systemctl stop firewalld
[root@node101.yinzhengjie.org.cn ~]# sed -i s'#SELINUX=enforcing#SELINUX=disabled#' /etc/selinux/config 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# grep SELINUX= /etc/selinux/config  | grep -v ^#
SELINUX=disabled
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# sed -i s'#SELINUX=enforcing#SELINUX=disabled#' /etc/selinux/config
[root@node101.yinzhengjie.org.cn ~]# getenforce 
Enforcing
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# setenforce 0
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# getenforce  
Permissive
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# setenforce 0

 

二.安装ansible软件

1>.查看yum源,我们此处默认你的服务器是可以联网

[root@node101.yinzhengjie.org.cn ~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
repo id                                                                     repo name                                                                                           status
base/7/x86_64                                                               CentOS-7 - Base - mirrors.aliyun.com                                                                10,019
extras/7/x86_64                                                             CentOS-7 - Extras - mirrors.aliyun.com                                                                 385
updates/7/x86_64                                                            CentOS-7 - Updates - mirrors.aliyun.com                                                              1,511
repolist: 11,915
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# yum repolist

2>. 查看当前的yum支持的ansible版本

[root@node101.yinzhengjie.org.cn ~/Downloads]# yum info ansible
Loaded plugins: fastestmirror, langpacks
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Available Packages
Name        : ansible
Arch        : noarch
Version     : 2.4.2.0
Release     : 2.el7
Size        : 7.6 M
Repo        : extras/7/x86_64
Summary     : SSH-based configuration management, deployment, and task execution system
URL         : http://ansible.com
License     : GPLv3+
Description : 
            : Ansible is a radically simple model-driven configuration management,
            : multi-node deployment, and remote task execution system. Ansible works
            : over SSH and does not require any software or daemons to be installed
            : on remote nodes. Extension modules can be written in any language and
            : are transferred to managed machines automatically.

[root@node101.yinzhengjie.org.cn ~/Downloads]# 
[root@node101.yinzhengjie.org.cn ~/Downloads]# yum info ansible

3>.安装ansible 

[root@node101.yinzhengjie.org.cn ~/Downloads]# yum -y install ansible
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                                                                                                                                                                                               | 3.6 kB  00:00:00     
extras                                                                                                                                                                                                             | 3.4 kB  00:00:00     
updates                                                                                                                                                                                                            | 3.4 kB  00:00:00     
(1/2): extras/7/x86_64/primary_db                                                                                                                                                                                  | 187 kB  00:00:00     
(2/2): updates/7/x86_64/primary_db                                                                                                                                                                                 | 3.4 MB  00:00:01     
Resolving Dependencies
--> Running transaction check
---> Package ansible.noarch 0:2.4.2.0-2.el7 will be installed
--> Processing Dependency: sshpass for package: ansible-2.4.2.0-2.el7.noarch
--> Processing Dependency: python2-jmespath for package: ansible-2.4.2.0-2.el7.noarch
--> Processing Dependency: python-passlib for package: ansible-2.4.2.0-2.el7.noarch
--> Processing Dependency: python-paramiko for package: ansible-2.4.2.0-2.el7.noarch
--> Processing Dependency: python-jinja2 for package: ansible-2.4.2.0-2.el7.noarch
--> Processing Dependency: python-httplib2 for package: ansible-2.4.2.0-2.el7.noarch
--> Running transaction check
---> Package python-httplib2.noarch 0:0.9.2-1.el7 will be installed
---> Package python-jinja2.noarch 0:2.7.2-2.el7 will be installed
--> Processing Dependency: python-babel >= 0.8 for package: python-jinja2-2.7.2-2.el7.noarch
--> Processing Dependency: python-markupsafe for package: python-jinja2-2.7.2-2.el7.noarch
---> Package python-paramiko.noarch 0:2.1.1-9.el7 will be installed
---> Package python-passlib.noarch 0:1.6.5-2.el7 will be installed
---> Package python2-jmespath.noarch 0:0.9.0-3.el7 will be installed
---> Package sshpass.x86_64 0:1.06-2.el7 will be installed
--> Running transaction check
---> Package python-babel.noarch 0:0.9.6-8.el7 will be installed
---> Package python-markupsafe.x86_64 0:0.11-10.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==========================================================================================================================================================================================================================================
 Package                                                        Arch                                                Version                                                    Repository                                            Size
==========================================================================================================================================================================================================================================
Installing:
 ansible                                                        noarch                                              2.4.2.0-2.el7                                              extras                                               7.6 M
Installing for dependencies:
 python-babel                                                   noarch                                              0.9.6-8.el7                                                base                                                 1.4 M
 python-httplib2                                                noarch                                              0.9.2-1.el7                                                extras                                               115 k
 python-jinja2                                                  noarch                                              2.7.2-2.el7                                                base                                                 515 k
 python-markupsafe                                              x86_64                                              0.11-10.el7                                                base                                                  25 k
 python-paramiko                                                noarch                                              2.1.1-9.el7                                                updates                                              269 k
 python-passlib                                                 noarch                                              1.6.5-2.el7                                                extras                                               488 k
 python2-jmespath                                               noarch                                              0.9.0-3.el7                                                extras                                                39 k
 sshpass                                                        x86_64                                              1.06-2.el7                                                 extras                                                21 k

Transaction Summary
==========================================================================================================================================================================================================================================
Install  1 Package (+8 Dependent packages)

Total download size: 10 M
Installed size: 51 M
Downloading packages:
python-httplib2-0.9.2-1.el7.no FAILED                                          
http://mirrors.cloud.aliyuncs.com/centos/7/extras/x86_64/Packages/python-httplib2-0.9.2-1.el7.noarch.rpm: [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs.com; Unknown error"       ]  0.0 B/s |    0 B  --:--:-- ETA 
Trying other mirror.
python-jinja2-2.7.2-2.el7.noar FAILED                                          
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/Packages/python-jinja2-2.7.2-2.el7.noarch.rpm: [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs.com; Unknown error"             ]  0.0 B/s |    0 B  --:--:-- ETA 
Trying other mirror.
(1/9): python-markupsafe-0.11-10.el7.x86_64.rpm                                                                                                                                                                    |  25 kB  00:00:00     
(2/9): python-babel-0.9.6-8.el7.noarch.rpm                                                                                                                                                                         | 1.4 MB  00:00:00     
(3/9): python-paramiko-2.1.1-9.el7.noarch.rpm                                                                                                                                                                      | 269 kB  00:00:01     
(4/9): ansible-2.4.2.0-2.el7.noarch.rpm                                                                                                                                                                            | 7.6 MB  00:00:04     
(5/9): python2-jmespath-0.9.0-3.el7.noarch.rpm                                                                                                                                                                     |  39 kB  00:00:00     
(6/9): sshpass-1.06-2.el7.x86_64.rpm                                                                                                                                                                               |  21 kB  00:00:00     
(7/9): python-httplib2-0.9.2-1.el7.noarch.rpm                                                                                                                                                                      | 115 kB  00:00:00     
(8/9): python-jinja2-2.7.2-2.el7.noarch.rpm                                                                                                                                                                        | 515 kB  00:00:00     
(9/9): python-passlib-1.6.5-2.el7.noarch.rpm                                                                                                                                                                       | 488 kB  00:00:05     
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                     1.7 MB/s |  10 MB  00:00:06     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : python-httplib2-0.9.2-1.el7.noarch                                                                                                                                                                                     1/9 
  Installing : sshpass-1.06-2.el7.x86_64                                                                                                                                                                                              2/9 
  Installing : python-babel-0.9.6-8.el7.noarch                                                                                                                                                                                        3/9 
  Installing : python-paramiko-2.1.1-9.el7.noarch                                                                                                                                                                                     4/9 
  Installing : python2-jmespath-0.9.0-3.el7.noarch                                                                                                                                                                                    5/9 
  Installing : python-passlib-1.6.5-2.el7.noarch                                                                                                                                                                                      6/9 
  Installing : python-markupsafe-0.11-10.el7.x86_64                                                                                                                                                                                   7/9 
  Installing : python-jinja2-2.7.2-2.el7.noarch                                                                                                                                                                                       8/9 
  Installing : ansible-2.4.2.0-2.el7.noarch                                                                                                                                                                                           9/9 
  Verifying  : python-markupsafe-0.11-10.el7.x86_64                                                                                                                                                                                   1/9 
  Verifying  : python-jinja2-2.7.2-2.el7.noarch                                                                                                                                                                                       2/9 
  Verifying  : python-passlib-1.6.5-2.el7.noarch                                                                                                                                                                                      3/9 
  Verifying  : python2-jmespath-0.9.0-3.el7.noarch                                                                                                                                                                                    4/9 
  Verifying  : python-paramiko-2.1.1-9.el7.noarch                                                                                                                                                                                     5/9 
  Verifying  : python-babel-0.9.6-8.el7.noarch                                                                                                                                                                                        6/9 
  Verifying  : ansible-2.4.2.0-2.el7.noarch                                                                                                                                                                                           7/9 
  Verifying  : sshpass-1.06-2.el7.x86_64                                                                                                                                                                                              8/9 
  Verifying  : python-httplib2-0.9.2-1.el7.noarch                                                                                                                                                                                     9/9 

Installed:
  ansible.noarch 0:2.4.2.0-2.el7                                                                                                                                                                                                          

Dependency Installed:
  python-babel.noarch 0:0.9.6-8.el7      python-httplib2.noarch 0:0.9.2-1.el7  python-jinja2.noarch 0:2.7.2-2.el7  python-markupsafe.x86_64 0:0.11-10.el7  python-paramiko.noarch 0:2.1.1-9.el7  python-passlib.noarch 0:1.6.5-2.el7 
  python2-jmespath.noarch 0:0.9.0-3.el7  sshpass.x86_64 0:1.06-2.el7          

Complete!
[root@node101.yinzhengjie.org.cn ~/Downloads]# 
[root@node101.yinzhengjie.org.cn ~/Downloads]# yum -y install ansible

4>.配置ansible服务器配置各个节点无密码登录

[root@node101.yinzhengjie.org.cn ~]# ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
Generating public/private rsa key pair.
Created directory '/root/.ssh'.
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:6KfrikhXwhdXAqulMqjKCHOmGca3aOfQMPuZemRHSUI root@node101.yinzhengjie.org.cn
The key's randomart image is:
+---[RSA 2048]----+
|  .E ... .       |
|   . .. o        |
|    o+..         |
|. . +oo.         |
|.= =.o. S        |
|o Bo+o           |
|=*=+. . .        |
|BX*++  o         |
|B+**.o+.         |
+----[SHA256]-----+
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa 
[root@node101.yinzhengjie.org.cn ~]# ssh-copy-id  root@node101.yinzhengjie.org.cn
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host 'node101.yinzhengjie.org.cn (172.30.1.101)' can't be established.
ECDSA key fingerprint is SHA256:aY4/OPQgpF74ffSpX26f80n7nuBv8Uc7wlH3CvsfI0k.
ECDSA key fingerprint is MD5:bd:af:b7:80:25:83:a6:9d:5a:54:86:e5:a5:69:47:69.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@node101.yinzhengjie.org.cn's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'root@node101.yinzhengjie.org.cn'"
and check to make sure that only the key(s) you wanted were added.

[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# ssh-copy-id root@node101.yinzhengjie.org.cn
[root@node101.yinzhengjie.org.cn ~]# ssh-copy-id  root@node102.yinzhengjie.org.cn
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host 'node102.yinzhengjie.org.cn (172.30.1.102)' can't be established.
ECDSA key fingerprint is SHA256:rDA5nSO2LcozxK76hXrtZ1xiXXZTXqQWu+wkBdpMDQA.
ECDSA key fingerprint is MD5:fd:75:9d:2b:28:ef:a2:0c:e2:c5:fc:fb:e9:5f:ee:c1.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@node102.yinzhengjie.org.cn's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'root@node102.yinzhengjie.org.cn'"
and check to make sure that only the key(s) you wanted were added.

[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# ssh-copy-id root@node102.yinzhengjie.org.cn
[root@node101.yinzhengjie.org.cn ~]# ssh-copy-id  root@node103.yinzhengjie.org.cn
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host 'node103.yinzhengjie.org.cn (172.30.1.103)' can't be established.
ECDSA key fingerprint is SHA256:5ucWsWQo98ucT5KLfpkXT9DtxurZgMQEMAtynmncvvE.
ECDSA key fingerprint is MD5:6b:fd:ed:8e:83:33:86:97:b0:4c:9f:23:87:50:85:4e.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@node103.yinzhengjie.org.cn's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'root@node103.yinzhengjie.org.cn'"
and check to make sure that only the key(s) you wanted were added.

[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# ssh-copy-id root@node103.yinzhengjie.org.cn
[root@node101.yinzhengjie.org.cn ~]# who
root     pts/0        2019-04-11 11:37 (172.30.1.2)
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# ssh node101.yinzhengjie.org.cn
Last login: Thu Apr 11 11:37:53 2019 from 172.30.1.2
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# who
root     pts/0        2019-04-11 11:37 (172.30.1.2)
root     pts/1        2019-04-11 12:17 (172.30.1.101)
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# logout
Connection to node101.yinzhengjie.org.cn closed.
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# who
root     pts/0        2019-04-11 11:37 (172.30.1.2)
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# ssh node101.yinzhengjie.org.cn
[root@node101.yinzhengjie.org.cn ~]# who
root     pts/0        2019-04-11 11:37 (172.30.1.2)
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# ssh node102.yinzhengjie.org.cn
Last login: Thu Apr 11 12:16:13 2019 from 172.30.1.101
[root@node102.yinzhengjie.org.cn ~]# 
[root@node102.yinzhengjie.org.cn ~]# who
root     pts/0        2019-04-11 12:17 (172.30.1.101)
[root@node102.yinzhengjie.org.cn ~]# 
[root@node102.yinzhengjie.org.cn ~]# logout
Connection to node102.yinzhengjie.org.cn closed.
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# who
root     pts/0        2019-04-11 11:37 (172.30.1.2)
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# ssh node102.yinzhengjie.org.cn
[root@node101.yinzhengjie.org.cn ~]# who
root     pts/0        2019-04-11 11:37 (172.30.1.2)
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# ssh node103.yinzhengjie.org.cn
Last login: Thu Apr 11 12:16:45 2019 from 172.30.1.101
[root@node103.yinzhengjie.org.cn ~]# 
[root@node103.yinzhengjie.org.cn ~]# who
root     pts/0        2019-04-11 12:18 (172.30.1.101)
[root@node103.yinzhengjie.org.cn ~]# 
[root@node103.yinzhengjie.org.cn ~]# logout
Connection to node103.yinzhengjie.org.cn closed.
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# who
root     pts/0        2019-04-11 11:37 (172.30.1.2)
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# ssh node103.yinzhengjie.org.cn

5>.编辑ansible的主机配置文件

[root@node101.yinzhengjie.org.cn ~]# tail -5 /etc/ansible/hosts 
[namenode]
node101.yinzhengjie.org.cn

[datanode]
node[101:103].yinzhengjie.org.cn
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# tail -5 /etc/ansible/hosts

6>.测试ansible工具是否可用 

[root@node101.yinzhengjie.org.cn ~]# tail -5 /etc/ansible/hosts 
[namenode]
node101.yinzhengjie.org.cn

[datanode]
node[101:103].yinzhengjie.org.cn
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# ansible namenode -m ping       
node101.yinzhengjie.org.cn | SUCCESS => {
    "changed": false, 
    "ping": "pong"
}
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# ansible namenode -m ping
[root@node101.yinzhengjie.org.cn ~]# ansible datanode -m ping        
node102.yinzhengjie.org.cn | SUCCESS => {
    "changed": false, 
    "ping": "pong"
}
node103.yinzhengjie.org.cn | SUCCESS => {
    "changed": false, 
    "ping": "pong"
}
node101.yinzhengjie.org.cn | SUCCESS => {
    "changed": false, 
    "ping": "pong"
}
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# ansible datanode -m ping
[root@node101.yinzhengjie.org.cn ~]# ansible all -m ping        
node103.yinzhengjie.org.cn | SUCCESS => {
    "changed": false, 
    "ping": "pong"
}
node102.yinzhengjie.org.cn | SUCCESS => {
    "changed": false, 
    "ping": "pong"
}
node101.yinzhengjie.org.cn | SUCCESS => {
    "changed": false, 
    "ping": "pong"
}
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# ansible all -m ping 

 

三.安装jdk1.8环境

1>.安装openjdk1.8的版本

[root@node101.yinzhengjie.org.cn ~]# yum -y install java-1.8.0-openjdk-devel
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package java-1.8.0-openjdk-devel.x86_64 1:1.8.0.201.b09-2.el7_6 will be installed
--> Processing Dependency: java-1.8.0-openjdk(x86-64) = 1:1.8.0.201.b09-2.el7_6 for package: 1:java-1.8.0-openjdk-devel-1.8.0.201.b09-2.el7_6.x86_64
--> Running transaction check
---> Package java-1.8.0-openjdk.x86_64 1:1.8.0.201.b09-2.el7_6 will be installed
--> Processing Dependency: java-1.8.0-openjdk-headless(x86-64) = 1:1.8.0.201.b09-2.el7_6 for package: 1:java-1.8.0-openjdk-1.8.0.201.b09-2.el7_6.x86_64
--> Running transaction check
---> Package java-1.8.0-openjdk-headless.x86_64 1:1.8.0.201.b09-2.el7_6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==========================================================================================================================================================================================================================================
 Package                                                             Arch                                           Version                                                         Repository                                       Size
==========================================================================================================================================================================================================================================
Installing:
 java-1.8.0-openjdk-devel                                            x86_64                                         1:1.8.0.201.b09-2.el7_6                                         updates                                         9.8 M
Installing for dependencies:
 java-1.8.0-openjdk                                                  x86_64                                         1:1.8.0.201.b09-2.el7_6                                         updates                                         260 k
 java-1.8.0-openjdk-headless                                         x86_64                                         1:1.8.0.201.b09-2.el7_6                                         updates                                          32 M

Transaction Summary
==========================================================================================================================================================================================================================================
Install  1 Package (+2 Dependent packages)

Total download size: 42 M
Installed size: 144 M
Downloading packages:
(1/3): java-1.8.0-openjdk-1.8.0.201.b09-2.el7_6.x86_64.rpm                                                                                                                                                         | 260 kB  00:00:00     
(2/3): java-1.8.0-openjdk-devel-1.8.0.201.b09-2.el7_6.x86_64.rpm                                                                                                                                                   | 9.8 MB  00:00:11     
(3/3): java-1.8.0-openjdk-headless-1.8.0.201.b09-2.el7_6.x86_64.rpm                                                                                                                                                |  32 MB  00:00:18     
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                     2.3 MB/s |  42 MB  00:00:18     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 1:java-1.8.0-openjdk-headless-1.8.0.201.b09-2.el7_6.x86_64                                                                                                                                                             1/3 
  Installing : 1:java-1.8.0-openjdk-1.8.0.201.b09-2.el7_6.x86_64                                                                                                                                                                      2/3 
  Installing : 1:java-1.8.0-openjdk-devel-1.8.0.201.b09-2.el7_6.x86_64                                                                                                                                                                3/3 
  Verifying  : 1:java-1.8.0-openjdk-1.8.0.201.b09-2.el7_6.x86_64                                                                                                                                                                      1/3 
  Verifying  : 1:java-1.8.0-openjdk-headless-1.8.0.201.b09-2.el7_6.x86_64                                                                                                                                                             2/3 
  Verifying  : 1:java-1.8.0-openjdk-devel-1.8.0.201.b09-2.el7_6.x86_64                                                                                                                                                                3/3 

Installed:
  java-1.8.0-openjdk-devel.x86_64 1:1.8.0.201.b09-2.el7_6                                                                                                                                                                                 

Dependency Installed:
  java-1.8.0-openjdk.x86_64 1:1.8.0.201.b09-2.el7_6                                                               java-1.8.0-openjdk-headless.x86_64 1:1.8.0.201.b09-2.el7_6                                                              

Complete!
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# yum -y install java-1.8.0-openjdk-devel

2>.查看openjdk版本

[root@node101.yinzhengjie.org.cn ~]# java -version   
openjdk version "1.8.0_201"
OpenJDK Runtime Environment (build 1.8.0_201-b09)
OpenJDK 64-Bit Server VM (build 25.201-b09, mixed mode)
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# java -version

3>.大家也可以去oracle官网下载相应的jdk1.8版本进行安装

  Oracle的jdk1.8官方下载地址:https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

 

四.搭建HDFS完全分布式集群

1>.解压Hadoop软件包

[root@node101.yinzhengjie.org.cn ~]# mkdir -pv /data/hadoop/{hdfs,yarn,mapreduce}
mkdir: created directory ‘/data’
mkdir: created directory ‘/data/hadoop’
mkdir: created directory ‘/data/hadoop/hdfs’
mkdir: created directory ‘/data/hadoop/yarn’
mkdir: created directory ‘/data/hadoop/mapreduce’
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# mkdir -pv /data/hadoop/{hdfs,yarn,mapreduce}
[root@node101.yinzhengjie.org.cn ~]# mkdir /yinzhengjie/{softwares,download} -pv
mkdir: created directory ‘/yinzhengjie’
mkdir: created directory ‘/yinzhengjie/softwares’
mkdir: created directory ‘/yinzhengjie/download’
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# mkdir /yinzhengjie/{softwares,download} -pv
[root@node101.yinzhengjie.org.cn ~]# mv ~/Downloads/hadoop-2.9.2.tar.gz  /yinzhengjie/download/
[root@node101.yinzhengjie.org.cn ~]# mv ~/Downloads/hadoop-2.9.2.tar.gz /yinzhengjie/download/
[root@node101.yinzhengjie.org.cn ~]# tar -zxf /yinzhengjie/download/hadoop-2.9.2.tar.gz -C /yinzhengjie/softwares/
[root@node101.yinzhengjie.org.cn ~]# tar -zxf /yinzhengjie/download/hadoop-2.9.2.tar.gz -C /yinzhengjie/softwares/

2>.修改Hadoop关于hdfs相关的配置文件

[root@node101.yinzhengjie.org.cn ~]# vi /yinzhengjie/softwares/hadoop-2.9.2/etc/hadoop/core-site.xml 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# cat /yinzhengjie/softwares/hadoop-2.9.2/etc/hadoop/core-site.xml   
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<configuration>
        <property>
                <name>fs.defaultFS</name>
                <value>hdfs://node101.yinzhengjie.org.cn:8020</value>
        </property>
        <property>
                <name>hadoop.tmp.dir</name>
                <value>/data/hadoop/hdfs</value>
        </property>
</configuration>


<!--

core-site.xml配置文件的作用:
    用于定义系统级别的参数,如HDFS URL、Hadoop的临时目录以及用于rack-aware集群中的配置文件的配置等,此中的参数定义会覆盖core-default.xml文件中的默认配置。

fs.defaultFS 参数的作用:
        #声明namenode的地址,相当于声明hdfs文件系统。

hadoop.tmp.dir 参数的作用:
        #声明hadoop工作目录的地址。

-->

[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# vi /yinzhengjie/softwares/hadoop-2.9.2/etc/hadoop/core-site.xml
[root@node101.yinzhengjie.org.cn ~]# vi /yinzhengjie/softwares/hadoop-2.9.2/etc/hadoop/hdfs-site.xml  
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# cat /yinzhengjie/softwares/hadoop-2.9.2/etc/hadoop/hdfs-site.xml 
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<configuration>
        <property>
                <name>dfs.replication</name>
                <value>2</value>
        </property>
</configuration>

<!--
hdfs-site.xml 配置文件的作用:
        #HDFS的相关设定,如文件副本的个数、块大小及是否使用强制权限等,此中的参数定义会覆盖hdfs-default.xml文件中的默认配置.

dfs.replication 参数的作用:
        #为了数据可用性及冗余的目的,HDFS会在多个节点上保存同一个数据块的多个副本,其默认为3个。而只有一个节点的伪分布式环境中其仅用
保存一个副本即可,这可以通过dfs.replication属性进行定义。它是一个软件级备份。

-->

[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# vi /yinzhengjie/softwares/hadoop-2.9.2/etc/hadoop/hdfs-site.xml
[root@node101.yinzhengjie.org.cn ~]# vi /yinzhengjie/softwares/hadoop-2.9.2/etc/hadoop/mapred-site.xml
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# cat /yinzhengjie/softwares/hadoop-2.9.2/etc/hadoop/mapred-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
        <property>
                <name>mapreduce.framework.name</name>
                <value>yarn</value>
        </property>
</configuration>

<!--
mapred-site.xml 配置文件的作用:
        #HDFS的相关设定,如reduce任务的默认个数、任务所能够使用内存的默认上下限等,此中的参数定义会覆盖mapred-default.xml文件中的默认配置.

mapreduce.framework.name 参数的作用:
        #指定MapReduce的计算框架,有三种可选,第一种:local(本地),第二种是classic(hadoop一代执行框架),第三种是yarn(二代执行框架),我们这里配置用目前版本最新的计算框架yarn即可。

-->
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# vi /yinzhengjie/softwares/hadoop-2.9.2/etc/hadoop/mapred-site.xml
[root@node101.yinzhengjie.org.cn ~]# vi /yinzhengjie/softwares/hadoop-2.9.2/etc/hadoop/yarn-site.xml    
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# cat /yinzhengjie/softwares/hadoop-2.9.2/etc/hadoop/yarn-site.xml    
<?xml version="1.0"?>
<configuration>
                <property>
                        <name>yarn.resourcemanager.hostname</name>
                        <value>node101.yinzhengjie.org.cn</value>
                </property>
        <property>
                <name>yarn.nodemanager.aux-services</name>
                <value>mapreduce_shuffle</value>
        </property>
</configuration>

<!--

yarn-site.xml配置文件的作用:
        #主要用于配置调度器级别的参数.

yarn.resourcemanager.hostname 参数的作用:
        #指定资源管理器(resourcemanager)的主机名

yarn.nodemanager.aux-services 参数的作用:
        #指定nodemanager使用shuffle

-->
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# vi /yinzhengjie/softwares/hadoop-2.9.2/etc/hadoop/yarn-site.xml
[root@node101.yinzhengjie.org.cn ~]# vi /yinzhengjie/softwares/hadoop-2.9.2/etc/hadoop/slaves    
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# cat /yinzhengjie/softwares/hadoop-2.9.2/etc/hadoop/slaves 
#该配置文件的作用:是NameNode用与记录需要连接哪些DataNode服务器节点,用与启动或停止服务时发送远程命令指令的目标主机。
node101.yinzhengjie.org.cn
node102.yinzhengjie.org.cn
node103.yinzhengjie.org.cn
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# vi /yinzhengjie/softwares/hadoop-2.9.2/etc/hadoop/slaves

3>. 添加Hadoop相关的系统环境变量 

[root@node101.yinzhengjie.org.cn ~]# echo ${JAVA_HOME}                 #我们发现系统并没有定义JAVA_HOME这个变量
   
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# grep JAVA_HOME /yinzhengjie/softwares/hadoop-2.9.2/etc/hadoop/hadoop-env.sh | grep -v ^#
export JAVA_HOME=${JAVA_HOME}                                #上面我们已经确认没有该变量,因此我们不应该使用默认的变量,而是指定我们安装JDK的路径
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# which java                     #使用which命令就可以轻松找到java的路径
/usr/bin/java
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# grep JAVA_HOME /yinzhengjie/softwares/hadoop-2.9.2/etc/hadoop/hadoop-env.sh | grep -v ^#
export JAVA_HOME=/usr                                            #在这里我们将其更换即可,注意,虽然我们配置的是/usr目录,但它默认回去/usr/bin目录下去找jdk相关命令工具,千万别画蛇添足写成/usr/bin 哟!
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# java -version
openjdk version "1.8.0_201"
OpenJDK Runtime Environment (build 1.8.0_201-b09)
OpenJDK 64-Bit Server VM (build 25.201-b09, mixed mode)
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# grep JAVA_HOME /yinzhengjie/softwares/hadoop-2.9.2/etc/hadoop/hadoop-env.sh | grep -v ^#
[root@node101.yinzhengjie.org.cn ~]# tail -3 /etc/profile
#Add HADOOP_HOME PATH
HADOOP_HOME=/yinzhengjie/softwares/hadoop-2.9.2
PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# tail -3 /etc/profile

4>.使用ansible将配置同步到其他2个节点中(把配置文件拷贝到其他节点的目的就是让整个集群共用同一套)

[root@node101.yinzhengjie.org.cn ~]# ansible all -m shell -a 'mkdir -pv /yinzhengjie'
 [WARNING]: Consider using file module with state=directory rather than running mkdir

node102.yinzhengjie.org.cn | SUCCESS | rc=0 >>
mkdir: created directory ‘/yinzhengjie’

node103.yinzhengjie.org.cn | SUCCESS | rc=0 >>
mkdir: created directory ‘/yinzhengjie’

node101.yinzhengjie.org.cn | SUCCESS | rc=0 >>


[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# ansible all -m shell -a 'mkdir -pv /yinzhengjie'
[root@node101.yinzhengjie.org.cn ~]# ansible all -m copy -a 'src=/etc/profile dest=/etc/profile owner=root mode=644'
node101.yinzhengjie.org.cn | SUCCESS => {
    "changed": false, 
    "checksum": "14029d7ba846a7d3465528d8b26e4b1a1d1c1d2f", 
    "gid": 0, 
    "group": "root", 
    "mode": "0644", 
    "owner": "root", 
    "path": "/etc/profile", 
    "secontext": "system_u:object_r:etc_t:s0", 
    "size": 1937, 
    "state": "file", 
    "uid": 0
}
node103.yinzhengjie.org.cn | SUCCESS => {
    "changed": true, 
    "checksum": "14029d7ba846a7d3465528d8b26e4b1a1d1c1d2f", 
    "dest": "/etc/profile", 
    "gid": 0, 
    "group": "root", 
    "md5sum": "5cde26e53478c543808d8f819bb599e6", 
    "mode": "0644", 
    "owner": "root", 
    "secontext": "system_u:object_r:etc_t:s0", 
    "size": 1937, 
    "src": "/root/.ansible/tmp/ansible-tmp-1554974518.2-51905803634200/source", 
    "state": "file", 
    "uid": 0
}
node102.yinzhengjie.org.cn | SUCCESS => {
    "changed": true, 
    "checksum": "14029d7ba846a7d3465528d8b26e4b1a1d1c1d2f", 
    "dest": "/etc/profile", 
    "gid": 0, 
    "group": "root", 
    "md5sum": "5cde26e53478c543808d8f819bb599e6", 
    "mode": "0644", 
    "owner": "root", 
    "secontext": "system_u:object_r:etc_t:s0", 
    "size": 1937, 
    "src": "/root/.ansible/tmp/ansible-tmp-1554974518.22-132567068637175/source", 
    "state": "file", 
    "uid": 0
}
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# ansible all -m copy -a 'src=/etc/profile dest=/etc/profile owner=root mode=644'
[root@node101.yinzhengjie.org.cn ~]# scp -r /yinzhengjie/softwares node102.yinzhengjie.org.cn:/yinzhengjie/

........                  #噼里啪啦一顿文件传输我就不贴了,只贴了局部!

yarn-config.sh                                                                                                                                                                                          100% 2134     5.0MB/s   00:00    
kms-config.sh                                                                                                                                                                                           100% 7899    13.6MB/s   00:00    
libhadooppipes.a                                                                                                                                                                                        100% 1594KB  94.8MB/s   00:00    
libhadooputils.a                                                                                                                                                                                        100%  465KB  86.8MB/s   00:00    
libhdfs.so.0.0.0                                                                                                                                                                                        100%  278KB  82.2MB/s   00:00    
wordcount-part                                                                                                                                                                                          100%  933KB  96.9MB/s   00:00    
wordcount-simple                                                                                                                                                                                        100%  924KB  97.7MB/s   00:00    
pipes-sort                                                                                                                                                                                              100%  910KB  97.2MB/s   00:00    
wordcount-nopipe                                                                                                                                                                                        100%  972KB  88.3MB/s   00:00    
libhdfs.so                                                                                                                                                                                              100%  278KB  80.2MB/s   00:00    
libhdfs.a                                                                                                                                                                                               100%  444KB  90.9MB/s   00:00    
libhadoop.so                                                                                                                                                                                            100%  822KB  93.1MB/s   00:00    
libhadoop.a                                                                                                                                                                                             100% 1406KB  98.5MB/s   00:00    
libhadoop.so.1.0.0                                                                                                                                                                                      100%  822KB  91.6MB/s   00:00    
[root@node101.yinzhengjie.org.cn ~]#  
[root@node101.yinzhengjie.org.cn ~]# scp -r /yinzhengjie/softwares node102.yinzhengjie.org.cn:/yinzhengjie/
[root@node101.yinzhengjie.org.cn ~]# scp -r /yinzhengjie/softwares node103.yinzhengjie.org.cn:/yinzhengjie/
......
commons-math3-3.1.1.jar                                                                                                                                                              100% 1562KB  76.8MB/s   00:00    
json-io-2.5.1.jar                                                                                                                                                                    100%   73KB  50.1MB/s   00:00    
ojalgo-43.0.jar                                                                                                                                                                      100% 1625KB 102.6MB/s   00:00    
hadoop-azure-datalake-2.9.2.jar                                                                                                                                                      100%   52KB  51.0MB/s   00:00    
README.txt                                                                                                                                                                           100% 1366     3.0MB/s   00:00    
mapred-config.cmd                                                                                                                                                                    100% 1640     4.0MB/s   00:00    
hdfs-config.sh                                                                                                                                                                       100% 1427     3.1MB/s   00:00    
httpfs-config.sh                                                                                                                                                                     100% 7666    14.8MB/s   00:00    
hdfs-config.cmd                                                                                                                                                                      100% 1640     4.3MB/s   00:00    
yarn-config.cmd                                                                                                                                                                      100% 2131     5.5MB/s   00:00    
mapred-config.sh                                                                                                                                                                     100% 2223     5.5MB/s   00:00    
hadoop-config.cmd                                                                                                                                                                    100% 8484    15.9MB/s   00:00    
hadoop-config.sh                                                                                                                                                                     100%   11KB  19.3MB/s   00:00    
yarn-config.sh                                                                                                                                                                       100% 2134     5.1MB/s   00:00    
kms-config.sh                                                                                                                                                                        100% 7899    13.8MB/s   00:00    
libhadooppipes.a                                                                                                                                                                     100% 1594KB 102.0MB/s   00:00    
libhadooputils.a                                                                                                                                                                     100%  465KB  91.0MB/s   00:00    
libhdfs.so.0.0.0                                                                                                                                                                     100%  278KB  75.5MB/s   00:00    
wordcount-part                                                                                                                                                                       100%  933KB  95.6MB/s   00:00    
wordcount-simple                                                                                                                                                                     100%  924KB  96.8MB/s   00:00    
pipes-sort                                                                                                                                                                           100%  910KB  92.5MB/s   00:00    
wordcount-nopipe                                                                                                                                                                     100%  972KB  91.0MB/s   00:00    
libhdfs.so                                                                                                                                                                           100%  278KB  76.4MB/s   00:00    
libhdfs.a                                                                                                                                                                            100%  444KB  88.2MB/s   00:00    
libhadoop.so                                                                                                                                                                         100%  822KB  95.8MB/s   00:00    
libhadoop.a                                                                                                                                                                          100% 1406KB  69.0MB/s   00:00    
libhadoop.so.1.0.0                                                                                                                                                                   100%  822KB 101.6MB/s   00:00    
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# scp -r /yinzhengjie/softwares node103.yinzhengjie.org.cn:/yinzhengjie/

  温馨提示,拷贝文件时我们也可以使用ansible进行拷贝,“[root@node101.yinzhengjie.org.cn ~]# ansible all -m copy -a 'src=/yinzhengjie/softwares dest=/yinzhengjie owner=root mode=0755'”,在服务器上使用该命令拷贝速度是相当可观的,但是在虚拟机上使用这条命令,我的虚拟机竟然卡顿了30分钟还没有拷贝完成(我查看的虚拟机资源还是充足的,配置都是4G,在虚拟机传输效率相比服务器上简直相差太大!当然你可以在电脑上使用上述命令,获取是我Mac的问题,但是我重新安装Mac系统发现依旧没有出现这个问题),如果大家出现和我一眼的问题就直接使用scp进行拷贝吧,1~2分钟就可以拷贝完成。

5>.格式化HDFS文件系统(目的是生成初始的元数据信息,生成的信息会存放在我们hdfs-core-site.xml配置文件中指定的工作目录下)

[root@node101.yinzhengjie.org.cn ~]# hdfs namenode -format
19/04/11 18:07:22 INFO namenode.NameNode: STARTUP_MSG: 
/************************************************************
STARTUP_MSG: Starting NameNode
STARTUP_MSG:   host = node101.yinzhengjie.org.cn/172.30.1.101
STARTUP_MSG:   args = [-format]
STARTUP_MSG:   version = 2.9.2
STARTUP_MSG:   classpath = /yinzhengjie/softwares/hadoop-2.9.2/etc/hadoop:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/woodstox-core-5.0.3.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/commons-collections-3.2.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/paranamer-2.3.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/apacheds-kerberos-codec-2.0.0-M15.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/asm-3.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/api-util-1.0.0-M20.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/zookeeper-3.4.6.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/xz-1.0.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/jettison-1.1.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/junit-4.11.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/jcip-annotations-1.0-1.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/snappy-java-1.0.5.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/commons-configuration-1.6.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/commons-beanutils-1.7.0.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/curator-recipes-2.7.1.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/httpclient-4.5.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/hadoop-annotations-2.9.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/commons-lang-2.6.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/xmlenc-0.52.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/java-xmlbuilder-0.4.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/commons-compress-1.4.1.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/jaxb-impl-2.2.3-1.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/avro-1.7.7.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/curator-framework-2.7.1.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/commons-codec-1.4.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/jetty-sslengine-6.1.26.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/json-smart-1.3.1.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/jsch-0.1.54.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/nimbus-jose-jwt-4.41.1.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/stax2-api-3.1.4.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/slf4j-api-1.7.25.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/mockito-all-1.8.5.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/jersey-server-1.9.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/jackson-xc-1.9.13.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/commons-cli-1.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/apacheds-i18n-2.0.0-M15.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/jaxb-api-2.2.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/htrace-core4-4.1.0-incubating.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/commons-net-3.1.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/guava-11.0.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/jsr305-3.0.0.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/hadoop-auth-2.9.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/stax-api-1.0-2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/api-asn1-api-1.0.0-M20.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/protobuf-java-2.5.0.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/servlet-api-2.5.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/jetty-6.1.26.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/jackson-jaxrs-1.9.13.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/jets3t-0.9.0.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/commons-digester-1.8.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/httpcore-4.4.4.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/jackson-mapper-asl-1.9.13.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/jsp-api-2.1.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/log4j-1.2.17.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/jersey-core-1.9.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/commons-io-2.4.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/curator-client-2.7.1.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/jersey-json-1.9.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/commons-lang3-3.4.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/hamcrest-core-1.3.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/commons-logging-1.1.3.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/jackson-core-asl-1.9.13.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/gson-2.2.4.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/commons-beanutils-core-1.8.0.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/activation-1.1.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/netty-3.6.2.Final.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/jetty-util-6.1.26.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/lib/commons-math3-3.1.1.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/hadoop-nfs-2.9.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/hadoop-common-2.9.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/common/hadoop-common-2.9.2-tests.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/lib/leveldbjni-all-1.8.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/lib/asm-3.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/lib/jackson-annotations-2.7.8.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/lib/okio-1.6.0.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/lib/commons-lang-2.6.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/lib/xmlenc-0.52.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/lib/xml-apis-1.3.04.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/lib/commons-codec-1.4.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/lib/jersey-server-1.9.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/lib/commons-cli-1.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/lib/htrace-core4-4.1.0-incubating.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/lib/guava-11.0.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/lib/jsr305-3.0.0.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/lib/protobuf-java-2.5.0.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/lib/servlet-api-2.5.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/lib/jetty-6.1.26.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/lib/jackson-mapper-asl-1.9.13.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/lib/log4j-1.2.17.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/lib/netty-all-4.0.23.Final.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/lib/jersey-core-1.9.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/lib/jackson-core-2.7.8.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/lib/jackson-databind-2.7.8.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/lib/commons-io-2.4.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/lib/commons-daemon-1.0.13.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/lib/xercesImpl-2.9.1.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/lib/okhttp-2.7.5.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/lib/hadoop-hdfs-client-2.9.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/lib/commons-logging-1.1.3.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/lib/jackson-core-asl-1.9.13.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/lib/netty-3.6.2.Final.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/lib/jetty-util-6.1.26.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/hadoop-hdfs-native-client-2.9.2-tests.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/hadoop-hdfs-nfs-2.9.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/hadoop-hdfs-2.9.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/hadoop-hdfs-client-2.9.2-tests.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/hadoop-hdfs-native-client-2.9.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/hadoop-hdfs-rbf-2.9.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/hadoop-hdfs-rbf-2.9.2-tests.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/hadoop-hdfs-client-2.9.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/hdfs/hadoop-hdfs-2.9.2-tests.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/woodstox-core-5.0.3.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/guice-3.0.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/commons-collections-3.2.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/paranamer-2.3.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/leveldbjni-all-1.8.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/apacheds-kerberos-codec-2.0.0-M15.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/asm-3.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/api-util-1.0.0-M20.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/ehcache-3.3.1.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/zookeeper-3.4.6.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/xz-1.0.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/jettison-1.1.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/jcip-annotations-1.0-1.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/snappy-java-1.0.5.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/commons-configuration-1.6.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/commons-beanutils-1.7.0.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/curator-recipes-2.7.1.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/httpclient-4.5.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/commons-lang-2.6.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/xmlenc-0.52.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/java-xmlbuilder-0.4.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/commons-compress-1.4.1.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/javax.inject-1.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/jaxb-impl-2.2.3-1.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/avro-1.7.7.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/curator-framework-2.7.1.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/commons-codec-1.4.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/jetty-sslengine-6.1.26.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/guice-servlet-3.0.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/json-smart-1.3.1.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/jsch-0.1.54.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/nimbus-jose-jwt-4.41.1.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/java-util-1.9.0.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/HikariCP-java7-2.4.12.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/stax2-api-3.1.4.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/jersey-server-1.9.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/jackson-xc-1.9.13.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/commons-cli-1.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/apacheds-i18n-2.0.0-M15.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/jaxb-api-2.2.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/metrics-core-3.0.1.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/htrace-core4-4.1.0-incubating.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/commons-net-3.1.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/guava-11.0.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/jsr305-3.0.0.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/stax-api-1.0-2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/api-asn1-api-1.0.0-M20.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/protobuf-java-2.5.0.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/servlet-api-2.5.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/jetty-6.1.26.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/jackson-jaxrs-1.9.13.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/jersey-guice-1.9.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/jets3t-0.9.0.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/commons-digester-1.8.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/httpcore-4.4.4.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/jackson-mapper-asl-1.9.13.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/jsp-api-2.1.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/log4j-1.2.17.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/jersey-client-1.9.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/jersey-core-1.9.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/commons-io-2.4.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/geronimo-jcache_1.0_spec-1.0-alpha-1.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/curator-client-2.7.1.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/jersey-json-1.9.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/aopalliance-1.0.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/commons-lang3-3.4.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/commons-logging-1.1.3.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/jackson-core-asl-1.9.13.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/gson-2.2.4.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/commons-beanutils-core-1.8.0.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/activation-1.1.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/netty-3.6.2.Final.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/jetty-util-6.1.26.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/fst-2.50.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/mssql-jdbc-6.2.1.jre7.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/commons-math3-3.1.1.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/lib/json-io-2.5.1.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/hadoop-yarn-applications-distributedshell-2.9.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/hadoop-yarn-server-sharedcachemanager-2.9.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/hadoop-yarn-api-2.9.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/hadoop-yarn-server-router-2.9.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/hadoop-yarn-server-web-proxy-2.9.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/hadoop-yarn-server-tests-2.9.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/hadoop-yarn-server-timeline-pluginstorage-2.9.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/hadoop-yarn-applications-unmanaged-am-launcher-2.9.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/hadoop-yarn-client-2.9.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/hadoop-yarn-registry-2.9.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/hadoop-yarn-common-2.9.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/hadoop-yarn-server-resourcemanager-2.9.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/hadoop-yarn-server-nodemanager-2.9.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/hadoop-yarn-server-common-2.9.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/yarn/hadoop-yarn-server-applicationhistoryservice-2.9.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/mapreduce/lib/guice-3.0.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/mapreduce/lib/paranamer-2.3.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/mapreduce/lib/leveldbjni-all-1.8.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/mapreduce/lib/asm-3.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/mapreduce/lib/xz-1.0.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/mapreduce/lib/junit-4.11.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/mapreduce/lib/snappy-java-1.0.5.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/mapreduce/lib/hadoop-annotations-2.9.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/mapreduce/lib/commons-compress-1.4.1.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/mapreduce/lib/javax.inject-1.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/mapreduce/lib/avro-1.7.7.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/mapreduce/lib/guice-servlet-3.0.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/mapreduce/lib/jersey-server-1.9.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/mapreduce/lib/protobuf-java-2.5.0.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/mapreduce/lib/jersey-guice-1.9.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/mapreduce/lib/jackson-mapper-asl-1.9.13.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/mapreduce/lib/log4j-1.2.17.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/mapreduce/lib/jersey-core-1.9.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/mapreduce/lib/commons-io-2.4.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/mapreduce/lib/aopalliance-1.0.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/mapreduce/lib/hamcrest-core-1.3.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/mapreduce/lib/jackson-core-asl-1.9.13.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/mapreduce/lib/netty-3.6.2.Final.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/mapreduce/hadoop-mapreduce-client-jobclient-2.9.2-tests.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/mapreduce/hadoop-mapreduce-client-shuffle-2.9.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/mapreduce/hadoop-mapreduce-client-core-2.9.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/mapreduce/hadoop-mapreduce-client-common-2.9.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/mapreduce/hadoop-mapreduce-client-hs-plugins-2.9.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/mapreduce/hadoop-mapreduce-client-app-2.9.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/mapreduce/hadoop-mapreduce-client-hs-2.9.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/mapreduce/hadoop-mapreduce-client-jobclient-2.9.2.jar:/yinzhengjie/softwares/hadoop-2.9.2/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.9.2.jar:/contrib/capacity-scheduler/*.jar
STARTUP_MSG:   build = https://git-wip-us.apache.org/repos/asf/hadoop.git -r 826afbeae31ca687bc2f8471dc841b66ed2c6704; compiled by 'ajisaka' on 2018-11-13T12:42Z
STARTUP_MSG:   java = 1.8.0_201
************************************************************/
19/04/11 18:07:22 INFO namenode.NameNode: registered UNIX signal handlers for [TERM, HUP, INT]
19/04/11 18:07:22 INFO namenode.NameNode: createNameNode [-format]
Formatting using clusterid: CID-5e6a5eca-6d94-4087-9ff8-7decc325338c
19/04/11 18:07:23 INFO namenode.FSEditLog: Edit logging is async:true
19/04/11 18:07:23 INFO namenode.FSNamesystem: KeyProvider: null
19/04/11 18:07:23 INFO namenode.FSNamesystem: fsLock is fair: true
19/04/11 18:07:23 INFO namenode.FSNamesystem: Detailed lock hold time metrics enabled: false
19/04/11 18:07:23 INFO namenode.FSNamesystem: fsOwner             = root (auth:SIMPLE)
19/04/11 18:07:23 INFO namenode.FSNamesystem: supergroup          = supergroup
19/04/11 18:07:23 INFO namenode.FSNamesystem: isPermissionEnabled = true
19/04/11 18:07:23 INFO namenode.FSNamesystem: HA Enabled: false
19/04/11 18:07:23 INFO common.Util: dfs.datanode.fileio.profiling.sampling.percentage set to 0. Disabling file IO profiling
19/04/11 18:07:23 INFO blockmanagement.DatanodeManager: dfs.block.invalidate.limit: configured=1000, counted=60, effected=1000
19/04/11 18:07:23 INFO blockmanagement.DatanodeManager: dfs.namenode.datanode.registration.ip-hostname-check=true
19/04/11 18:07:23 INFO blockmanagement.BlockManager: dfs.namenode.startup.delay.block.deletion.sec is set to 000:00:00:00.000
19/04/11 18:07:23 INFO blockmanagement.BlockManager: The block deletion will start around 2019 Apr 11 18:07:23
19/04/11 18:07:23 INFO util.GSet: Computing capacity for map BlocksMap
19/04/11 18:07:23 INFO util.GSet: VM type       = 64-bit
19/04/11 18:07:23 INFO util.GSet: 2.0% max memory 889 MB = 17.8 MB
19/04/11 18:07:23 INFO util.GSet: capacity      = 2^21 = 2097152 entries
19/04/11 18:07:23 INFO blockmanagement.BlockManager: dfs.block.access.token.enable=false
19/04/11 18:07:23 WARN conf.Configuration: No unit for dfs.heartbeat.interval(3) assuming SECONDS
19/04/11 18:07:23 WARN conf.Configuration: No unit for dfs.namenode.safemode.extension(30000) assuming MILLISECONDS
19/04/11 18:07:23 INFO blockmanagement.BlockManagerSafeMode: dfs.namenode.safemode.threshold-pct = 0.9990000128746033
19/04/11 18:07:23 INFO blockmanagement.BlockManagerSafeMode: dfs.namenode.safemode.min.datanodes = 0
19/04/11 18:07:23 INFO blockmanagement.BlockManagerSafeMode: dfs.namenode.safemode.extension = 30000
19/04/11 18:07:23 INFO blockmanagement.BlockManager: defaultReplication         = 2
19/04/11 18:07:23 INFO blockmanagement.BlockManager: maxReplication             = 512
19/04/11 18:07:23 INFO blockmanagement.BlockManager: minReplication             = 1
19/04/11 18:07:23 INFO blockmanagement.BlockManager: maxReplicationStreams      = 2
19/04/11 18:07:23 INFO blockmanagement.BlockManager: replicationRecheckInterval = 3000
19/04/11 18:07:23 INFO blockmanagement.BlockManager: encryptDataTransfer        = false
19/04/11 18:07:23 INFO blockmanagement.BlockManager: maxNumBlocksToLog          = 1000
19/04/11 18:07:23 INFO namenode.FSNamesystem: Append Enabled: true
19/04/11 18:07:23 INFO namenode.FSDirectory: GLOBAL serial map: bits=24 maxEntries=16777215
19/04/11 18:07:23 INFO util.GSet: Computing capacity for map INodeMap
19/04/11 18:07:23 INFO util.GSet: VM type       = 64-bit
19/04/11 18:07:23 INFO util.GSet: 1.0% max memory 889 MB = 8.9 MB
19/04/11 18:07:23 INFO util.GSet: capacity      = 2^20 = 1048576 entries
19/04/11 18:07:23 INFO namenode.FSDirectory: ACLs enabled? false
19/04/11 18:07:23 INFO namenode.FSDirectory: XAttrs enabled? true
19/04/11 18:07:23 INFO namenode.NameNode: Caching file names occurring more than 10 times
19/04/11 18:07:23 INFO snapshot.SnapshotManager: Loaded config captureOpenFiles: falseskipCaptureAccessTimeOnlyChange: false
19/04/11 18:07:23 INFO util.GSet: Computing capacity for map cachedBlocks
19/04/11 18:07:23 INFO util.GSet: VM type       = 64-bit
19/04/11 18:07:23 INFO util.GSet: 0.25% max memory 889 MB = 2.2 MB
19/04/11 18:07:23 INFO util.GSet: capacity      = 2^18 = 262144 entries
19/04/11 18:07:23 INFO metrics.TopMetrics: NNTop conf: dfs.namenode.top.window.num.buckets = 10
19/04/11 18:07:23 INFO metrics.TopMetrics: NNTop conf: dfs.namenode.top.num.users = 10
19/04/11 18:07:23 INFO metrics.TopMetrics: NNTop conf: dfs.namenode.top.windows.minutes = 1,5,25
19/04/11 18:07:23 INFO namenode.FSNamesystem: Retry cache on namenode is enabled
19/04/11 18:07:23 INFO namenode.FSNamesystem: Retry cache will use 0.03 of total heap and retry cache entry expiry time is 600000 millis
19/04/11 18:07:23 INFO util.GSet: Computing capacity for map NameNodeRetryCache
19/04/11 18:07:23 INFO util.GSet: VM type       = 64-bit
19/04/11 18:07:23 INFO util.GSet: 0.029999999329447746% max memory 889 MB = 273.1 KB
19/04/11 18:07:23 INFO util.GSet: capacity      = 2^15 = 32768 entries
19/04/11 18:07:23 INFO namenode.FSImage: Allocated new BlockPoolId: BP-681013498-172.30.1.101-1554977243283
19/04/11 18:07:23 INFO common.Storage: Storage directory /data/hadoop/hdfs/dfs/name has been successfully formatted.
19/04/11 18:07:23 INFO namenode.FSImageFormatProtobuf: Saving image file /data/hadoop/hdfs/dfs/name/current/fsimage.ckpt_0000000000000000000 using no compression
19/04/11 18:07:23 INFO namenode.FSImageFormatProtobuf: Image file /data/hadoop/hdfs/dfs/name/current/fsimage.ckpt_0000000000000000000 of size 323 bytes saved in 0 seconds .
19/04/11 18:07:23 INFO namenode.NNStorageRetentionManager: Going to retain 1 images with txid >= 0
19/04/11 18:07:23 INFO namenode.NameNode: SHUTDOWN_MSG: 
/************************************************************
SHUTDOWN_MSG: Shutting down NameNode at node101.yinzhengjie.org.cn/172.30.1.101
************************************************************/
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# hdfs namenode -format
[root@node101.yinzhengjie.org.cn ~]# ll /data/hadoop/hdfs/dfs/name/current/            #上面的格式话操作就是为了生成镜像文件!我们在数据目录可以看到,如下所示。
total 16
-rw-r--r--. 1 root root 323 Apr 11 18:07 fsimage_0000000000000000000
-rw-r--r--. 1 root root  62 Apr 11 18:07 fsimage_0000000000000000000.md5
-rw-r--r--. 1 root root   2 Apr 11 18:07 seen_txid
-rw-r--r--. 1 root root 215 Apr 11 18:07 VERSION
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# cat /data/hadoop/hdfs/dfs/name/current/seen_txid       #该文件存放的是编辑日志的编号,由于咱们是刚刚格式化hdfs文件系统,因此只有镜像文件!等启动集群并有操作写入时改值会变动!
0
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# ll /data/hadoop/hdfs/dfs/name/current/            #上面的格式话操作就是为了生成镜像文件!我们在数据目录可以看到,如下所示。

6>.启动namenode服务

[root@node101.yinzhengjie.org.cn ~]# ansible all -m shell -a 'jps'
node101.yinzhengjie.org.cn | SUCCESS | rc=0 >>
27253 Jps

node102.yinzhengjie.org.cn | SUCCESS | rc=0 >>
24797 Jps

node103.yinzhengjie.org.cn | SUCCESS | rc=0 >>
9658 Jps

[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# ansible all -m shell -a 'jps'
[root@node101.yinzhengjie.org.cn ~]# hadoop-daemon.sh start namenode
starting namenode, logging to /yinzhengjie/softwares/hadoop-2.9.2/logs/hadoop-root-namenode-node101.yinzhengjie.org.cn.out
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# hadoop-daemon.sh start namenode
[root@node101.yinzhengjie.org.cn ~]# ansible all -m shell -a 'jps'  
node102.yinzhengjie.org.cn | SUCCESS | rc=0 >>
24972 Jps

node103.yinzhengjie.org.cn | SUCCESS | rc=0 >>
9837 Jps

node101.yinzhengjie.org.cn | SUCCESS | rc=0 >>
27363 NameNode              #该进程为NameNode服务的进程名称
27564 Jps

[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# ss -ntl | grep 50070
LISTEN     0      128          *:50070                    *:*                  
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# ansible all -m shell -a 'jps'

  NameNode启动成功后,我们可以访问到它到WebUI界面,默认的端口为:50070 

  但是细心的小伙伴会发现,在NameNode的Web UI中找不到相应的DataNode节点,这是正常的,因为我们还没有启动DataNode呢!

  启动NameNode后,我们会发现生成了编辑日志,如下图所示:

7>.启动datanode服务

[root@node101.yinzhengjie.org.cn ~]# ansible all -m shell -a 'jps'  
node102.yinzhengjie.org.cn | SUCCESS | rc=0 >>
Jps

node103.yinzhengjie.org.cn | SUCCESS | rc=0 >>
Jps

node101.yinzhengjie.org.cn | SUCCESS | rc=0 >>
NameNode              #该进程为NameNode服务的进程名称
Jps

[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# ss -ntl | grep 50070
LISTEN     0      128          *:50070                    *:*                  
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# ansible all -m shell -a 'jps'
[root@node101.yinzhengjie.org.cn ~]# start-dfs.sh 
Starting namenodes on [node101.yinzhengjie.org.cn]
node101.yinzhengjie.org.cn: namenode running as process 27363. Stop it first.
node103.yinzhengjie.org.cn: starting datanode, logging to /yinzhengjie/softwares/hadoop-2.9.2/logs/hadoop-root-datanode-node103.yinzhengjie.org.cn.out
node102.yinzhengjie.org.cn: starting datanode, logging to /yinzhengjie/softwares/hadoop-2.9.2/logs/hadoop-root-datanode-node102.yinzhengjie.org.cn.out
node101.yinzhengjie.org.cn: starting datanode, logging to /yinzhengjie/softwares/hadoop-2.9.2/logs/hadoop-root-datanode-node101.yinzhengjie.org.cn.out
Starting secondary namenodes [account.jetbrains.com]
The authenticity of host 'account.jetbrains.com (0.0.0.0)' can't be established.
ECDSA key fingerprint is SHA256:aY4/OPQgpF74ffSpX26f80n7nuBv8Uc7wlH3CvsfI0k.
ECDSA key fingerprint is MD5:bd:af:b7:80:25:83:a6:9d:5a:54:86:e5:a5:69:47:69.
Are you sure you want to continue connecting (yes/no)? yes                #注意,第一次启动时,会弹出这个交互页面,我们输入yes即可!
account.jetbrains.com: Warning: Permanently added 'account.jetbrains.com,0.0.0.0' (ECDSA) to the list of known hosts.
account.jetbrains.com: starting secondarynamenode, logging to /yinzhengjie/softwares/hadoop-2.9.2/logs/hadoop-root-secondarynamenode-node101.yinzhengjie.org.cn.out
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# start-dfs.sh
[root@node101.yinzhengjie.org.cn ~]# ansible all -m shell -a 'jps'                                         
node102.yinzhengjie.org.cn | SUCCESS | rc=0 >>
31976 Jps
31612 DataNode

node103.yinzhengjie.org.cn | SUCCESS | rc=0 >>
16873 Jps
16509 DataNode

node101.yinzhengjie.org.cn | SUCCESS | rc=0 >>
27363 NameNode
2404 DataNode
3016 Jps
2684 SecondaryNameNode

[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# ansible all -m shell -a 'jps'

 

五.其他命令扩展

   博主推荐阅读:Hadoop启动脚本分析

 

 

未完待续......

posted @ 2019-04-10 23:51  尹正杰  阅读(2657)  评论(0编辑  收藏  举报