hadoop全分布模式安装

本文详细介绍了如何根据《Hadoop实战》一书的指导,在四台服务器上搭建Hadoop全分布模式集群的过程,包括配置核心XML文件、格式化HDFS及启动集群等步骤,并分享了作者在实践中遇到的问题及解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

参考:
http://hadoop.apache.org/docs/r1.2.1/cluster_setup.html
Hadoop实战.pdf(page17-page30)


先看一个集群拓扑图:


本文主要实践《Hadoop实战》的2.3.3全分布模式.参考上图,使用四台服务器如下:
master(192.168.1.118)--集群主节点,驻留NameNode和JobTracker守护进程.
backup(192.168.1.119)--驻留SNN守护进程.
hadoop1(192.168.1.120)和hadoop2(192.168.1.121)--集群从节点,驻留DataNode和TaskTracker守护进程.

准备工作:
a.修改主机名,修改IP,修改/etc/hosts域名解析
b.添加用户hadoop/123456,四名机器能相互通过此用户免密码ssh登录.
c.下载jdk,hadoop-1.2.1.tar.gz,解析到/opt目录,修改拥有者和所属组为hadoop,按前文在conf/hadoop-env.sh配置JAVA_HOME变量.


1.先在master下修改三个xml和masters,slaves.此五个文件都在conf目录下:

$ vim core-site.xml 

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
        <property>
                <name>fs.default.name</name>
                <value>hdfs://master:9000</value>     
                <description>The name of the default file system. A URI whose scheme and authority determine the FileSystem implementation.</description>
        </property>
</configuration>
$ vim mapred-site.xml 
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
        <property>
                <name>mapred.job.tracker</name>
                <value>master:9001</value>       
                <description>The host and port that the MapReduce job tracker runs at.</description>
        </property>
</configuration>
$ vim hdfs-site.xml 
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
        <property>
                <name>dfs.replication</name>
                <value>3</value>         
                <description>The actual number of replications can be specified when the file is created.</description>
        </property>
</configuration>

$ vim masters 
backup


$ vim slaves 
hadoop1
hadoop2


将此5个文件使用scp都同步都其它3台机器覆盖原有文件.
2.在master上格式化hdfs.
$ bin/hadoop namenode -format
3.在master上启动hadoop集群.
$ bin/start-all.sh
4.
a.检查每个角色是否都正常.
在master上
$ jps
1745 JobTracker
2080 Jps
1593 NameNode
在backup上
$ jps
1507 SecondaryNameNode
1774 Jps
在hadoop1上
$ jps
1927 Jps
1522 DataNode
1601 TaskTracker
在hadoop2上
$ jps
1507 DataNode
1920 Jps
1584 TaskTracker
b.使用浏览器查看集群相关信息
在浏览器输入http://192.168.1.118:50070/就可查看NameNode相关信息,其它信息都可在此页面找到入口.
5.停止hadoop集群

$ bin/stop-all.sh



我个人遇到的问题:
启动集群后,我在hadoo1机器上使用jps发现datanode并没有起来.停止集群发现报no datanode to stop.这是因为我之前使用这台机器做伪分布模式安装,没有清除多余文件.解决方法可参考:http://blog.sina.com.cn/s/blog_6d932f2a0101fsxn.html


小结:要安装一个hadoop集群,其实不难.但很多参数的配置,不仅要看官方的文档,还是要靠生产环境的实践以及别人的经验来学习



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值