下载地址: http://apache.etoak.com/hadoop/common/
打开会发现不同版本,我这里选择的是:hadoop-1.0.3.tar.gz
下载位置到:/data/software
二、安装
利用命令tar解压缩安装,解压结果如下:
[root@SC-026 ~]# cd /data/software/ [root@SC-026 software]# tar xvf hadoop-1.0.3.tar.gz
如果JAVA_HOME环境变量已经指向一个java安装,则不需要进行配置。
[root@SC-026 software]# echo $JAVA_HOME /usr/java/jdk1.7.0_01
否则,编辑../conf/hadoop-env.sh文件来设置JAVA_HOME变量
[root@SC-026 software]# cd hadoop-1.0.3/conf [root@SC-026 conf]# vim hadoop-env.sh
本机中是如下编辑:
export JAVA_HOME=/usr/java/jdk1.7.0_01 export HADOOP_HOME=//data/software/hadoop-1.0.3 export PATH=$PATH:$HADOOP_HOME/bin
:wq保存,退出。
三、配置
Hadoop的各个组件均可利用xml文件配置。
core-site.xml: 用于配置Common组件的属性;
hdfs-site.xml: 用于配置HDFS属性;
mapred-site.xml: 用于配置MapReduce属性。
这些配置文件都在以下路径中:
[root@SC-026 conf]# ls capacity-scheduler.xml hadoop-env.sh~ mapred-site.xml configuration.xsl hadoop-metrics2.properties masters core-site.xml hadoop-policy.xml slaves core-site.xml~ hdfs-site.xml ssl-client.xml.example fair-scheduler.xml log4j.properties ssl-server.xml.example hadoop-env.sh mapred-queue-acls.xml taskcontroller.cfg
通过vim依次打开3个文件,配置如下:
[root@SC-026 conf]# vim core-site.xml <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <!-- Put site-specific property overrides in this file. --> <configuration> <property> <name>fs.default.name</name> <value>hdfs://localhost</value> </property> </configuration>
[root@SC-026 conf]# vim hdfs-site.xml <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <!-- Put site-specific property overrides in this file. --> <configuration> <property> <name>dfs.replication</name> <value>1</value> </property> </configuration>
[root@SC-026 conf]# vim mapred-site.xml <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <!-- Put site-specific property overrides in this file. --> <configuration> <property> <name>mapred.job.tracker</name> <value>localhost:8021</value> </property> </configuration>
四、配置SSH
如本机中未安装,直接利用以下命令安装:
[root@SC-026 conf]#yum install ssh
启用无密码登录,输入以下命令直接回车即可:
[root@SC-026 conf]# ssh-keygen -t dsa Generating public/private dsa key pair. Enter file in which to save the key (/root/.ssh/id_dsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_dsa. Your public key has been saved in /root/.ssh/id_dsa.pub. The key fingerprint is: 4d:f1:da:e9:a4:80:4f:c2:32:d5:f8:94:55:32:70:cb [email protected]
连接本机,测试无需输入密码成功:
[root@SC-026 conf]# ssh 192.168.15.45 Last login: Thu Jun 14 08:37:05 2012
五、格式化HDFS文件系统
[root@SC-026 conf]# cd ../bin [root@SC-026 bin]# hadoop namenode -format 12/08/29 12:43:55 INFO namenode.NameNode: STARTUP_MSG: /************************************************************ STARTUP_MSG: Starting NameNode STARTUP_MSG: host = SC-026.cfind.com/192.168.15.45 STARTUP_MSG: args = [-format] STARTUP_MSG: version = 1.0.3 STARTUP_MSG: build = https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1.0 -r 1335192; compiled by 'hortonfo' on Tue May 8 20:31:25 UTC 2012 ************************************************************/ 12/08/29 12:43:56 INFO util.GSet: VM type = 64-bit 12/08/29 12:43:56 INFO util.GSet: 2% max memory = 17.77875 MB 12/08/29 12:43:56 INFO util.GSet: capacity = 2^21 = 2097152 entries 12/08/29 12:43:56 INFO util.GSet: recommended=2097152, actual=2097152 12/08/29 12:43:56 INFO namenode.FSNamesystem: fsOwner=root 12/08/29 12:43:56 INFO namenode.FSNamesystem: supergroup=supergroup 12/08/29 12:43:56 INFO namenode.FSNamesystem: isPermissionEnabled=true 12/08/29 12:43:56 INFO namenode.FSNamesystem: dfs.block.invalidate.limit=100 12/08/29 12:43:56 INFO namenode.FSNamesystem: isAccessTokenEnabled=false accessKeyUpdateInterval=0 min(s), accessTokenLifetime=0 min(s) 12/08/29 12:43:56 INFO namenode.NameNode: Caching file names occuring more than 10 times 12/08/29 12:43:56 INFO common.Storage: Image file of size 110 saved in 0 seconds. 12/08/29 12:43:56 INFO common.Storage: Storage directory [color=red]/tmp/hadoop-root/dfs/name has been successfully formatted.[/color] 12/08/29 12:43:56 INFO namenode.NameNode: SHUTDOWN_MSG: /************************************************************ SHUTDOWN_MSG: Shutting down NameNode at SC-026.cfind.com/192.168.15.45
六、启动和终止守护进程
启动进程:
[root@SC-026 bin]# start-all.sh starting namenode, logging to /data/software/hadoop-1.0.3/libexec/../logs/hadoop-root-namenode-SC-026.cfind.com.out localhost: starting datanode, logging to /data/software/hadoop-1.0.3/libexec/../logs/hadoop-root-datanode-SC-026.cfind.com.out localhost: starting secondarynamenode, logging to /data/software/hadoop-1.0.3/libexec/../logs/hadoop-root-secondarynamenode-SC-026.cfind.com.out starting jobtracker, logging to /data/software/hadoop-1.0.3/libexec/../logs/hadoop-root-jobtracker-SC-026.cfind.com.out localhost: starting tasktracker, logging to /data/software/hadoop-1.0.3/libexec/../logs/hadoop-root-tasktracker-SC-026.cfind.com.out
这里启动三个守护进程:namenode, senconaryNameNode, DataNode,用命令jps可以查看进程是否成功?
[root@SC-026 bin]# jps 6247 JobTracker 3572 org.eclipse.equinox.launcher_1.2.0.v20110502.jar 5902 NameNode 6161 SecondaryNameNode 6396 TaskTracker 6467 Jps 6029 DataNode
终止进程:
[root@SC-026 bin]# stop-all.sh stopping jobtracker localhost: stopping tasktracker stopping namenode localhost: stopping datanode localhost: stopping secondarynamenode
以上配置成功后,在浏览器中输入:http://localhost:50030 会有以下页面:
![](http://dl.iteye.com/upload/attachment/0073/0618/485a872b-d058-324b-b788-43a086a7ba1d.png)
输入:http://localhost:50070 会有以下页面:
![](http://dl.iteye.com/upload/attachment/0073/0620/d54a896d-7e30-3aa1-ba73-3f3124487f04.png)
在上述安装过程中,碰到不少问题,下一篇文章会统一说明解决。