博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Hadoop伪分布式环境搭建
阅读量:6115 次
发布时间:2019-06-21

本文共 7505 字,大约阅读时间需要 25 分钟。

  hot3.png

 创建一个目录用于管理软件包

   095320_ZSC9_1985346.png

1.安装JDK

(1)下载

     密码:kbem

(2)使用sftp服务器(Alt+P 打开)上传jdk 至linux服务器

  092243_KGne_1985346.png

(3)查看服务器是否有jdk 

 091850_K4BR_1985346.png

(4)解压JDK至app目录下

   094931_NFXj_1985346.png

(5)检验jdk是否可以运行

   095556_S2h8_1985346.png

(6)配置全局环境变量

   修改配置文件

    095818_23SM_1985346.png

   加入配置

    100340_9cvZ_1985346.png

(7)配置文件生效

    100518_YDYb_1985346.png

 

2.安装hadoop

(1)下载

     密码:ujvh

(2)使用sftp服务器(Alt+P 打开)上传hadoop至linux服务器

 103945_aHkE_1985346.png

(3)查看服务器是否有hadoop

 103919_nYuh_1985346.png

(4)解压hadoop至app目录下

 104248_rSS3_1985346.png

(5)修改配置文件etc/hadoop/hadoop-env.sh

[hadoop@weekend110 hadoop]$ vi hadoop-env.sh
export JAVA_HOME=/home/hadoop/app/jdk1.7.0_65

(6)修改配置文件etc/hadoop/core-site.xml

fs.defaultFS
hdfs://weekend110:9000
hadoop.tmp.dir
        
/home/hadoop/app/hadoop-2.4.1/data/
          
    

(7)修改配置文件etc/hadoop/hdfs-site.xml(配置副本个数一般为3个)

   
       
dfs.replication
       
1
   

(8)修改配置文件etc/hadoop/mapred-site.xml.template

文件重命名,否则无法加载

mv mapred-site.xml.template  mapred-site.xml
 
       
mapreduce.framework.name
       
yarn
 

(9)修改配置文件etc/hadoop/yarn-site.xml

yarn.resourcemanager.hostname
weekend110
yarn.nodemanager.aux-services
mapreduce_shuffle

(10)关闭防火墙

查看防火墙的状态

[hadoop@weekend110 ~]$ sudo service iptables status[sudo] password for hadoop: Table: filterChain INPUT (policy ACCEPT)num  target     prot opt source               destination         1    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED 2    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0           3    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           4    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22 5    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited Chain FORWARD (policy ACCEPT)num  target     prot opt source               destination         1    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited Chain OUTPUT (policy ACCEPT)num  target     prot opt source               destination

关闭防火墙

[hadoop@weekend110 ~]$ sudo service iptables stopiptables: Flushing firewall rules: [  OK  ]iptables: Setting chains to policy ACCEPT: filter [  OK  ]iptables: Unloading modules: [  OK  ]

查看自启服务的状态及列表

[hadoop@weekend110 ~]$ sudo chkconfig iptables statuschkconfig version 1.3.49.3 - Copyright (C) 1997-2000 Red Hat, Inc.This may be freely redistributed under the terms of the GNU Public License.usage:   chkconfig [--list] [--type 
] [name] chkconfig --add
chkconfig --del
chkconfig --override
chkconfig [--level
] [--type
]
[hadoop@weekend110 ~]$ sudo chkconfig iptables --listiptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off

关闭自启服务

[hadoop@weekend110 ~]$ sudo chkconfig iptables off[sudo] password for hadoop: [hadoop@weekend110 ~]$ sudo chkconfig iptables  --listiptables        0:off   1:off   2:off   3:off   4:off   5:off   6:off

(11)配置环境变量

[hadoop@weekend110 /]$ sudo vi /etc/profile
export JAVA_HOME=/home/hadoop/app/jdk1.7.0_65export HADOOP_HOME=/home/hadoop/app/hadoop-2.4.1export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin

(12)配置文件生效

[hadoop@weekend110 /]$ source /etc/profile

(13)格式化hadoop

[hadoop@weekend110 hadoop]$ hadoop namenode -formatDEPRECATED: Use of this script to execute hdfs command is deprecated.Instead use the hdfs command for it.16/07/13 21:42:36 INFO namenode.NameNode: STARTUP_MSG: /************************************************************STARTUP_MSG: Starting NameNodeSTARTUP_MSG:   host = weekend110/192.168.2.100STARTUP_MSG:   args = [-format]STARTUP_MSG:   version = 2.4.1........................................................16/07/13 21:44:13 INFO namenode.FSImage: Allocated new BlockPoolId: BP-1726093789-192.168.2.100-146847145312416/07/13 21:44:13 INFO common.Storage: Storage directory /home/hadoop/app/hadoop-2.4.1/data/dfs/name has been successfully formatted.16/07/13 21:44:13 INFO namenode.NNStorageRetentionManager: Going to retain 1 images with txid >= 016/07/13 21:44:13 INFO util.ExitUtil: Exiting with status 016/07/13 21:44:13 INFO namenode.NameNode: SHUTDOWN_MSG: /************************************************************SHUTDOWN_MSG: Shutting down NameNode at weekend110/192.168.2.100************************************************************/

(14)格式化完成后hadoop目录下会产生一些目录

124634_Vyr8_1985346.png

/home/hadoop/app/hadoop-2.4.1/data/dfs/name/current

3.启动hadoop

(1)启动hdfs

