基于hadoop完全分布式基础上
1 克隆s200 为s206
配置:
---1
-----2
-----3
[/etc/sysconfig/network-scripts/ifcfg-ethxxxx]
...
IPADDR=..
-----4
service network restart
2配置200 206完全一致
/home/centos/soft/hadoop/etc/hadoop
[centos@s200 /home/centos/soft/hadoop/etc/hadoop]$cat 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>
<property>
<name>dfs.replication</name>
<value>3</value>
</property>
<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>192.168.77.200:8020</value>
</property>
<property>
<name>dfs.namenode.rpc-address.mycluster.nn2</name>
<value>192.168.77.206:8020</value>
</property>
<property>
<name>dfs.namenode.http-address.mycluster.nn1</name>
<value>192.168.77.200:50070</value>
</property>
<property>
<name>dfs.namenode.http-address.mycluster.nn2</name>
<value>192.168.77.206:50070</value>
</property>
<property>
<name>dfs.namenode.shared.edits.dir</name>
<value>qjournal://192.168.77.201:8485;192.168.77.202:8485;192.168.77.203:8485/mycluster</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>/home/centos/.ssh/id_rsa</value>
</property>
<property>
<name>dfs.journalnode.edits.dir</name>
<value>/home/centos/hadoop/journal</value>
</property>
<property>
<name>dfs.journalnode.edits.dir</name>
<value>/home/centos/hadoop/journal</value>
</property>
</configuration>
[core-site.xml]
<property>
<name>fs.defaultFS</name>
<value>hdfs://mycluster</value>
</property>
scp -r /home/centos/soft/hadoop/etc/hadoop/* centos@s206:/home/centos/soft/hadoop/etc/hadoop
拷贝s200 s206配置一致
3 删掉缓存
xcall.sh "rm -rf /home/centos/hadooptmp/"
4 hadoop namenode -format
5 在新的nn(未格式化的nn)上运行一下命令,实现待命状态引导。
[s206]
$>hdfs namenode -bootstrapStandby //需要s201为启动状态,提示是否格式化,选择N
6)在一个NN上执行以下命令,完成edit日志到jn节点的传输。
$>hdfs namenode -initializeSharedEdits
#查看s202,s203是否有edit数据.
7启动所有节点.
[s201]
$>hadoop-daemon.sh start namenode //启动名称节点
$>hadoop-daemons.sh start datanode //启动所有数据节点
[s206]
$>hadoop-daemon.sh start namenode //启动名称节点
HA管理
-----------------
$>hdfs haadmin -transitionToActive nn1 //切成激活态
$>hdfs haadmin -transitionToStandby nn1 //切成待命态
$>hdfs haadmin -transitionToActive --forceactive nn2//强行激活
$>hdfs haadmin -failover nn1 nn2 //模拟容灾演示,从nn1切换到nn2