标签:edits 分割 hadoop1 zookeeper 密钥对 erp expand path 2.4
192.168.182.12 (bigdata12)
192.168.182.13 (bigdata13)
192.168.182.14 (bigdata14)
192.168.182.12 (bigdata12) NameNode1主节点 ResourceManager1主节点 Journalnode
192.168.182.13 (bigdata13) NameNode2备用主节点 ResourceManager2备用主节点 Journalnode
192.168.182.14 (bigdata14) DataNode1 NodeManager1
192.168.182.15 (bigdata15) DataNode2 NodeManager2
我这里使用的是jdk-8u152-linux-x64.tar.gz安装包
tar -zxvf jdk-8u144-linux-x64.tar.gz -C ~/training
vi ~/.bash_profile
export JAVA_HOME=/root/training/jdk1.8.0_144
export PATH=$JAVA_HOME/bin:$PATH
source ~/.bash_profile
java -version
vi /etc/hosts
192.168.182.13 bigdata13
192.168.182.14 bigdata14
192.168.182.15 bigdata15
ssh-keygen -t rsa
含义:通过ssh协议采用非对称加密算法的rsa算法生成一组密钥对:公钥和私钥
注:以下四个命令需要在每台机器上都运行一遍
ssh-copy-id -i .ssh/id_rsa.pub root@bigdata12
ssh-copy-id -i .ssh/id_rsa.pub root@bigdata13
ssh-copy-id -i .ssh/id_rsa.pub root@bigdata14
ssh-copy-id -i .ssh/id_rsa.pub root@bigdata15
在主节点(bigdata12)上安装和配置ZooKeeper
我这里使用的是zookeeper-3.4.10.tar.gz安装
tar -zxvf zookeeper-3.4.10.tar.gz -C ~/training
export ZOOKEEPER_HOME=/root/training/zookeeper-3.4.10
export PATH=$ZOOKEEPER_HOME/bin:$PATH
source ~/.bash_profile
vi /root/training/zookeeper-3.4.10/conf/zoo.cfg
dataDir=/root/training/zookeeper-3.4.10/tmp
server.1=bigdata12:2888:3888
server.2=bigdata13:2888:3888
server.3=bigdata14:2888:3888
在/root/training/zookeeper-3.4.10/tmp目录下创建一个myid的空文件:
mkdir /root/training/zookeeper-3.4.10/tmp/myid
echo 1 > /root/training/zookeeper-3.4.10/tmp/myid
scp -r /root/training/zookeeper-3.4.10/ bigdata13:/root/training
scp -r /root/training/zookeeper-3.4.10/ bigdata14:/root/training
进入bigdata13和bigdata14两台机器中,找到myid文件,将其中的1分别修改为2和3:
vi myid
在bigdata13中输入:2在bigdata14中输入:3
export JAVA_HOME=/root/training/jdk1.8.0_144
<configuration>
<!-- 指定hdfs的nameservice为ns1 -->
<property>
<name>fs.defaultFS</name>
<value>hdfs://ns1</value>
</property>
<!-- 指定HDFS数据存放路径,默认存放在linux的/tmp目录中 -->
<property>
<name>hadoop.tmp.dir</name>
<value>/root/training/hadoop-2.7.3/tmp</value>
</property>
<!-- 指定zookeeper的地址 -->
<property>
<name>ha.zookeeper.quorum</name>
<value>bigdata12:2181,bigdata13:2181,bigdata14:2181</value>
</property>
</configuration>
<configuration>
<!--指定hdfs的nameservice为ns1,需要和core-site.xml中的保持一致 -->
<property>
<name>dfs.nameservices</name>
<value>ns1</value>
</property>
?
<!-- ns1下面有两个NameNode,分别是nn1,nn2 -->
<property>
<name>dfs.ha.namenodes.ns1</name>
<value>nn1,nn2</value>
</property>
?
<!-- nn1的RPC通信地址 -->
<property>
<name>dfs.namenode.rpc-address.ns1.nn1</name>
<value>bigdata12:9000</value>
</property>
?
<!-- nn1的http通信地址 -->
<property>
<name>dfs.namenode.http-address.ns1.nn1</name>
<value>bigdata12:50070</value>
</property>
?
<!-- nn2的RPC通信地址 -->
<property>
<name>dfs.namenode.rpc-address.ns1.nn2</name>
<value>bigdata13:9000</value>
</property>
?
<!-- nn2的http通信地址 -->
<property>
<name>dfs.namenode.http-address.ns1.nn2</name>
<value>bigdata13:50070</value>
</property>
?
<!-- 指定NameNode的日志在JournalNode上的存放位置 -->
<property>
<name>dfs.namenode.shared.edits.dir</name>
<value>qjournal://bigdata12:8485;bigdata13:8485;/ns1</value>
</property>
?
<!-- 指定JournalNode在本地磁盘存放数据的位置 -->
<property>
<name>dfs.journalnode.edits.dir</name>
<value>/root/training/hadoop-2.7.3/journal</value>
</property>
?
<!-- 开启NameNode失败自动切换 -->
<property>
<name>dfs.ha.automatic-failover.enabled</name>
<value>true</value>
</property>
?
<!-- 配置失败自动切换实现方式 -->
<property>
<name>dfs.client.failover.proxy.provider.ns1</name>
<value>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider</value>
</property>
?
<!-- 配置隔离机制方法,多个机制用换行分割,即每个机制暂用一行-->
<property>
<name>dfs.ha.fencing.methods</name>
<value>
sshfence
shell(/bin/true)
</value>
</property>
<!-- 使用sshfence隔离机制时需要ssh免登陆 -->
<property>
<name>dfs.ha.fencing.ssh.private-key-files</name>
<value>/root/.ssh/id_rsa</value>
</property>
<!-- 配置sshfence隔离机制超时时间 -->
<property>
<name>dfs.ha.fencing.ssh.connect-timeout</name>
<value>30000</value>
</property>
</configuration>
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>
配置Yarn的HA
<configuration>
<!-- 开启RM高可靠 -->
<property>
<name>yarn.resourcemanager.ha.enabled</name>
<value>true</value>
</property>
<!-- 指定RM的cluster id -->
<property>
<name>yarn.resourcemanager.cluster-id</name>
<value>yrc</value>
</property>
<!-- 指定RM的名字 -->
<property>
<name>yarn.resourcemanager.ha.rm-ids</name>
<value>rm1,rm2</value>
</property>
<!-- 分别指定RM的地址 -->
<property>
<name>yarn.resourcemanager.hostname.rm1</name>
<value>bigdata12</value>
</property>
<property>
<name>yarn.resourcemanager.hostname.rm2</name>
<value>bigdata13</value>
</property>
<!-- 指定zk集群地址 -->
<property>
<name>yarn.resourcemanager.zk-address</name>
<value>bigdata12:2181,bigdata13:2181,bigdata14:2181</value>
</property>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
</configuration>
bigdata14
bigdata15
scp -r /root/training/hadoop-2.7.3/ root@bigdata13:/root/training/
scp -r /root/training/hadoop-2.7.3/ root@bigdata14:/root/training/
scp -r /root/training/hadoop-2.7.3/ root@bigdata15:/root/training/
在每一台机器上输入:
zkServer.sh start
在bigdata12和bigdata13两台节点上启动journalnode节点:
hadoop-daemon.sh start journalnode
hdfs namenode -format
将/root/training/hadoop-2.7.3/tmp拷贝到bigdata13的/root/training/hadoop-2.7.3/tmp下
scp -r dfs/ root@bigdata13:/root/training/hadoop-2.7.3/tmp
hdfs zkfc -formatZK
日志:INFO ha.ActiveStandbyElector: Successfully created /hadoop-ha/ns1 in ZK.
以上日志表明在Zookeeper的文件系统中创建了/hadoop-ha/ns1的子目录用于保存Namenode的结构信息
start-all.sh
日志: Starting namenodes on [bigdata12 bigdata13] bigdata12: starting namenode, logging to /root/training/hadoop-2.4.1/logs/hadoop-root-namenode-hadoop113.out bigdata13: starting namenode, logging to /root/training/hadoop-2.4.1/logs/hadoop-root-namenode-hadoop112.out bigdata14: starting datanode, logging to /root/training/hadoop-2.4.1/logs/hadoop-root-datanode-hadoop115.out bigdata15: starting datanode, logging to /root/training/hadoop-2.4.1/logs/hadoop-root-datanode-hadoop114.out bigdata13: starting zkfc, logging to /root/training/hadoop-2.7.3/logs/hadoop-root-zkfc- bigdata13.out bigdata12: starting zkfc, logging to /root/training/hadoop-2.7.3/logs/hadoop-root-zkfc-bigdata12.out
yarn-daemon.sh start resourcemanager
至此,Hadoop集群的HA架构就已经搭建成功。
版权声明:本文为博主原创文章, 未经博主允许不得转载。http://www.cnblogs.com/lijinze-tsinghua/
标签:edits 分割 hadoop1 zookeeper 密钥对 erp expand path 2.4
原文地址:https://www.cnblogs.com/lijinze-tsinghua/p/9267876.html