Hadoop集群的安装和配置,主要分为两个部分:一部分是主机环境配置,主要是指Hadoop集群所依赖的操作系统及其相关软件的安装配置,包括操作系统安装、JDK安装配置、主机规划与IP地址映射配置、无密码认证会话配置;另一部分是Hadoop基本配置,主要是指Hadoop集群的各种基本组件的配置,包括HDFS的配置、MapReduce配置。
下面根据上面总结的两个部分进行详细配置实践。在配置之前,先准备一下我们使用的软件,如下所示:
- 操作系统:centos 6.2
- Sun JDK:jdk-6u31-linux-x64.bin
- Hadoop:hadoop-0.20.2.tar.gz
hadoop集群IP:
直接安装即可,执行如下命令:
- cd ~/installation
- chmod +x jdk-6u31-linux-x64.bin
- ./jdk-6u31-linux-x64.bin
cd ~/installation
chmod +x jdk-6u31-linux-x64.bin
./jdk-6u31-linux-x64.bin
JDK配置,需要修改环境变量文件vim etc/profile , 在vim etc/profile文件的最后面增加如下配置行,如下所示:
- export JAVA_HOME=/home/jdk1.6.0_31
- export JRE_HOME=/home/jdk1.6.0_31/jre
- export PATH=$PATH:/home/jdk1.6.0_31/bin
- export CLASSPATH=./:/home/jdk1.6.0_31/lib:/home/jdk1.6.0_31/jre/lib
export JAVA_HOME=/home/jdk1.6.0_31
export JRE_HOME=/home/jdk1.6.0_31/jre
export PATH=$PATH:/home/jdk1.6.0_31/bin
export CLASSPATH=./:/home/jdk1.6.0_31/lib:/home/jdk1.6.0_31/jre/lib
最后,使配置生效,并验证:
- [root@hadoop-1 ~]# java -version
- java version "1.6.0_31"
- Java(TM) SE Runtime Environment (build 1.6.0_31-b04)
- Java HotSpot(TM) 64-Bit Server VM (build 20.6-b01, mixed mode)
[root@hadoop-1 ~]# java -version
java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b04)
Java HotSpot(TM) 64-Bit Server VM (build 20.6-b01, mixed mode)
在每台机器上的配置,都按照上面的步骤进行配置。
主机规划与IP地址映射配置
集群中分为主结点(Master Node)和从结点(Slave Node)两种结点。我们选择一个主结点,两个从结点进行配置。
主结点IP为172.16.0.90,修改主结点的/etc/hosts(sudo vi /etc/hosts),内容配置如下所示(不需要改动IPV6的配置内容):
- 127.0.0.1 localhost
- 172.16.0.90 hadoop-1
- 172.16.0.91 hadoop-2
- 172.16.0.92 hadoop-3
- 172.16.0.93 hadoop-4
127.0.0.1 localhost
172.16.0.90 hadoop-1
172.16.0.91 hadoop-2
172.16.0.92 hadoop-3
172.16.0.93 hadoop-4
还要修改主机名,对应的配置文件为/etc/hostname,修改该配置文件(sudo vi /etc/hostname),内容如下所示:
hadoop-1
这里,因为在集群启动以后,hadoop-1需要登录到任意一个从结点上,执行相应的授权操作,所以,hadoop-1的/etc/hosts中要配置上集群中全部从结点的主机名到对应IP地址的映射。
从结点分别为hadoop-2(172.16.0.91)、hadoop-3(172.16.0.92)、hadoop-4(172.16.0.93)。
从结点的配置方式相同。
总结说明
为什么建议使用主机名称,而不直接使用IP地址?
第一,比较直观。通过看主机名称,你就能够知道集群中哪台机器是什么角色。
第二,扩展性好。因为通过/etc/hosts对主机名和IP地址进行了映射,即使IP变了,主机名可以保持不变。在Hadoop安装的时候,需要配置 master和slaves两个文件,如果这两个文件都使用IP的话,试想,一个具有200个结点的集群,因为一次企业的网络规划重新分配网段,导致IP 全部变更,那么这些配置都要进行修改,工作量很大。但是,如果使用主机名的话,Hadoop的配置不需要任何改变,而对于主机名到IP地址的映射配置交给系统管理员去做好了。
首先检查,你的ssh是否安装并启动,如果没有则进行安装:
- sudo apt-get install openssh-server
sudo apt-get install openssh-server
在hadoop-1主结点上,生成密钥对:
ssh-keygen -t rsa
一路回车下去即可,即可生成公钥(~/.ssh/id_rsa.pub)和私钥(~/.ssh/id_rsa)文件。
添加认证公钥,并设置权限:
- cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
- chmod 644 ~/.ssh/authorized_keys
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 644 ~/.ssh/authorized_keys
验证配置,执行如下命令:
hadoop-1
如果不需要输入密码,即可登录hadoop-1(登录本机),说明配置正确。
接着,我们要进行认证公钥的分发传播。
(1)远程拷贝master的公钥到slave-01结点上
执行如下命令:
- scp ~/.ssh/id_rsa.pub root@hadoop-2:/home/hadoop/.ssh/id_rsa.pub.master
scp ~/.ssh/id_rsa.pub root@hadoop-2:/home/hadoop/.ssh/id_rsa.pub.master
这时,因为结点之间(master到slave-01)要进行数据交换,需要输入slave-01结点的登录密码(hadoop用户),才能执行文件的远程拷贝。这里输入密码是正常的,不要与结点之间通过ssh进行无密码公钥认证混淆。
注意:分发公钥时,主要修改目标master公钥文件副本名称,以防覆盖掉从结点上已经存在并且正在使用的公钥文件。
在slave-01结点上,将master生成的密钥加入到认证密钥文件:
- cat ~/.ssh/id_rsa.pub.master >> ~/.ssh/authorized_keys
- chmod 644 ~/.ssh/authorized_keys
cat ~/.ssh/id_rsa.pub.master >> ~/.ssh/authorized_keys
chmod 644 ~/.ssh/authorized_keys
(2)远程拷贝master的公钥到slave-02结点上
类似地,执行如下命令:
- scp ~/.ssh/id_rsa.pub hadoop@slave-02:/home/hadoop/.ssh/id_rsa.pub.master
scp ~/.ssh/id_rsa.pub hadoop@slave-02:/home/hadoop/.ssh/id_rsa.pub.master
在slave-02结点上,将master生成的密钥加入到认证密钥文件,同样执行命令:
- cat ~/.ssh/id_rsa.pub.master >> ~/.ssh/authorized_keys
- chmod 644 ~/.ssh/authorized_keys
cat ~/.ssh/id_rsa.pub.master >> ~/.ssh/authorized_keys
chmod 644 ~/.ssh/authorized_keys
这时,可以验证从master结点分别登录到slave-01和slave-02结点:
- ssh slave-01
- ssh slave-02
ssh slave-01
ssh slave-02
如果不需要输入密码,则配置成功。
2、总结说明
(1)为什么要将master上的公钥分发到集群中各从结点slaves上?
密钥是用来进行安全认证的。在两个结点之间进行认证,主要有两种方式:
一是通过输入密码进行认证,你必须知道对方主机的登录用户名和口令,才能登录到对方主机上进行合法的授权操作;
二是不需要密码就能够认证,这就需要用到密钥,当一个主机A访问另一个主机B时,如果对方主机B的认证密钥配置了A的公钥,那么A访问B是就能够通过配置的A的公钥进行认证,而不需要进行输入密码认证。
Hadoop集群master分发公钥到slaves结点,并且,在各个slaves结点上配置了公钥认证,这时,当master通过ssh登录到 slaves结点上以后,可以执行相应的授权操作,例如,当master要停止整个HDFS集群(namenode、datanode)时,可以在 master上就能直接登录到各个slaves结点上,直接关闭datanode,从而关闭整个集群。这样的话,你就不需要分别登录每个datanode 上,去执行相应的关闭操作。
(2)使用dsa密钥还是rsa密钥?
DSA和RSA都可以用于认证,不过是基于不同的加密和解密算法的而已。有关DSA和RSA可以查阅相关资料。
Hadoop集群配置
Hadoop集群基本配置
1、解压缩
- tar -xvzf hadoop-0.20.2.tar.gz
tar -xvzf hadoop-0.20.2.tar.gz
2、配置Hadoop环境变量
修改vi ~/.bashrc,在文件最后面加上如下配置:
- export HADOOP_HOME=/usr/local/hadoop-0.20.2
- export PATH=$PATH:$HADOOP_HOME/bin
export HADOOP_HOME=/usr/local/hadoop-0.20.2
export PATH=$PATH:$HADOOP_HOME/bin
3、配置master和slaves文件
修改 vim /usr/local/hadoop-0.20.2/conf/masters 文件,内容如下所示:
hadoop-1
修改 vim /usr/local/hadoop-0.20.2/conf/slaves 文件,内容如下所示:
- hadoop-2
- hadoop-3
- hadoop-4
hadoop-2
hadoop-3
hadoop-4
4、配置hadoop-env.sh文件
配置文件 vim /usr/local/hadoop-0.20.2/conf/hadoop-env.sh ,只需要修改JAVA_HOME配置,如下所示:
- export JAVA_HOME=/home/jdk1.6.0_31
export JAVA_HOME=/home/jdk1.6.0_31
其它选项,可以根据需要进行配置。
5、配置conf/core-site.xml文件
配置文件vim /usr/local/hadoop-0.20.2/conf/core-site.xml的内容,如下所示:
- <?xml version="1.0"?>
- <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
-
- <!-- Do not modify this file directly. Instead, copy entries that you -->
- <!-- wish to modify from this file into core-site.xml and change them -->
- <!-- there. If core-site.xml does not already exist, create it. -->
-
- <configuration>
- <property>
- <name>fs.default.name</name>
- <value>hdfs:
- <description></description>
- </property>
- <property>
- <name>dfs.replication</name>
- <value>3</value>
- </property>
- <property>
- <name>fs.inmemory.size.mb</name>
- <value>10</value>
- <description>Larger amount of memory allocated for the in-memory file-system used to merge map-outputs at the reduce
- s.</description>
- </property>
- <property>
- <name>io.sort.factor</name>
- <value>10</value>
- <description>More streams merged at once while sorting files.</description>
- </property>
- <property>
- <name>io.sort.mb</name>
- <value>10</value>
- <description>Higher memory-limit while sorting data.</description>
- </property>
- <property>
- <name>io.file.buffer.size</name>
- <value>131072</value>
- <description>Size of read/write buffer used in SequenceFiles.</description>
- </property>
- <property>
- <name>hadoop.tmp.dir</name>
- <value>/home/hadoop/storage1/tmp/hadoop-${user.name}</value>
- <description></description>
- </property>
-
- </configuration>
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Do not modify this file directly. Instead, copy entries that you -->
<!-- wish to modify from this file into core-site.xml and change them -->
<!-- there. If core-site.xml does not already exist, create it. -->
<configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://hadoop-1:9000/</value>
<description></description>
</property>
<property>
<name>dfs.replication</name>
<value>3</value>
</property>
<property>
<name>fs.inmemory.size.mb</name>
<value>10</value>
<description>Larger amount of memory allocated for the in-memory file-system used to merge map-outputs at the reduce
s.</description>
</property>
<property>
<name>io.sort.factor</name>
<value>10</value>
<description>More streams merged at once while sorting files.</description>
</property>
<property>
<name>io.sort.mb</name>
<value>10</value>
<description>Higher memory-limit while sorting data.</description>
</property>
<property>
<name>io.file.buffer.size</name>
<value>131072</value>
<description>Size of read/write buffer used in SequenceFiles.</description>
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>/home/hadoop/storage1/tmp/hadoop-${user.name}</value>
<description></description>
</property>
</configuration>
上面配置内容,是与HDFS的基本属性相关的,一般在系统运行过程中比较固定的配置,都放到这里面。如果需要根据实际应用的变化,可以配置到hdfs-site.xml文件中,下面会解释。
6、配置 hdfs-site.xml文件
配置文件 vim /usr/local/hadoop-0.20.2/conf/hdfs-site.xml 的内容,如下所示:
- <?xml version="1.0"?>
- <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
- <configuration>
- <property>
- <name>dfs.name.dir</name>
- <value>/home/hadoop/storage1/name/a,/home/hadoop/storage1/name/b</value>
- <description>Path on the local filesystem where the NameNode stores the namespace and transactions logs persistently
- .</description>
- </property>
- <property>
- <name>dfs.data.dir</name>
- <value>/home/hadoop/storage1/data/a,/home/hadoop/storage1/data/b,/home/hadoop/storage1/data/c</value>
- <description>Comma separated list of paths on the local filesystem of a DataNode where it should store its blocks.</
- description>
- </property>
- <property>
- <name>dfs.block.size</name>
- <value>67108864</value>
- <description>HDFS blocksize of 64MB for large file-systems.</description>
- </property>
- <property>
- <name>dfs.namenode.handler.count</name>
- <value>10</value>
- <description>More NameNode server threads to handle RPCs from large number of DataNodes.</description>
- </property>
- </configuration>
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>dfs.name.dir</name>
<value>/home/hadoop/storage1/name/a,/home/hadoop/storage1/name/b</value>
<description>Path on the local filesystem where the NameNode stores the namespace and transactions logs persistently
.</description>
</property>
<property>
<name>dfs.data.dir</name>
<value>/home/hadoop/storage1/data/a,/home/hadoop/storage1/data/b,/home/hadoop/storage1/data/c</value>
<description>Comma separated list of paths on the local filesystem of a DataNode where it should store its blocks.</
description>
</property>
<property>
<name>dfs.block.size</name>
<value>67108864</value>
<description>HDFS blocksize of 64MB for large file-systems.</description>
</property>
<property>
<name>dfs.namenode.handler.count</name>
<value>10</value>
<description>More NameNode server threads to handle RPCs from large number of DataNodes.</description>
</property>
</configuration>
该配置文件配置与HDFS相关的属性,而且这些属性可能在使用计算过程中(如进行MapReduce计算),需要变化,如数据存储目录等等。如果该配置文件hdfs-site.xml和core-site.xml中同时都配置了某个属性,则hdfs-site.xml会覆盖掉 core-site.xml中配置的属性。
7、配置mapred-site.xml文件
配置文件conf/mapred-site.xml是与MapReduce计算相关的,在实际使用中根据需要进行配置某些参数,如JVM堆内存分配大小等。该配置文件的内容,配置如下所示:
- <?xml version="1.0"?>
- <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
- <configuration>
- <property>
- <name>mapred.job.tracker</name>
- <value>hdfs:
- <description>Host or IP and port of JobTracker.</description>
- </property>
- <property>
- <name>mapred.system.dir</name>
- <value>/home/hadoop/storage1/mapred/system</value>
- <description>Path on the HDFS where where the MapReduce framework stores system files.Note: This is in the default filesystem (HDFS) and must be accessible from both the server and client machines.</description>
- </property>
- <property>
- <name>mapred.local.dir</name>
- <value>/home/hadoop/storage1/mapred/local</value>
- <description>Comma-separated list of paths on the local filesystem where temporary MapReduce data is written. Note: Multiple paths help spread disk i/o.</description>
- </property>
- <property>
- <name>mapred.tasktracker.map.tasks.maximum</name>
- <value>10</value>
- <description>The maximum number of Map tasks, which are run simultaneously on a given TaskTracker, individually.Note: Defaults to 2 maps, but vary it depending on your hardware.</description>
- </property>
- <property>
- <name>mapred.tasktracker.reduce.tasks.maximum</name>
- <value>2</value>
- <description>The maximum number of Reduce tasks, which are run simultaneously on a given TaskTracker, individually. Note: Defaults to 2 reduces, but vary it depending on your hardware.</description>
- </property>
- <property>
- <name>mapred.reduce.parallel.copies</name>
- <value>5</value>
- <description>Higher number of parallel copies run by reduces to fetch outputs from very large number of maps.</description>
- </property>
- <property>
- <name>mapred.map.child.java.opts</name>
- <value>-Xmx1024M</value>
- <description>Larger heap-size for child jvms of maps.</description>
- </property>
- <property>
- <name>mapred.reduce.child.java.opts</name>
- <value>-Xms300M</value>
- <description>Larger heap-size for child jvms of reduces.</description>
- </property>
- <property>
- <name>tasktracker.http.threads</name>
- <value>5</value>
- <description>More worker threads for the TaskTracker's http server. The http server is used by reduces to fetch intermediate map-outputs.</description>
- </property>
- <property>
- <name>mapred.queue.names</name>
- <value>default</value>
- <description>Comma separated list of queues to which jobs can be submitted. Note: The MapReduce system always supports atleast one queue with the name as default. Hence, this parameter's value should always contain the string default. Some job schedulers supported in Hadoop, like the Capacity Scheduler(http:
- </property>
- <property>
- <name>mapred.acls.enabled</name>
- <value>false</value>
- <description>Boolean, specifying whether checks for queue ACLs and job ACLs are to be done for authorizing users for doing queue operations and job operations. Note: If true, queue ACLs are checked while submitting and administering jobs and job ACLs are checked for authorizing view and modification of jobs. Queue ACLs are specified using the configuration parameters of the form mapred.queue.queue-name.acl-name, defined below under mapred-queue-acls.xml. Job ACLs are described at Job Authorization(http:
- </property>
- </configuration>
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>mapred.job.tracker</name>
<value>hdfs://hadoop-1:9001/</value>
<description>Host or IP and port of JobTracker.</description>
</property>
<property>
<name>mapred.system.dir</name>
<value>/home/hadoop/storage1/mapred/system</value>
<description>Path on the HDFS where where the MapReduce framework stores system files.Note: This is in the default filesystem (HDFS) and must be accessible from both the server and client machines.</description>
</property>
<property>
<name>mapred.local.dir</name>
<value>/home/hadoop/storage1/mapred/local</value>
<description>Comma-separated list of paths on the local filesystem where temporary MapReduce data is written. Note: Multiple paths help spread disk i/o.</description>
</property>
<property>
<name>mapred.tasktracker.map.tasks.maximum</name>
<value>10</value>
<description>The maximum number of Map tasks, which are run simultaneously on a given TaskTracker, individually.Note: Defaults to 2 maps, but vary it depending on your hardware.</description>
</property>
<property>
<name>mapred.tasktracker.reduce.tasks.maximum</name>
<value>2</value>
<description>The maximum number of Reduce tasks, which are run simultaneously on a given TaskTracker, individually. Note: Defaults to 2 reduces, but vary it depending on your hardware.</description>
</property>
<property>
<name>mapred.reduce.parallel.copies</name>
<value>5</value>
<description>Higher number of parallel copies run by reduces to fetch outputs from very large number of maps.</description>
</property>
<property>
<name>mapred.map.child.java.opts</name>
<value>-Xmx1024M</value>
<description>Larger heap-size for child jvms of maps.</description>
</property>
<property>
<name>mapred.reduce.child.java.opts</name>
<value>-Xms300M</value>
<description>Larger heap-size for child jvms of reduces.</description>
</property>
<property>
<name>tasktracker.http.threads</name>
<value>5</value>
<description>More worker threads for the TaskTracker's http server. The http server is used by reduces to fetch intermediate map-outputs.</description>
</property>
<property>
<name>mapred.queue.names</name>
<value>default</value>
<description>Comma separated list of queues to which jobs can be submitted. Note: The MapReduce system always supports atleast one queue with the name as default. Hence, this parameter's value should always contain the string default. Some job schedulers supported in Hadoop, like the Capacity Scheduler(http://hadoop.apache.org/common/docs/stable/capacity_scheduler.html), support multiple queues. If such a scheduler is being used, the list of configured queue names must be specified here. Once queues are defined, users can submit jobs to a queue using the property name mapred.job.queue.name in the job configuration. There could be a separate configuration file for configuring properties of these queues that is managed by the scheduler. Refer to the documentation of the scheduler for information on the same.</description>
</property>
<property>
<name>mapred.acls.enabled</name>
<value>false</value>
<description>Boolean, specifying whether checks for queue ACLs and job ACLs are to be done for authorizing users for doing queue operations and job operations. Note: If true, queue ACLs are checked while submitting and administering jobs and job ACLs are checked for authorizing view and modification of jobs. Queue ACLs are specified using the configuration parameters of the form mapred.queue.queue-name.acl-name, defined below under mapred-queue-acls.xml. Job ACLs are described at Job Authorization(http://hadoop.apache.org/common/docs/stable/mapred_tutorial.html#Job+Authorization).</description>
</property>
</configuration>
9、安装文件远程分发
执行远程拷贝命令:
- scp -r /usr/local/hadoop-0.20.2/ root@hadoop-2:/usr/local/hadoop-0.20.2
- scp -r /usr/local/hadoop-0.20.2/ root@hadoop-3:/usr/local/hadoop-0.20.2
- scp -r /usr/local/hadoop-0.20.2/ root@hadoop-4:/usr/local/hadoop-0.20.2
scp -r /usr/local/hadoop-0.20.2/ root@hadoop-2:/usr/local/hadoop-0.20.2
scp -r /usr/local/hadoop-0.20.2/ root@hadoop-3:/usr/local/hadoop-0.20.2
scp -r /usr/local/hadoop-0.20.2/ root@hadoop-4:/usr/local/hadoop-0.20.2
10、其它配置
因为我们在上面的配置中,使用了存储目录storage,需要预先在master和slaves结点上创建该目录,执行如下命令:
Hadoop集群配置验证
1、启动HDFS集群
在master上,启动HDFS集群。
注:运行hadoop之前一定要格式化创建相关文件。
格式化HDFS,执行命令:-
- bin/hadoop namenode -format
bin/hadoop namenode -format
如果没有错误,继续执行,启动HDFS,执行命令:
- 1166 Jps
- [root@hadoop-1 hadoop-0.20.2]# bin/start-all.sh
- starting namenode, logging to /usr/local/hadoop-0.20.2/bin/../logs/hadoop-root-namenode-hadoop-1.out
- hadoop-2: starting datanode, logging to /usr/local/hadoop-0.20.2/bin/../logs/hadoop-root-datanode-hadoop-2.out
- hadoop-3: starting datanode, logging to /usr/local/hadoop-0.20.2/bin/../logs/hadoop-root-datanode-hadoop-3.out
- hadoop-4: starting datanode, logging to /usr/local/hadoop-0.20.2/bin/../logs/hadoop-root-datanode-hadoop-4.out
- hadoop-1: starting secondarynamenode, logging to /usr/local/hadoop-0.20.2/bin/../logs/hadoop-root-secondarynamenode-hadoop-1.out
- starting jobtracker, logging to /usr/local/hadoop-0.20.2/bin/../logs/hadoop-root-jobtracker-hadoop-1.out
- hadoop-3: starting tasktracker, logging to /usr/local/hadoop-0.20.2/bin/../logs/hadoop-root-tasktracker-hadoop-3.out
- hadoop-2: starting tasktracker, logging to /usr/local/hadoop-0.20.2/bin/../logs/hadoop-root-tasktracker-hadoop-2.out
- hadoop-4: starting tasktracker, logging to /usr/local/hadoop-0.20.2/bin/../logs/hadoop-root-tasktracker-hadoop-4.out
1166 Jps
[root@hadoop-1 hadoop-0.20.2]# bin/start-all.sh
starting namenode, logging to /usr/local/hadoop-0.20.2/bin/../logs/hadoop-root-namenode-hadoop-1.out
hadoop-2: starting datanode, logging to /usr/local/hadoop-0.20.2/bin/../logs/hadoop-root-datanode-hadoop-2.out
hadoop-3: starting datanode, logging to /usr/local/hadoop-0.20.2/bin/../logs/hadoop-root-datanode-hadoop-3.out
hadoop-4: starting datanode, logging to /usr/local/hadoop-0.20.2/bin/../logs/hadoop-root-datanode-hadoop-4.out
hadoop-1: starting secondarynamenode, logging to /usr/local/hadoop-0.20.2/bin/../logs/hadoop-root-secondarynamenode-hadoop-1.out
starting jobtracker, logging to /usr/local/hadoop-0.20.2/bin/../logs/hadoop-root-jobtracker-hadoop-1.out
hadoop-3: starting tasktracker, logging to /usr/local/hadoop-0.20.2/bin/../logs/hadoop-root-tasktracker-hadoop-3.out
hadoop-2: starting tasktracker, logging to /usr/local/hadoop-0.20.2/bin/../logs/hadoop-root-tasktracker-hadoop-2.out
hadoop-4: starting tasktracker, logging to /usr/local/hadoop-0.20.2/bin/../logs/hadoop-root-tasktracker-hadoop-4.out
通过浏览器访问监控:
- nameNode url: http:
-
- jobtracker url: http:
-
- task tracker url: http:
nameNode url: http://172.16.0.90:50070
jobtracker url: http://172.16.0.90:50030
task tracker url: http://172.16.0.91:50060
hadoop 命令学习:
- bin/hadoop fs -mkdir /wordcount 新增DFS文件
-
- bin/hadoop fs -rmr /wordcout 删除DFS文件
-
- bin/hadoop fs -put /opt/mapr/d.text /wordcount/d.text 向DFS中放文件
-
- bin/hadoop fs -ls /wordcount 查看DFS文件
-
- bin/hadoop jar hadoop-0.20.2-examples.jar wordcount /wordcount /output 运行examples
bin/hadoop fs -mkdir /wordcount 新增DFS文件
bin/hadoop fs -rmr /wordcout 删除DFS文件
bin/hadoop fs -put /opt/mapr/d.text /wordcount/d.text 向DFS中放文件
bin/hadoop fs -ls /wordcount 查看DFS文件
bin/hadoop jar hadoop-0.20.2-examples.jar wordcount /wordcount /output 运行examples
总结说明
在Hadoop集群外部为什么无法通过域名(如:http://master:50030)访问Hadoop集群结点?
你在Hadoop集群的外部,例如,在局域网的Windows 系统中访问master,必须能够将域名master映射到对应的IP地址,否则无法建立到目标主机的链路。在Windows 下,可以通过设置C:\Windows\System32\drivers\etc目录下面的hosts映射文件,增加如下映射内容:
- 172.16.0.90 hadoop-1
- 172.16.0.91 hadoop-2
- 172.16.0.92 hadoop-3
- 172.16.0.93 hadoop-4
172.16.0.90 hadoop-1
172.16.0.91 hadoop-2
172.16.0.92 hadoop-3
172.16.0.93 hadoop-4
保存以后,这时,你再通过域名访问Hadoop集群结点,就可以看到该结点的一些基本信息。