设为首页 收藏本站
查看: 1319|回复: 0

[经验分享] Hadoop全分布式集群环境配置

[复制链接]

尚未签到

发表于 2017-12-17 14:38:37 | 显示全部楼层 |阅读模式
  

192.168.5.128 Master.Hadoop  

192.168.5.129 Slave1.Hadoop  

192.168.5.130 Slave2.Hadoop  

  3 配置SSH (实现三台服务器能够无密码互联)
  以Maste.Hadoop这台服务器为例,输入如下命令:
  

ssh-keygen -t dsa -P '' -f .ssh/id_dsa  

  这个命令会在.ssh目录下产生两个文件id_dsa及id_dsa.pub,相当于现实中的锁和钥匙,把后者追加到授权的key中去,输入:
  

cat>  

  这样就可以实现无密码ssh自登陆,可以试试命令:ssh localhost,如果登陆成功后输入exit退出
  完成以上操作后分别按照相同的步骤分别在Slave1.Hadoop和Slave2.Hadoop服务器上产生对应的锁和钥匙,现在以Slave1.Hadoop服务器为例,输入如下命令
  

ssh-keygen -t dsa -P '' -f .ssh/id_dsa  

  在Slave1.Hadoop服务器上产生对应的锁和钥匙,然后把产生的id_dsa.pub通过命令传输到Master.Hadoop服务器上,命令如下:
  

scp .ssh/id_dsa.pub root@192.168.5.128:.ssh/id_dsa.pub.Slave1  

  Slave2.Hadoop执行上述相同的步骤,把产生id_dsa.pub传输到Master.Hadoop服务器上的id_dsa.pub.Slave2
  现在在Master.Hadoop服务器上将id_dsa.pub.Slave1和id_dsa.pub.Slave2文件中的内容追加到授权的key中,命令如下:
  

cat .ssh/id_dsa.pub.Slave1 >> authorized_keys  

cat .ssh/id_dsa.pub.Slave2 >> authorized_keys  

  完成以上操作后,现在通过命令把Master.Hadoop服务器上的授权key分别传输到Slave1.Hadoop和Slave2.Hadoop服务器上,命令如下:
  

scp .ssh/authorized_keys root@192.168.5.129:.ssh/authorized_keys  

scp .ssh/authorized_keys root@192.168.5.130:.ssh/authorized_keys  

  完成以上步骤以后通过ssh Slave1.Hadoop,ssh Slave2.Hadoop,你会发现三台服务器之间都可以实现无密码互联了,进行这样设置的目的是为了能够在Master.Hadoop服务器上能够维护其他节点的相关信息,方便系统维护
  4 配置Hadoop
  现在仍旧以Master.Hadoop服务器为例,配置Hadoop集群的masters和slaves,修改Hadoop的配置文件masters,vi/masters,然后在文件中输入Master.Hadoop保存退出,修改slaves,vi/slaves,去掉文件中的localhost,按照如下方式输入如下内容:
  

Slave1.Hadoop  

Slave2.Hadoop  

  保存退出,Hadoop的masters和slaves配置完毕
  现在修改Hadoop集群运行需要的配置配置主要的配置文件有四个分别是core-site.xml,hdfs-site.xml,mapred-site.xml和yarn-site.xml,这几个文件的配置相对较简单,可以根据具体的业务要求参考Hadoop相关资料进行修改,本文就不做赘述了,直接上配置文件
  core-site.xml
  

<?xml version="1.0" encoding="UTF-8"?>  
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
  
<!--
  
   Licensed under the Apache License, Version 2.0 (the "License");
  

   you may not use this file except in compliance with the License.  

   You may obtain a copy of the License at  

  
     http://www.apache.org/licenses/LICENSE-2.0
  
   Unless required by applicable law or agreed to in writing, software
  
   distributed under the License is distributed on an "AS IS" BASIS,
  
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  
   See the License for the specific language governing permissions and
  
   limitations under the License. See accompanying LICENSE file.
  
-->
  

  
<!-- Put site-specific property overrides in this file. -->
  
<configuration>
  

  
<property>
  
  <name>hadoop.tmp.dir</name>
  
<value>/usr/hadoop-2.8.1/data</value>
  
  #记住该位置,为防止找不到该文件位置以及hadoop namenode -format不成功,每次在应在/opt新建一个hadoop目录
  
</property>
  
  <property>
  
<name>fs.defaultFS</name>
  
<value>hdfs://Master.Hadoop:9000</value>
  
</property>
  
</configuration>
  

  hdfs-site.xml
  

<?xml version="1.0" encoding="UTF-8"?>  
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
  
<!--
  
   Licensed under the Apache License, Version 2.0 (the "License");
  

   you may not use this file except in compliance with the License.  

   You may obtain a copy of the License at  

  
     http://www.apache.org/licenses/LICENSE-2.0
  

  
   Unless required by applicable law or agreed to in writing, software
  
   distributed under the License is distributed on an "AS IS" BASIS,
  
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  
   See the License for the specific language governing permissions and
  
   limitations under the License. See accompanying LICENSE file.
  
-->
  

  
<!-- Put site-specific property overrides in this file. -->
  

  
<configuration>
  
<property>
  
