hadoop是由java 语言编写的主从结构分布式计算存储架构
准备工作:
-
操作系统: Ubuntu16.04
-
软件安装包:jdk-8u171-linux-x64.tar.gz ; hadoop-2.6.5.tar.gz
-
配置环境:3台虚拟机
master:192.168.122.10node1 :192.168.122.11 node1 :192.168.122.12
- 前提条件:三台虚拟机已经配置过SSH和主机名,如果没有,请自行百度配置。
第一步:安装jdk
因为hadoop是由java编写的,所以底层需要依赖java环境, jdk下载地址,可选择合适的版本 http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
在master上操作
1.下载jdk
用wget下载,如下
root@master:/opt/tar# wget http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz
root@master:/opt/tar# l
jdk-8u171-linux-x64.tar.gz
2.解压tar包
可以自己先创一个目录来解压方便以后管理,这次我就解压在opt目录下
root@master:/opt/tar# tar -zxvf jdk-8u171-linux-x64.tar.gz -C /opt/root@master:/opt# l
jdk1.8.0_171/
3.将jdk添加到环境变量中
root@master:/opt# vim /etc/profile
在文件末尾添加
export JAVA_HOME=/opt/jdk1.8.0_171
export PATH=$PATH:$JAVA_HOME/bin
4.刷新环境变量文件
root@master:/opt# echo $JAVA_HOME #没刷新前的结果为空root@master:/opt# source /etc/profile #刷新
root@master:/opt# echo $JAVA_HOME
/opt/jdk1.8.0_171
root@master:/opt# java -version #看java版本 openjdk version "1.8.0_171" OpenJDK Runtime Environment (build 1.8.0_171-8u171-b11-0ubuntu0.16.04.1-b11) OpenJDK 64-Bit Server VM (build 25.171-b11, mixed mode)
-
到这里master的上面的jdk就安装好了 接下来就是将从节点上也安装,这里就可以将master上解压好和修改好的/etc/profile文件直接拷贝到从节点上了,这样比较方便,不然还得重复配置。
-
这里我还是将jdk放在从节点的/opt目录下
root@master:/opt# scp -r jdk1.8.0_171/ node1:/opt #拷贝jdk到node1
root@master:/opt# scp -r jdk1.8.0_171/ node2:/opt #拷贝jdk到node2 root@master:/opt# scp -r /etc/profile node2:/etc/ #拷贝环境变量文件到node1 root@master:/opt# scp -r /etc/profile node2:/etc/ #拷贝环境变量文件到node2
在node1和node2上执行
source /etc/profile #刷新
- 到这里三台虚拟机的JDK就全部安装好了!
第二步:安装hadoop
从网站http://hadoop.apache.org/releases.html找到合适的hadoop的二进制版本,本次我用的是2.6.5
1. 下载
root@master:/opt/tar# wget http://www-eu.apache.org/dist/hadoop/common/hadoop-2.6.5/hadoop-2.6.5.tar.gz
2.解压
root@master:/opt/tar# tar -zxvf hadoop-2.6.5.tar.gz -C /opt/root@master:/opt# l
hadoop-2.6.5/ jdk1.8.0_171/
3.修改配置文件
进入/opt/hadoop-2.6.5/etc/hadoop目录下,这里面都是配置文件
root@master:/opt/hadoop-2.6.5/etc/hadoop# l
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 kms-acls.xml mapred-env.cmd ssl-client.xml.example
1.修改hadoop-env.sh
里面是启动的脚本文件,将jdk导入
root@master:/opt/hadoop-2.6.5/etc/hadoop# echo $JAVA_HOME #获取jdk据对路径
/opt/jdk1.8.0_171
root@master:/opt/hadoop-2.6.5/etc/hadoop# vim hadoop-env.sh
写入export JAVA_HOME=/opt/jdk1.8.0_171保存退出
2.修改core-site.xml
核心配置文件
root@master:/opt/hadoop-2.6.5/etc/hadoop# vim core-site.xml
写入
<configuration> <property> <name>fs.defaultFS</name> <value>hdfs://master:9000</value> </property> <property> <name>hadoop.tmp.dir</name> <value>file:/opt/hadoop-2.6.5/tmp</value> </property> </configuration>
里面内容以key-value形式书写,规定hadoop的默认文件系统为hdfs以对应的路径和端口(9000)。hadoop产生的临时文件存放地址(/opt/hadoop-2.6.5/tmp)
3.hdfs-site.xml
这个文件不配置也行,就会用默认值,配置了就根据配置的内容来
root@master:/opt/hadoop-2.6.5/etc/hadoop# vim hdfs-site.xml
<configuration> <property> <name>dfs.namenode.secondy.http-address</name> <value>master:50090</value> </property> <property> <name>dfs.namenode.name.dir</name> <value>file:/opt/hadoop-2.6.5/tmp/dfs/name</value> </property> <property> <name>dfs.datanode.data.dir</name> <value>file:/opt/hadoop-2.6.5/tmp/dfs/name</value> </property> <property> <name>dfs.replication</name> <value>1</value> </property> </configuration>
在这里面我配置了hdfs文件的副本数,默认为3份,但因为我的虚拟机空间不足,这里就配置了1份。大家也可以根据实际要求进行配置。
4.mapred-site.xml
这个文件是没有的,只提供一个tmp文件
root@master:/opt/hadoop-2.6.5/etc/hadoop# cp mapred-site.xml.template mapred-site.xml
root@master:/opt/hadoop-2.6.5/etc/hadoop# vim mapred-site.xml
<configuration> <property> <name>mapreduce.framework.name</name> <value>yarn</value> </property> </configuration>
mapreduce平行平台的名称(这里指定为yarn)
5.yarn-site.xml
root@master:/opt/hadoop-2.6.5/etc/hadoop# vim yarn-site.xml
<configuration> <!-- Site specific YARN configuration properties --> <property> <name>yarn.resourcemanager.hostname</name> <value>master</value> </property> <property> <name>yarn.nodemanager.aux-services</name> <value>mapreduce_shuffle</value> </property> </configuration>
这里面配置yarn的resourcemanager在哪个节点上运行(这里我I设置为master),和yarn需要的shuffle服务。
- 到这里master上的hadoop就配置好了,接下来就这这个hadoop文件复制到从节点上
root@master:/opt# scp -r hadoop-2.6.5/ node1:/opt/
root@master:/opt# scp -r hadoop-2.6.5/ node2:/opt/
2. 为Hadoop添加环境变量
输入命令:vim /etc/profile
添加如下内容: export HADOOP_HOME=/opt/hadoop-2.6.5 export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
刷新
source /etc/profile #刷新
- 将这些内容也写到从节点的文件下,或者通过scp传过去 从节点刷新。
3. 配置slaves
root@master:/opt/hadoop-2.6.5/etc/hadoop# vim slaves
- 如图所示配置意味着master节点此时既充当主节点也充当从节点(这样可以少开一个虚拟机,节省资源,服务器性能好可以不这样做)
4. 格式化文件系统
输入命令:hdfs namenode -format 看到高亮语句证明格式化成功!
安装成功!
测试
启动namenode
root@master:/opt/hadoop-2.6.5/sbin# hadoop-daemon.sh start namenode
starting namenode, logging to /opt/hadoop-2.6.5/logs/hadoop-root-namenode-master.out root@master:/opt/hadoop-2.6.5/sbin# jps 2420 NameNode 3406 Jps
成功!其中hadoop-daemon.sh是一个启动脚本
关闭namenode
root@master:/opt/hadoop-2.6.5/sbin# hadoop-daemon.sh stop namenode
stopping namenode
root@master:/opt/hadoop-2.6.5/sbin# jps 11754 Jps
一键启动所有节点(集群) namenode+datanode
主节点
root@master:/opt/hadoop-2.6.5/etc/hadoop# start-all.sh
This script is Deprecated. Instead use start-dfs.sh and start-yarn.sh
Starting namenodes on [master]
master: starting namenode, logging to /opt/hadoop-2.6.5/logs/hadoop-root-namenode-master.out node1: starting datanode, logging to /opt/hadoop-2.6.5/logs/hadoop-root-datanode-node1.out node2: starting datanode, logging to /opt/hadoop-2.6.5/logs/hadoop-root-datanode-node2.out localhost: starting datanode, logging to /opt/hadoop-2.6.5/logs/hadoop-root-datanode-master.out Starting secondary namenodes [0.0.0.0] 0.0.0.0: starting secondarynamenode, logging to /opt/hadoop-2.6.5/logs/hadoop-root-secondarynamenode-master.out starting yarn daemons starting resourcemanager, logging to /opt/hadoop-2.6.5/logs/yarn-root-resourcemanager-master.out node1: starting nodemanager, logging to /opt/hadoop-2.6.5/logs/yarn-root-nodemanager-node1.out node2: starting nodemanager, logging to /opt/hadoop-2.6.5/logs/yarn-root-nodemanager-node2.out localhost: starting nodemanager, logging to /opt/hadoop-2.6.5/logs/yarn-root-nodemanager-master.out root@master:/opt/hadoop-2.6.5/etc/hadoop# jps 14961 ResourceManager 15204 NodeManager 13125 NameNode 16188 Jps
从节点查看
root@node1:/opt# jps
20656 NodeManager
19927 DataNode
21660 Jps
root@node2:~# jps
17553 DataNode
19514 Jps
18314 NodeManager
成功!
在hdfs中创建一个目录firstTestDir
root@master:/opt/hadoop-2.6.5/hadooptmp# hadoop dfs -ls / #查看原始状态下的目录(没有)
DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it.root@master:/opt/hadoop-2.6.5/hadooptmp# hadoop dfs -mkdir /firstTestDir #创建目录 DEPRECATED: Use of this script to execute hdfs command is deprecated. Instead use the hdfs command for it. root@master:/opt/hadoop-2.6.5/hadooptmp# hadoop dfs -ls / #查看目录,已经存在 DEPRECATED: Use of this script to execute hdfs command is deprecated. Instead use the hdfs command for it. Found 1 items drwxr-xr-x - root supergroup 0 2018-05-13 21:13 /firstTestDir
向这个目录下上传文件
这里我将root下的a.txt文件上传为例
root@master:~# l
a.txt
root@master:~# hadoop dfs -put ./a.txt /firstTestDir #上传文件a.txt
DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it.root@master:~# hadoop dfs -ls /firstTestDir #查看是否成功,ok!
DEPRECATED: Use of this script to execute hdfs command is deprecated. Instead use the hdfs command for it. Found 1 items -rw-r--r-- 1 root supergroup 22002 2018-05-13 21:14 /firstTestDir/a.txt
关闭所有组件
root@master:/opt/hadoop-2.6.5/etc/hadoop# stop-all.sh
可能遇到的问题:
1.格式化时出现问题
root@master:/opt/hadoop-2.6.5/etc/hadoop# hdfs namenode –format
18/05/12 20:50:16 INFO namenode.NameNode: STARTUP_MSG:
/************************************************************ STARTUP_MSG: Starting NameNode STARTUP_MSG: host = localhost/127.0.0.1 STARTUP_MSG: args = [–format] STARTUP_MSG: version = 2.6.5 STARTUP_MSG: classpath = /opt/hadoop-2.6.5/etc/hadoop:/opt/hadoop-2.6.5/share/hadoop/common/lib/commons-httpclient-3.1.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/stax-api-1.0-2.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/avro-1.7.4.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/jackson-jaxrs-1.9.13.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/snappy-java-1.0.4.1.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/httpclient-4.2.5.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/httpcore-4.2.5.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/slf4j-api-1.7.5.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/zookeeper-3.4.6.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/guava-11.0.2.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/jackson-mapper-asl-1.9.13.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/mockito-all-1.8.5.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/jersey-core-1.9.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/commons-compress-1.4.1.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/jetty-util-6.1.26.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/commons-cli-1.2.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/jasper-runtime-5.5.23.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/hadoop-auth-2.6.5.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/apacheds-kerberos-codec-2.0.0-M15.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/activation-1.1.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/xz-1.0.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/curator-recipes-2.6.0.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/jaxb-impl-2.2.3-1.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/commons-logging-1.1.3.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/jetty-6.1.26.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/commons-collections-3.2.2.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/paranamer-2.3.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/servlet-api-2.5.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/jaxb-api-2.2.2.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/jersey-server-1.9.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/jettison-1.1.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/commons-beanutils-1.7.0.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/jersey-json-1.9.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/protobuf-java-2.5.0.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/log4j-1.2.17.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/api-asn1-api-1.0.0-M20.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/jets3t-0.9.0.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/commons-beanutils-core-1.8.0.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/junit-4.11.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/htrace-core-3.0.4.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/asm-3.2.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/jsr305-1.3.9.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/java-xmlbuilder-0.4.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/jasper-compiler-5.5.23.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/commons-codec-1.4.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/curator-framework-2.6.0.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/apacheds-i18n-2.0.0-M15.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/commons-configuration-1.6.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/api-util-1.0.0-M20.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/commons-lang-2.6.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/commons-math3-3.1.1.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/jsch-0.1.42.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/commons-el-1.0.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/netty-3.6.2.Final.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/curator-client-2.6.0.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/jsp-api-2.1.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/jackson-xc-1.9.13.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/jackson-core-asl-1.9.13.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/commons-io-2.4.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/hadoop-annotations-2.6.5.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/gson-2.2.4.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/commons-digester-1.8.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/xmlenc-0.52.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/hamcrest-core-1.3.jar:/opt/hadoop-2.6.5/share/hadoop/common/lib/commons-net-3.1.jar:/opt/hadoop-2.6.5/share/hadoop/common/hadoop-nfs-2.6.5.jar:/opt/hadoop-2.6.5/share/hadoop/common/hadoop-common-2.6.5.jar:/opt/hadoop-2.6.5/share/hadoop/common/hadoop-common-2.6.5-tests.jar:/opt/hadoop-2.6.5/share/hadoop/hdfs:/opt/hadoop-2.6.5/share/hadoop/hdfs/lib/guava-11.0.2.jar:/opt/hadoop-2.6.5/share/hadoop/hdfs/lib/jackson-mapper-asl-1.9.13.jar:/opt/hadoop-2.6.5/share/hadoop/hdfs/lib/jersey-core-1.9.jar:/opt/hadoop-2.6.5/share/hadoop/hdfs/lib/jetty-util-6.1.26.jar:/opt/hadoop-2.6.5/share/hadoop/hdfs/lib/commons-cli-1.2.jar:/opt/hadoop-2.6.5/share/hadoop/hdfs/lib/jasper-runtime-5.5.23.jar:/opt/hadoop-2.6.5/share/hadoop/hdfs/lib/commons-logging-1.1.3.jar:/opt/hadoop-2.6.5/share/hadoop/hdfs/lib/jetty-6.1.26.jar:/opt/hadoop-2.6.5/share/hadoop/hdfs/lib/commons-daemon-1.0.13.jar:/opt/hadoop-2.6.5/share/hadoop/hdfs/lib/xml-apis-1.3.04.jar:/opt/hadoop-2.6.5/share/hadoop/hdfs/lib/servlet-api-2.5.jar:/opt/hadoop-2.6.5/share/hadoop/hdfs/lib/jersey-server-1.9.jar:/opt/hadoop-2.6.5/share/hadoop/hdfs/lib/protobuf-java-2.5.0.jar:/opt/hadoop-2.6.5/share/hadoop/hdfs/lib/log4j-1.2.17.jar:/opt/hadoop-2.6.5/share/hadoop/hdfs/lib/htrace-core-3.0.4.jar:/opt/hadoop-2.6.5/share/hadoop/hdfs/lib/asm-3.2.jar:/opt/hadoop-2.6.5/share/hadoop/hdfs/lib/jsr305-1.3.9.jar:/opt/hadoop-2.6.5/share/hadoop/hdfs/lib/xercesImpl-2.9.1.jar:/opt/hadoop-2.6.5/share/hadoop/hdfs/lib/commons-codec-1.4.jar:/opt/hadoop-2.6.5/share/hadoop/hdfs/lib/commons-lang-2.6.jar:/opt/hadoop-2.6.5/share/hadoop/hdfs/lib/commons-el-1.0.jar:/opt/hadoop-2.6.5/share/hadoop/hdfs/lib/netty-3.6.2.Final.jar:/opt/hadoop-2.6.5/share/hadoop/hdfs/lib/jsp-api-2.1.jar:/opt/hadoop-2.6.5/share/hadoop/hdfs/lib/jackson-core-asl-1.9.13.jar:/opt/hadoop-2.6.5/share/hadoop/hdfs/lib/commons-io-2.4.jar:/opt/hadoop-2.6.5/share/hadoop/hdfs/lib/xmlenc-0.52.jar:/opt/hadoop-2.6.5/share/hadoop/hdfs/hadoop-hdfs-2.6.5-tests.jar:/opt/hadoop-2.6.5/share/hadoop/hdfs/hadoop-hdfs-2.6.5.jar:/opt/hadoop-2.6.5/share/hadoop/hdfs/hadoop-hdfs-nfs-2.6.5.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/commons-httpclient-3.1.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/stax-api-1.0-2.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/jackson-jaxrs-1.9.13.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/zookeeper-3.4.6.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/guava-11.0.2.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/jackson-mapper-asl-1.9.13.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/jersey-core-1.9.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/commons-compress-1.4.1.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/jetty-util-6.1.26.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/commons-cli-1.2.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/activation-1.1.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/xz-1.0.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/jaxb-impl-2.2.3-1.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/commons-logging-1.1.3.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/jetty-6.1.26.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/commons-collections-3.2.2.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/servlet-api-2.5.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/jaxb-api-2.2.2.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/jersey-server-1.9.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/jettison-1.1.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/jersey-json-1.9.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/jline-0.9.94.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/protobuf-java-2.5.0.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/log4j-1.2.17.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/guice-3.0.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/asm-3.2.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/jersey-guice-1.9.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/jsr305-1.3.9.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/leveldbjni-all-1.8.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/jersey-client-1.9.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/commons-codec-1.4.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/guice-servlet-3.0.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/commons-lang-2.6.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/netty-3.6.2.Final.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/aopalliance-1.0.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/jackson-xc-1.9.13.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/jackson-core-asl-1.9.13.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/commons-io-2.4.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/lib/javax.inject-1.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/hadoop-yarn-server-resourcemanager-2.6.5.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/hadoop-yarn-server-web-proxy-2.6.5.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/hadoop-yarn-api-2.6.5.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/hadoop-yarn-applications-distributedshell-2.6.5.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/hadoop-yarn-server-applicationhistoryservice-2.6.5.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/hadoop-yarn-server-common-2.6.5.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/hadoop-yarn-applications-unmanaged-am-launcher-2.6.5.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/hadoop-yarn-client-2.6.5.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/hadoop-yarn-common-2.6.5.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/hadoop-yarn-server-tests-2.6.5.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/hadoop-yarn-server-nodemanager-2.6.5.jar:/opt/hadoop-2.6.5/share/hadoop/yarn/hadoop-yarn-registry-2.6.5.jar:/opt/hadoop-2.6.5/share/hadoop/mapreduce/lib/avro-1.7.4.jar:/opt/hadoop-2.6.5/share/hadoop/mapreduce/lib/snappy-java-1.0.4.1.jar:/opt/hadoop-2.6.5/share/hadoop/mapreduce/lib/jackson-mapper-asl-1.9.13.jar:/opt/hadoop-2.6.5/share/hadoop/mapreduce/lib/jersey-core-1.9.jar:/opt/hadoop-2.6.5/share/hadoop/mapreduce/lib/commons-compress-1.4.1.jar:/opt/hadoop-2.6.5/share/hadoop/mapreduce/lib/xz-1.0.jar:/opt/hadoop-2.6.5/share/hadoop/mapreduce/lib/paranamer-2.3.jar:/opt/hadoop-2.6.5/share/hadoop/mapreduce/lib/jersey-server-1.9.jar:/opt/hadoop-2.6.5/share/hadoop/mapreduce/lib/protobuf-java-2.5.0.jar:/opt/hadoop-2.6.5/share/hadoop/mapreduce/lib/log4j-1.2.17.jar:/opt/hadoop-2.6.5/share/hadoop/mapreduce/lib/guice-3.0.jar:/opt/hadoop-2.6.5/share/hadoop/mapreduce/lib/junit-4.11.jar:/opt/hadoop-2.6.5/share/hadoop/mapreduce/lib/asm-3.2.jar:/opt/hadoop-2.6.5/share/hadoop/mapreduce/lib/jersey-guice-1.9.jar:/opt/hadoop-2.6.5/share/hadoop/mapreduce/lib/leveldbjni-all-1.8.jar:/opt/hadoop-2.6.5/share/hadoop/mapreduce/lib/guice-servlet-3.0.jar:/opt/hadoop-2.6.5/share/hadoop/mapreduce/lib/netty-3.6.2.Final.jar:/opt/hadoop-2.6.5/share/hadoop/mapreduce/lib/aopalliance-1.0.jar:/opt/hadoop-2.6.5/share/hadoop/mapreduce/lib/jackson-core-asl-1.9.13.jar:/opt/hadoop-2.6.5/share/hadoop/mapreduce/lib/commons-io-2.4.jar:/opt/hadoop-2.6.5/share/hadoop/mapreduce/lib/hadoop-annotations-2.6.5.jar:/opt/hadoop-2.6.5/share/hadoop/mapreduce/lib/hamcrest-core-1.3.jar:/opt/hadoop-2.6.5/share/hadoop/mapreduce/lib/javax.inject-1.jar:/opt/hadoop-2.6.5/share/hadoop/mapreduce/hadoop-mapreduce-client-jobclient-2.6.5.jar:/opt/hadoop-2.6.5/share/hadoop/mapreduce/hadoop-mapreduce-client-jobclient-2.6.5-tests.jar:/opt/hadoop-2.6.5/share/hadoop/mapreduce/hadoop-mapreduce-client-common-2.6.5.jar:/opt/hadoop-2.6.5/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.6.5.jar:/opt/hadoop-2.6.5/share/hadoop/mapreduce/hadoop-mapreduce-client-app-2.6.5.jar:/opt/hadoop-2.6.5/share/hadoop/mapreduce/hadoop-mapreduce-client-core-2.6.5.jar:/opt/hadoop-2.6.5/share/hadoop/mapreduce/hadoop-mapreduce-client-hs-plugins-2.6.5.jar:/opt/hadoop-2.6.5/share/hadoop/mapreduce/hadoop-mapreduce-client-shuffle-2.6.5.jar:/opt/hadoop-2.6.5/share/hadoop/mapreduce/hadoop-mapreduce-client-hs-2.6.5.jar:/opt/hadoop-2.6.5/contrib/capacity-scheduler/*.jar STARTUP_MSG: build = https://github.com/apache/hadoop.git -r e8c9fe0b4c252caf2ebf1464220599650f119997; compiled by 'sjlee' on 2016-10-02T23:43Z STARTUP_MSG: java = 1.8.0_171 ************************************************************/ 18/05/12 20:50:16 INFO namenode.NameNode: registered UNIX signal handlers for [TERM, HUP, INT] 18/05/12 20:50:16 INFO namenode.NameNode: createNameNode [–format] Usage: java NameNode [-backup] | [-checkpoint] | [-format [-clusterid cid ] [-force] [-nonInteractive] ] | [-upgrade [-clusterid cid] [-renameReserved<k-v pairs>] ] | [-upgradeOnly [-clusterid cid] [-renameReserved<k-v pairs>] ] | [-rollback] | [-rollingUpgrade <rollback|downgrade|started> ] | [-finalize] | [-importCheckpoint] | [-initializeSharedEdits] | [-bootstrapStandby] | [-recover [ -force] ] | [-metadataVersion ] ] 18/05/12 20:50:16 INFO namenode.NameNode: SHUTDOWN_MSG: /************************************************************ SHUTDOWN_MSG: Shutting down NameNode at localhost/127.0.0.1 ************************************************************/
原因 hdfs namenode –format "-format"中的-是中文横线,改成英文就好了
2. 通过hadoop dfsadmin -report命令查看到的全是0值,或者上传文件时提示失败,报错是没有可用的datanode。
解决方法,
- 1.可能是/etc/hosts文件里的主机名和ip对应有问题,可删除没用的对应或易混淆的。
- 2.防火墙没关
- 3.ssh没配成功
- 4.可能多次格式化后namenode和datanode上的clusterID不一致,删除主从节点上的tmp文件,重新格式化。
- 5.节点的内存。