建立ssh无密码登陆本机
root@fonxian-desktop:~# apt-get install openssh-server
root@fonxian-desktop:~# ssh-keygen -t rsa -P " "
root@fonxian-desktop:~/.ssh# cat id_rsa.pub >> authorized_keys
Hadoop部署
下载hadoop1.2.1
http://archive.apache.org/dist/hadoop/core/hadoop-1.2.1/
apache项目下载地址http://archive.apache.org/dist/
1、使用解压命令解压
tar -zxvf hadoop1.2.1.tar.gz
2、进入解压后的hadoop文件夹中,进行配置
(1)打开conf/hadoop-env.sh
将#export JAVA_HOME=…,去掉#,将…设置为本机jdk所在的路径
(2)打开conf/core-site.xml,在中补充代码
<configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://localhost:9000</value>
</property>
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>/home/hadoop/tmp</value>
</property>
</configuration>
(3)打开conf/mapred-site.xml
<configuration>
<property>
<name>mapred.job.tracker</name>
<value>localhost:9001</value>
</property>
</configuration>
(4)打开conf/hdfs-site.xml
注意/usr/local/hadoop/,这段路径是你解压之后的hadoop所在的路径,名字也要对应,如果解压后的文件名没有修改成hadoop,就要用原先的名字hadoop1.2.1…..,修改文件名的方法,mv hadoop1.2.1 hadoop,就可以将文件名hadoop1.2.1修改成hadoop
<configuration>
<property>
<name>dfs.name.dir</name>
<value>/usr/local/hadoop/datalog1,/usr/local/hadoop/datalog2</value>
</property>
<property>
<name>dfs.data.dir</name>
<value>/usr/local/hadoop/data1,/usr/local/hadoop/data2</value>
</property>
<property>
<name>dfs.replication</name>
<value>2</value>
</property>
</configuration>
3、进入hadoop目录下,格式化hdfs文件系统,初次运行hadoop时一定要有该操作
root@fonxian-desktop:~/hadoop# bin/hadoop namenode -format
4、启动bin/start-all.sh
root@fonxian-desktop:~/hadoop# bin/start-all.sh
starting namenode, logging to /root/hadoop/libexec/../logs/hadoop-root-namenode-fonxian-desktop.out
localhost: starting datanode, logging to /root/hadoop/libexec/../logs/hadoop-root-datanode-fonxian-desktop.out
localhost: starting secondarynamenode, logging to /root/hadoop/libexec/../logs/hadoop-root-secondarynamenode-fonxian-desktop.out
starting jobtracker, logging to /root/hadoop/libexec/../logs/hadoop-root-jobtracker-fonxian-desktop.out
localhost: starting tasktracker, logging to /root/hadoop/libexec/../logs/hadoop-root-tasktracker-fonxian-desktop.out
出现Namenode,SecondaryNameNode,TaskTracker,DataNode,JobTracker五个进程,说明Hadoop单机部署成功
出现问题及其解决方法
系统关机或重启之后,启动hadoop,使用jps命令会发现namenode无法出现,这时执行下面的命令
root@fonxian-desktop:~/hadoop# bin/hadoop namenode -format
就能解决问题,暂时还不知道有其他更好的解决方法