分享

Hadoop2.6集群环境搭建(HDFS HA+YARN)


问题导读


1.安装hadoop,本文做了哪些前提工作?

2.ssh免密码登录如何分发id_rsa.pub,有没有其它方式?
3.如何验证hadoop是否安装成功?






准备工作:
1、笔记本4G内存 ,操作系统WIN7 (屌丝的配置)
2、工具VMware Workstation
3、虚拟机:CentOS6.4共四台


虚拟机设置:
每台机器:内存512M,硬盘40G,网络适配器:NAT模式

o_1.png

选择高级,新生成虚机Mac地址(克隆虚拟机,Mac地址不会改变,每次最后手动重新生成)

o_2.png

编辑虚拟机网络:

o_3.png

点击NAT设置,查看虚机网关IP,并记住它,该IP在虚机的网络设置中非常重要。
NAT设置默认IP会自动生成,但是我们的集群中IP需要手动设置。

o_4.png


本机Win7 :VMnet8 网络设置

o_5.png


实验环境:


Ip
hostname
role
192.168.249.130
SY-0130
ActiveNameNode
192.168.249.131
SY-0131
StandByNameNode
192.168.249.132
SY-0132
DataNode1
192.168.249.133
SY-0133
DataNode2


Linux网络设置:
1、新建用户如:hadoop。不建议使用root用户搭建集群(root权限过大)
2、使得hadoop用户获得sudo权限。

  1. [root@SY-0130 ~]# vi /etc/sudoers
  2. ## Allow root to run any commands anywhere
  3. root    ALL=(ALL)       ALL
  4. hadoop  ALL=(ALL)       ALL
复制代码



3、查看当前虚机当前网络使用网卡设备
  1. [root@SY-0130 hadoop]# ifconfig
  2. eth2      Link encap:Ethernet  HWaddr 00:50:56:35:8E:E8  
  3.           inet addr:192.168.249.130  Bcast:192.168.249.255  Mask:255.255.255.0
  4.           inet6 addr: fe80::250:56ff:fe35:8ee8/64 Scope:Link
  5.           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
  6.           RX packets:877059 errors:0 dropped:0 overruns:0 frame:0
  7.           TX packets:597769 errors:0 dropped:0 overruns:0 carrier:0
  8.           collisions:0 txqueuelen:1000
  9.           RX bytes:865720294 (825.6 MiB)  TX bytes:324530557 (309.4 MiB)
  10.           Interrupt:19 Base address:0x2024
  11. lo        Link encap:Local Loopback  
  12.           inet addr:127.0.0.1  Mask:255.0.0.0
  13.           inet6 addr: ::1/128 Scope:Host
  14.           UP LOOPBACK RUNNING  MTU:16436  Metric:1
  15.           RX packets:1354 errors:0 dropped:0 overruns:0 frame:0
  16.           TX packets:1354 errors:0 dropped:0 overruns:0 carrier:0
  17.           collisions:0 txqueuelen:0
  18.           RX bytes:196675 (192.0 KiB)  TX bytes:196675 (192.0 KiB)
复制代码


[root@SY-0130 ~]# cat /proc/net/dev,当前网卡,我的为eth2
  1. [root@SY-0130 ~]# cat /proc/net/dev
  2. Inter-|   Receive                                                |  Transmit
  3. face |bytes    packets errs drop fifo frame compressed multicast|bytes    packets errs drop fifo colls carrier compressed
  4.     lo:  196675    1354    0    0    0     0          0         0   196675    1354    0    0    0     0       0          0
  5.   eth2:865576893  875205    0    0    0     0          0         0 324425517  596433    0    0    0     0       0          0
复制代码


4、查看当前网卡对应的Mac地址

  1. [root@SY-0130 ~]# cat /etc/udev/rules.d/70-persistent-net.rules
  2. # This file was automatically generated by the /lib/udev/write_net_rules
  3. # program, run by the persistent-net-generator.rules rules file.
  4. #
  5. # You can modify it, as long as you keep each rule on a single
  6. # line, and change only the value of the NAME= key.
  7. # PCI device 0x1022:0x2000 (vmxnet)
  8. SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:b5:fd:bb", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
  9. # PCI device 0x1022:0x2000 (vmxnet)
  10. SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:35:8e:e8", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
