Hadoop部署方式-本地模式(Local (Standalone) Mode)
Hadoop部署方式-本地模式(Local (Standalone) Mode)
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
Hadoop总共有三种运行方式。本地模式(Local (Standalone) Mode),伪分布式(Pseudo-Distributed Mode),分布式(Fully-Distributed Mode)。本篇博客主要讲解第一种运行方式,即本地运行方式,想要查看伪分布式的小伙伴请参考:https://www.cnblogs.com/yinzhengjie/p/9058415.html,想要查看完全分布式的小伙伴请参考:https://www.cnblogs.com/yinzhengjie/p/9065191.html。
需要注意的是,本地运行模式,实际上就是用Linux操作系统,会直接把文件存储在Linux路径上,我们在上传文件的时候要注意权限哟,比如你在搭建好Hadoop本地模式后,直接就提交一个文件到根下的话,可能会报权限错误哟,但是,如果你是root用户的话就另当别论了。
一.下载相应的jdk和Hadoop安装包
jdk:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Hadoop:http://hadoop.apache.org/releases.html
注意,Hadoop官方虽然没有windows版本,但是可用通过“visual studio”编译工具将Linux的运行伪分布式迁移到windows中,建议安装2015版本,网上的教程有很多。遗憾的是,这个工具的使用并不是本篇博客的重点。
二.安装Java环境
1>.创建软件解压目录并授权给普通用户
[yinzhengjie@yinzhengjie ~]$ ll total 390268 -rw-rw-r--. 1 yinzhengjie yinzhengjie 214092195 Aug 26 2016 hadoop-2.7.3.tar.gz -rw-rw-r--. 1 yinzhengjie yinzhengjie 185540433 May 17 2017 jdk-8u131-linux-x64.tar.gz [yinzhengjie@yinzhengjie ~]$ sudo mkdir /soft [sudo] password for yinzhengjie: [yinzhengjie@yinzhengjie ~]$ sudo chown yinzhengjie:yinzhengjie /soft/ [yinzhengjie@yinzhengjie ~]$ ll /soft/ -d drwxr-xr-x. 2 yinzhengjie yinzhengjie 6 May 24 02:30 /soft/ [yinzhengjie@yinzhengjie ~]$
2>.解压jdk并配置软连接路径
[yinzhengjie@yinzhengjie ~]$ tar zxf jdk-8u131-linux-x64.tar.gz -C /soft/ [yinzhengjie@yinzhengjie ~]$ cd /soft/ [yinzhengjie@yinzhengjie soft]$ ll total 4 drwxr-xr-x. 8 yinzhengjie yinzhengjie 4096 Mar 15 2017 jdk1.8.0_131 [yinzhengjie@yinzhengjie soft]$ ln -s jdk1.8.0_131/ jdk [yinzhengjie@yinzhengjie soft]$ ll total 4 lrwxrwxrwx. 1 yinzhengjie yinzhengjie 13 May 24 02:33 jdk -> jdk1.8.0_131/ drwxr-xr-x. 8 yinzhengjie yinzhengjie 4096 Mar 15 2017 jdk1.8.0_131 [yinzhengjie@yinzhengjie soft]$
3>.设置Java环境变量
[yinzhengjie@yinzhengjie soft]$ sudo vi /etc/profile [yinzhengjie@yinzhengjie soft]$ tail -3 /etc/profile #Add by yinzhengjie JAVA_HOME=/soft/jdk/ PATH=$PATH:$JAVA_HOME/bin [yinzhengjie@yinzhengjie soft]$ . /etc/profile [yinzhengjie@yinzhengjie soft]$ [yinzhengjie@yinzhengjie soft]$ java -version java version "1.8.0_131" Java(TM) SE Runtime Environment (build 1.8.0_131-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode) [yinzhengjie@yinzhengjie soft]$
三.安装Hadoop
1>.解压jdk并配置软连接路径
[yinzhengjie@yinzhengjie ~]$ ll total 390268 -rw-rw-r--. 1 yinzhengjie yinzhengjie 214092195 Aug 26 2016 hadoop-2.7.3.tar.gz -rw-rw-r--. 1 yinzhengjie yinzhengjie 185540433 May 17 2017 jdk-8u131-linux-x64.tar.gz [yinzhengjie@yinzhengjie ~]$ tar zxf hadoop-2.7.3.tar.gz -C /soft/ [yinzhengjie@yinzhengjie ~]$ ln -s /soft/hadoop-2.7.3/ /soft/hadoop [yinzhengjie@yinzhengjie ~]$ ll /soft/ total 8 lrwxrwxrwx. 1 yinzhengjie yinzhengjie 19 May 24 02:40 hadoop -> /soft/hadoop-2.7.3/ drwxr-xr-x. 9 yinzhengjie yinzhengjie 4096 Aug 17 2016 hadoop-2.7.3 lrwxrwxrwx. 1 yinzhengjie yinzhengjie 13 May 24 02:33 jdk -> jdk1.8.0_131/ drwxr-xr-x. 8 yinzhengjie yinzhengjie 4096 Mar 15 2017 jdk1.8.0_131 [yinzhengjie@yinzhengjie ~]$
2>.设置Hadoop的环境变量
[yinzhengjie@yinzhengjie ~]$ sudo vi /etc/profile [sudo] password for yinzhengjie: [yinzhengjie@yinzhengjie ~]$ tail -7 /etc/profile #Add by yinzhengjie JAVA_HOME=/soft/jdk/ PATH=$PATH:$JAVA_HOME/bin #Add HADOOP_HOME HADOOP_HOME=/soft/hadoop/ PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin [yinzhengjie@yinzhengjie ~]$ [yinzhengjie@yinzhengjie ~]$ source /etc/profile [yinzhengjie@yinzhengjie ~]$ grep JAVA_HOME /soft/hadoop/etc/hadoop/hadoop-env.sh | grep -v ^# export JAVA_HOME=/soft/jdk/ [yinzhengjie@yinzhengjie ~]$
3>.验证是否安装完毕(注意,提交的目录当前用户需要有权限,因为本地部署不需要启动服务,它用的就是Linux操作系统,如果普通用户把文件直接提交到根的话肯定会报异常的哟!)
[yinzhengjie@yinzhengjie ~]$ ll total 599344 -rw-rw-r--. 1 yinzhengjie yinzhengjie 214092195 Aug 26 2016 hadoop-2.7.3.tar.gz -rw-rw-r--. 1 yinzhengjie yinzhengjie 185540433 May 17 2017 jdk-8u131-linux-x64.tar.gz -rw-r--r--. 1 yinzhengjie yinzhengjie 214092195 May 24 03:24 test [yinzhengjie@yinzhengjie ~]$ rm -rf test [yinzhengjie@yinzhengjie ~]$ [yinzhengjie@yinzhengjie ~]$ [yinzhengjie@yinzhengjie ~]$ ll total 390268 -rw-rw-r--. 1 yinzhengjie yinzhengjie 214092195 Aug 26 2016 hadoop-2.7.3.tar.gz -rw-rw-r--. 1 yinzhengjie yinzhengjie 185540433 May 17 2017 jdk-8u131-linux-x64.tar.gz [yinzhengjie@yinzhengjie ~]$ [yinzhengjie@yinzhengjie ~]$ hdfs dfs -put hadoop-2.7.3.tar.gz /home/yinzhengjie/test [yinzhengjie@yinzhengjie ~]$ tar zxf test [yinzhengjie@yinzhengjie ~]$ ll total 599348 drwxr-xr-x. 9 yinzhengjie yinzhengjie 4096 Aug 17 2016 hadoop-2.7.3 -rw-rw-r--. 1 yinzhengjie yinzhengjie 214092195 Aug 26 2016 hadoop-2.7.3.tar.gz -rw-rw-r--. 1 yinzhengjie yinzhengjie 185540433 May 17 2017 jdk-8u131-linux-x64.tar.gz -rw-r--r--. 1 yinzhengjie yinzhengjie 214092195 May 24 03:24 test [yinzhengjie@yinzhengjie ~]$
本文来自博客园,作者:尹正杰,转载请注明原文链接:https://www.cnblogs.com/yinzhengjie/p/9049027.html,个人微信: "JasonYin2020"(添加时请备注来源及意图备注,有偿付费)
当你的才华还撑不起你的野心的时候,你就应该静下心来学习。当你的能力还驾驭不了你的目标的时候,你就应该沉下心来历练。问问自己,想要怎样的人生。