基于hadoop2.7.6的搭建
解压
hdfs-site.xml配置
<!--副本数据-->
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<!--2namenode -->
<property>
<name>dfs.namenode.secondary.http-address</name>
<value>YZ-222-113-91.h.chinabank.com.cn:50090</value>
</property>
<property>
<name>hadoop.http.staticuser.user</name>
<value>supdev</value>
</property>
core-site.xml配置
<property>
<name>fs.defaultFS</name>
<value>hdfs://YZ-222-113-88.h.chinabank.com.cn:9000</value>
</property>
<!--运行时候产生临时文件存放地址 -->
<property>
<name>hadoop.tmp.dir</name>
<value>/usr/local/module/hadoop/data/tmp</value>
</property>
yarn-site.xml配置
<!--rm-->
<property>
<name>yarn.resourcemanager.hostname</name>
<value>YZ-222-113-90.h.chinabank.com.cn</value>
</property>
<!--NodeManager上运行的附属服务。需配置成mapreduce_shuffle,才可运行MapReduce程序-->
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<!--下面两个主要是针对spark配置,防止任务大了不执行直接就溢出-->
<property>
<name>yarn.nodemanager.pmem-check-enabled</name>
<value>false</value>
</property>
<property>
<name>yarn.nodemanager.vmem-check-enabled</name>
<value>false</value>
</property>
maperd-site.xml配置
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
<description>The runtime framework for executing MapReduce jobs.
Can be one of local, classic or yarn.
</description>
</property>
修改hadoop-env.sh配置
修改 export JAVA_HOME=/export/servers/jdk1.8.0_66
修改maperd-env.sh配置
修改 export JAVA_HOME=/export/servers/jdk1.8.0_66
修改yarn-env.sh配置
修改 export JAVA_HOME=/export/servers/jdk1.8.0_66
配置slaves(主要一台机器启动hdfs,其他全部都能启动)
YZ-222-113-88.h.chinabank.com.cn
YZ-222-113-90.h.chinabank.com.cn
YZ-222-113-91.h.chinabank.com.cn
以上就是基本的配置,然后修改/etc/profile文件,配置#HADOOP_HOME
export HADOOP_HOME=/usr/local/module/hadoop
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin 然后source /etc/profile,接着就是启动hadoop了 记得分发 第一步需要先格式化 bin/hdfs namenode -format,第二步需要在任何一台机子上执行sbin/start-dfs.sh(启动nn dn 2nn),第三步是在配置的rm的机子上执行sbin/start-yarn.sh,以上是最基本的配置
高可用的配置,首先配置好zookeeper
解压 创建一个文件夹zkData,在这个文件夹下面touch myid 这个里面填写一个序号。然后打开 conf,将zoo.cfg.telm改成zoo.cfg这里面的配置 dataDir=/usr/local/module/zookeeper-3.4.10/zkData,同时配置集群 server.1=10.222.113.88:2888:3888
server.2=10.222.113.90:2888:3888
server.3=10.222.113.91:2888:3888
同时避免日志乱放可以在zkEnv.sh将ZOO_LOG_DIR="$ZOOKEEPER_PREFIX/logs",这样还是会出个日志,虽然日志已经是0字节的,还可以在zkServer.sh,增加一个_ZOO_DAEMON_OUT="$ZOO_LOG_DIR/zookeeper.log",完美了
接着配置高可用(相同还是hadoop-env.sh配置,yarn-env.sh配置,maperd-env.sh配置都一样,不做说明 )
hdfs-site.xml配置
<!--https://hadoop.apache.org/docs/r2.7.6/hadoop-project-dist/hadoop-hdfs/HDFSHighAvailabilityWithQJM.html-->
<!--副本数据-->
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<!--此新名称服务的逻辑名称-->
<property>
<name>dfs.nameservices</name>
<value>mycluster</value>
</property>
<!-- 服务中每个NameNode的唯一标识符 -->
<property>
<name>dfs.ha.namenodes.mycluster</name>
<value>nn1,nn2</value>
</property>
<!-- 每个NameNode监听的标准RPC地址-->
<property>
<name>dfs.namenode.rpc-address.mycluster.nn1</name>
<value>10.222.113.88:9000</value>
</property>
<property>
<name>dfs.namenode.rpc-address.mycluster.nn2</name>
<value>10.222.113.90:9000</value>
</property>
<!-- 每个NameNode监听的标准HTTP地址-->
<property>
<name>dfs.namenode.http-address.mycluster.nn1</name>
<value>10.222.113.88:50070</value>
</property>
<property>
<name>dfs.namenode.http-address.mycluster.nn2</name>
<value>10.222.113.90:50070</value>
</property>
<!-- 标识NameNode将在其中写入/读取编辑内容的JN组的URI-->
<property>
<name>dfs.namenode.shared.edits.dir</name>
<value>qjournal://10.222.113.88:8485;10.222.113.90:8485;10.222.113.91:8485/mycluster</value>
</property>
<!--脚本或Java类的列表,这些列表将用于在故障转移期间隔离Active NameNodesshfence -SSH到Active NameNode并终止进程 -->
<property>
<name>dfs.ha.fencing.methods</name>
<value>sshfence</value>
</property>
<!-- 该sshfence选项SSHes到目标节点,然后通过定影杀该服务的TCP端口上侦听的过程。为了使该防护选项起作用,它必须能够在不提供密码的情况下SSH到目标节点。因此,还必须配置dfs.ha.fencing.ssh.private-key-files选项,这是一个用逗号分隔的SSH私钥文件列表-->
<property>
<name>dfs.ha.fencing.ssh.private-key-files</name>
<value>/home/supdev/.ssh/id_rsa</value>
</property>
<!--JournalNode守护程序将存储其本地状态的路径-->
<property>
<name>dfs.journalnode.edits.dir</name>
<value>/usr/local/module/hadoop/data/jn</value>
</property>
<!-- 关闭权限检查-->
<property>
<name>dfs.permissions.enable</name>
<value>false</value>
</property>
<!-- Hadoop当前随附的唯一实现是ConfiguredFailoverProxyProvider-->
<property>
<name>dfs.client.failover.proxy.provider.mycluster</name>
<value>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider</value>
</property>
<!--发生故障自动转移-->
<property>
<name>dfs.ha.automatic-failover.enabled</name>
<value>true</value>
</property>
core-site.xml配置
<!---绑定namenode-->
<property>
<name>fs.defaultFS</name>
<value>hdfs://mycluster</value>
</property>
<!--运行时候产生临时文件存放地址 -->
<property>
<name>hadoop.tmp.dir</name>
<value>/usr/local/module/hadoop/data/tmp</value>
</property>
<!--锁定zk-->
<property>
<name>ha.zookeeper.quorum</name>
<value>10.222.113.88:2181,10.222.113.90:2181,10.222.113.91:2181</value>
</property>
yarn-site.xml配置
<!--http://hadoop.apache.org/docs/r2.7.6/hadoop-yarn/hadoop-yarn-site/ResourceManagerHA.html-->
<!--NodeManager上运行的附属服务。需配置成mapreduce_shuffle,才可运行MapReduce程序-->
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<property>
<name>yarn.nodemanager.pmem-check-enabled</name>
<value>false</value>
</property>
<property>
<name>yarn.nodemanager.vmem-check-enabled</name>
<value>false</value>
</property>
<property>
<name>yarn.resourcemanager.ha.enabled</name>
<value>true</value>
</property>
<property>
<name>yarn.resourcemanager.cluster-id</name>
<value>cluster-yarn1</value>
</property>
<property>
<name>yarn.resourcemanager.ha.rm-ids</name>
<value>rm1,rm2</value>
</property>
<property>
<name>yarn.resourcemanager.hostname.rm1</name>
<value>10.222.113.88</value>
</property>
<property>
<name>yarn.resourcemanager.hostname.rm2</name>
<value>10.222.113.90</value>
</property>
<property>
<name>yarn.resourcemanager.zk-address</name>
<value>10.222.113.88:2181,10.222.113.90:2181,10.222.113.91:2181</value>
</property>
<property>
<name>yarn.resourcemanager.recovery.enabled</name>
<value>true</value>
</property>
<property>
<name>yarn.resourcemanager.store.class</name>
<value>org.apache.hadoop.yarn.server.resourcemanager.recovery.ZKRMStateStore</value>
</property>
maperd-site.xml配置
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
<description>The runtime framework for executing MapReduce jobs.
Can be one of local, classic or yarn.
</description>
</property>
基本上就是一些配置。关于高可用的启动
首先还是需要格式化 bin/hdfs namenode -format,然后启动zookeeper,然后启动hdfs和yarn就可以了