环境:
虚拟机
CentOS6.4
Java:默认的 OpenJDK1.7.0.9
1:配置JAVA_HOME
http://blog.csdn.net/wind520/article/details/9308809
2:下载
hadoop1.1.2 http://download.csdn.net/detail/wind520/5693609
3:解压
tar
zxf
hadoop-1.1.2-bin.tar.gz
4:配置
hadoop1/conf下需要配置的文件:
1).hadoop-env.sh
2).core-site.xml
3).hdfs-site.xml
4).mapred-site.xml
如何修改请参考 http://blog.csdn.net/wind520/article/details/9225429
5:启动Hadoop
第一步,在hadoop目录下创建目录logs,用于保存日志
第二步,Format a new distributed-filesystem: 格式化namenode,创建HDFS
执行命令: ./hadoop namenode -format
[jifeng@localhost bin]$ ./hadoop namenode -format 13/07/12 17:56:14 INFO namenode.NameNode: STARTUP_MSG: /************************************************************ STARTUP_MSG: Starting NameNode STARTUP_MSG: host = localhost/127.0.0.1 STARTUP_MSG: args = [-format] STARTUP_MSG: version = 1.1.2 STARTUP_MSG: build = https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1.1 -r 1440782; compiled by 'hortonfo' on Thu Jan 31 02:03:24 UTC 2013 ************************************************************/ 13/07/12 17:56:15 INFO util.GSet: VM type = 32-bit 13/07/12 17:56:15 INFO util.GSet: 2% max memory = 19.33375 MB 13/07/12 17:56:15 INFO util.GSet: capacity = 2^22 = 4194304 entries 13/07/12 17:56:15 INFO util.GSet: recommended=4194304, actual=4194304 13/07/12 17:56:15 INFO namenode.FSNamesystem: fsOwner=jifeng 13/07/12 17:56:15 INFO namenode.FSNamesystem: supergroup=supergroup 13/07/12 17:56:15 INFO namenode.FSNamesystem: isPermissionEnabled=true 13/07/12 17:56:15 INFO namenode.FSNamesystem: dfs.block.invalidate.limit=100 13/07/12 17:56:15 INFO namenode.FSNamesystem: isAccessTokenEnabled=false accessKeyUpdateInterval=0 min(s), accessTokenLifetime=0 min(s) 13/07/12 17:56:15 INFO namenode.NameNode: Caching file names occuring more than 10 times 13/07/12 17:56:15 INFO common.Storage: Image file of size 112 saved in 0 seconds. 13/07/12 17:56:16 INFO namenode.FSEditLog: closing edit log: position=4, editlog=/tmp/hadoop-jifeng/dfs/name/current/edits 13/07/12 17:56:16 INFO namenode.FSEditLog: close success: truncate to 4, editlog=/tmp/hadoop-jifeng/dfs/name/current/edits 13/07/12 17:56:16 INFO common.Storage: Storage directory /tmp/hadoop-jifeng/dfs/name has been successfully formatted. 13/07/12 17:56:16 INFO namenode.NameNode: SHUTDOWN_MSG: /************************************************************ SHUTDOWN_MSG: Shutting down NameNode at localhost/127.0.0.1 ************************************************************/ [jifeng@localhost bin]$ ./start-all.sh starting namenode, logging to /home/jifeng/down/hadoop/libexec/../logs/hadoop-jifeng-namenode-localhost.localdomain.out jifeng@localhost's password: localhost: starting datanode, logging to /home/jifeng/down/hadoop/libexec/../logs/hadoop-jifeng-datanode-localhost.out jifeng@localhost's password: localhost: secondarynamenode running as process 3118. Stop it first. jobtracker running as process 3190. Stop it first. jifeng@localhost's password: localhost: tasktracker running as process 4973. Stop it first. [jifeng@localhost bin]$
第三步,启动Hadoop,执行命令: ./start-all.sh
需要输入3次密码.
hadoop默认的NameNode 和 JobTracker
<ul><li><span class="codefrag">NameNode</span> - <a target=_blank href="http://localhost:50070/"><span style="color:#336699;">http://localhost:50070/</span></a></li><li><span class="codefrag">JobTracker</span> - <a target=_blank href="http://localhost:50030/"><span style="color:#336699;">http://localhost:50030/</span></a></li></ul>
其他命令:
上传本地文件到HDFS
[jifeng@localhost hadoop]$ bin/hadoop fs -copyFromLocal local/hadoop.tar.gz /user/zip/hadoop.tar.gz
查看运行:
[jifeng@localhost hadoop]$ jps
2822 DataNode
3198 TaskTracker
3510 Jps
3043 JobTracker
2704 NameNode
2960 SecondaryNameNode