<name>dfs.replication</name>
  
   <value>2</value>
  
</property>
  
<property>
  
   <name>dfs.namenode.name.dir</name>
  
   <value>file:/usr/hadoop-2.8.1/data/hdfs/namenode</value>
  
   <final>true</final>
  
</property>
  
<property>
  
   <name>dfs.datanode.data.dir</name>
  
   <value>file:/usr/hadoop-2.8.1/data/hdfs/datanode</value>
  
   <final>true</final>
  
</property>
  
<property>
  
   <name>dfs.namenode.secondary.http-address</name>
  
   <value>Master.Hadoop:9001</value>
  
</property>
  
<property>
  
   <name>dfs.webhdfs.enabled</name>
  
   <value>true</value>
  
</property>
  
<property>
  
   <name>dfs.permissions</name>
  
   <value>false</value>
  
</property>
  
</configuration>
  

  mapred-site.xml
  

<?xml version="1.0"?>  
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
  
<!--
  
   Licensed under the Apache License, Version 2.0 (the "License");
  

   you may not use this file except in compliance with the License.  

   You may obtain a copy of the License at  

  
     http://www.apache.org/licenses/LICENSE-2.0
  

  
   Unless required by applicable law or agreed to in writing, software
  
   distributed under the License is distributed on an "AS IS" BASIS,
  
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  
   See the License for the specific language governing permissions and
  
   limitations under the License. See accompanying LICENSE file.
  
-->
  

  
<!-- Put site-specific property overrides in this file. -->
  

  
<configuration>
  

  
<property>
  
   <name>mapreduce.framework.name</name>
  
   <value>yarn</value>
  
</property>
  
  <property>
  
     <name>mapreduce.jobhistory.address</name>
  
         <value>Master.Hadoop:10020</value>
  
   </property>
  
   <property>
  
      <name>mapreduce.jobhistory.webapp.address</name>
  
        <value>Master.Hadoop:19888</value>
  
   </property>
  
</configuration>
  

  yarn-site.xml
  

<?xml version="1.0"?>  
<!--
  
   Licensed under the Apache License, Version 2.0 (the "License");
  

   you may not use this file except in compliance with the License.  

   You may obtain a copy of the License at  

  
     http://www.apache.org/licenses/LICENSE-2.0
  

  
   Unless required by applicable law or agreed to in writing, software
  
   distributed under the License is distributed on an "AS IS" BASIS,
  
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  
   See the License for the specific language governing permissions and
  
   limitations under the License. See accompanying LICENSE file.
  
-->
  

  
<configuration>
  
  <property>
  
<name>yarn.nodemanager.aux-services</name>
  
<value>mapreduce_shuffle</value>
  
</property>
  
<property>
  
<name>yarn.nodemanager.auxservices.mapreduce.shuffle.class</name>
  
  <value>org.apache.hadoop.mapred.ShuffleHandler</value>
  
</property>
  
<property>
  
<name>yarn.resourcemanager.address</name>
  
<value>Master.Hadoop:8032</value>
  
</property>
  
<property>
  
<name>yarn.resourcemanager.scheduler.address</name>
  
<value>Master.Hadoop:8030</value>
  
</property>
  
<property>
  
<name>yarn.resourcemanager.resource-tracker.address</name>
  
<value>Master.Hadoop:8031</value>
  
</property>
  
<property>
  
<name>yarn.resourcemanager.admin.address</name>
  
<value>Master.Hadoop:8033</value>
  
</property>
  
<property>
  
<name>yarn.resourcemanager.webapp.address</name>
  
<value>Master.Hadoop:8088</value>
  
</property>
  
<!-- Site specific YARN configuration properties -->
  
  </configuration>
  

  完成以上操作后Master.Hadoop服务器上的Hadoop配置就基本完成了,现在通过命令将Hadoop这个目录分别传输到Slave1.Hadoop,Slave2.Hadoop服务器上,命令如下:
  

scp /usr/hadoop-2.8.1 root@Slave1.Hadoop:/usr/hadoop-2.8.1  
scp /usr/hadoop-2.8.1 root@Slave2.Hadoop:/usr/hadoop-2.8.1
  

  文件传输完成后,Hadoop全分布式集群就配置完成了
  5 测试部署的集群
  先在Master.Hadoop上通过如下命令进行初始化
  

cd /usr/hadoop-2.8.1/bin ./hadoop namenode -format  

  完成上述初始化以后,启动Master.Hadoop上的Hadoop集群,命令如下
  

cd /usr/hadoop-2.8.1/sbin  

./start-all.sh  

  启动后会看到如下信息:
DSC0000.jpg

  集群启动的同时会同时启动Slave1.Hadoop,Slave2.Hadoop上对应的节点,现在通过jps命令查看集群信息
  在Master.Hadoop服务器上jps如果能看到如下进程信息,就说明我们的Hadoop全分布式集群部署成功了!!!
DSC0001.jpg

  Slave1.Hadoop
DSC0002.jpg

  Slave2.Hadoop
DSC0003.jpg

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-425035-1-1.html 上篇帖子: 大数据Hadoop学习之了解Hadoop(1) 下篇帖子: Linux下配置Hadoop全分布式环境
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表