复制代码
5、Network Configuration
   [root@SY-0130 ~]# setup
o_6.png
o_7.png

选择eth2,进行设置,更改为当前网卡设备eth2,并且进行IP、网管、DNS设置。
o_8.png
DNS Server 与Win7的网络中的DNS Server一致,这样虚拟机也可以连接Internet网了,方便下载安装软件。
另外还有将防火墙关闭。
6、修改hostname


  1. [root@SY-0130 ~]# vi /etc/sysconfig/network
  2. NETWORKING=yes
  3. HOSTNAME=SY-0130
复制代码


7、修改hosts

[hadoop@SY-0130 ~]$ sudo vi /etc/hosts

#添加如下内容


  1. 192.168.249.130 SY-0130
  2. 192.168.249.131 SY-0131
  3. 192.168.249.132 SY-0132
  4. 192.168.249.133 SY-0133
复制代码
8、重启虚机.  reboot

软件安装:
(注:用户hadoop登录SY-130)
1、SY-130用户目录创建toolkit 文件夹,用来保存所有软件安装包,建立labc文件作为本次实验环境目录。
[hadoop@SY-0130 ~]$ mkdir labc
[hadoop@SY-0130 ~]$ mkdir toolkit
[hadoop@SY-0130 ~]$ ls
labc  toolkit
#我将下载的软件包存放在toolkit中如下

  1. [hadoop@SY-0130 toolkit]$ ls
  2. hadoop-2.5.2.tar.gz  hadoop-2.6.0.tar.gz  jdk-7u71-linux-i586.gz  scala-2.10.3.tgz  spark-1.2.0-bin-hadoop2.3.tgz  zookeeper-3.4.6.tar.gz
复制代码
1、JDK安装及环境变量设置
[hadoop@SY-0130 ~]$ mkdir lab
#我将jdk7安装在lab目录
[hadoop@SY-0130 jdk1.7.0_71]$ pwd
/home/hadoop/lab/jdk1.7.0_71
#环境变量设置:
[hadoop@SY-0130 ~]$ vi .bash_profile

  1. # User specific environment and startup programs
  2. export JAVA_HOME=/home/hadoop/lab/jdk1.7.0_71
  3. PATH=$JAVA_HOME/bin:$PATH:$HOME/bin
  4. export PATH
  5. export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
复制代码
#设置生效
[hadoop@SY-0130 ~]$ source .bash_profile

2、Hadoop2.6安装及设置
#解压toolkit 文件夹中的hadoop-2.6.0.tar.gz到. /home/hadoop/labc目录
[hadoop@SY-0130 hadoop-2.6.0]$ pwd
/home/hadoop/labc/hadoop-2.6.0
JDK,Hadoop基本安装完成,除了一些配置,现在可以将此虚拟机进行克隆。
该虚拟机命名:
130.ActiveNameNode
我将它克隆了3次,分别命名为:
131.StandbyNameNode
132.DataNode1
133..DataNode2
并且将克隆之后的3个虚拟机,重新生成了Mac地址,查看了他们分别使用的网卡,更改了对应的IP,dns,hostname , hosts,关闭防火墙。 具体操作按照上述说明操作即可。在网络配置这块我花了不少的时间。

o_9.png
o_10.png
软件配置:
至此,我拥有了四台安装好了JDK、Hadoop、及配置好对应的IP,能够访问Internet的Linux虚机。
在具体Hadoop HA 配置前,为了让节点之间通信方便,将4节点之间设置SSH免密码登录。

