Hadoop的HA高可用(可行)
Zookeeper集群
192.168.116.121 | 192.168.116.122 | 192.168.116.123 |
hsiehchou121 | hsiehchou122 | hsiehchou123 |
Hadoop集群
192.168.116.121 | 192.168.116.122 | 192.168.116.123 | 192.168.116.124 |
hsiehchou121 | hsiehchou122 | hsiehchou123 | hsiehchou124 |
NameNode1 | NameNode2 | DataNode1 | DataNode2 |
ResourceManager1 | ResourceManager2 | NodeManager1 | NodeManager2 |
Journalnode | Journalnode |
1、安装JDK
2、配置环境变量
3、配置免密码登录
4、配置主机名
在主节点(hsiehchou121)上配置ZooKeeper
dataDir=
/root/hd
/zookeeper-3.4.10/zkData
+++++++++++++++zkconfig+++++++++++++++++
server
.1=
hsiehchou121:
2888:
3888
server
.2=
hsiehchou122:
2888:
3888
server
.3=
hsiehchou123:
2888:
3888
echo 1 > /root/hd/zookeeper-3.4.10/tmp/myid
scp -r /root/hd/zookeeper-3.4.10/ hsiehchou122:/root/hd
scp -r /root/hd/zookeeper-3.4.10/ hsiehchou123:/root/hd
export JAVA_HOME=
/root/hd/jdk1
.8
.0_192
<configuration>
<property>
<name>fs.defaultFS
name>
<value>hdfs://mycluster
value>
property>
<property>
<name>hadoop.tmp.dir
name>
<value>/root/hd/hadoop-2.8.4/tmp
value>
property>
<property>
<name>ha.zookeeper.quorum
name>
<value>hsiehchou121:2181,hsiehchou122:2181,hsiehchou123:2181
value>
property>
configuration>
<configuration>
<property>
<name>dfs.nameservices
name>
<value>mycluster
value>
property>
<property>
<name>dfs.ha.namenodes.mycluster
name>
<value>nn1,nn2
value>
property>
<property>
<name>dfs.namenode.rpc-address.mycluster.nn1
name>
<value>hsiehchou121:9000
value>
property>
<property>
<name>dfs.namenode.http-address.mycluster.nn1
name>
<value>hsiehchou121:50070
value>
property>
<property>
<name>dfs.namenode.rpc-address.mycluster.nn2
name>
<value>hsiehchou122:9000
value>
property>
<property>
<name>dfs.namenode.http-address.mycluster.nn2
name>
<value>hsiehchou122:50070
value>
property>
<property>
<name>dfs.namenode.shared.edits.dir
name>
<value>qjournal://hsiehchou121:8485;hsiehchou122:8485;/mycluster
value>
property>
<property>
<name>dfs.journalnode.edits.dir
name>
<value>/root/hd/hadoop-2.8.4/journal
value>
property>
<property>
<name>dfs.ha.automatic-failover.enabled
name>
<value>true
value>
property>
<property>
<name>dfs.client.failover.proxy.provider.mycluster
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>
<property>
<name>dfs.ha.fencing.ssh.private-key-files
name>
<value>/root/.ssh/id_rsa
value>
property>
<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>
<configuration>
<property>
<name>yarn.resourcemanager.ha.enabled
name>
<value>true
value>
property>
<property>
<name>yarn.resourcemanager.cluster-id
name>
<value>yarncluster
value>
property>
<property>
<name>yarn.resourcemanager.ha.rm-ids
name>
<value>rm1,rm2
value>
property>
<property>
<name>yarn.resourcemanager.hostname.rm1
name>
<value>hsiehchou121
value>
property>
<property>
<name>yarn.resourcemanager.hostname.rm2
name>
<value>hsiehchou122
value>
property>
<property>
<name>yarn.resourcemanager.zk-address
name>
<value>hsiehchou121:2181,hsiehchou122:2181,hsiehchou123:2181
value>
property>
<property>
<name>yarn.nodemanager.aux-services
name>
<value>mapreduce_shuffle
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>
<property>
<name>yarn.scheduler.maximum-allocation-mb
name>
<value>32768
value>
property>
<property>
<name>yarn.nodemanager.resource.memory-mb
name>
<value>32768
value>
property>
<property>
<name>yarn.scheduler.minimum-allocation-mb
name>
<value>4096
value>
property>
<property>
<name>yarn.nodemanager.resource.cpu-vcores
name>
<value>24
value>
property>
<property>
<name>yarn.log-aggregation-enable
name>
<value>true
value>
property>
<property>
<name>yarn.nodemanager.remote-app-log-dir
name>
<value>/tmp/yarn-logs
value>
property>
configuration>
hsiehchou123
hsiehchou124
scp -r /root/hd/hadoop-2.8.4/ root@hsiehchou122:/root/hd/
scp -r /root/hd/hadoop-2.8.4/ root@hsiehchou123:/root/hd/
scp -r /root/hd/hadoop-2.8.4/ root@hsiehchou124:/root/hd/
[root@hsiehchou121 hadoop-2.8.4]# hdfs zkfc -formatZK
[root@hsiehchou121 hadoop-2.8.4]# zkServer.sh start
[root@hsiehchou122 hadoop-2.8.4]# zkServer.sh start
[root@hsiehchou123 hadoop-2.8.4]# zkServer.sh start
hadoop-daemon.sh start journalnode
[root@hsiehchou121 hadoop-2.8.4]# hdfs zkfc -formatZK
1)在各个JournalNode节点上,输入以下命令启动journalnode服务
[root@hsiehchou121 hadoop-2.8.4]# sbin/hadoop-daemon.sh start journalnode
2)在[nn1]上,对其进行格式化,并启动
[root@hsiehchou121 hadoop-2.8.4]# bin/hdfs namenode -format
[root@hsiehchou121 hadoop-2.8.4]# sbin/hadoop-daemon.sh start namenode
3)在[nn2]上,同步nn1的元数据信息
[root@hsiehchou121 hadoop-2.8.4]# bin/hdfs namenode -bootstrapStandby
[root@hsiehchou121 hadoop-2.8.4]# start-all.sh
日志
This script is Deprecated. Instead use start-dfs.sh and start-yar
Starting namenodes on [hsiehchou121 hsiehchou122]
hsiehchou121: starting namenode, logging to /root/hd/hadoop-2.8.4-hsiehchou121.out
hsiehchou122: starting namenode, logging to /root/hd/hadoop-2.8.4-hsiehchou122.out
hsiehchou124: starting datanode, logging to /root/hd/hadoop-2.8.4-hsiehchou124.out
hsiehchou123: starting datanode, logging to /root/hd/hadoop-2.8.4-hsiehchou123.out
Starting journal nodes [hsiehchou121 hsiehchou122 ]
hsiehchou121: starting journalnode, logging to /root/hd/hadoop-2.alnode-hsiehchou121.out
hsiehchou122: starting journalnode, logging to /root/hd/hadoop-2.alnode-hsiehchou122.out
Starting ZK Failover Controllers on NN hosts [hsiehchou121 hsiehc
hsiehchou121: starting zkfc, logging to /root/hd/hadoop-2.8.4/logou121.out
hsiehchou122: starting zkfc, logging to /root/hd/hadoop-2.8.4/logou122.out
starting yarn daemons
starting resourcemanager, logging to /root/hd/hadoop-2.8.4/logs/ysiehchou121.out
hsiehchou123: starting nodemanager, logging to /root/hd/hadoop-2.ager-hsiehchou123.out
hsiehchou124: starting nodemanager, logging to /root/hd/hadoop-2.ager-hsiehchou124.out
hsiehchou122上的ResourceManager需要单独启动
命令
[root@hsiehchou121 hadoop-2.8.4]# ./sbin/yarn-daemon.sh start resourcemanager