网上的安装文档基本都是,参考 Hadoop快速入门 http://hadoop.apache.org/common/docs/r1.0.1/cn/quickstart.html
我也留一个我安装过程的步骤吧。
安装介质的下载,http://hadoop.apache.org/common/releases.html#Download
1、创建用户
groupadd hadoop
useradd –d /home/hadoop –g hadoop –s /bin/bash hadoop
passwd hadoop
su - hadoop
2、ssh免密码登录
ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
ssh localhost看一下是否可以不输入密码就登录
第一次可能需要输入yes
3、JAVA安装
这里不介绍了,最好java1.6以上版本
4、hadoop配置
解压hadoop
gunzip hadoop-1.0.1.tar.gz
tar -xvf hadoop-1.0.1.tar
增加环境变量配置
cd
vi .bash_profile
export JAVA_HOME=/home/hadoop/jdk1.6.0_30
export HADOOP_VERSION=1.0.1
export HADOOP_HOME=/home/hadoop/hadoop-1.0.1
export PATH=$HOME/bin:$HADOOP_HOME/bin:$JAVA_HOME/bin:$PATH:.
. .bash_profile
添加hadoop配置
cd hadoop-1.0.1/conf
vi hadoop-env.sh
export JAVA_HOME=/home/hadoop/jdk1.6.0_30
export HADOOP_HOME=/home/hadoop/hadoop-1.0.1
export PATH=$PATH:/opt/hadoop/bin
vi core-site.xml
<configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://localhost:9000</value>
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>/home/hadoop/hadoop-1.0.1/tmp</value>
</property>
</configuration>
vi hdfs-site.xml
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>
vi mapred-site.xml
<configuration>
<property>
<name>mapred.job.tracker</name>
<value>localhost:9001</value>
</property>
</configuration>
5、格式化和启动
格式化
hadoop namenode -format
启动
start-all.sh
查看集群状态 http://localhost:50070/dfshealth.jsp
查看JOB状态 http://localhost:50030/jobtracker.jsp
jps
1925 TaskTracker
1324 NameNode
1663 SecondaryNameNode
2412 Jps
1770 JobTracker
1470 DataNode
6、mapreduce测试
mkdir input
mkdir input
echo "a a a a a b b b c c c c c c c c c 1 1 1" > input/file
hadoop fs -mkdir /wordcount
hadoop fs -put input /wordcount
hadoop jar ${HADOOP_HOME}/hadoop-examples-1.0.1.jar wordcount /wordcount/input /wordcount/output