【甘道夫】Hadoop2.4.1尝鲜部署+完整版配置文件

引言
      转眼间,Hadoop的stable版本已经升级到2.4.1了,社区的力量真是强大!3.0啥时候release呢?
      今天做了个调研,尝鲜了一下2.4.1版本的分布式部署,包括NN HA(目前已经部署好了2.2.0的NN HA,ZK和ZKFC用现成的),顺便也结合官方文档 http://hadoop.apache.org/docs/r2.4.1/hadoop-project-dist/hadoop-common/ClusterSetup.html  梳理、补全了关键的配置文件属性,将同类属性归类,方便以后阅读修改,及作为模板使用。
      下面记录参照官方文档及过去经验部署2.4.1的过程。
      欢迎转载,请注明来源:http://blog.csdn.net/u010967382/article/details/37706181

注意
     1.本文只记录配置文件,不记录其余部署过程,其余过程和2.2.0相同,参见
     http://blog.csdn.net/u010967382/article/details/20380387
     http://blog.csdn.net/u010967382/article/details/30976935
     2.配置中所有的路径、IP、hostname均需根据实际情况修改。

1.实验环境
4节点集群,ZK节点3个,hosts文件和各节点角色分配如下:
hosts
192.168.66.91 master
192.168.66.92 slave1
192.168.66.93 slave2
192.168.66.94 slave3

角色分配
  Active NN Standby NN DN JournalNode Zookeeper FailoverController
master V     V V V
slave1   V V V V V
slave2     V V V  
slave3     V      


2.hadoop-env.sh  修改以下三处即可
# The java implementation to use.
export  JAVA_HOME =/usr/lib/jvm/jdk1.7.0_07

# The directory where pid files are stored. /tmp by default.
# NOTE: this should be set to a directory that can only be written to by the user that will run the hadoop daemons.  Otherwise there is the potential for a symlink attack.
export  HADOOP_PID_DIR =/home/yarn/Hadoop/hadoop-2.4.1/hadoop_pid_dir
export  HADOOP_SECURE_DN_PID_DIR =/home/yarn/Hadoop/hadoop-2.4.1/hadoop_pid_dir


3.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>fs.defaultFS</name>
        <value>hdfs://myhadoop</value>
        <description>NameNode UR,格式是hdfs://host:port/,如果开启了NN
            HA特性,则配置集群的逻辑名,具体参见我的博客http://blog.csdn.net/u010967382/article/details/30976935
        </description>
    </property>
    <property>
        <name>hadoop.tmp.dir</name>
        <value>/home/yarn/Hadoop/hadoop-2.4.1/tmp</value>
    </property>
    <property>
        <name>io.file.buffer.size</name>
        <value>131072</value>
        <description>Size of read/write buffer used in SequenceFiles.
        </description>
    </property>
    <property>
        <name>ha.zookeeper.quorum</name>
        <value>master:2181,slave1:2181,slave2:2181</value>
        <description>注意,配置了ZK以后,在格式化、启动NameNode之前必须先启动ZK,否则会报连接错误
        </description>
    </property>
</configuration>  



4.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>
    <!-- NN HA related configuration **BEGIN** -->
    <property>
        <name>dfs.nameservices</name>
        <value>myhadoop</value>
        <description>
            Comma-separated list of nameservices.
            as same as fs.defaultFS in core-site.xml.
        </description>
    </property>
    <property>
        <name>dfs.ha.namenodes.myhadoop</name>
        <value>nn1,nn2</value>
        <description>
            The prefix for a given nameservice, contains a comma-separated
            list of namenodes for a given nameservice (eg EXAMPLENAMESERVICE).
        </description>
    </property>
    <property>
        <name>dfs.namenode.rpc-address.myhadoop.nn1</name>
        <value>master:8020</value>
        <description>
            RPC address for nomenode1 of hadoop-test
        </description>
    </property>
    <property>
        <name>dfs.namenode.rpc-address.myhadoop.nn2</name>
        <value>slave1:8020</value>
        <description>
            RPC address for nomenode2 of hadoop-test
        </description>
    </property>