1、SSH免密码登录
[hadoop@SY-0130 ~]$ ssh-keygen -t rsa     #一直回车即可.
#查看生成公钥
[hadoop@SY-0130 .ssh]$ ls
id_rsa  id_rsa.pub  known_hosts
#远程复制id_rsa.pub到SY-0131, SY-0132, SY-0133 节点。
  1. [hadoop@SY-0130 .ssh]$ scp id_rsa.pub hadoop@SY-0131:.ssh/authorized_keys
  2. [hadoop@SY-0130 .ssh]$ scp id_rsa.pub hadoop@SY-0132:.ssh/authorized_keys
  3. [hadoop@SY-0130 .ssh]$ scp id_rsa.pub hadoop@SY-0133:.ssh/authorized_keys
复制代码

#注意:SY-130为ActiveName , 在此我只配置了SY-0130到其他节点的免密码登录,即只是单向,没有设置双向。
#完成上述配置后,测试SY-130免密码登录


  1. #连接sy-0131
  2. [hadoop@SY-0130 ~]$ ssh sy-0131
  3. Last login: Tue Jan  6 07:32:46 2015 from 192.168.249.1
  4. [hadoop@SY-0131 ~]$
  5. #ctrl+d 可退出连接
  6. #连接sy-0132
  7. [hadoop@SY-0130 ~]$ ssh sy-0132
  8. Last login: Tue Jan  6 21:25:16 2015 from 192.168.249.1
  9. [hadoop@SY-0132 ~]$
  10. #连接sy-0132
  11. [hadoop@SY-0130 ~]$ ssh sy-0133
  12. Last login: Tue Jan  6 21:25:18 2015 from 192.168.249.1
  13. [hadoop@SY-0133 ~]$
  14. #测试成功
复制代码
2、Hadoop设置
#进入hadoop安装目录
[hadoop@SY-0130 hadoop-2.6.0]$ pwd
/home/hadoop/labc/hadoop-2.6.0
#修改 hadoop-env.sh ,添加Java环境变量
[hadoop@SY-0130 hadoop-2.6.0]$ vi etc/hadoop/hadoop-env.sh

  1. # The java implementation to use.
  2. export JAVA_HOME=/home/hadoop/lab/jdk1.7.0_71
复制代码
#修改core-site.xml
  1. <?xml version="1.0"?>
  2. <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
  3. <!--
  4.    Licensed to the Apache Software Foundation (ASF) under one or more
  5.    contributor license agreements.  See the NOTICE file distributed with
  6.    this work for additional information regarding copyright ownership.
  7.    The ASF licenses this file to You under the Apache License, Version 2.0
  8.    (the "License"); you may not use this file except in compliance with
  9.    the License.  You may obtain a copy of the License at
  10.        http://www.apache.org/licenses/LICENSE-2.0
  11.    Unless required by applicable law or agreed to in writing, software
  12.    distributed under the License is distributed on an "AS IS" BASIS,
  13.    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.    See the License for the specific language governing permissions and
  15.    limitations under the License.
  16. -->
  17. <!-- Do not modify this file directly.  Instead, copy entries that you -->
  18. <!-- wish to modify from this file into core-site.xml and change them -->
  19. <!-- there.  If core-site.xml does not already exist, create it.      -->
  20. <configuration>
  21. <property>
  22.   <name>fs.defaultFS</name>
  23.   <value>hdfs://SY-0130:8020</value>
  24.   <description>The name of the default file system.  A URI whose
  25.   scheme and authority determine the FileSystem implementation.  The
  26.   uri's scheme determines the config property (fs.SCHEME.impl) naming
  27.   the FileSystem implementation class.  The uri's authority is used to
  28.   determine the host, port, etc. for a filesystem.</description>
  29. </property>
  30. </configuration>