[hadoop@weekend110 hadoop-2.4.1]$ start-dfs.shStarting namenodes on [weekend110]hadoop@weekend110's password: weekend110: starting namenode, logging to /home/hadoop/app/hadoop-2.4.1/logs/hadoop-hadoop-namenode-weekend110.outhadoop@localhost's password: localhost: starting datanode, logging to /home/hadoop/app/hadoop-2.4.1/logs/hadoop-hadoop-datanode-weekend110.outStarting secondary namenodes [0.0.0.0]hadoop@0.0.0.0's password: 0.0.0.0: starting secondarynamenode, logging to /home/hadoop/app/hadoop-2.4.1/logs/hadoop-hadoop-secondarynamenode-weekend110.out

查看hdfs服务进程

[hadoop@weekend110 hadoop-2.4.1]$ jps28770 SecondaryNameNode28864 Jps28622 DataNode28502 NameNode

修改配置文件

[hadoop@weekend110 hadoop]$ vi slaves

启动的主机名

weekend110

(2)启动yarn

[hadoop@weekend110 hadoop]$ start-yarn.shstarting yarn daemonsstarting resourcemanager, logging to /home/hadoop/app/hadoop-2.4.1/logs/yarn-hadoop-resourcemanager-weekend110.outhadoop@weekend110's password: weekend110: starting nodemanager, logging to /home/hadoop/app/hadoop-2.4.1/logs/yarn-hadoop-nodemanager-weekend110.out

查看yarn服务进程

[hadoop@weekend110 hadoop]$ jps28770 SecondaryNameNode28960 ResourceManager29344 Jps29242 NodeManager28622 DataNode28502 NameNode

(3)验证dfs是否可以用

http://192.168.2.100:50070/dfshealth.html#tab-overview

查看dfs根目录文件

131828_qEjf_1985346.png

131808_kbQf_1985346.png

上传文件至dfs

[hadoop@weekend110 ~]$ hadoop fs -put jdk-7u65-linux-i586.tar.gz hdfs://weekend110:9000/

132221_6i9N_1985346.png

从dfs取文件到主机

[hadoop@weekend110 ~]$ hadoop fs -get hdfs://weekend110:9000/jdk-7u65-linux-i586.tar.gz[hadoop@weekend110 ~]$ lltotal 275636drwxrwxr-x. 4 hadoop hadoop      4096 Jul 13 19:46 app-rw-rw-r--. 1 hadoop hadoop 138656756 Jan 20 20:33 hadoop-2.4.1.tar.gz-rw-r--r--. 1 hadoop hadoop 143588167 Jul 13 22:33 jdk-7u65-linux-i586.tar.gz

(4)测试mapreduce程序

使用mapreduce程序测试圆周率

[hadoop@weekend110 mapreduce]$ hadoop jar hadoop-mapreduce-examples-2.4.1.jar pi 5 5

使用mapreduce程序统计字符数

创建文本

[hadoop@weekend110 mapreduce]$ vi test.txtheloo aahelllo aaheeej  sdkfadkfdj  kesdfsdkf sdfsdhello  sd

在fds下创建目录,用于存储该文件

[hadoop@weekend110 mapreduce]$ hadoop fs -mkdir /workcount[hadoop@weekend110 mapreduce]$ hadoop fs -mkdir /workcount/input

将该文件上传的fds

[hadoop@weekend110 mapreduce]$ hadoop fs -put test.txt /workcount/input

使用程序测试

[hadoop@weekend110 mapreduce]$ hadoop jar hadoop-mapreduce-examples-2.4.1.jar  workcount /workcount/input /workcount/output

查看统计结果的目录文件

[hadoop@weekend110 mapreduce]$ hadoop fs -ls /workcount/outputFound 2 items-rw-r--r--   1 hadoop supergroup          0 2016-07-13 22:54 /workcount/output/_SUCCESS-rw-r--r--   1 hadoop supergroup         82 2016-07-13 22:54 /workcount/output/part-r-00000

 查看统计结果的具体信息

[hadoop@weekend110 mapreduce]$ hadoop fs -cat /workcount/output/part-r-00000aa      2adkfdj  1heeej   1helllo  1hello   1heloo   1ke      1sd      1sdfsd   1sdfsdkf 1sdkf    1

 

转载于:https://my.oschina.net/hfzj/blog/711534

你可能感兴趣的文章
Linux命令行访问网页
查看>>
md5对比文件
查看>>
JavaScript强化教程——正则表达式回溯
查看>>
Windows Server Backup恢复Exchange 2010用户邮箱(Windows2008R2)
查看>>
数据可视化(三)基于 Graphviz 实现程序化绘图
查看>>
寻找apache启动报”Segmentation fault”的原因 <已解决,待分析>
查看>>
Python练手,numpy.genfromtxt
查看>>
MySQL事务隔离级别详解
查看>>
windows server 2008 R2 和windows 7 安装telnet服务
查看>>
Zookeeper【最新版V3.4.6】- 翻译系列 1: FAQ
查看>>
SQL SERVER 分区表的总结
查看>>
Citrix XenDesktop 7.6 VDA TechPreview版 交付 Windows 10
查看>>
初学者安装oracle11g报错,求赐教
查看>>
D3.js area函数
查看>>
win7下运行nodejs的中文报错:Error: write EIO
查看>>
为tomcat指定JDK
查看>>
互动百科旗下HDwiki漏洞补丁包暗藏后门 加速乐紧急防御
查看>>
glbp详解
查看>>
一个简单好用的zabbix告警信息发送工具
查看>>
彻底解决SysFader:IEXPLORE.EXE应用程序错误
查看>>