赞
踩
主从结构:集群中有部分节点充当主服务器,其他节点相对的充当从服务器的结构。主从结构一般分为:一主多从
、多主多从
。
Hadoop
中的HDFS
和YARN
都是主从结构,主从结构有多种叫法:主节点-从节点
、master-slave
、管理者-工作者
、leader-follower
Hadoop集群中各个角色的名称:
服务 | 主节点 | 从节点 |
---|---|---|
HDFS | NameNode | DataNode |
YARN | ResourceManager | NodeManager |
1、准备一台CentOS7的虚拟机
2、虚拟机中已安装JDK,如果没有,请参考《CentOS7安装JDK1.8简单体验(java开发必备)》
3、准备好Hadoop的安装文件,本次使用的版本是hadoop-2.7.3.tar.gz
,可以点击进行下载。
服务主机 | ip地址 | 主机名称 | 用户 | HDFS | YARN |
---|---|---|---|---|---|
Hadoop-Msater | 192.192.168.223.131 | hadoop-master | root | NameNode,DataNode | ResourceManager,NodeManager |
Hadoop-Slave1 | 192.192.168.223.128 | hadoop-slave1 | root | SecondaryNameNode,DataNode | NodeManager |
Hadoop-Slave2 | 192.192.168.223.129 | hadoop-slave2 | root | DataNode | NodeManager |
Hadoop-Slave3 | 192.192.168.223.130 | hadoop-slave3 | root | DataNode | NodeManager |
规划安装目录:/usr/local/hadoop/apps
规划数据目录:/usr/local/hadoop/data
说明:请自行创建或者自定义安装目录
首先将压缩文包拷贝到/usr/local/hadoop/apps
下,然后执行解压程序
[root@hadoop-master apps]# cd /usr/local/hadoop/apps/
[root@hadoop-master apps]# ls
hadoop-2.7.3.tar.gz
[root@hadoop-master apps]# tar zxvf hadoop-2.7.3.tar.gz
配置文件的目录在:/usr/local/hadoop/apps/hadoop-2.7.3/etc/hadoop/
[root@hadoop-master apps]# cd /usr/local/hadoop/apps/hadoop-2.7.3/etc/hadoop/
[root@hadoop-master hadoop]# ls
capacity-scheduler.xml hadoop-env.sh httpfs-env.sh kms-env.sh mapred-env.sh ssl-server.xml.example
configuration.xsl hadoop-metrics2.properties httpfs-log4j.properties kms-log4j.properties mapred-queues.xml.template yarn-env.cmd
container-executor.cfg hadoop-metrics.properties httpfs-signature.secret kms-site.xml mapred-site.xml.template yarn-env.sh
core-site.xml hadoop-policy.xml httpfs-site.xml log4j.properties slaves yarn-site.xml
hadoop-env.cmd hdfs-site.xml
hadoop-env.sh
配置打开hadoop-env.sh
配置文件,修改JDK环境变量
[root@hadoop-master hadoop]# vi hadoop-env.sh
默认的环境变量取系统环境变量${JAVA_HOME}
,当然也可以自己修改成。
# The java implementation to use.
export JAVA_HOME=${JAVA_HOME}
因为我本机配置过JDK环境变量,因此此处不做修改。
[root@hadoop-master hadoop]# echo $JAVA_HOME
/usr/local/jdk/jdk1.8.0_261
注意:我上面的示范太想当然了,这里必须配置jdk绝对路径,不然启动会报错
。
正确的配置是按照如下修改:
[root@hadoop-master hadoop]# vi hadoop-env.sh
# The java implementation to use.
export JAVA_HOME=/usr/local/jdk/jdk1.8.0_261
core-site.xml
配置首先打开core-site.xml
配置文件
[root@hadoop-master hadoop]# vim core-site.xml
配置参数介绍:
fs.defaultFS : 这个属性用来指定namenode的hdfs协议的文件系统通信地址,可以指定一个主机+端口,也可以指定为一个namenode服务(这个服务内部可以有多台namenode实现ha的namenode服务
hadoop.tmp.dir : hadoop集群在工作的时候存储的一些临时文件的目录
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://hadoop-master:9000</value>
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>/usr/local/hadoop/data/hadoopdata</value>
</property>
</configuration>
hdfs-site.xml
配置[root@hadoop-master hadoop]# vi hdfs-site.xml
dfs.namenode.name.dir:namenode数据的存放地点。也就是namenode元数据存放的地方,记录了hdfs系统中文件的元数据。
dfs.datanode.data.dir: datanode数据的存放地点。也就是block块存放的目录了。
dfs.replication:hdfs的副本数设置。也就是上传一个文件,其分割为block块后,每个block的冗余副本个数,默认配置是3。
dfs.secondary.http.address:secondarynamenode 运行节点的信息,和 namenode 不同节点
<configuration> <property> <name>dfs.namenode.name.dir</name> <value>/usr/local/hadoop/data/hadoopdata/name</value> <description>为了保证元数据的安全一般配置多个不同目录</description> </property> <property> <name>dfs.datanode.data.dir</name> <value>/usr/local/hadoop/data/hadoopdata/data</value> <description>datanode 的数据存储目录</description> </property> <property> <name>dfs.replication</name> <value>2</value> <description>HDFS 的数据块的副本存储个数, 默认是3</description> </property> <property> <name>dfs.secondary.http.address</name> <value>hadoop-slave1:50090</value> <description>secondarynamenode 运行节点的信息,和 namenode 不同节点</description> </property> </configuration>
mapred-site.xml
配置[root@hadoop-master hadoop]# cp mapred-site.xml.template mapred-site.xml
[root@hadoop-master hadoop]# vi mapred-site.xml
mapreduce.framework.name:指定mr框架为yarn方式,Hadoop二代MP也基于资源管理系统Yarn来运行。
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>
yarn-site.xml
配置[root@hadoop-master hadoop]# vi yarn-site.xml
yarn.resourcemanager.hostname:yarn总管理器的IPC通讯地址
yarn.nodemanager.aux-services:NodeManager上运行的附属服务。需配置成mapreduce_shuffle,才可运行MapReduce程序,默认""
<configuration>
<!-- Site specific YARN configuration properties -->
<property>
<name>yarn.resourcemanager.hostname</name>
<value>hadoop-master</value>
</property>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
<description>YARN 集群为 MapReduce 程序提供的 shuffle 服务</description>
</property>
</configuration>
slaves
配置[root@hadoop-master hadoop]# vi slaves
hadoop-master
hadoop-slave1
hadoop-slave2
hadoop-slave3
增加Hadoop环境变量
将光标调整到文件尾部,并添加以下内容
export HADOOP_HOME=/usr/local/hadoop/apps/hadoop-2.7.3
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:
更新配置文件,并查看hadoop版本
[root@hadoop-master hadoop]# source /etc/profile
[root@hadoop-master hadoop]# hadoop version
Hadoop 2.7.3
Subversion https://git-wip-us.apache.org/repos/asf/hadoop.git -r baa91f7c6bc9cb92be5982de4719c1c8af91ccff
Compiled by root on 2016-08-18T01:41Z
Compiled with protoc 2.5.0
From source with checksum 2e4ce5f957ea4db193bce3734ff29ff4
This command was run using /usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/hadoop-common-2.7.3.jar
将Hadoop-Master克隆成三份:
Hadoop-Slave1
Hadoop-Slave2
Hadoop-Slave3
修改主机名:
Hadoop-Slave1主机名修改为:hadoop-slave1
[root@hadoop-master ~]# hostnamectl set-hostname hadoop-slave1
[root@hadoop-master ~]# hostname
hadoop-slave1
Hadoop-Slave2主机名修改为:hadoop-slave2
[root@hadoop-master ~]# hostnamectl set-hostname hadoop-slave2
[root@hadoop-master ~]# hostname
hadoop-slave2
Hadoop-Slave3主机名修改为:hadoop-slave3
[root@hadoop-master ~]# hostnamectl set-hostname hadoop-slave3
[root@hadoop-master ~]# hostname
hadoop-slave3
并且在每一台的主机里添加ip地址:
[root@hadoop-master ~]# vi /etc/hosts
192.168.223.131 hadoop-master
192.168.223.128 hadoop-slave1
192.168.223.129 hadoop-slave2
192.168.223.130 hadoop-slave3
主机之间设置免密登录
可以参考《CentOS7虚拟机之间设置免密登录》
注意:HDFS初始化只能在主节点上进行
[root@hadoop-master hadoop]# hadoop namenode -format
初始化结果:
[root@hadoop-master hadoop]# hadoop namenode -format DEPRECATED: Use of this script to execute hdfs command is deprecated. Instead use the hdfs command for it. 20/08/08 13:23:37 INFO namenode.NameNode: STARTUP_MSG: /************************************************************ STARTUP_MSG: Starting NameNode STARTUP_MSG: host = hadoop-master/192.168.223.131 STARTUP_MSG: args = [-format] STARTUP_MSG: version = 2.7.3 STARTUP_MSG: classpath = /usr/local/hadoop/apps/hadoop-2.7.3/etc/hadoop:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/jaxb-impl-2.2.3-1.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/jaxb-api-2.2.2.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/stax-api-1.0-2.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/activation-1.1.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/jackson-core-asl-1.9.13.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/jackson-mapper-asl-1.9.13.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/jackson-jaxrs-1.9.13.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/jackson-xc-1.9.13.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/jersey-server-1.9.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/asm-3.2.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/log4j-1.2.17.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/jets3t-0.9.0.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/httpclient-4.2.5.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/httpcore-4.2.5.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/java-xmlbuilder-0.4.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/commons-lang-2.6.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/commons-configuration-1.6.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/commons-digester-1.8.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/commons-beanutils-1.7.0.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/commons-beanutils-core-1.8.0.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/slf4j-api-1.7.10.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/avro-1.7.4.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/paranamer-2.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/snappy-java-1.0.4.1.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/commons-compress-1.4.1.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/xz-1.0.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/protobuf-java-2.5.0.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/gson-2.2.4.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/hadoop-auth-2.7.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/apacheds-kerberos-codec-2.0.0-M15.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/apacheds-i18n-2.0.0-M15.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/api-asn1-api-1.0.0-M20.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/api-util-1.0.0-M20.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/zookeeper-3.4.6.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/netty-3.6.2.Final.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/curator-framework-2.7.1.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/curator-client-2.7.1.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/jsch-0.1.42.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/curator-recipes-2.7.1.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/htrace-core-3.1.0-incubating.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/junit-4.11.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/hamcrest-core-1.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/mockito-all-1.8.5.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/hadoop-annotations-2.7.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/guava-11.0.2.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/jsr305-3.0.0.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/commons-cli-1.2.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/commons-math3-3.1.1.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/xmlenc-0.52.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/commons-httpclient-3.1.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/commons-logging-1.1.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/commons-codec-1.4.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/commons-io-2.4.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/commons-net-3.1.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/commons-collections-3.2.2.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/servlet-api-2.5.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/jetty-6.1.26.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/jetty-util-6.1.26.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/jsp-api-2.1.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/jersey-core-1.9.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/jersey-json-1.9.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/lib/jettison-1.1.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/hadoop-common-2.7.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/hadoop-common-2.7.3-tests.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/common/hadoop-nfs-2.7.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/hdfs:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/hdfs/lib/commons-codec-1.4.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/hdfs/lib/log4j-1.2.17.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/hdfs/lib/commons-logging-1.1.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/hdfs/lib/netty-3.6.2.Final.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/hdfs/lib/guava-11.0.2.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/hdfs/lib/jsr305-3.0.0.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/hdfs/lib/commons-cli-1.2.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/hdfs/lib/xmlenc-0.52.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/hdfs/lib/commons-io-2.4.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/hdfs/lib/servlet-api-2.5.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/hdfs/lib/jetty-6.1.26.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/hdfs/lib/jetty-util-6.1.26.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/hdfs/lib/jersey-core-1.9.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/hdfs/lib/jackson-core-asl-1.9.13.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/hdfs/lib/jackson-mapper-asl-1.9.13.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/hdfs/lib/jersey-server-1.9.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/hdfs/lib/asm-3.2.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/hdfs/lib/commons-lang-2.6.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/hdfs/lib/protobuf-java-2.5.0.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/hdfs/lib/htrace-core-3.1.0-incubating.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/hdfs/lib/commons-daemon-1.0.13.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/hdfs/lib/netty-all-4.0.23.Final.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/hdfs/lib/xercesImpl-2.9.1.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/hdfs/lib/xml-apis-1.3.04.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/hdfs/lib/leveldbjni-all-1.8.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/hdfs/hadoop-hdfs-2.7.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/hdfs/hadoop-hdfs-2.7.3-tests.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/hdfs/hadoop-hdfs-nfs-2.7.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/zookeeper-3.4.6-tests.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/commons-lang-2.6.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/guava-11.0.2.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/jsr305-3.0.0.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/commons-logging-1.1.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/protobuf-java-2.5.0.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/commons-cli-1.2.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/log4j-1.2.17.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/jaxb-api-2.2.2.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/stax-api-1.0-2.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/activation-1.1.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/commons-compress-1.4.1.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/xz-1.0.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/servlet-api-2.5.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/commons-codec-1.4.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/jetty-util-6.1.26.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/jersey-core-1.9.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/jersey-client-1.9.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/jackson-core-asl-1.9.13.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/jackson-mapper-asl-1.9.13.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/jackson-jaxrs-1.9.13.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/jackson-xc-1.9.13.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/guice-servlet-3.0.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/guice-3.0.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/javax.inject-1.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/aopalliance-1.0.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/commons-io-2.4.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/jersey-server-1.9.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/asm-3.2.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/jersey-json-1.9.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/jettison-1.1.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/jaxb-impl-2.2.3-1.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/jersey-guice-1.9.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/zookeeper-3.4.6.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/netty-3.6.2.Final.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/leveldbjni-all-1.8.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/commons-collections-3.2.2.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/lib/jetty-6.1.26.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-api-2.7.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-common-2.7.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-server-common-2.7.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-server-nodemanager-2.7.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-server-web-proxy-2.7.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-server-applicationhistoryservice-2.7.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-server-resourcemanager-2.7.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-server-tests-2.7.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-client-2.7.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-server-sharedcachemanager-2.7.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-applications-distributedshell-2.7.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-applications-unmanaged-am-launcher-2.7.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/yarn/hadoop-yarn-registry-2.7.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/mapreduce/lib/protobuf-java-2.5.0.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/mapreduce/lib/avro-1.7.4.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/mapreduce/lib/jackson-core-asl-1.9.13.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/mapreduce/lib/jackson-mapper-asl-1.9.13.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/mapreduce/lib/paranamer-2.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/mapreduce/lib/snappy-java-1.0.4.1.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/mapreduce/lib/commons-compress-1.4.1.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/mapreduce/lib/xz-1.0.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/mapreduce/lib/hadoop-annotations-2.7.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/mapreduce/lib/commons-io-2.4.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/mapreduce/lib/jersey-core-1.9.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/mapreduce/lib/jersey-server-1.9.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/mapreduce/lib/asm-3.2.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/mapreduce/lib/log4j-1.2.17.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/mapreduce/lib/netty-3.6.2.Final.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/mapreduce/lib/leveldbjni-all-1.8.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/mapreduce/lib/guice-3.0.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/mapreduce/lib/javax.inject-1.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/mapreduce/lib/aopalliance-1.0.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/mapreduce/lib/jersey-guice-1.9.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/mapreduce/lib/guice-servlet-3.0.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/mapreduce/lib/junit-4.11.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/mapreduce/lib/hamcrest-core-1.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-client-core-2.7.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-client-common-2.7.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-client-shuffle-2.7.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-client-app-2.7.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-client-hs-2.7.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-client-jobclient-2.7.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-client-hs-plugins-2.7.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.3.jar:/usr/local/hadoop/apps/hadoop-2.7.3/share/hadoop/mapreduce/hadoop-mapreduce-client-jobclient-2.7.3-tests.jar:/usr/local/hadoop/apps/hadoop-2.7.3/contrib/capacity-scheduler/*.jar:/usr/local/hadoop/apps/hadoop-2.7.3/contrib/capacity-scheduler/*.jar STARTUP_MSG: build = https://git-wip-us.apache.org/repos/asf/hadoop.git -r baa91f7c6bc9cb92be5982de4719c1c8af91ccff; compiled by 'root' on 2016-08-18T01:41Z STARTUP_MSG: java = 1.8.0_261 ************************************************************/ 20/08/08 13:23:37 INFO namenode.NameNode: registered UNIX signal handlers for [TERM, HUP, INT] 20/08/08 13:23:37 INFO namenode.NameNode: createNameNode [-format] 20/08/08 13:23:38 WARN common.Util: Path /usr/local/hadoop/data/hadoopdata/name should be specified as a URI in configuration files. Please update hdfs configuration. 20/08/08 13:23:38 WARN common.Util: Path /usr/local/hadoop/data/hadoopdata/name should be specified as a URI in configuration files. Please update hdfs configuration. Formatting using clusterid: CID-fce3113f-05f1-4de1-bc28-6927ce8d03ca 20/08/08 13:23:38 INFO namenode.FSNamesystem: No KeyProvider found. 20/08/08 13:23:38 INFO namenode.FSNamesystem: fsLock is fair:true 20/08/08 13:23:38 INFO blockmanagement.DatanodeManager: dfs.block.invalidate.limit=1000 20/08/08 13:23:38 INFO blockmanagement.DatanodeManager: dfs.namenode.datanode.registration.ip-hostname-check=true 20/08/08 13:23:38 INFO blockmanagement.BlockManager: dfs.namenode.startup.delay.block.deletion.sec is set to 000:00:00:00.000 20/08/08 13:23:38 INFO blockmanagement.BlockManager: The block deletion will start around 2020 八月 08 13:23:38 20/08/08 13:23:38 INFO util.GSet: Computing capacity for map BlocksMap 20/08/08 13:23:38 INFO util.GSet: VM type = 64-bit 20/08/08 13:23:38 INFO util.GSet: 2.0% max memory 966.7 MB = 19.3 MB 20/08/08 13:23:38 INFO util.GSet: capacity = 2^21 = 2097152 entries 20/08/08 13:23:38 INFO blockmanagement.BlockManager: dfs.block.access.token.enable=false 20/08/08 13:23:38 INFO blockmanagement.BlockManager: defaultReplication = 2 20/08/08 13:23:38 INFO blockmanagement.BlockManager: maxReplication = 512 20/08/08 13:23:38 INFO blockmanagement.BlockManager: minReplication = 1 20/08/08 13:23:38 INFO blockmanagement.BlockManager: maxReplicationStreams = 2 20/08/08 13:23:38 INFO blockmanagement.BlockManager: replicationRecheckInterval = 3000 20/08/08 13:23:38 INFO blockmanagement.BlockManager: encryptDataTransfer = false 20/08/08 13:23:38 INFO blockmanagement.BlockManager: maxNumBlocksToLog = 1000 20/08/08 13:23:38 INFO namenode.FSNamesystem: fsOwner = root (auth:SIMPLE) 20/08/08 13:23:38 INFO namenode.FSNamesystem: supergroup = supergroup 20/08/08 13:23:38 INFO namenode.FSNamesystem: isPermissionEnabled = true 20/08/08 13:23:38 INFO namenode.FSNamesystem: HA Enabled: false 20/08/08 13:23:38 INFO namenode.FSNamesystem: Append Enabled: true 20/08/08 13:23:39 INFO util.GSet: Computing capacity for map INodeMap 20/08/08 13:23:39 INFO util.GSet: VM type = 64-bit 20/08/08 13:23:39 INFO util.GSet: 1.0% max memory 966.7 MB = 9.7 MB 20/08/08 13:23:39 INFO util.GSet: capacity = 2^20 = 1048576 entries 20/08/08 13:23:39 INFO namenode.FSDirectory: ACLs enabled? false 20/08/08 13:23:39 INFO namenode.FSDirectory: XAttrs enabled? true 20/08/08 13:23:39 INFO namenode.FSDirectory: Maximum size of an xattr: 16384 20/08/08 13:23:39 INFO namenode.NameNode: Caching file names occuring more than 10 times 20/08/08 13:23:39 INFO util.GSet: Computing capacity for map cachedBlocks 20/08/08 13:23:39 INFO util.GSet: VM type = 64-bit 20/08/08 13:23:39 INFO util.GSet: 0.25% max memory 966.7 MB = 2.4 MB 20/08/08 13:23:39 INFO util.GSet: capacity = 2^18 = 262144 entries 20/08/08 13:23:39 INFO namenode.FSNamesystem: dfs.namenode.safemode.threshold-pct = 0.9990000128746033 20/08/08 13:23:39 INFO namenode.FSNamesystem: dfs.namenode.safemode.min.datanodes = 0 20/08/08 13:23:39 INFO namenode.FSNamesystem: dfs.namenode.safemode.extension = 30000 20/08/08 13:23:39 INFO metrics.TopMetrics: NNTop conf: dfs.namenode.top.window.num.buckets = 10 20/08/08 13:23:39 INFO metrics.TopMetrics: NNTop conf: dfs.namenode.top.num.users = 10 20/08/08 13:23:39 INFO metrics.TopMetrics: NNTop conf: dfs.namenode.top.windows.minutes = 1,5,25 20/08/08 13:23:39 INFO namenode.FSNamesystem: Retry cache on namenode is enabled 20/08/08 13:23:39 INFO namenode.FSNamesystem: Retry cache will use 0.03 of total heap and retry cache entry expiry time is 600000 millis 20/08/08 13:23:39 INFO util.GSet: Computing capacity for map NameNodeRetryCache 20/08/08 13:23:39 INFO util.GSet: VM type = 64-bit 20/08/08 13:23:39 INFO util.GSet: 0.029999999329447746% max memory 966.7 MB = 297.0 KB 20/08/08 13:23:39 INFO util.GSet: capacity = 2^15 = 32768 entries 20/08/08 13:23:39 INFO namenode.FSImage: Allocated new BlockPoolId: BP-1166270090-192.168.223.131-1596864219273 20/08/08 13:23:39 INFO common.Storage: Storage directory /usr/local/hadoop/data/hadoopdata/name has been successfully formatted. 20/08/08 13:23:39 INFO namenode.FSImageFormatProtobuf: Saving image file /usr/local/hadoop/data/hadoopdata/name/current/fsimage.ckpt_0000000000000000000 using no compression 20/08/08 13:23:39 INFO namenode.FSImageFormatProtobuf: Image file /usr/local/hadoop/data/hadoopdata/name/current/fsimage.ckpt_0000000000000000000 of size 351 bytes saved in 0 seconds. 20/08/08 13:23:39 INFO namenode.NNStorageRetentionManager: Going to retain 1 images with txid >= 0 20/08/08 13:23:39 INFO util.ExitUtil: Exiting with status 0 20/08/08 13:23:39 INFO namenode.NameNode: SHUTDOWN_MSG: /************************************************************ SHUTDOWN_MSG: Shutting down NameNode at hadoop-master/192.168.223.131 ************************************************************/
启动HDFS,不管在集群哪个节点都可以
[root@hadoop-master ~]# start-dfs.sh
Starting namenodes on [hadoop-master]
root@hadoop-master's password:
hadoop-master: starting namenode, logging to /usr/local/hadoop/apps/hadoop-2.7.3/logs/hadoop-root-namenode-hadoop-master.out
root@hadoop-master's password:
hadoop-slave1: starting datanode, logging to /usr/local/hadoop/apps/hadoop-2.7.3/logs/hadoop-root-datanode-hadoop-slave1.out
hadoop-slave2: starting datanode, logging to /usr/local/hadoop/apps/hadoop-2.7.3/logs/hadoop-root-datanode-hadoop-slave2.out
hadoop-slave3: starting datanode, logging to /usr/local/hadoop/apps/hadoop-2.7.3/logs/hadoop-root-datanode-hadoop-slave3.out
hadoop-master: starting datanode, logging to /usr/local/hadoop/apps/hadoop-2.7.3/logs/hadoop-root-datanode-hadoop-master.out
Starting secondary namenodes [hadoop-slave1]
hadoop-slave1: starting secondarynamenode, logging to /usr/local/hadoop/apps/hadoop-2.7.3/logs/hadoop-root-secondarynamenode-hadoop-slave1.out
[root@hadoop-master ~]#
历尽艰难终于启动成功了,期间遇到了输入密码两次,刚开始不知道于是乎傻傻的等,然后杀进程,重复了好几次操作。下面介绍一个快速杀进程的命令:
ps -ef | grep hadoop | grep -v grep | cut -c 9-15 | xargs kill -s 9
注意:这个只能在主节点进行启动。
[root@hadoop-master ~]# start-yarn.sh
starting yarn daemons
starting resourcemanager, logging to /usr/local/hadoop/apps/hadoop-2.7.3/logs/yarn-root-resourcemanager-hadoop-master.out
root@hadoop-master's password:
hadoop-slave2: starting nodemanager, logging to /usr/local/hadoop/apps/hadoop-2.7.3/logs/yarn-root-nodemanager-hadoop-slave2.out
hadoop-slave3: starting nodemanager, logging to /usr/local/hadoop/apps/hadoop-2.7.3/logs/yarn-root-nodemanager-hadoop-slave3.out
hadoop-slave1: starting nodemanager, logging to /usr/local/hadoop/apps/hadoop-2.7.3/logs/yarn-root-nodemanager-hadoop-slave1.out
hadoop-master: starting nodemanager, logging to /usr/local/hadoop/apps/hadoop-2.7.3/logs/yarn-root-nodemanager-hadoop-master.out
[root@hadoop-master ~]#
hadoop-master
[root@hadoop-master ~]# jps
8737 Jps
8003 DataNode
8317 ResourceManager
7870 NameNode
8606 NodeManager
hadoop-slave1
[root@hadoop-slave1 hadoop]# jps
6055 NodeManager
5913 SecondaryNameNode
6185 Jps
5818 DataNode
hadoop-slave2
[root@hadoop-slave2 hadoop]# jps
4922 NodeManager
5068 Jps
4751 DataNode
hadoop-slave3
[root@hadoop-slave3 hadoop]# jps
5184 Jps
4868 DataNode
5038 NodeManager
HDFS:http://192.168.223.131:50070
YARN:http://192.168.223.131:8088
这里我只看到了一个节点:
网上查询原因,大意是:直接克隆的机器storageID一样,导致访问总是出现错误。
可以参考:hadoop集群通过web管理界面只显示一个节点,datanode只启动一个
但是,但是,但是我几乎试遍了所有的方式,耗时3个多小时都没有解决,几乎要放弃了,突然想到一个问题,我虚拟机的防火墙还开着,集群之间需要通信是否被防火墙所阻挡了
???
尝试关闭虚拟机防火墙:
systemctl stop firewalld.service
然后奇迹出现了:
看到这个结果,也不知道想哭还是想笑,以后一定要引以为戒。
1. start-all.sh 启动所有的Hadoop守护进程。包括NameNode、 Secondary NameNode、DataNode、JobTracker、 TaskTrack 2. stop-all.sh 停止所有的Hadoop守护进程。包括NameNode、 Secondary NameNode、DataNode、JobTracker、 TaskTrack 3. start-dfs.sh 启动Hadoop HDFS守护进程NameNode、SecondaryNameNode和DataNode 4. stop-dfs.sh 停止Hadoop HDFS守护进程NameNode、SecondaryNameNode和DataNode 5. hadoop-daemons.sh start namenode 单独启动NameNode守护进程 6. hadoop-daemons.sh stop namenode 单独停止NameNode守护进程 7. hadoop-daemons.sh start datanode 单独启动DataNode守护进程 8. hadoop-daemons.sh stop datanode 单独停止DataNode守护进程 9. hadoop-daemons.sh start secondarynamenode 单独启动SecondaryNameNode守护进程 10. hadoop-daemons.sh stop secondarynamenode 单独停止SecondaryNameNode守护进程 11. start-mapred.sh 启动Hadoop MapReduce守护进程JobTracker和TaskTracker 12. stop-mapred.sh 停止Hadoop MapReduce守护进程JobTracker和TaskTracker 13. hadoop-daemons.sh start jobtracker 单独启动JobTracker守护进程 14. hadoop-daemons.sh stop jobtracker 单独停止JobTracker守护进程 15. hadoop-daemons.sh start tasktracker 单独启动TaskTracker守护进程 16. hadoop-daemons.sh stop tasktracker 单独启动TaskTracker守护进程
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。