03_HADOOP_04_HDFS高可用环境搭建

参考文章:https://blog.csdn.net/weixin_42782897/article/details/89335674

Hadoop高可用架构图

环境规划

演示环境规划

在node01修改hdfs-site.xml配置


    
    
        dfs.replication
        2
    
    
    
    dfs.nameservices
    zhhcluster
    
    
    
        dfs.ha.namenodes.zhhcluster
        zhh_nn1,zhh_nn2
    
    
    
        dfs.namenode.rpc-address.zhhcluster.zhh_nn1
        node01:8020
    
    
        dfs.namenode.rpc-address.zhhcluster.zhh_nn2
        node02:8020
    
    
    
        dfs.namenode.http-address.zhhcluster.zhh_nn1
        node01:50070
    
    
        dfs.namenode.http-address.zhhcluster.zhh_nn2
        node02:50070
    
    
    
        dfs.namenode.shared.edits.dir
        qjournal://node01:8485;node02:8485;node03:8485/zhhcluster
    
    
    
        dfs.client.failover.proxy.provider.zhhcluster
        org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider
    
    
    
        dfs.journalnode.edits.dir
        /var/hadoop/ha/jn
    
    
    
        dfs.ha.fencing.methods
        sshfence
    
    
        dfs.ha.fencing.ssh.private-key-files
        /root/.ssh/id_dsa
    
    
    
        dfs.ha.automatic-failover.enabled
        true
    

在node01修改core-site.xml配置


    
    
        fs.defaultFS
        hdfs://zhhcluster
    
    
    
        hadoop.tmp.dir
        /var/hadoop/ha
    
    
        ha.zookeeper.quorum
        node02:2181,node03:2181,node04:2181
        

分发node01的hdfs-site.xml和core-site.xml到其他机器

前提是已经完成了前面几节,其他机器已经有hadoop了

cd $HADOOP_PREFIX/etc/hadoop
scp  hdfs-site.xml  core-site.xml  node02:`pwd`
scp  hdfs-site.xml  core-site.xml  node03:`pwd`
scp  hdfs-site.xml  core-site.xml  node04:`pwd`

在node02开启对其他三台机器免秘钥

参考前面分布式搭建章节

在node02,node03,node04搭建zookeeper集群

  1. 复制zoo_sample.conf,命名为zoo.conf,作如下配置
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/var/zk
clientPort=2181
server.1=192.168.80.12:2888:3888     -
server.2=192.168.80.13:2888:3888
server.3=192.168.80.14:2888:3888
  1. 往dataDir目录写入一个myid文件,跟配置文件的序号对应1,2,3
echo 1 > /var/zk/myid
  1. 启动zookeeper集群
zkServer.sh start   ||   zkServer.sh status

在node01,node02,node03启动journalNode

[root@node01 ~]# hadoop-daemon.sh start journalnode
starting journalnode, logging to /opt/hadoop-2.9.2/logs/hadoop-root-journalnode-node01.out
[root@node01 ~]# jps
21238 JournalNode
21289 Jps

在node01格式化nameNode

hdfs namenode –format

单独启动node01的nameNode

hadoop-deamon.sh start namenode

standby机器node02的nameNode

hdfs  namenode  -bootstrapStandby

格式化zkfc

hdfs zkfc -formatZK

启动start-hdfs.sh

[root@node01 ~]# start-dfs.sh 
Starting namenodes on [node01 node02]
node01: starting namenode, logging to /opt/hadoop-2.9.2/logs/hadoop-root-namenode-node01.out
node02: starting namenode, logging to /opt/hadoop-2.9.2/logs/hadoop-root-namenode-node02.out
node04: starting datanode, logging to /opt/hadoop-2.9.2/logs/hadoop-root-datanode-node04.out
node03: starting datanode, logging to /opt/hadoop-2.9.2/logs/hadoop-root-datanode-node03.out
node02: starting datanode, logging to /opt/hadoop-2.9.2/logs/hadoop-root-datanode-node02.out
Starting journal nodes [node01 node02 node03]
node03: journalnode running as process 8526. Stop it first.
node01: journalnode running as process 21238. Stop it first.
node02: journalnode running as process 9295. Stop it first.
Starting ZK Failover Controllers on NN hosts [node01 node02]
node02: starting zkfc, logging to /opt/hadoop-2.9.2/logs/hadoop-root-zkfc-node02.out
node01: starting zkfc, logging to /opt/hadoop-2.9.2/logs/hadoop-root-zkfc-node01.out

遇到的问题

  • 配置dfs.journalnode.edits.dir时多了一个'>',导致启动JN时,用jps看不到启动后的进程,实际是启动失败了,可以到logs目录查看报错

你可能感兴趣的:(03_HADOOP_04_HDFS高可用环境搭建)