hadoop安装
ubuntu10.10
hadoop0.21
jdk1.6
1.安装jdk
sudoapt-getinstalljava6
2.安装设置ssh
由于Hadoop用ssh通信,因此先进行免密码登录设定,
sudo apt-get install ssh ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys ssh localhost
完成后请登入确认不用输入密码,第一次登入需按enter键,第二次就可以直接登入到系统。
ssh localhost exit ssh localhost exit
3.下载安装hadoop
•请至下载Hadoop0.21,并解开压缩文件到/opt路径。
tar zxvf hadoop-0.21.0.tar.gz sudo mv hadoop-0.21.0 /opt/ sudo chown -R hadoop:hadoop /opt/hadoop-0.21.0 sudo ln -sf /opt/hadoop-0.21.0 /opt/hadoop
4.编辑hadoop-env.sh
step4.设定hadoop-env.sh
•进入hadoop目录,做进一步的设定。我们需要修改两个档案,第一个是hadoop-env.sh,需要设定JAVA_HOME,HADOOP_HOME,PATH三个环境变量。
/opt$ cd hadoop/ /opt/hadoop$ cat >> conf/hadoop-env.sh << EOF
贴上以下信息
export JAVA_HOME=/usr/lib/jvm/java-6-sun export HADOOP_HOME=/opt/hadoop export PATH=$PATH:/opt/hadoop/bin EOF
step5.设定hadoop配置文件
编辑/opt/hadoop/conf/core-site.xml
<configuration> <property> <name>fs.default.name</name> <value>hdfs://localhost:9000</value> </property> <property> <name>hadoop.tmp.dir</name> <value>/tmp/hadoop/hadoop-${user.name}</value> </property> </configuration>
編輯/opt/hadoop/conf/hdfs-site.xml
<configuration> <property> <name>dfs.replication</name> <value>1</value> </property> </configuration>
編輯/opt/hadoop/conf/mapred-site.xml
<configuration> <property> <name>mapred.job.tracker</name> <value>localhost:9001</value> </property> </configuration>
6.格式化HDFS
•以上我们已经设定好Hadoop单机测试的环境,接着让我们来启动Hadoop相关服务,格式化namenode,secondarynamenode,tasktracker
•$cd/opt/hadoop
•$source/opt/hadoop/conf/hadoop-env.sh
•$hadoopnamenode-format
执行画面如:
09/03/2320:19:47INFOdfs.NameNode:STARTUP_MSG:
/************************************************************
STARTUP_MSG:StartingNameNode
STARTUP_MSG:host=/localhost
STARTUP_MSG:args=[-format]
STARTUP_MSG:version=0.20.3
STARTUP_MSG:build=https://svn.apache.org/repos/asf/hadoop/core/branches/branch-0.20-r736250;compiledby'ndaley'onThuJan2223:12:08UTC2009
************************************************************/
09/03/2320:19:47INFOfs.FSNamesystem:fsOwner=hadooper,hadooper
09/03/2320:19:47INFOfs.FSNamesystem:supergroup=supergroup
09/03/2320:19:47INFOfs.FSNamesystem:isPermissionEnabled=true
09/03/2320:19:47INFOdfs.Storage:Imagefileofsize82savedin0seconds.
09/03/2320:19:47INFOdfs.Storage:Storagedirectory/tmp/hadoop-hadooper/dfs/namehasbeensuccessfullyformatted.
09/03/2320:19:47INFOdfs.NameNode:SHUTDOWN_MSG:
/************************************************************
SHUTDOWN_MSG:ShuttingdownNameNodeat/localhost
************************************************************/
step7.启动Hadoop
•接着用start-all.sh来启动所有服务,包含namenode,datanode,
/opt/hadoop$bin/start-all.sh
执行画面如:
startingnamenode,loggingto/opt/hadoop/logs/hadoop-hadooper-namenode-vPro.out
localhost:startingdatanode,loggingto/opt/hadoop/logs/hadoop-hadooper-datanode-vPro.out
localhost:startingsecondarynamenode,loggingto/opt/hadoop/logs/hadoop-hadooper-secondarynamenode-vPro.out
startingjobtracker,loggingto/opt/hadoop/logs/hadoop-hadooper-jobtracker-vPro.out
step8.安装完毕测试
•启动之后,可以检查以下网址,来观看服务是否正常。Hadoop管理接口HadoopTaskTracker状态HadoopDFS状态
•http://localhost:50030/-Hadoop管理接口