天天看点

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

CentOS 6.5 伪分布安装

软件准备  jdk-6u24-linux-i586.bin 、hadoop-1.2.1.tar.gz、hadoop-eclipse-plugin-1.2.1.jar 、

         Eclipse-jee-indigo-SR2-linux-gtk.tar.gz

假设:  所有软件压缩包都放在  /home/hadoop 文件夹下。

1、JDK安装

1.1           root用户登录,使用命令 mkdir  /usr/local/program 新建目录program,用来存放jdk,本教材采用jdk版本 jdk-6u24-linux-i586.bin。

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

1.2 (如事先jdk在hadoop目录下,则可以采用命令 cp /home/hadoop/ jdk-6u24-linux-i586.bin /usr/local/program/  进行复制)。

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装
CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

1.3 对jdk进行解压

进入 /usr/local/program/ 目录下,使用命令 ./jdk-6u24-linux-i586.bin进行解压。

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

解压成功:

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

会出现注册界面,可以直接跳过:

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

1.4 可以选择删除 jdk的bin包,命令如下:

rm  -rf jdk-6u24-linux-i586.bin.

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装
CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

1.5 配置jdk

Root 用户登录,执行命令  vim  /etc/profile    (/etc/profile这个文件很重要,后面hadoop配置也会用到)。  按键盘i键,进行插入。

在后面添加如下:

 #set javaenvironment

exportJAVA_HOME=/usr/local/program/jdk1.6.0_24

exportJRE_HOME=/usr/local/program/jdk1.6.0_24/jre

exportCLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib

exportPATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

按 Esc+(shift+;)+wq  保存退出。

退出后输入 source  /etc/profile   是配置生效。

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

配置完成后,在命令行中输入java  -version 查看是否配置成功。

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

2、SSH无密码验证

2.1       root权限下,输入rpm –qa | grep openssh 命令看看 ssh和rsync是否安装。

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

2.2       生成无密码密钥对

使用ssh-kaygen –t rsa –P ‘ ‘ 命令

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

第一次验证不是这样,我这是第二次了,所以有overwrite,不过没关系,我只是演示一下。

2.3       把 id_rsa.pub追加到授权key里面去

命令  cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

2.4  验证是否配置成功

   输入 ssh  localhost 命令,看是否可以无密码进行登录。

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

不需要输入密码,只需要输入 yes 即配置成功。

3、hadoop安装

  3.1 把hadoop拷到 opt 目录下,如果之前hadoop在hadoop目录下,执行命令进行拷贝    cp /home/hadoop/hadoop-1.2.1.tar.gz  /usr/local/ 

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装
CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

3.2 进入 hadoop目录,对hadoop进行解压。

 cd  /usr/local/                 tar -zxvf hadoop-1.2.1.tar.gz

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

解压完毕:

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

3.3 配置环境变量

  命令  vim  /etc/profile

输入   #set hadoop

      export HADOOP_HOME=/usr/local/hadoop-1.2.1

      export PATH=$PATH:$HADOOP_HOME/bin

退出  输入 source /etc/profile 使配置文件生效。

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装
CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

3.4 配置hadoop 配置文件

 命令  cd /usr/local/hadoop-1.2.1/conf   进入conf目录

3.4.1 配置 hadoop-env.sh 文件

打开文件命令   vim  hadoop-env.sh

添加           #setjava environment

               export JAVA_HOME=/usr/local/program/jdk1.6.0_24

编辑后保存退出。

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装
CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

下面三个文件配置非常重要!!!

3.4.2       配置core-site.xml  文件

<?xmlversion="1.0"?>

<?xml-stylesheettype="text/xsl" href="configuration.xsl" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" ?>

<!--Put site-specific property overrides in this file. -->

<configuration>

<property>

<name>fs.default.name</name>

<value>hdfs://localhost:9000/</value>注:9000后面的“/”不能少

</property>

<property>

<name>hadoop.tmp.dir</name>

<value>/usr/local/hadoop-1.2.1/hadooptmp</value>

</property>

</configuration>

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

3.4.3       配置 hdfs-site.xml  文件

<?xmlversion="1.0"?>

<?xml-stylesheettype="text/xsl" href="configuration.xsl" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" ?>

<!--Put site-specific property overrides in this file. -->

<configuration>

<property>

<name>dfs.replication</name>

<value>1</value>

</property>

<property>

<name>dfs.permissions</name>

<value>false</value>

</property>

</configuration>

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

3.4.4       配置 mapred-site.xml   文件

<?xmlversion="1.0"?>

<?xml-stylesheettype="text/xsl" href="configuration.xsl" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" ?>

<!--Put site-specific property overrides in this file. -->

<configuration>

<property>

<name>mapred.job.tracker</name>

<value>localhost:9001</value>

</property>

</configuration>

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

配置以上三个文件一定要注意,千万不能写错了!!!

3.4.5 配置 masters文件和slaves文件

[[email protected]]# vim masters

localhost

[[email protected]]# vim slaves

localhost

注:因为在伪分布模式下,作为 master 的 namenode 与作为 slave 的 datanode 是同一台

服务器,所以配置文件中的 ip 是一样的。

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

3.4.6  主机名和IP 解析设置 (这一步非常重要)

   命令   vim  /etc/hosts

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装
CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

3.4.7 编辑主机名

命令  vim  /etc/hostname

      vim  /etc/sysconfig/network

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装
CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装
CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

4、启动 hadoop

 命令  cd  /usr/local/hadoop-1.2.1/bin   进入bin目录

先格式化  命令  hadoop namenode  -format

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

启动     命令   start-all.sh         

查看   jps

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

5、安装 eclipse

5.1 把eclipse 拷到opt文件夹下

  命令 cp /home/hadoop/ecipse-jee-indigo-SR2-linux-gtk.tar.gz  /opt

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

5.2 对eclipse 进行解压

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

解压成功

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

5.3  插入插件hadoop-eclipse-plugin-1.2.1.jar

命令 cp  /home/hadoop/hadoop-eclipse-plugin-1.2.1.jar  /opt/eclipse/plugins

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装
CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

5.4 启动eclipse

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

配置eclipse

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

创建 DFS Location

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

查看配置是否有错

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

创建工程

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

运行代码

CentOS 6.5 伪分布安装CentOS 6.5 伪分布安装

继续阅读