复制代码
#修改hdfs-site.xml

  1. <?xml version="1.0"?>
  2. <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
  3. <!--
  4.    Licensed to the Apache Software Foundation (ASF) under one or more
  5.    contributor license agreements.  See the NOTICE file distributed with
  6.    this work for additional information regarding copyright ownership.
  7.    The ASF licenses this file to You under the Apache License, Version 2.0
  8.    (the "License"); you may not use this file except in compliance with
  9.    the License.  You may obtain a copy of the License at
  10.        http://www.apache.org/licenses/LICENSE-2.0
  11.    Unless required by applicable law or agreed to in writing, software
  12.    distributed under the License is distributed on an "AS IS" BASIS,
  13.    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.    See the License for the specific language governing permissions and
  15.    limitations under the License.
  16. -->
  17. <!-- Do not modify this file directly.  Instead, copy entries that you -->
  18. <!-- wish to modify from this file into hdfs-site.xml and change them -->
  19. <!-- there.  If hdfs-site.xml does not already exist, create it.      -->
  20. <configuration>
  21. <property>
  22.   <name>dfs.nameservices</name>
  23.   <value>hadoop-test</value>
  24.   <description>
  25.     Comma-separated list of nameservices.
  26.   </description>
  27. </property>
  28. <property>
  29.   <name>dfs.ha.namenodes.hadoop-test</name>
  30.   <value>nn1,nn2</value>
  31.   <description>
  32.     The prefix for a given nameservice, contains a comma-separated
  33.     list of namenodes for a given nameservice (eg EXAMPLENAMESERVICE).
  34.   </description>
  35. </property>
  36. <property>
  37.   <name>dfs.namenode.rpc-address.hadoop-test.nn1</name>
  38.   <value>SY-0130:8020</value>
  39.   <description>
  40.     RPC address for nomenode1 of hadoop-test
  41.   </description>
  42. </property>
  43. <property>
  44.   <name>dfs.namenode.rpc-address.hadoop-test.nn2</name>
  45.   <value>SY-0131:8020</value>
  46.   <description>
  47.     RPC address for nomenode2 of hadoop-test
  48.   </description>
  49. </property>
  50. <property>
  51.   <name>dfs.namenode.http-address.hadoop-test.nn1</name>
  52.   <value>SY-0130:50070</value>
  53.   <description>
  54.     The address and the base port where the dfs namenode1 web ui will listen on.
  55.   </description>
  56. </property>
  57. <property>
  58.   <name>dfs.namenode.http-address.hadoop-test.nn2</name>
  59.   <value>SY-0131:50070</value>
  60.   <description>
  61.     The address and the base port where the dfs namenode2 web ui will listen on.
  62.   </description>
  63. </property>
  64. <property>
  65.   <name>dfs.namenode.name.dir</name>
  66.   <value>file:///home/hadoop/labc/hdfs/name</value>
  67.   <description>Determines where on the local filesystem the DFS name node
  68.       should store the name table(fsimage).  If this is a comma-delimited list
  69.       of directories then the name table is replicated in all of the
  70.       directories, for redundancy. </description>
  71. </property>
  72. <property>
  73.   <name>dfs.namenode.shared.edits.dir</name>
  74.   <value>qjournal://SY-0131:8485;SY-0132:8485;SY-0133:8485/hadoop-test</value>
  75.   <description>A directory on shared storage between the multiple namenodes
  76.   in an HA cluster. This directory will be written by the active and read
  77.   by the standby in order to keep the namespaces synchronized. This directory
  78.   does not need to be listed in dfs.namenode.edits.dir above. It should be
  79.   left empty in a non-HA cluster.
  80.   </description>
  81. </property>
  82. <property>
  83.   <name>dfs.datanode.data.dir</name>
  84.   <value>file:///home/hadoop/labc/hdfs/data</value>
  85.   <description>Determines where on the local filesystem an DFS data node
  86.   should store its blocks.  If this is a comma-delimited
  87.   list of directories, then data will be stored in all named
  88.   directories, typically on different devices.
  89.   Directories that do not exist are ignored.
  90.   </description>
  91. </property>
  92. <property>
  93.   <name>dfs.ha.automatic-failover.enabled</name>
  94.   <value>false</value>
  95.   <description>
  96.     Whether automatic failover is enabled. See the HDFS High
  97.     Availability documentation for details on automatic HA
  98.     configuration.
  99.   </description>
  100. </property>
  101. <property>
  102.   <name>dfs.journalnode.edits.dir</name>
  103.   <value>/home/hadoop/labc/hdfs/journal/</value>
  104. </property>
  105. </configuration>