<
  • 4
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
1.准备Linux环境 1.0点击VMware快捷方式,右键打开文件所在位置 -> 双击vmnetcfg.exe -> VMnet1 host-only ->修改subnet ip 设置网段:192.168.1.0 子网掩码:255.255.255.0 -> apply -> ok 回到windows --> 打开网络和共享中心 -> 更改适配器设置 -> 右键VMnet1 -> 属性 -> 双击IPv4 -> 设置windows的IP:192.168.1.100 子网掩码:255.255.255.0 -> 点击确定 在虚拟软件上 --My Computer -> 选中虚拟机 -> 右键 -> settings -> network adapter -> host only -> ok 1.1修改主机名 vim /etc/sysconfig/network NETWORKING=yes HOSTNAME=itcast ### 1.2修改IP 两种方式: 第一种:通过Linux图形界面进行修改(强烈推荐) 进入Linux图形界面 -> 右键点击右上方的两个小电脑 -> 点击Edit connections -> 选中当前网络System eth0 -> 点击edit按钮 -> 选择IPv4 -> method选择为manual -> 点击add按钮 -> 添加IP:192.168.1.101 子网掩码:255.255.255.0 网关:192.168.1.1 -> apply 第二种:修改配置文件方式(屌丝程序猿专用) vim /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE="eth0" BOOTPROTO="static" ### HWADDR="00:0C:29:3C:BF:E7" IPV6INIT="yes" NM_CONTROLLED="yes" ONBOOT="yes" TYPE="Ethernet" UUID="ce22eeca-ecde-4536-8cc2-ef0dc36d4a8c" IPADDR="192.168.1.101" ### NETMASK="255.255.255.0" ### GATEWAY="192.168.1.1" ### 1.3修改主机名和IP的映射关系 vim /etc/hosts 192.168.1.101 itcast 1.4关闭防火墙 #查看防火墙状态 service iptables status #关闭防火墙 service iptables stop #查看防火墙开机启动状态 chkconfig iptables --list #关闭防火墙开机启动 chkconfig iptables off 1.5重启Linux reboot 2.安装JDK 2.1上传alt+p 后出现sftp窗口,然后put d:\xxx\yy\ll\jdk-7u_65-i585.tar.gz 2.2解压jdk #创建文件夹 mkdir /home/hadoop/app #解压 tar -zxvf jdk-7u55-linux-i586.tar.gz -C /home/hadoop/app 2.3将java添加到环境变量中 vim /etc/profile #在文件最后添加 export JAVA_HOME=/home/hadoop/app/jdk-7u_65-i585 export PATH=$PATH:$JAVA_HOME/bin #刷新配置 source /etc/profile 3.安装hadoop2.4.1 先上传hadoop的安装包到服务器上去/home/hadoop/ 注意:hadoop2.x的配置文件$HADOOP_HOME/etc/hadoop 伪分布式需要修改5个配置文件 3.1配置hadoop 第一个:hadoop-env.sh vim hadoop-env.sh #第27行 export JAVA_HOME=/usr/java/jdk1.7.0_65 第二个:core-site.xml <!-- 指定HADOOP所使用的文件系统schema(URI),HDFS的老大(NameNode)的地址 --> fs.defaultFS hdfs://weekend-1206-01:9000 <!-- 指定hadoop运行时产生文件的存储目录 --> hadoop.tmp.dir /home/hadoop/hadoop-2.4.1/tmp 第三个:hdfs-site.xml hdfs-default.xml (3) <!-- 指定HDFS副本的数量 --> dfs.replication 1 第四个:mapred-site.xml (mv mapred-site.xml.template mapred-site.xml) mv mapred-site.xml.template mapred-site.xml vim mapred-site.xml <!-- 指定mr运行在yarn上 --> mapreduce.framework.name yarn 第五个:yarn-site.xml <!-- 指定YARN的老大(ResourceManager)的地址 --> yarn.resourcemanager.hostname weekend-1206-01 <!-- reducer获取数据的方式 --> yarn.nodemanager.aux-services mapreduce_shuffle 3.2将hadoop添加到环境变量 vim /etc/proflie export JAVA_HOME=/usr/java/jdk1.7.0_65 export HADOOP_HOME=/itcast/hadoop-2.4.1 export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin source /etc/profile 3.3格式化namenode(是对namenode进行初始化) hdfs namenode -format (hadoop namenode -format) 3.4启动hadoop 先启动HDFS sbin/start-dfs.sh 再启动YARN sbin/start-yarn.sh 3.5验证是否启动成功 使用jps命令验证 27408 NameNode 28218 Jps 27643 SecondaryNameNode 28066 NodeManager 27803 ResourceManager 27512 DataNode http://192.168.1.101:50070 (HDFS管理界面) http://192.168.1.101:8088 (MR管理界面) 4.配置ssh免登陆 #生成ssh免登陆密钥 #进入到我的home目录 cd ~/.ssh ssh-keygen -t rsa (四个回车) 执行完这个命令后,会生成两个文件id_rsa(私钥)、id_rsa.pub(公钥) 将公钥拷贝到要免登陆的机器上 ssh-copy-id localhost

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值