hadoop 环境配置修改


http://hadoop.apache.org/ (hadoop 官网)。这里介绍的比较详细。 
hadoop可以在这里下载,按照现在的版本已经更新到2.7了,1.x的版本和2.x的版本听说差距挺大,且学且感受吧。

1、首先将hadoop解压到 /opt

$sudo tar -zxvf hadoop.xx.xx.tar.gz 
到达/opt下,然后建立hadoop文件夹,里面建立name和data两个文件夹 
$sudo mkdir hadoop 
到达/hadoop 
$sudo mkdir name 
$sudo mkdir data

2、配置hadoop

**core-size.xml**
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>hadoop.tmp.dir</name>
<value>/opt/hadoop</value>
</property>
<property>
<name>dfs.name.dir</name>
<value>/opt/hadoop/name</value>
</property>
<property>
<name>fs.default.name</name>
<value>hdfs://localhost:9000</value>
</property>
</configuration>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19

hdfs-size.xml

<configuration>
<property>
<name>dfs.data.dir</name>
<value>/opt/hadoop/data</value>
</property>

<property>
<name>dfs.replication</name>
<value>1</value>
</property>

</configuration>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

mapred-size.xml

<configuration>
<property>
<name>maperd.job.tracker</name>
<value>localhost:9001</value>
</property>
</configuration>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

hadoop-env.sh

# The java implementation to use.  Required.
 **export JAVA_HOME=/usr/local/java/jdk1.7.0_67**
# Extra Java CLASSPATH elements.  Optional.
  • 1
  • 2
  • 3

打开/etc/profile

export JAVA_HOME=/usr/local/java/jdk1.7.0_67
export HADOOP_HOME=/opt/hadoop-1.2.1
export PATH=$JAVA_HOME/bin:$HADOOP_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
  • 1
  • 2
  • 3
  • 4
  • 5

到这里配置Hadoop配置差不多没问题了。 
$ hadoop (可以看到是否成功) 
1、格式化HDFS 到达hadoop的bin目录下 执行 
$hadoop namenode -format 
这里我直接报了这个错 (namenode 无法启动) 
ERROR namenode.NameNode: java.io.IOException: Cannot create directory /export/home/dfs/name/current

解决:原因是 没有设置 /opt/hadoop 的权限没有设置, 将之改为: 
$ chown –R hadoop:hadoop /opt/hadoop 
$ sudo chmod -R a+w /opt/hadoop

2、启动Hadoop

执行 start-all.sh 
当前用户对hadoop安装目录无足够权限 
hm@hm-ubuntu:/usr/hadoop-1.1.2/bin$ start-all.sh 
mkdir: cannot create directory /usr/hadoop-1.1.2/libexec/../logs': Permission denied 
chown: cannot access
/usr/hadoop-1.1.2/libexec/../logs’: No such file or directory

starting namenode, logging to /usr/hadoop-1.1.2/libexec/../logs/hadoop-hm-namenode-hm-ubuntu.out 
/usr/hadoop-1.1.2/bin/hadoop-daemon.sh: line 136: /usr/hadoop-1.1.2/libexec/../logs/hadoop-hm-namenode-hm-ubuntu.out: No such file or directory 
head: cannot open `/usr/hadoop-1.1.2/libexec/../logs/hadoop-hm-namenode-hm-ubuntu.out’ for reading: No such file or directory 
hm@localhost’s password: 
… … 
解决: 
执行 chown 命令为当前用户赋予对目录可写的权限 
sudo chown -hR Eddie(当前用户名) hadoop-xxx(当前版本)

posted @ 2016-03-11 18:38  stewartlj  阅读(80)  评论(0编辑  收藏  举报