复制代码
#修改mapred-site.xml
  1. <?xml version="1.0"?>
  2. <!--
  3.    Licensed to the Apache Software Foundation (ASF) under one or more
  4.    contributor license agreements.  See the NOTICE file distributed with
  5.    this work for additional information regarding copyright ownership.
  6.    The ASF licenses this file to You under the Apache License, Version 2.0
  7.    (the "License"); you may not use this file except in compliance with
  8.    the License.  You may obtain a copy of the License at
  9.        http://www.apache.org/licenses/LICENSE-2.0
  10.    Unless required by applicable law or agreed to in writing, software
  11.    distributed under the License is distributed on an "AS IS" BASIS,
  12.    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.    See the License for the specific language governing permissions and
  14.    limitations under the License.
  15. -->
  16. <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
  17. <!-- Do not modify this file directly.  Instead, copy entries that you -->
  18. <!-- wish to modify from this file into mapred-site.xml and change them -->
  19. <!-- there.  If mapred-site.xml does not already exist, create it.      -->
  20. <configuration>
  21. <!-- MR YARN Application properties -->
  22. <property>
  23.   <name>mapreduce.framework.name</name>
  24.   <value>yarn</value>
  25.   <description>The runtime framework for executing MapReduce jobs.
  26.   Can be one of local, classic or yarn.
  27.   </description>
  28. </property>
  29. <!-- jobhistory properties -->
  30. <property>
  31.   <name>mapreduce.jobhistory.address</name>
  32.   <value>SY-0131:10020</value>
  33.   <description>MapReduce JobHistory Server IPC host:port</description>
  34. </property>
  35. <property>
  36.   <name>mapreduce.jobhistory.webapp.address</name>
  37.   <value>SY-0131:19888</value>
  38.   <description>MapReduce JobHistory Server Web UI host:port</description>
  39. </property>
  40. </configuration>
