手机版
你好,游客 登录 注册
背景:
阅读新闻

Linux下从安装JDK到安装SSH到Hadoop单机伪分布式部署

[日期:2011-10-11] 来源:Linux社区  作者:ydd326 [字体:大 中 小]

环境: Ubuntu 10.10  JDK1.6.0.27  Hadoop 0.20.2

一. ubuntu 下 JDK 的安装:

1. 下载jdk-6u27-linux-i586.bin

2. 拷贝到/usr/java,设置文件的操作权限

3. $ ./jdk-6u27-linux-i586.bin开始安装

4. 设置环境变量 vi /etc/profile 在文件最后添加

JAVA_HOME=/usr/Java/jdk1.6.0_27

PATH=$JAVA_HOME/bin:$PATH

CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar

export PATH JAVA_HOME CLASSPATH

5. 设置用户安装的JDK为默认JDK,执行

$ update-alternatives --install /usr/bin/java java /usr/lib/jvm/java/jdk1.6.0_12/bin/java 300

$ update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/java/jdk1.6.0_12/bin/javac 300

$ update-alternatives --config java

6. 输入 java -version 成功安装

二.ubuntu下安装ssh:

1. $ sudo apt-get install openssh-server

2. 启动ssh    /etc/init.d/ssh start

3. $ ps -e | grep ssh 来验证是否启动sshserver

4. 免密码化

$ ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa

$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys

三.ubuntu 下安装 hadoop:

1. 下载hadoop-0.20.2.tar.gz,放在/usr/hadoop 下载地址http://apache.etoak.com//hadoop/core/

2.  解压$ tar zxvf hadoop-0.20.2.tar.gz

3. 修改hadoop配置文件

conf/hadoop-env.sh  修改JAVA_HOME选项:

export JAVA_HOME=/usr/java/jdk.1.6.0_27

4. 伪分布式单机配置

conf/core-site.xml

  1. <?xml version="1.0"?>  
  2. <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>  
  3. <!-- Put site-specific property overrides in this file. -->  
  4. <configuration>  
  5.          <property>  
  6.                   <name>fs.default.name</name>  
  7.                   <value>hdfs://localhost:9000</value>  
  8.         </property>  
  9. </configuration>  

conf/hdfs-site.xml:

  1. <?xml version="1.0"?>  
  2. <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>  
  3. <!-- Put site-specific property overrides in this file. -->  
  4. <configuration>  
  5.          <property>  
  6.                   <name>dfs.replication</name>  
  7.                    <value>1</value>  
  8.          </property>  
  9. </configuration>  

conf/mapred-site.xml:

  1. <?xml version="1.0"?>  
  2. <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>  
  3. <!-- Put site-specific property overrides in this file. -->  
  4. <configuration>  
  5.         <property>  
  6.                  <name>mapred.job.tracker</name>  
  7.                           <value>localhost:9001</value>  
  8.         </property>  
  9. </configuration>  

5. 创建hdfs文件系统

$ bin/hadoop namenode -format

6. 启动hadoop    需要先启动ssh  $ /etc/init.d/ssh start

$ bin/hadoop start-all.sh

7. 在hadoop下创建test目录,然后建立file1.txt file2.txt 写入几个单词;将hadoop/test下的测试文件上传到hadoop 文件系统中

$ bin/hadoop dfs -put ./test input

8. 运行wordCount例子

$ bin/hadoop jar hadoop-0.20.2-examples.jar wordcount input output

9. 把结果从dfs上拷贝下来

$ bin/hadoop dfs -get output output

10. 查看结果

$ cat output/* 也可以直接查看 $ bin/hadoop dfs -cat output/*

11. 停止hadoop运行

$ bin/hadoop stop-all.sh

12. 关闭ssh-server

$  /etc/init.d/ssh stop

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款