您好,登錄后才能下訂單哦!
HA(high availability)
HA 使用的是分布式日志管理方式
1. 問題
Namenode出現問題,整個集群將不能使用。
配置兩個namenode:Active namenode,standby namenode
2. 實現方式
1. 兩個namenode內存中存儲的元數據同步,namenode啟動時,會讀鏡像文件。
2. 編輯日志的安全
分布式的存儲日志文件,存儲于2n+1奇數個節點。(n個節點寫入成功,日志寫入成功。)
Zookeeper監控
監控兩個namenode,一個namenode出現問題,實現故障轉移。
Zookeeper對時間同步要求較高(ntp時間同步)
3. 客戶端如何知道訪問哪一個namenode
使用proxy代理
隔離機制
使用sshfence
兩個namenode之間無密碼登陸
安裝配置
1. 基礎環境配置
node1 | node2 | node3 | node1 | node2 |
---|---|---|---|---|
192.168.103.26 | 192.168.103.27 | 192.168.103.28 | 192.168.103.29 | 192.168.103.30 |
namenode | namenode | datanode | datanode | datanode |
DFSZKFailoverController | DFSZKFailoverController | journalnode | journalnode | journalnode |
QuorumPeerMain | QuorumPeerMain | QuorumPeerMain |
配置主機名與IP之間的映射
vim /etc/hosts
192.168.103.26 node1
192.168.103.27 node2
192.168.103.28 node3
192.168.103.29 node4
192.168.103.30 node5
配置各個節點之間的免密登陸
Node1
ssh-kengen –t rsa –P ‘’ 在~/.ssh/目錄下生成id_rsa, id_rsa.put密鑰
ssh-copy-id –I ~/.ssh/id._rsa.pub (node1,node2,node3,node4.node5)
Node2操作同node1
配置時間同步,node1作為ntp服務器
1. yum install ntp –y (所有節點)
2. node1
vim /etc/ntp.conf
server 210.72.145.44 # 中國國家受時中心
server 127.127.1.0 #為局域網用戶提供服務
fudge 127.127.1.0 stratum 10
systemctl start ntpd
3.node2,node3,node4,node5
ntpdate node1
2. 安裝hadoop
1. tar –zxvf jdk-8u171-linux-x64.tar.gz –C /
mv jdk1.8.0_171/ jdk
tar –zxvf hadoop-2.7.7.tar.gz –C /
mv hadoop-2.7.7/ Hadoop
tar –zxvf zookeeper-3.4.10.tar.gz –C /
mv zookeeper-3.4.10 zookeeper
3. vim /etc/profile
export JAVA_HOME=/jdk
export HADOOP_HOME=/Hadoop
export ZOOKEEPER_HOME=/zookeeper
export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$ZOOKEEPER_HOME/bin
source /etc/profile
scp /etc/profile node2:/etc/
node3,node4,node5
scp –r /jdk node2:/etc
node3,node4,node5
4. 配置zookeeper
進入zookeeper目錄,創建zkdata目錄
創建myid文件,node3,node4,node5文件中的值為1,2,3
scp –r /zookeeper node2:/etc
node3,node4,node5
分別修改zookeeper節點的myid文件
5. 安裝hadoop(重點!!!)
1. hadoop-env.sh
export JAVA_HOME = /jdk
2. core-site.xml
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://ns1</value>
</property>
<property>
<name>ha.zookeeper.quorum</name>
<value>node3:2181,node4:2181,node5:2181</value>
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>/hadoop/tmp</value>
</property>
</configuration>
3. hdfs.site.xml
<configuration>
<property>
<name>dfs.nameservices</name>
<value>ns1</value>
</property>
<property>
<name>dfs.ha.namenodes.ns1</name>
<value>nn1,nn2</value>
</property>
<property>
<name>dfs.namenode.rpc-address.ns1.nn1</name>
<value>node1:8020</value>
</property>
<property>
<name>dfs.namenode.rpc-address.ns1.nn2</name>
<value>node2:8020</value>
</property>
<property>
<name>dfs.ha.namenode.http-address.ns1.nn1</name>
<value>node1:50070</value>
</property>
<property>
<name>dfs.ha.namenode.http-address.ns1.nn2</name>
<value>node2:50070</value>
</property>
<property>
<name>dfs.namenode.shared.edits.dir</name>
<value>qjournal://node3:8485;node4:8485;node5:8485/ns1</value>
</property>
<property>
<name>dfs.journalnode.edits.dir</name>
<value>/journalnode</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</value>
</property>
<property>
<name>dfs.ha.fencing.ssh.private-key-files</name>
<value>/home/root/.ssh/id_rsa</value>
</property>
<property>
<name>dfs.ha.automatic-failover.enabled</name>
<value>true</value>
</property>
vim slaves
node3
node4
node5
4. 啟動
node3,node4,node5
hadoop-daemon.sh start journalnode
zkServer.sh start
node1
hdfs namenode -format
scp –r /Hadoop/tmp node2:/Hadoop/
hdfs zkfc –formatZK
start-dfs.sh
5. 驗證HDFS HA
通過瀏覽器查看node1與node2 namenode狀態
![](https://cache.yisu.com/upload/information/20200310/72/146158.jpg?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
![](https://cache.yisu.com/upload/information/20200310/72/146160.jpg?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
hadoop-daemon.sh stop namenode
![](https://cache.yisu.com/upload/information/20200310/72/146161.jpg?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。