Hadoop学习笔记

Coding Alan 10年前 (2015-06-16) 5185次浏览 0个评论 扫描二维码

第一步:安装Linux

第二步:安装JDK

javac查是否安装配置好了JDK,若未安装,以JAVA 7为例:

#Centos
yum install java-1.7.0-openjdk-devel
#Ubuntu
apt-get install openjdk-7-jdk -y

再次输入javac若出现类似下面的提示则表明安装成功

Usage: javac <options> <source files>
where possible options include:
  -g                         Generate all debugging info
  -g:none                    Generate no debugging info
  -g:{lines,vars,source}     Generate only some debugging info
  -nowarn                    Generate no warnings
  -verbose                   Output messages about what the compiler is doing
  -deprecation               Output source locations where deprecated APIs are used
  -classpath <path>          Specify where to find user class files and annotation processors
  -cp <path>                 Specify where to find user class files and annotation processors
  -sourcepath <path>         Specify where to find input source files
  -bootclasspath <path>      Override location of bootstrap class files
  -extdirs <dirs>            Override location of installed extensions
  -endorseddirs <dirs>       Override location of endorsed standards path
  -proc:{none,only}          Control whether annotation processing and/or compilation is done.
  -processor <class1>[,<class2>,<class3>...] Names of the annotation processors to run; bypasses default discovery process
  -processorpath <path>      Specify where to find annotation processors
  -d <directory>             Specify where to place generated class files
  -s <directory>             Specify where to place generated source files
  -implicit:{none,class}     Specify whether or not to generate class files for implicitly referenced files
  -encoding <encoding>       Specify character encoding used by source files
  -source <release>          Provide source compatibility with specified release
  -target <release>          Generate class files for specific VM version
  -version                   Version information
  -help                      Print a synopsis of standard options
  -Akey[=value]              Options to pass to annotation processors
  -X                         Print a synopsis of nonstandard options
  -J<flag>                   Pass <flag> directly to the runtime system
  -Werror                    Terminate compilation if warnings occur
  @<filename>                Read options and filenames from file

要在整个系统中使用JDK,还需要配置环境变量,首先打开/etc/profile下

#centos
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk.x86_64/
#ubuntu
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=$JAVA_HOME/lib:$JER_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/BIN:$JRE_HOME/bin:$PATH

通过source /etc/pofile设置生效

第三步:配置Hadoop

首先需要下载Hadoop安装包,以1.2.1版本为例,比如:

wget http://apache.mesi.com.ar/hadoop/common/hadoop-1.2.1/hadoop-1.2.1.tar.gz
mv hadoop-1.2.1.tar.gz /opt/
cd /opt/
tar -xzvf hadoop-1.2.1.tar.gz
cd hadoop-1.2.1/conf/
nano hadoop-env.sh
#找到 # export JAVA_HOME=/usr/lib/j2sdk1.5-sun,去除注释交将JAVA_HOME修改为
/usr/lib/jvm/java-1.7.0-openjdk.x86_64/
nano core-site.xml
#在configuration标签内添加
<property>
    <name>hadoop.tmp.dir</name>
    <value>/hadoop</value>
</property>
<property>
    <name>dfs.name.dir</name>
    <value>/hadoop/name</value>
</property>
<property>
    <name>fs.default.name</name>
    <value>hdfs://localhost:9000</value>
</property>
nano hdfs-site.xml
<property>
    <name>dfs.data.dir</name>
    <value>/hadoop/data</value>
</property>
nano mapred-site.xml
<property>
    <name>mapred.job.tracker</name>
    <value>localhost:9001</value>
</property>
nano /etc/profile
添加export HADOOP_HOME=/opt/hadoop-1.2.1
PATH内添加一条$HADOOP_HOME/bin
source /etc/profile
cd ..
hadoop namenode -format

些时在命令窗口输入hadoop来检查配置是否成功

喜欢 (0)
[]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址