您好,登錄后才能下訂單哦!
【1】搭建HA高可用hadoop-2.3(規(guī)劃+環(huán)境準(zhǔn)備)
【2】搭建HA高可用hadoop-2.3(安裝zookeeper)
【3】搭建HA高可用hadoop-2.3(部署配置hadoop--cdh6.1.0)
【4】搭建HA高可用hadoop-2.3(部署配置HBase)
安裝部署hadoop
(1)安裝hadoop
master1、master2、slave1、slave2、slave3
#cd /opt/ #tar xf hadoop-2.3.0-cdh6.1.0.tar.gz #ln -s ln -s hadoop-2.3.0-cdh6.1.0 hadoop
(2)添加hadoop環(huán)境變量
master1、master2、slave1、slave2、slave3
#cat >> /etc/profile <<EOF export HADOOP_HOME=/opt/hadoop export PATH=$PATH:$HADOOP_HOME/bin EOF #source /etc/profile
(3)配置hadoop
主要配置文件 (hadoop-2.3.0-cdh6.1.0 /etc/hadoop/) | 格式 | 作用 |
hadoop-env.sh | bash腳本 | hadoop需要的環(huán)境變量 |
core-site.xml | xml | hadoop的core的配置項(xiàng) |
hdfs-site.xml | xml | hdfs的守護(hù)進(jìn)程配置,包括namenode、datanode |
slaves | 純文本 | datanode的節(jié)點(diǎn)列表(每行一個(gè)) |
mapred-env.sh | bash腳本 | mapreduce需要的環(huán)境變量 |
mapre-site.xml | xml | mapreduce的守護(hù)進(jìn)程配置 |
yarn-env.sh | bash腳本 | yarn需要的環(huán)境變量 |
yarn-site.xml | xml | yarn的配置項(xiàng) |
以下1-8的配置,所有機(jī)器都相同,可先配置一臺(tái),將配置統(tǒng)一copy到另外幾臺(tái)機(jī)器。
master1、master2、slave1、slave2、slave3
1:配置hadoop-env.sh
cat >> hadoop-env.sh <<EOF export JAVA_HOME=/usr/java/jdk1.8.0_60 export HADOOP_HOME=/opt/hadoop-2.3.0-cdh6.1.0 EOF
2:配置core-site.xml
#mkdir -p /data/hadoop/tmp #vim core-site.xml <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <configuration> <property> <!--填寫(xiě)hdfs集群名,因?yàn)槭荋A,兩個(gè)namenode--> <name>fs.defaultFS</name> <value>hdfs://mycluster</value> </property> <property> <!-- hadoop很多路徑都依賴(lài)他,namenode節(jié)點(diǎn)該目錄不可以刪除,否則要重新格式化--> <name>hadoop.tmp.dir</name> <value>/data/hadoop/tmp</value> </property> <property> <!--zookeeper集群的地址--> <name>ha.zookeeper.quorum</name> <value>master1:2181,master2:2181,slave1:2181,slave2:2181,slave3:2181</value> </property> </configuration>
3:配置hdfs-site.xml
#mkdir -p /data/hadoop/dfs/{namenode,datanode} #mkdir -p /data/hadoop/ha/journal #vim hdfs-site.xml <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <!--hdfs-site.xml--> <configuration> <property> <!--設(shè)置為true,否則一些命令無(wú)法使用如:webhdfs的LISTSTATUS--> <name>dfs.webhdfs.enabled</name> <value>true</value> </property> <property> <!--數(shù)據(jù)三副本--> <name>dfs.replication</name> <value>3</value> </property> <property> <!--namenode的數(shù)據(jù)目錄,存儲(chǔ)集群元數(shù)據(jù)--> <name>dfs.namenode.name.dir</name> <value>file:/data/hadoop/dfs/namenode</value> </property> <property> <!--datenode的數(shù)據(jù)目錄--> <name>dfs.datanode.data.dir</name> <value>file:/data/hadoop/dfs/datanode</value> </property> <property> <!--可選,關(guān)閉權(quán)限帶來(lái)一些不必要的麻煩--> <name>dfs.permissions</name> <value>false</value> </property> <property> <!--可選,關(guān)閉權(quán)限帶來(lái)一些不必要的麻煩--> <name>dfs.permissions.enabled</name> <value>false</value> </property> <!--HA配置--> <property> <!--設(shè)置集群的邏輯名--> <name>dfs.nameservices</name> <value>mycluster</value> </property> <property> <!--hdfs集群中的namenode節(jié)點(diǎn)邏輯名--> <name>dfs.ha.namenodes.mycluster</name> <value>namenode1,namenode2</value> </property> <property> <!--hdfs namenode邏輯名中RPC配置,rpc簡(jiǎn)單理解為序列化文件上傳輸出文件要用到--> <name>dfs.namenode.rpc-address.mycluster.namenode1</name> <value>master1:9000</value> </property> <property> <!--hdfs namenode邏輯名中RPC配置,rpc簡(jiǎn)單理解為序列化文件上傳輸出文件要用到--> <name>dfs.namenode.rpc-address.mycluster.namenode2</name> <value>master2:9000</value> </property> <property> <!--配置hadoop頁(yè)面訪(fǎng)問(wèn)端口--> <name>dfs.namenode.http-address.mycluster.namenode1</name> <value>master1:50070</value> </property> <property> <name>dfs.namenode.http-address.mycluster.namenode2</name> <value>master2:50070</value> </property> <property> <!--建立與namenode的通信--> <name>dfs.namenode.servicerpc-address.mycluster.namenode1</name> <value>master1:53310</value> </property> <property> <name>dfs.namenode.servicerpc-address.mycluster.namenode2</name> <value>master2:53310</value> </property> <property> <!--journalnode 共享文件集群--> <name>dfs.namenode.shared.edits.dir</name> <value>qjournal://master1:8485;master2:8485;slave1:8485;slave2:8485;slave3:8485/mycluster</value> </property> <property> <!--journalnode對(duì)namenode的進(jìn)行共享設(shè)置--> <name>dfs.journalnode.edits.dir</name> <value>/data/hadoop/ha/journal</value> </property> <property> <!--設(shè)置故障處理類(lèi)--> <name>dfs.client.failover.proxy.provider.mycluster</name> <value>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider</value> </property> <property> <!--開(kāi)啟自動(dòng)切換,namenode1 stanby后nn2或active--> <name>dfs.ha.automatic-failover.enabled</name> <value>true</value> </property> <property> <!--zookeeper集群的地址--> <name>ha.zookeeper.quorum</name> <value>master1:2181,master2:2181,slave1:2181,slave2:2181,slave3:2181</value> </property> <property> <!--使用ssh方式進(jìn)行故障切換--> <name>dfs.ha.fencing.methods</name> <value>sshfence</value> </property> <property> <!--ssh通信密碼通信位置--> <name>dfs.ha.fencing.ssh.private-key-files</name> <value>/root/.ssh/id_rsa</value> </property> </configuration>
4:配置mapred-env.sh
cat >> mapred-env.sh <<EOF #heqinqin configure export JAVA_HOME=/usr/java/jdk1.8.0_60 EOF
5:配置mapred-site.xml
<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <configuration> <name>mapreduce.framework.name</name> <value>yarn<value> </configuration>
6:配置yarn-env.sh
cat >> yarn-env.sh <<EOF #heqinqin configure export JAVA_HOME=/usr/java/jdk1.8.0_60 EOF
7:配置yarn-site.xml
#mkdir -p /data/hadoop/yarn/local #mkdir -p /data/hadoop/logs #chown -R hadoop /data/hadoop #vim yarn-site.xml <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <!--####################yarn-site.xml#########################--> <configuration> <property> <!--rm失聯(lián)后重新鏈接的時(shí)間--> <name>yarn.resourcemanager.connect.retry-interval.ms</name> <value>2000</value> </property> <property> <!--開(kāi)啟resource manager HA,默認(rèn)為false--> <name>yarn.resourcemanager.ha.enabled</name> <value>true</value> </property> <property> <!--開(kāi)啟故障自動(dòng)切換--> <name>yarn.resourcemanager.ha.automatic-failover.enabled</name> <value>true</value> </property> <property> <!--配置resource manager --> <name>yarn.resourcemanager.ha.rm-ids</name> <value>rm1,rm2</value> </property> <property> <name>yarn.resourcemanager.ha.id</name> <value>rm1</value> <description>If we want to launch more than one RM in single node, we need this configuration</description> </property> <property> <!--開(kāi)啟自動(dòng)恢復(fù)功能--> <name>yarn.resourcemanager.recovery.enabled</name> <value>true</value> </property> <property> <!--配置與zookeeper的連接地址--> <name>yarn.resourcemanager.zk-state-store.address</name> <value>localhost:2181</value> </property> <property> <name>yarn.resourcemanager.store.class</name> <value>org.apache.hadoop.yarn.server.resourcemanager.recovery.ZKRMStateStore</value> </property> <property> <name>yarn.resourcemanager.zk-address</name> <value>localhost:2181</value> </property> <property> <name>yarn.resourcemanager.cluster-id</name> <value>yarncluster</value> </property> <property> <!--schelduler失聯(lián)等待連接時(shí)間--> <name>yarn.app.mapreduce.am.scheduler.connection.wait.interval-ms</name> <value>5000</value> </property> <!--配置resourcemanager--> <!--配置rm1--> <property> <!--配置應(yīng)用管理端口--> <name>yarn.resourcemanager.address.rm1</name> <value>master1:8032</value> </property> <property> <!--scheduler調(diào)度器組建的ipc端口--> <name>yarn.resourcemanager.scheduler.address.rm1</name> <value>master1:8030</value> </property> <property> <!--http服務(wù)端口--> <name>yarn.resourcemanager.webapp.address.rm1</name> <value>master1:8088</value> </property> <property> <!--IPC端口--> <name>yarn.resourcemanager.resource-tracker.address.rm1</name> <value>master1:8031</value> </property> <property> <!--IPC端口--> <name>yarn.resourcemanager.admin.address.rm1</name> <value>master1:8033</value> </property> <property> <name>yarn.resourcemanager.ha.admin.address.rm1</name> <value>master1:8035</value> </property> <!--配置rm2--> <property> <!--application 管理端口--> <name>yarn.resourcemanager.address.rm2</name> <value>master2:8032</value> </property> <property> <!--scheduler調(diào)度器端口--> <name>yarn.resourcemanager.scheduler.address.rm2</name> <value>master2:8030</value> </property> <property> <!--http服務(wù)端口--> <name>yarn.resourcemanager.webapp.address.rm2</name> <value>master2:8088</value> </property> <property> <!--ipc端口--> <name>yarn.resourcemanager.resource-tracker.address.rm2</name> <value>master2:8031</value> </property> <property> <!--ipc端口--> <name>yarn.resourcemanager.admin.address.rm2</name> <value>master2:8033</value> </property> <property> <name>yarn.resourcemanager.ha.admin.address.rm2</name> <value>master2:8035</value> </property> <!--配置nodemanager--> <property> <!--配置localizer ipc端口--> <description>Address where the localizer IPC is.</description> <name>yarn.nodemanager.localizer.address</name> <value>0.0.0.0:8040</value> </property> <property> <!--nodemanager http訪(fǎng)問(wèn)端口--> <description>NM Webapp address.</description> <name>yarn.nodemanager.webapp.address</name> <value>0.0.0.0:8042</value> </property> <property> <name>yarn.nodemanager.aux-services</name> <value>mapreduce_shuffle</value> </property> <property> <name>yarn.nodemanager.aux-services.mapreduce.shuffle.class</name> <value>org.apache.hadoop.mapred.ShuffleHandler</value> </property> <property> <name>yarn.nodemanager.local-dirs</name> <value>/data/hadoop/yarn/local</value> </property> <property> <name>yarn.nodemanager.log-dirs</name> <value>/data/hadoop/logs</value> </property> <property> <name>mapreduce.shuffle.port</name> <value>8050</value> </property> <!--故障處理類(lèi)--> <property> <name>yarn.client.failover-proxy-provider</name> <value>org.apache.hadoop.yarn.client.ConfiguredRMFailoverProxyProvider</value> </property> </configuration>
8:配置slaves
cat >> slaves <<EOF slave1 slave2 slave3 EOF
配置完畢
啟動(dòng)集群
(1)格式化命名空間
master1
#/opt/hadoop/bin/hdfs zkfc -formatZK
(2)啟動(dòng)journalnode
master1、master2、slave1、slave2、slave3 (集群內(nèi)隨意算則奇數(shù)臺(tái)機(jī)器作為journalnode,三臺(tái)也可以)
#/opt/hadoop/sbin/hadoop-daemon.sh start journalnode
(3)master1節(jié)點(diǎn)格式化,并啟動(dòng)namenode
master1
格式化namenode的目錄
#/opt/hadoop/bin/hadoop namenode -format mycluster
啟動(dòng)namenode
#/opt/hadoop/sbin/hadoop-daemon.sh start namenode
(4)master2節(jié)點(diǎn)同步master1的格式化目錄,并啟動(dòng)namenode
master2
從master1將格式化的目錄同步過(guò)來(lái)
#/opt/hadoop/bin/hdfs namenode -bootstrapStandby
啟動(dòng)namenode
#/opt/hadoop/sbin/hadoop-daemon.sh start namenode
(5)master節(jié)點(diǎn)啟動(dòng)zkfs
master1、master2
#/opt/hadoop/sbin/hadoop-daemon.sh start zkfc
(6)slave節(jié)點(diǎn)啟動(dòng)datanode
slave1、slave2、slave3
#/opt/hadoop/sbin/hadoop-daemon.sh start datanode
(7)master節(jié)點(diǎn)啟動(dòng)yarn
master1
#/opt/hadoop/sbin/start-yarn.sh
(8)master節(jié)點(diǎn)啟動(dòng)historyserver
master1
./mr-jobhistory-daemon.sh start historyserver
集群已啟動(dòng)。在各服務(wù)器執(zhí)行jps查看,兩個(gè)master上各一個(gè)namenode,形成namenode高可用,實(shí)現(xiàn)故障自動(dòng)切換。
【1】搭建HA高可用hadoop-2.3(規(guī)劃+環(huán)境準(zhǔn)備)
【2】搭建HA高可用hadoop-2.3(安裝zookeeper)
【3】搭建HA高可用hadoop-2.3(部署配置hadoop--cdh6.1.0)
【4】搭建HA高可用hadoop-2.3(部署配置HBase)
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。