Hadoop伪分布式搭建CentOS

Posted polestar

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Hadoop伪分布式搭建CentOS相关的知识,希望对你有一定的参考价值。

所需软件及版本:
jdk-7u80-linux-x64.tar.gz
hadoop-2.6.0.tar.gz

1.安装JDK
    Hadoop 在需在JDK下运行,注意JDK最好使用Oracle的否则可能出bug
2.创建用户
    [[email protected] ~]# groupadd hadoop
    [[email protected] ~]# useradd -g hadoop hadoop
    [[email protected] ~]# passwd hadoop 

3.配置SSH
    确认SSH的客户端和服务端已安装
    [[email protected] ~]$ rpm -qa|grep ssh
    libssh2-1.4.2-1.el6.x86_64
    openssh-clients-5.3p1-94.el6.x86_64
    openssh-server-5.3p1-94.el6.x86_64
    openssh-5.3p1-94.el6.x86_64
    [[email protected] ~]$ 

    配置SSH免密码登陆
    [[email protected] ~]$ mkdir ~/.ssh
    [[email protected] ~]$ cd ~/.ssh/                            # 若没有该目录,请先执行一次ssh localhost  
    [[email protected] .ssh]$ ssh-keygen -t dsa                  # 会有提示,都按回车就可以  
    [[email protected] .ssh]$ cat id_dsa.pub >> authorized_keys  # 加入授权  
    [[email protected] .ssh]$ chmod 600 ./authorized_keys        # 修改文件权限,如果不改,无法通过,原因好像是cent os的权限验证比较严格
    [[email protected] .ssh]$ssh MyDB01                          # 测试

4.安装hadoop
    下载
    [[email protected] ~]$ wget  http://archive.apache.org/dist/hadoop/core/hadoop-2.6.0/hadoop-2.6.0.tar.gz
    
    解压
    [[email protected] hadoop]#tar -zxvf hadoop-2.6.0.tar.gz -C /usr/local

    修改权限
    [[email protected] local]# mv hadoop-2.6.0/ hadoop/          #更改文件夹名称  
    [[email protected] local]# chown -R hadoop:hadoop ./hadoop   #修改权限


    修改环境变量
    [[email protected] ~]$ vi .bash_profile
    export HADOOP_HOME=/usr/local/hadoop  
    export HADOOP_INSTALL=$HADOOP_HOME  
    export HADOOP_MAPRED_HOME=$HADOOP_HOME  
    export HADOOP_COMMON_HOME=$HADOOP_HOME  
    export HADOOP_HDFS_HOME=$HADOOP_HOME  
    export YARN_HOME=$HADOOP_HOME  
    export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native  
    export PATH=$PATH:$HADOOP_HOME/sbin:$HADOOP_HOME/bin  
    export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.111.x86_64 
    export PATH=$JAVA_HOME/bin:$PATH  
    export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar  


5.配置伪分布式
    #手动创建根目录/hadoop  属主:hadoop
    1、core-site.xml文件
       <configuration>
        <property>  
            <name>hadoop.tmp.dir</name>  
            <value>file:/hadoop/tmp</value>  
        </property>  
        <property>  
            <name>fs.defaultFS</name>  
            <value>hdfs://MyDB01:9000</value>  
        </property> 
       </configuration>   



    2、hdfs-site.xml文件
       <configuration>
        <property>  
            <name>dfs.replication</name>  
            <value>1</value>  
        </property>  
        <property>  
            <name>dfs.namenode.name.dir</name>  
            <value>file:/hadoop/tmp/dfs/name</value>  
        </property>  
        <property>  
            <name>dfs.datanode.data.dir</name>  
            <value>file:/hadoop/tmp/dfs/data</value>  
        </property> 
 
       </configuration> 



6.对文件系统HDFS格式化操作
    hadoop namenode -format

 

以上是关于Hadoop伪分布式搭建CentOS的主要内容,如果未能解决你的问题,请参考以下文章

Hadoop伪分布式搭建CentOS

Hadoop伪分布式搭建

超详细!CentOS 7 + Hadoop3.0.0 搭建伪分布式集群

Hadoop单机模式和伪分布式搭建教程CentOS

HADOOP 伪分布式集群搭建

hadoop伪分布式搭建