复制代码
#修改:yarn-site.xml
  1. <?xml version="1.0"?>
  2. <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
  3. <!--
  4.    Licensed to the Apache Software Foundation (ASF) under one or more
  5.    contributor license agreements.  See the NOTICE file distributed with
  6.    this work for additional information regarding copyright ownership.
  7.    The ASF licenses this file to You under the Apache License, Version 2.0
  8.    (the "License"); you may not use this file except in compliance with
  9.    the License.  You may obtain a copy of the License at
  10.        http://www.apache.org/licenses/LICENSE-2.0
  11.    Unless required by applicable law or agreed to in writing, software
  12.    distributed under the License is distributed on an "AS IS" BASIS,
  13.    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.    See the License for the specific language governing permissions and
  15.    limitations under the License.
  16. -->
  17. <!-- Do not modify this file directly.  Instead, copy entries that you -->
  18. <!-- wish to modify from this file into yarn-site.xml and change them -->
  19. <!-- there.  If yarn-site.xml does not already exist, create it.      -->
  20. <configuration>
  21.   
  22.   <!-- Resource Manager Configs -->
  23.   <property>
  24.     <description>The hostname of the RM.</description>
  25.     <name>yarn.resourcemanager.hostname</name>
  26.     <value>SY-0130</value>
  27.   </property>   
  28.   
  29.   <property>
  30.     <description>The address of the applications manager interface in the RM.</description>
  31.     <name>yarn.resourcemanager.address</name>
  32.     <value>${yarn.resourcemanager.hostname}:8032</value>
  33.   </property>
  34.   <property>
  35.     <description>The address of the scheduler interface.</description>
  36.     <name>yarn.resourcemanager.scheduler.address</name>
  37.     <value>${yarn.resourcemanager.hostname}:8030</value>
  38.   </property>
  39.   <property>
  40.     <description>The http address of the RM web application.</description>
  41.     <name>yarn.resourcemanager.webapp.address</name>
  42.     <value>${yarn.resourcemanager.hostname}:8088</value>
  43.   </property>
  44.   <property>
  45.     <description>The https adddress of the RM web application.</description>
  46.     <name>yarn.resourcemanager.webapp.https.address</name>
  47.     <value>${yarn.resourcemanager.hostname}:8090</value>
  48.   </property>
  49.   <property>
  50.     <name>yarn.resourcemanager.resource-tracker.address</name>
  51.     <value>${yarn.resourcemanager.hostname}:8031</value>
  52.   </property>
  53.   <property>
  54.     <description>The address of the RM admin interface.</description>
  55.     <name>yarn.resourcemanager.admin.address</name>
  56.     <value>${yarn.resourcemanager.hostname}:8033</value>
  57.   </property>
  58.   <property>
  59.     <description>The class to use as the resource scheduler.</description>
  60.     <name>yarn.resourcemanager.scheduler.class</name>
  61.     <value>org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler</value>
  62.   </property>
  63.   <property>
  64.     <description>fair-scheduler conf location</description>
  65.     <name>yarn.scheduler.fair.allocation.file</name>
  66.     <value>${yarn.home.dir}/etc/hadoop/fairscheduler.xml</value>
  67.   </property>
  68.   <property>
  69.     <description>List of directories to store localized files in. An
  70.       application's localized file directory will be found in:
  71.       ${yarn.nodemanager.local-dirs}/usercache/${user}/appcache/application_${appid}.
  72.       Individual containers' work directories, called container_${contid}, will
  73.       be subdirectories of this.
  74.    </description>
  75.     <name>yarn.nodemanager.local-dirs</name>
  76.     <value>/home/hadoop/labc/yarn/local</value>
  77.   </property>
  78.   <property>
  79.     <description>Whether to enable log aggregation</description>
  80.     <name>yarn.log-aggregation-enable</name>
  81.     <value>true</value>
  82.   </property>
  83.   <property>
  84.     <description>Where to aggregate logs to.</description>
  85.     <name>yarn.nodemanager.remote-app-log-dir</name>
  86.     <value>/tmp/logs</value>
  87.   </property>
  88.   <property>
  89.     <description>Amount of physical memory, in MB, that can be allocated
  90.     for containers.</description>
  91.     <name>yarn.nodemanager.resource.memory-mb</name>
  92.     <value>30720</value>
  93.   </property>
  94.   <property>
  95.     <description>Number of CPU cores that can be allocated
  96.     for containers.</description>
  97.     <name>yarn.nodemanager.resource.cpu-vcores</name>
  98.     <value>12</value>
  99.   </property>
  100.   <property>
  101.     <description>the valid service name should only contain a-zA-Z0-9_ and can not start with numbers</description>
  102.     <name>yarn.nodemanager.aux-services</name>
  103.     <value>mapreduce_shuffle</value>
  104.   </property>
  105.   
  106. </configuration>
复制代码
#修改slaves
  1. SY-0131
  2. SY-0132
  3. SY-0133
复制代码
#在/home/hadoop/labc/hadoop-2.6.0/etc/hadoop下,增加fairscheduler.xml
  1. <?xml version="1.0"?>
  2. <allocations>
  3.   <queue name="infrastructure">
  4.     <minResources>102400 mb, 50 vcores </minResources>
  5.     <maxResources>153600 mb, 100 vcores </maxResources>
  6.     <maxRunningApps>200</maxRunningApps>
  7.     <minSharePreemptionTimeout>300</minSharePreemptionTimeout>
  8.     <weight>1.0</weight>
  9.     <aclSubmitApps>root,yarn,search,hdfs</aclSubmitApps>
  10.   </queue>
  11.    <queue name="tool">
  12.       <minResources>102400 mb, 30 vcores</minResources>
  13.       <maxResources>153600 mb, 50 vcores</maxResources>
  14.    </queue>
  15.    <queue name="sentiment">
  16.       <minResources>102400 mb, 30 vcores</minResources>
  17.       <maxResources>153600 mb, 50 vcores</maxResources>
  18.    </queue>
  19. </allocations>
