1.安装 Red Hat 环境
2.安装JDK
3.下载hadoop2.8.0
http://mirrors.tuna.tsinghua.edu.cn/apache/hadoop/common/hadoop-2.8.0/hadoop-2.8.0.tar.gz
4.在用户目录下新建hadoop文件夹,并解压hadoop压缩包
mkdir Hadoop tar -zxvf hadoop-2.8.0.tar.gz
5.为hadoop配置JAVA_HOME
[[email protected] ~]$ cd hadoop/hadoop-2.8.0/etc/hadoop/ [[email protected] hadoop]$ vi hadoop-env.sh
6.格式化(初始化)HDFS文件系统
[[email protected] ~]$ cd hadoop/hadoop-2.8.0/bin [[email protected] bin]$ ./hadoop namenode -format
(ps:hadoop namenode -format 已经过时 hdfs namenode -format 最新的需要等待较长时间)
7.启动haddop
[[email protected] ~]$ cd hadoop/hadoop-2.8.0/sbin/ [[email protected] sbin]$ ./start-all.sh
(ps:现在推荐使用 ./start-hdfs.sh ./start-yarn.sh)
8.jps查看hadoop是否成功启动
9.在hadoop目录里下新建文件夹并新建两个测试文件
[[email protected] ~]$ cd hadoop/ [[email protected] hadoop]$ mkdir test [[email protected] hadoop]$ cd test/ [[email protected] test]$ echo "hello word" > file1.txt [[email protected] test]$ echo "hello hadoop" > file2.txt
10.在hdfs文件系统里新建input文件夹并将测试文件上传
[[email protected] ~]$ cd hadoop/hadoop-2.8.0/bin/ [[email protected] bin]$ ./hadoop fs -mkdir input [[email protected] bin]$ ./hadoop fs -put ~/hadoop/test/file*.txt input 17/07/06 16:33:34 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable [[email protected] bin]$ ./hadoop fs -ls input 17/07/06 16:33:45 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable Found 2 items -rw-r--r-- 1 chenguangjin chenguangjin 11 2017-07-06 16:33 input/file1.txt -rw-r--r-- 1 chenguangjin chenguangjin 13 2017-07-06 16:33 input/file2.txt
(ps:注意此处由WARN,不需要管它,可以成功上传)
11.运行wordcount小例子
[[email protected] bin]$ ./hadoop jar ~/hadoop/hadoop-2.8.0/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.8.0.jar wordcount input output
12.查看结果
[[email protected] bin]$ ./hadoop fs -text output/part-r-00000 17/07/06 16:46:02 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable hadoop 1 hello 2 word 1 [[email protected] bin]$
(over怎么样是不是还挺有趣的)
时间: 2024-10-05 23:41:04