hadoop@ubuntu:/opt/hadoop$ vi libexec/hadoop-config.sh
在
if [[ -z $JAVA_HOME ]]; then
# On OSX use java_home (or /Library for older versions)
if [ "Darwin" == "$(uname -s)" ]; then
if [ -x /usr/libexec/java_home ]; then
export JAVA_HOME=($(/usr/libexec/java_home))
else
export JAVA_HOME=(/Library/Java/Home)
fi
fi
# Bail if we did not detect it
if [[ -z $JAVA_HOME ]]; then
echo "Error: JAVA_HOME is not set and could not be found." 1>&2
exit 1
fi
fi
之前添加
export JAVA_HOME=/usr/lib/jvm/java-7-sun (自己电脑的java地址)
2. 格式化namenode. 进入 /opt/hadoop/
键入 bin/hadoop namenode -format
3. 启动
于/opt/hadoop/sbin
$ ./start-dfs.sh
4.检查启动是否成功
hadoop@ubuntu:/opt/hadoop/sbin$ jps
5036 DataNode
5246 SecondaryNameNode
5543 NodeManager
5369 ResourceManager
4852 NameNode
5816 Jps
5.试着运行wordcount
1)构造输入数据
生成一个字符文本文件
hadoop@ubuntu:/opt/hadoop$ cat tmp/test.txt
a c b a b d f f e b a c c d g i s a b c d e a b f g e i k m m n a b d g h i j a k j e
hadoop@ubuntu:/opt/hadoop$ hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-0.23.6.jar wordcount /test/test.txt /test/out #其中/test/out 为输出目录
13/04/18 22:41:11 INFO input.FileInputFormat: Total input paths to process : 1
13/04/18 22:41:11 INFO util.NativeCodeLoader: Loaded the native-hadoop library
13/04/18 22:41:11 WARN snappy.LoadSnappy: Snappy native library not loaded
13/04/18 22:41:12 INFO mapreduce.JobSubmitter: number of splits:1
13/04/18 22:41:12 WARN conf.Configuration: mapred.jar is deprecated. Instead, use mapreduce.job.jar
13/04/18 22:41:12 WARN conf.Configuration: mapred.output.value.class is deprecated. Instead, use mapreduce.job.output.value.class
13/04/18 22:41:12 WARN conf.Configuration: mapreduce.combine.class is deprecated. Instead, use mapreduce.job.combine.class
13/04/18 22:41:12 WARN conf.Configuration: mapreduce.map.class is deprecated. Instead, use mapreduce.job.map.class
13/04/18 22:41:12 WARN conf.Configuration: mapred.job.name is deprecated. Instead, use mapreduce.job.name
13/04/18 22:41:12 WARN conf.Configuration: mapreduce.reduce.class is deprecated. Instead, use mapreduce.job.reduce.class
13/04/18 22:41:12 WARN conf.Configuration: mapred.input.dir is deprecated. Instead, use mapreduce.input.fileinputformat.inputdir
13/04/18 22:41:12 WARN conf.Configuration: mapred.output.dir is deprecated. Instead, use mapreduce.output.fileoutputformat.outputdir
13/04/18 22:41:12 WARN conf.Configuration: mapred.map.tasks is deprecated. Instead, use mapreduce.job.maps
13/04/18 22:41:12 WARN conf.Configuration: mapred.output.key.class is deprecated. Instead, use mapreduce.job.output.key.class
13/04/18 22:41:12 WARN conf.Configuration: mapred.working.dir is deprecated. Instead, use mapreduce.job.working.dir
13/04/18 22:41:13 INFO mapred.ResourceMgrDelegate: Submitted application application_1366295287642_0001 to ResourceManager at localhost/127.0.0.1:54311
13/04/18 22:41:13 INFO mapreduce.Job: The url to track the job: http://localhost:54315/proxy/application_1366295287642_0001/
13/04/18 22:41:13 INFO mapreduce.Job: Running job: job_1366295287642_0001
13/04/18 22:41:21 INFO mapreduce.Job: Job job_1366295287642_0001 running in uber mode : false
13/04/18 22:41:21 INFO mapreduce.Job: map 0% reduce 0%
13/04/18 22:41:36 INFO mapreduce.Job: map 100% reduce 0%
13/04/18 22:41:36 INFO mapreduce.Job: Task Id : attempt_1366295287642_0001_m_000000_0, Status : FAILED
Killed by external signal
13/04/18 22:41:37 INFO mapreduce.Job: map 0% reduce 0%
13/04/18 22:42:11 INFO mapreduce.Job: map 100% reduce 0%
13/04/18 22:42:26 INFO mapreduce.Job: map 100% reduce 100%
13/04/18 22:42:26 INFO mapreduce.Job: Job job_1366295287642_0001 completed successfully
13/04/18 22:42:27 INFO mapreduce.Job: Counters: 45
4)查看结果
hadoop@ubuntu:/opt/hadoop$ hadoop fs -ls /test
Found 2 items
drwxr-xr-x - hadoop supergroup 0 2013-04-18 22:42 /test/out
-rw-r--r-- 1 hadoop supergroup 86 2013-04-18 07:47 /test/test.txt
hadoop@ubuntu:/opt/hadoop$ hadoop fs -ls /test/out
Found 2 items
-rw-r--r-- 1 hadoop supergroup 0 2013-04-18 22:42 /test/out/_SUCCESS
-rw-r--r-- 1 hadoop supergroup 56 2013-04-18 22:42 /test/out/part-r-00000
hadoop@ubuntu:/opt/hadoop$ hadoop fs -cat /test/out/part-r-00000
13/04/18 22:45:25 INFO util.NativeCodeLoader: Loaded the native-hadoop library
a 7
b 6
c 4
d 4
e 4
f 3
g 3
h 1
i 3
j 2
k 2
m 2
n 1
s 1
--------------------
1.第一个错误是碰到说找不到加载类. namenode
解决过程: 经过查找发现是xml配置文件写错了 多了一个符号 删去后好了
2.第二个碰到的错误是执行示例程序时,出现 INFO ipc.Client: Retrying connect to server: localhost/127.0.0.1:12200. 报错.