HA(高可用hadoop集群)与安装

 

安装 

        ZK    NN    DN    RM    NM    JN    ZKFC
master    1    1        1        1    1
node1    1    1    1    1    1    1    1
node2    1        1        1    1

先删除所有的tmp文件


1、防火墙
    service firewalld stop
2、时间同步
    yum install ntp
    ntpdate -u s2c.time.edu.cn
    
    或者
    date -s 20180503

3、免密钥   (远程执行命令)
    在两个主节点生成密钥文件
    ssh-keygen -t rsa
    ssh-copy-id ip

    master-->master,node1,node2
    node1-->master,node1,node2

4、修改hadoop配置文件
    core-site.xml
    hdfs-site.xml

 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://cluster</value>
	</property>
	<property>
		<name>hadoop.tmp.dir</name>
		<value>/usr/local/soft/hadoop-2.7.6/tmp</value>
	</property>
	<property>
		<name>fs.trash.interval</name>
		<value>1440</value>
	</property>
	<property>
	      <name>ha.zookeeper.quorum</name>
	      <value>master:2181,node1:2181,node2:2181</value>
	</property>
</configuration>

 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>
<!-- 指定hdfs元数据存储的路径 -->
<property>
<name>dfs.namenode.name.dir</name>
<value>/usr/local/soft/hadoop-2.7.6/data/namenode</value>
</property>

<!-- 指定hdfs数据存储的路径 -->
<property>
<name>dfs.datanode.data.dir</name>
<value>/usr/local/soft/hadoop-2.7.6/data/datanode</value>
</property>

<!-- 数据备份的个数 -->
<property>
<name>dfs.replication</name>
<value>1</value>
</property>

<!-- 关闭权限验证 -->
<property>
<name>dfs.permissions.enabled</name>
<value>false</value>
</property>

<!-- 开启WebHDFS功能(基于REST的接口服务) -->
<property>
<name>dfs.webhdfs.enabled</name>
<value>true</value>
</property>

<!-- //以下为HDFS HA的配置// -->
<!-- 指定hdfs的nameservices名称为mycluster -->
<property>
<name>dfs.nameservices</name>
<value>cluster</value>
</property>

<!-- 指定cluster的两个namenode的名称分别为nn1,nn2 -->
<property>
<name>dfs.ha.namenodes.cluster</name>
<value>nn1,nn2</value>
</property>

<!-- 配置nn1,nn2的rpc通信端口 -->
<property>
<name>dfs.namenode.rpc-address.cluster.nn1</name>
<value>master:8020</value>
</property>
<property>
<name>dfs.namenode.rpc-address.cluster.nn2</name>
<value>node1:8020</value>
</property>

<!-- 配置nn1,nn2的http通信端口 -->
<property>
<name>dfs.namenode.http-address.cluster.nn1</name>
<value>master:50070</value>
</property>
<property>
<name>dfs.namenode.http-address.cluster.nn2</name>
<value>node1:50070</value>
</property>

<!-- 指定namenode元数据存储在journalnode中的路径 -->
<property>
<name>dfs.namenode.shared.edits.dir</name>
<value>qjournal://master:8485;node1:8485;node2:8485/cluster</value>
</property>

<!-- 指定journalnode日志文件存储的路径 -->
<property>
<name>dfs.journalnode.edits.dir</name>
<value>/usr/local/soft/hadoop-2.7.6/data/journal</value>
</property>

<!-- 指定HDFS客户端连接active namenode的java类 -->
<property>
<name>dfs.client.failover.proxy.provider.cluster</name>
<value>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider</value>
</property>

<!-- 配置隔离机制为ssh -->
<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.automatic-failover.enabled</name>
<value>true</value>
</property>
</configuration>

    停止HDFS集群:stop-dfs.sh


    同步到其它节点
        cd /usr/local/soft/hadoop-2.7.6/etc/hadoop
        scp ./* node1:`pwd`
        scp ./* node2:`pwd`

5、删除hadoop数据存储目录下的文件  每个节点都需要删除
     rm -rf /usr/local/soft/hadoop-2.7.6/tmp

6、启动zookeeper  三台都需要启动
    zkServer.sh start
    zkServer.sh status

7、启动JN   存储hdfs元数据
     三台JN上执行 启动命令: 
     /usr/local/soft/hadoop-2.7.6/sbin/hadoop-daemon.sh start journalnode

 8、格式化 在一台NN上执行,这里选择master
      hdfs namenode -format
      启动当前的NN
      hadoop-daemon.sh start namenode


9、执行同步 没有格式化的NN上执行  在另外一个namenode上面执行 这里选择node1
    /usr/local/soft/hadoop-2.7.6/bin/hdfs namenode -bootstrapStandby

 


10、格式化ZK   在master上面执行
    !!一定要先 把zk集群正常 启动起来
      /usr/local/soft/hadoop-2.7.6/bin/hdfs zkfc -formatZK

11、启动hdfs集群,在master上执行
    start-dfs.sh

此时master为活跃的,node1是备用

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值