Hadoop-2.4.0安装和wordcount运行验证
来源:互联网 发布:淘宝卖点卡 编辑:程序博客网 时间:2024/05/16 15:11
此文转载自:http://blog.csdn.net/u012432778/article/details/23964873
Hadoop-2.4.0安装和wordcount运行验证
以下描述了64位centos6.5机器下,安装32位hadoop-2.4.0,并通过运行
系统自带的WordCount例子来验证服务正确性的步骤。
建立目录
/home/QiumingLu/hadoop-2.4.0,以后这个是hadoop的安装目录。
安装hadoop-2.4.0,解压hadoop-2.4.0.tar.gz到目录
/home/QiumingLu/hadoop-2.4.0即可
[root@localhosthadoop-2.4.0]# ls
bin etc lib LICENSE.txt NOTICE.txt sbin synthetic_control.data
dfs include libexec logs README.txt share
配置etc/hadoop/hadoop-env.sh
[root@localhosthadoop-2.4.0]#
- cat etc/hadoop/hadoop-env.sh
- #The java implementation to use.
- exportJAVA_HOME=/home/QiumingLu/mycloud/jdk/jdk1.7.0_51
因为hadoop是默认32位的,所以要加这个:
- exportHADOOP_COMMON_LIB_NATIVE_DIR=${HADOOP_PREFIX}/lib/native
- exportHADOOP_OPTS="-Djava.library.path=$HADOOP_PREFIX/lib"
否则,可能出现一下错误:
<span style="font-family:DejaVu Sans Mono,monospace;"><span style="font-size:14px;"><span lang="en-US">Unable to load native-hadoop library for your platform... using builtin-java classes where applicable</span></span></span>
<span style="font-family:DejaVu Sans Mono,monospace;"><span lang="en-US">Starting namenodes on [Java HotSpot(TM) 64-Bit Server VM warning: You have loaded library /home/hadoop/2.2.0/lib/native/libhadoop.so.1.0.0 which might have disabled stack guard. The VM will try to fix the stack guard now.</span></span>
<span style="font-family:DejaVu Sans Mono,monospace;"><span lang="en-US">It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.</span></span>
<span style="font-family:DejaVu Sans Mono,monospace;"><span lang="en-US">localhost]</span></span>
<span style="font-family:DejaVu Sans Mono,monospace;"><span lang="en-US">sed: -e expression #1, char 6: unknown option to `s'</span></span>
<span style="font-family:DejaVu Sans Mono,monospace;"><span lang="en-US">HotSpot(TM): ssh: Could not resolve hostname HotSpot(TM): Name or service not known</span></span>
<span style="font-family:DejaVu Sans Mono,monospace;"><span lang="en-US">64-Bit: ssh: Could not resolve hostname 64-Bit: Name or service not known</span></span>
<span style="font-family:DejaVu Sans Mono,monospace;"><span lang="en-US">Java: ssh: Could not resolve hostname Java: Name or service not known</span></span>
<span style="font-family:DejaVu Sans Mono,monospace;"><span lang="en-US">Server: ssh: Could not resolve hostname Server: Name or service not known</span></span>
<span style="font-family:DejaVu Sans Mono,monospace;"><span lang="en-US">VM: ssh: Could not resolve hostname VM: Name or service not known</span></span>
配置etc/hadoop/hdfs-site.xml
[root@localhosthadoop-2.4.0]# cat etc/hadoop/hdfs-site.xml
- <configuration>
- <property>
- <name>dfs.replication</name>
- <value>1</value>
- </property>
- <property>
- <name>dfs.namenode.name.dir</name>
- <value>file:/home/QiumingLu/hadoop-2.4.0/dfs/name</value>
- </property>
- <property>
- <name>dfs.datanode.data.dir</name>
- <value>file:/home/QiumingLu/hadoop-2.4.0/dfs/data</value>
- </property>
- </configuration>
配置etc/hadoop/core-site.xml
- <configuration>
- <property>
- <name>fs.default.name</name>
- <value>hdfs://localhost:9000</value>
- </property>
- </configuration>
配置etc/hadoop/yarn-site.xml
- <configuration>
- <!--Site specific YARN configuration properties -->
- <property>
- <name>mapreduce.framework.name</name>
- <value>yarn</value>
- </property>
- <property>
- <name>yarn.nodemanager.aux-services</name>
- <value>mapreduce_shuffle</value>
- </property>
- </configuration>
配置etc/hadoop/mapred-site.xml.template
- [root@localhosthadoop-2.4.0]# cat etc/hadoop/mapred-site.xml.template
- <configuration>
- <property>
- <name>mapreduce.framework.name</name>
- <value>yarn</value>
- </property>
- </configuration>
格式化文件系统
[root@localhosthadoop-2.4.0]#
- ./bin/hadoop namenode -format
启动服务,这里使用root用户,需要输入密码的时候,输入root用户密码
如果使用非root,并假设分布式服务,需要先解决ssh登录问题,此处不详
细描述。
[root@localhosthadoop-2.4.0]#
- sbin/start-all.sh
查看启动状态:
[root@localhosthadoop-2.4.0]#
- ./bin/hadoop dfsadmin -report
DEPRECATED:Use of this script to execute hdfs command is deprecated.
Insteaduse the hdfs command for it.
14/04/1805:15:30 WARN util.NativeCodeLoader: Unable to load native-hadooplibrary for your platform... using builtin-java classes whereapplicable
ConfiguredCapacity: 135938813952 (126.60 GB)
PresentCapacity: 126122217472 (117.46 GB)
DFSRemaining: 126121320448 (117.46 GB)
DFSUsed: 897024 (876 KB)
DFSUsed%: 0.00%
Underreplicated blocks: 0
Blockswith corrupt replicas: 0
Missingblocks: 0
-------------------------------------------------
Datanodesavailable: 1 (1 total, 0 dead)
Livedatanodes:
Name:127.0.0.1:50010 (localhost)
Hostname:localhost
DecommissionStatus : Normal
ConfiguredCapacity: 135938813952 (126.60 GB)
DFSUsed: 897024 (876 KB)
NonDFS Used: 9816596480 (9.14 GB)
DFSRemaining: 126121320448 (117.46 GB)
DFSUsed%: 0.00%
DFSRemaining%: 92.78%
ConfiguredCache Capacity: 0 (0 B)
CacheUsed: 0 (0 B)
CacheRemaining: 0 (0 B)
CacheUsed%: 100.00%
CacheRemaining%: 0.00%
Lastcontact: Fri Apr 18 05:15:29 CST 2014
[root@localhosthadoop-2.4.0]# jps
3614DataNode
3922ResourceManager
3514NameNode
9418Jps
4026NodeManager
http://localhost:50070
http://localhost:8088
构造数据文件(file1.txt,file2.txt)
[root@localhosthadoop-2.4.0]# cat example/file1.txt
- hello world
- hello markhuang
- hello hadoop
[root@localhosthadoop-2.4.0]# cat example/file2.txt
- hadoop ok
- hadoop fail
- hadoop 2.4
[root@localhosthadoop-2.4.0]#
- ./bin/hadoop fs -mkdir /data
把数据文件加入到hadoop系统。
[root@localhosthadoop-2.4.0]#
- ./bin/hadoop fs -put -f example/file1.txtexample/file2.txt /data
运行WordCount(java)版本。
[root@localhosthadoop-2.4.0]#
- ./bin/hadoop jar./share/hadoop/mapreduce/sources/hadoop-mapreduce-examples-2.4.0-sources.jarorg.apache.hadoop.examples.WordCount /data /output
查看结果。
[root@localhosthadoop-2.4.0]#
- ./bin/hadoop fs -cat /output/part-r-00000
2.4 1
fail 1
hadoop 4
hello 3
markhuang 1
ok 1
world 1
- Hadoop-2.4.0安装和wordcount运行验证
- Hadoop-2.4.0安装和wordcount运行验证
- Hadoop-2.4.0安装和wordcount运行验证
- hadoop2.3安装和wordcount运行验证
- hadoop2.3安装和wordcount运行验证
- hadoop 安装+本地运行wordCount
- Hadoop eclipse插件安装和在eclipse运行wordcount程序
- hadoop安装--18-- 验证 WordCount 例子
- CentOS安装Hadoop并运行WordCount实例
- 一步一步跟我学习hadoop(2)----hadoop eclipse插件安装和运行wordcount程序
- 【Hadoop】编写和运行WordCount.java
- hadoop-2.4.0 wordcount
- hadoop-2.3.0运行wordcount程序
- hadoop-2.6.0伪分布运行WordCount
- hadoop 2.2.0 编译运行wordcount
- hadoop 运行 wordcount
- hadoop wordcount运行实例
- Hadoop WordCount 运行
- Cocos2d-x3.1通过JniHelper类调用java中非静态函数
- Git与Repo入门
- TreeSet有趣问题之add方法原理
- 第四章 通过示例探索 F# 和 .NET 库
- Android开发资源推荐第2季
- Hadoop-2.4.0安装和wordcount运行验证
- linux下服务器命令小结【持续更新】
- 使用CURL封装HttpClient
- oracle 执行计划
- java8大排序
- 【学习python】eclipse导入Flask报错,但程序执行正常
- 在局域网的情况下,使用真机(手机)测试web程序
- 【codeforces】 472C Design Tutorial: Make It Nondeterministic
- 在字符串中寻找连续最长的数字串