一、在Linux中安装JDK并配置环境变量
输入javac 查看是否已安装java环境
如果没有安装 sudo apt-get install openjdk-7-jdk
再次检测 javac
修改配置参数 vim /etc/profile
发现没有安装vim编辑器 apt-get install vim
安装完成后 vim /etc/profile 配置环境变量,参照安装过程中路径,具体如下
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
source /etc/profile
二、下载Hadoop并配置环境变量
网址:http://mirror.bit.edu.cn/apache/hadoop/common/
下载:wget http://mirror.bit.edu.cn/apache/hadoop/common/hadoop-1.2.1/hadoop-1.2.1-bin.tar.gz
ls 查看已下载 hadoop-1.2.1-bin.tar.gz
移动到/opt/文件夹:mv hadoop-1.2.1-bin.tar.gz /opt/
进入到/opt/文件夹:cd /opt/
ls 查看/opt/目录下:hadoop-1.2.1-bin.tar.gz
解压:tar -zxvf hadoop-1.2.1-bin.tar.gz
ls 出现解压后的 hadoop-1.2.1
三、修改hadoop-1.2.1/conf/下四个配置文件
[email protected]:/opt# cd hadoop-1.2.1
[email protected]:/opt/hadoop-1.2.1# ls
[email protected]:/opt/hadoop-1.2.1# cd conf
[email protected]:/opt/hadoop-1.2.1/conf# ls
[email protected]:/opt/hadoop-1.2.1/conf# vim hadoop-env.sh
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
[email protected]:/opt/hadoop-1.2.1/conf# vim mapred-site.xml
<configuration>
<property>
<name>mapred.job.tracker</name>
<value>imooc:9001</value>
</property>
</configuration>
[email protected]:/opt/hadoop-1.2.1/conf# vim core-site.xml
<configuration>
<property>
<name>hedoop.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://imooc:9000</value>
</property>
</configuration>
[email protected]:/opt/hadoop-1.2.1/conf# vim hdfs-site.xml
<configuration>
<property>
<name>dfs.data.dir</name> 文件块的存放目录
<value>/hadoop/data</value>
</property>
</configuration>
[email protected]:/opt/hadoop-1.2.1/conf# vim /etc/profile
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export JRE_HOME=$JAVA_HOME/jre
export HADOOP_HOME=/opt/hadoop-1.2.1
export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$HADOOP_HOME/bin:$PATH
[email protected]:/opt/hadoop-1.2.1/conf# source /etc/profile
四、检测是否安装成功
[email protected]:/opt/hadoop-1.2.1/conf# hadoop
[email protected]:/opt/hadoop-1.2.1/conf# cd ..
[email protected]:/opt/hadoop-1.2.1# cd bin/
[email protected]:/opt/hadoop-1.2.1/bin# ls
[email protected]:/opt/hadoop-1.2.1/bin# hadoop namenode -format 格式化
[email protected]:/opt/hadoop-1.2.1/bin# start-all.sh
[email protected]:/opt/hadoop-1.2.1/bin# jps 查看Hadoop是否正常运行