启动hadoop,这里hadoop的版本是2.7.4
进入Hadoop的安装目录的bin目录下,采用-format命令格式化文件系统。
hadoop namenode -format
hadoop datanode -format
start-all.sh
注意:在执行格式化-format命令时,要避免NameNode的namespace ID与DataNode的namespace ID
的不一致。这是因为每格式化就会产生Name、Data、temp等临时文件记录信息,多次格式化就会产生很多的Name、Data、temp,这样容易导致ID的不同,使Hadoop不能正常运行。每次执行格式化命令是,就需要将DataNode和NameNode上原来的data、temp文件删除。
启动Hadoop,采用start-all.sh命令:start-all.sh
查看进程,采用jps命令:jps
使用了废弃的命令
DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it.
$ hadoop dfs -ls
DEPRECATED: Use ofthis script. to execute hdfs command is deprecated.
Instead use the hdfscommand for it.
原来从0.21.0版本以后,hadoop 命令换成了hdfs命令,上面的命令如同下面的命令:
$ hdfs dfs -ls // 这时就没有错误了
This script is Deprecated. Instead use stop-dfs.sh and stop-yarn.sh
This script is Deprecated. Instead use start-dfs.sh and start-yarn.sh
主从时间不对
Got exception: org.apache.hadoop.yarn.exceptions.YarnException: Unauthorized request to start container.
This token is expired. current time is 1508407745227 found 1508379544313
Note: System times on machines may be out of sync. Check system time and time zones.
调整一下master和slave的时间,使其一致吧
hostname和/etc/hosts的配置错误
Got exception: java.net.ConnectException: Call From hadoop.master/192.168.168.11 to hadoop.master:41190 failed on connection exception: java.net.ConnectException: Connection refused; For more details see: http://wiki.apache.org/hadoop/ConnectionRefused
老子,尼玛,沃日啊,
下图给出了解释,自己看
#!/bin/bash # 下面对hdfs的操作都在绝对路径下 # 在HDFS中创建input文件目录 hdfs dfs -rm /input/* # 删除结果文件 hdfs dfs -rm /output/* hdfs dfs -rmdir /output # 上传文件到/input目录 hdfs dfs -put /root/test.txt /input hadoop jar /usr/local/hadoop-2.7.4/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.4.jar wordcount /input /output hdfs dfs -ls /output # 查看输出结果的目录 # 查看输出结果 hdfs dfs -cat /output/part-r-00000
查看集群状态:
hdfs dfsadmin -report