实验环境:
vmware9+ubuntu12+jdk7(master:192.168.0.128 )
vmware9+ubuntu12+jdk7(salve:192.168.0.129 )
首先去http://www.apache.org/dyn/closer.cgi/hadoop/common/下载hadoop,我下载的是1.2.1版本的,稳定版的
配置ubuntu的IP为固定IP,分别是192.168.0.128、192.168.0.129 参考的博客,虚拟机下ubuntu上网
解压到/opt目录下,并重命名为hadoop,赋予读写权限,省得麻烦,sudo chmod -R 777 /opt/hadoop(-R代表目录下所有文件和目录)。
1、安装ssh
sudo apt-get install ssh
sudo apt-get install rsync
2、设置ssh无密码登录
ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
测试是否可以无密码登录:ssh localhost
3、我也不知道干啥的,照着官网弄吧
The following example copies the unpacked conf directory to use as input and then finds and displays every match of the given regular expression. Output is written to the given output directory.
mkdir input
cp conf/*.xml input
bin/hadoop jar hadoop-examples-*.jar grep input output 'dfs[a-z.]+'
cat output/*
4、配置hadoop
配置JAVA_HOME:
在conf/hadoop-env.sh中
# The java implementation to use.
export JAVA_HOME=/usr/local/jdk1.7/jdk1.7.0_25
Use the following:
conf/core-site.xml:
<configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://localhost:9000</value>
</property>
</configuration>
conf/hdfs-site.xml:
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>
conf/mapred-site.xml:
<configuration>
<property>
<name>mapred.job.tracker</name>
<value>localhost:9001</value>
</property>
</configuration>
5、格式化&启动hadood
Format a new distributed-filesystem:
$ bin/hadoop namenode -format
Start the hadoop daemons:
$ bin/start-all.sh
日志在
${HADOOP_HOME}/logs
6、查看hadoop运行状态(至此hadoop的单点配置已经大功告成)
Browse the web interface for the NameNode and the JobTracker; by default they are available at:
NameNode - http://localhost:50070/
JobTracker - http://localhost:50030/
7、停止hadoop
When you're done, stop the daemons with:
$ bin/stop-all.sh