复制代码
将etc/hadoop/目录中的这几个配置文件通过scp 命令远程拷贝到SY-0131,SY-0132,SY-0133节点对应目录。
3、Hadoop 启动(HDFS , YARN启动)

  1. 注意:所有操作均在Hadoop部署目录下进行。
  2. 启动Hadoop集群:
  3. Step1 :
  4. 在各个JournalNode节点上,输入以下命令启动journalnode服务:
  5. sbin/hadoop-daemon.sh start journalnode
  6. Step2:
  7. 在[nn1]上,对其进行格式化,并启动:
  8. bin/hdfs namenode -format
  9. sbin/hadoop-daemon.sh start namenode
  10. Step3:
  11. 在[nn2]上,同步nn1的元数据信息:
  12. bin/hdfs namenode -bootstrapStandby
  13. Step4:
  14. 启动[nn2]:
  15. sbin/hadoop-daemon.sh start namenode
  16. 经过以上四步操作,nn1和nn2均处理standby状态
  17. Step5:
  18. 将[nn1]切换为Active
  19. bin/hdfs haadmin -transitionToActive nn1
  20. Step6:
  21. 在[nn1]上,启动所有datanode
  22. sbin/hadoop-daemons.sh start datanode
  23. 关闭Hadoop集群:
  24. 在[nn1]上,输入以下命令
  25. sbin/stop-dfs.sh
复制代码


web地址访问:
activenamenode
o_11.png
standbynamenode
o_12.png
datanodes info
o_13.png


开始Hadoop之旅!
PS:
一、Hdfs命令的区别:
1、如果Apache hadoop版本是0.x 或者1.x,
  bin/hadoop hdfs fs -mkdir -p /in
  bin/hadoop hdfs fs  -put /home/du/input  /in

2、如果Apache hadoop版本是2.x.
  bin/hdfs  dfs  -mkdir -p /in
  bin/hdfs  dfs   -put /home/du/input   /in
二、 有时候DataNode启动不了有如下原因:
1、因重复格式化namenode时候,集群ID会更改,原先已有数据的datanode中记录的集群ID与NameNode不一致,该问题会导致datanode启动不了。
在第一次格式化dfs后,启动并使用了hadoop,后来又重新执行了格式化命令(hdfs namenode -format),这时namenode的clusterID会重新生成,而datanode的clusterID 保持不变。
#对比clusterID :
namenode

  1. [hadoop@SY-0131 current]$ pwd
  2. /home/hadoop/labc/hdfs/name/current
  3. [hadoop@SY-0131 current]$ cat VERSION
  4. #Tue Jan 06 23:39:38 PST 2015
  5. namespaceID=313333531
  6. clusterID=CID-c402aa07-4128-4cad-9d65-75afc5241fe1
  7. cTime=0
  8. storageType=NAME_NODE
  9. blockpoolID=BP-1463638609-192.168.249.130-1420523102441
  10. layoutVersion=-60
复制代码
datanode

  1. [hadoop@SY-0132 current]$ pwd
  2. /home/hadoop/labc/hdfs/data/current
  3. [hadoop@SY-0132 current]$ cat VERSION
  4. #Tue Jan 06 23:41:36 PST 2015
  5. storageID=DS-9475efc9-f890-4890-99e2-fdedaf1540c5
  6. clusterID=CID-c402aa07-4128-4cad-9d65-75afc5241fe1
  7. cTime=0
  8. datanodeUuid=d3f6a297-9b79-4e17-9e67-631732f94698
  9. storageType=DATA_NODE
  10. layoutVersion=-56
复制代码



2、data目录的权限不够











转载自JackyKen (http://www.cnblogs.com/xiejin)




已有(5)人评论

跳转到指定楼层
hapjin 发表于 2015-3-25 09:25:13
请问下楼主有没有创建过Hadoop2.6.0的源代码分析环境?就是在eclipse中创建java项目,然后把hadoop2.6.0的源代码导入(总是报错?),就可以在eclipse中查看源代码了?
回复

使用道具 举报

luorihuanying 发表于 2015-3-25 13:59:06
多谢楼主分享
回复

使用道具 举报

hadoopdba 发表于 2015-4-1 09:43:56
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条