【實驗】Hadoop-2.7.2+zookeeper-3.4.6完全分散式環境搭建(HDFS、YARN HA)
Hadoop-2.7.2+Zookeeper-3.4.6完全分散式環境搭建
一.版本
元件名 |
版本 |
說明 |
JRE |
java version "1.7.0_67" Java(TM) SE Runtime Environment (build 1.7.0_67-b01) Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode) |
|
Hadoop |
hadoop-2.7.2.tar.gz |
主程式包 |
Zookeeper |
zookeeper-3.4.6.tar.gz |
熱切,Yarn 儲存資料使用的協調服務 |
二.主機規劃
IP |
Host 及安裝軟體 |
部署模組 |
程式 |
172.16.101.55 |
sht-sgmhadoopnn-01 hadoop |
NameNode ResourceManager |
NameNode DFSZKFailoverController ResourceManager |
172.16.101.56 |
sht-sgmhadoopnn-02 hadoop |
NameNode ResourceManager |
NameNode DFSZKFailoverController ResourceManager |
172.16.101.58 |
sht-sgmhadoopdn-01 hadoop、zookeeper |
DataNode NodeManager Zookeeper |
DataNode NodeManager JournalNode QuorumPeerMain |
172.16.101.59 |
sht-sgmhadoopdn-02 Hadoop、zookeeper |
DataNode NodeManager Zookeeper |
DataNode NodeManager JournalNode QuorumPeerMain |
172.16.101.60 |
sht-sgmhadoopdn-03 Hadoop、zookeeper |
DataNode NodeManager Zookeeper |
DataNode NodeManager JournalNode QuorumPeerMain |
三.目錄規劃
名稱 |
路徑 |
$HADOOP_HOME |
/hadoop/hadoop-2.7.2 |
Data |
$ HADOOP_HOME/data |
Log |
$ HADOOP_HOME/logs |
四.常用指令碼及命令
1.啟動叢集
start-dfs.sh
start-yarn.sh
2.關閉叢集
stop-yarn.sh
stop-dfs.sh
3.監控叢集
hdfs dfsadmin -report
4.單個程式啟動/關閉
hadoop-daemon.sh start|stop namenode|datanode| journalnode
yarn-daemon.sh start |stop resourcemanager|nodemanager
http://blog.chinaunix.net/uid-25723371-id-4943894.html
五.環境準備
1 .設定ip地址(5臺)
點選(此處)摺疊或開啟
-
[root@sht-sgmhadoopnn-01 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
-
DEVICE="eth0"
-
BOOTPROTO="static"
-
DNS1="172.16.101.63"
-
DNS2="172.16.101.64"
-
GATEWAY="172.16.101.1"
-
HWADDR="00:50:56:82:50:1E"
-
IPADDR="172.16.101.55"
-
NETMASK="255.255.255.0"
-
NM_CONTROLLED="yes"
-
ONBOOT="yes"
-
TYPE="Ethernet"
- UUID="257c075f-6c6a-47ef-a025-e625367cbd9c"
執行命令: service network restart
驗證:ifconfig
2 .關閉防火牆(5臺)
執行命:service iptables stop
驗證:service iptables status
3.關閉防火牆的自動執行(5臺)
執行命令:chkconfig iptables off
驗證:chkconfig --list | grep iptables
4 設定主機名(5臺)
執行命令
(1)hostname sht-sgmhadoopnn-01
(2)vi /etc/sysconfig/network
點選(此處)摺疊或開啟
-
[root@sht-sgmhadoopnn-01 ~]# vi /etc/sysconfig/network
-
NETWORKING=yes
-
HOSTNAME=sht-sgmhadoopnn-01.telenav.cn
- GATEWAY=172.16.101.1
5 ip與hostname繫結(5臺)
點選(此處)摺疊或開啟
-
[root@sht-sgmhadoopnn-01 ~]# vi /etc/hosts
-
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
-
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
-
172.16.101.55 sht-sgmhadoopnn-01.telenav.cn sht-sgmhadoopnn-01
-
172.16.101.56 sht-sgmhadoopnn-02.telenav.cn sht-sgmhadoopnn-02
-
172.16.101.58 sht-sgmhadoopdn-01.telenav.cn sht-sgmhadoopdn-01
-
172.16.101.59 sht-sgmhadoopdn-02.telenav.cn sht-sgmhadoopdn-02
-
172.16.101.60 sht-sgmhadoopdn-03.telenav.cn sht-sgmhadoopdn-03
- 驗證:ping sht-sgmhadoopnn-01
6. 設定5臺machines,SSH互相通訊
http://blog.itpub.net/30089851/viewspace-1992210/
7 .安裝JDK(5臺)
點選(此處)摺疊或開啟
-
(1)執行命令
-
[root@sht-sgmhadoopnn-01 ~]# cd /usr/java
-
[root@sht-sgmhadoopnn-01 java]# cp /tmp/jdk-7u67-linux-x64.gz ./
-
[root@sht-sgmhadoopnn-01 java]# tar -xzvf jdk-7u67-linux-x64.gz
-
(2)vi /etc/profile 增加內容如下:
-
export JAVA_HOME=/usr/java/jdk1.7.0_67
-
export HADOOP_HOME=/hadoop/hadoop-2.7.2
-
export ZOOKEEPER_HOME=/hadoop/zookeeper
-
export PATH=.:$HADOOP_HOME/bin:$JAVA_HOME/bin:$ZOOKEEPER_HOME/bin:$PATH
-
#先把HADOOP_HOME, ZOOKEEPER_HOME配置了
-
#本次實驗機器已經配置好了jdk1.7.0_67-cloudera
-
(3)執行 source /etc/profile
- (4)驗證:java –version
8.建立資料夾(5臺)
mkdir /hadoop
六.安裝Zookeeper
sht-sgmhadoopdn-01/02/03
1.下載解壓zookeeper-3.4.6.tar.gz
點選(此處)摺疊或開啟
-
[root@sht-sgmhadoopdn-01 tmp]# wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz
-
[root@sht-sgmhadoopdn-02 tmp]# wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz
-
[root@sht-sgmhadoopdn-03 tmp]# wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz
-
[root@sht-sgmhadoopdn-01 tmp]# tar -xvf zookeeper-3.4.6.tar.gz
-
[root@sht-sgmhadoopdn-02 tmp]# tar -xvf zookeeper-3.4.6.tar.gz
-
[root@sht-sgmhadoopdn-03 tmp]# tar -xvf zookeeper-3.4.6.tar.gz
-
[root@sht-sgmhadoopdn-01 tmp]# mv zookeeper-3.4.6 /hadoop/zookeeper
-
[root@sht-sgmhadoopdn-02 tmp]# mv zookeeper-3.4.6 /hadoop/zookeeper
- [root@sht-sgmhadoopdn-03 tmp]# mv zookeeper-3.4.6 /hadoop/zookeeper
2.修改配置
點選(此處)摺疊或開啟
-
[root@sht-sgmhadoopdn-01 tmp]# cd /hadoop/zookeeper/conf
-
[root@sht-sgmhadoopdn-01 conf]# cp zoo_sample.cfg zoo.cfg
-
[root@sht-sgmhadoopdn-01 conf]# vi zoo.cfg
-
修改dataDir
-
dataDir=/hadoop/zookeeper/data
-
新增下面三行
-
server.1=sht-sgmhadoopdn-01:2888:3888
-
server.2=sht-sgmhadoopdn-02:2888:3888
-
server.3=sht-sgmhadoopdn-03:2888:3888
-
[root@sht-sgmhadoopdn-01 conf]# cd ../
-
[root@sht-sgmhadoopdn-01 zookeeper]# mkdir data
-
[root@sht-sgmhadoopdn-01 zookeeper]# touch data/myid
-
[root@sht-sgmhadoopdn-01 zookeeper]# echo 1 > data/myid
-
[root@sht-sgmhadoopdn-01 zookeeper]# more data/myid
-
1
-
## sht-sgmhadoopdn-02/03,也修改配置,就如下不同
-
[root@sht-sgmhadoopdn-02 zookeeper]# echo 2 > data/myid
- [root@sht-sgmhadoopdn-03 zookeeper]# echo 3 > data/myid
七.安裝Hadoop(HDFS HA+YARN HA)
#step3~7,用SecureCRT ssh 到 linux的環境中,假如copy 內容從window 到 linux 中,中文亂碼,請參照修改http://www.cnblogs.com/qi09/archive/2013/02/05/2892922.html
1.下載解壓hadoop-2.7.2.tar.gz
點選(此處)摺疊或開啟
-
[root@sht-sgmhadoopdn-01 tmp]# cd /hadoop/zookeeper/conf
-
[root@sht-sgmhadoopdn-01 conf]# cp zoo_sample.cfg zoo.cfg
-
[root@sht-sgmhadoopdn-01 conf]# vi zoo.cfg
-
修改dataDir
-
dataDir=/hadoop/zookeeper/data
-
新增下面三行
-
server.1=sht-sgmhadoopdn-01:2888:3888
-
server.2=sht-sgmhadoopdn-02:2888:3888
-
server.3=sht-sgmhadoopdn-03:2888:3888
-
[root@sht-sgmhadoopdn-01 conf]# cd ../
-
[root@sht-sgmhadoopdn-01 zookeeper]# mkdir data
-
[root@sht-sgmhadoopdn-01 zookeeper]# touch data/myid
-
[root@sht-sgmhadoopdn-01 zookeeper]# echo 1 > data/myid
-
[root@sht-sgmhadoopdn-01 zookeeper]# more data/myid
-
1
-
## sht-sgmhadoopdn-02/03,也修改配置,就如下不同
-
[root@sht-sgmhadoopdn-02 zookeeper]# echo 2 > data/myid
- [root@sht-sgmhadoopdn-03 zookeeper]# echo 3 > data/myid
2.修改$HADOOP_HOME/etc/hadoop/hadoop-env.sh
export JAVA_HOME="/usr/java/jdk1.7.0_67-cloudera"
3.修改$HADOOP_HOME/etc/hadoop/core-site.xml
點選(此處)摺疊或開啟
-
<?xml version="1.0" encoding="UTF-8"?>
-
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
-
<configuration>
-
<!--Yarn 需要使用 fs.defaultFS 指定NameNode URI -->
-
<property>
-
<name>fs.defaultFS</name>
-
<value>hdfs://mycluster</value>
-
</property>
-
<!--HDFS超級使用者 -->
-
<property>
-
<name>dfs.permissions.superusergroup</name>
-
<value>root</value>
-
</property>
-
<!--==============================Trash機制======================================= -->
-
<property>
-
<!--多長時間建立CheckPoint NameNode截點上執行的CheckPointer 從Current資料夾建立CheckPoint;預設:0 由fs.trash.interval項指定 -->
-
<name>fs.trash.checkpoint.interval</name>
-
<value>0</value>
-
</property>
-
<property>
-
<!--多少分鐘.Trash下的CheckPoint目錄會被刪除,該配置伺服器設定優先順序大於客戶端,預設:0 不刪除 -->
-
<name>fs.trash.interval</name>
-
<value>1440</value>
-
</property>
- </configuration>
4.修改$HADOOP_HOME/etc/hadoop/hdfs-site.xml
點選(此處)摺疊或開啟
-
<?xml version="1.0" encoding="UTF-8"?>
-
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
-
<configuration>
-
<!--開啟web hdfs -->
-
<property>
-
<name>dfs.webhdfs.enabled</name>
-
<value>true</value>
-
</property>
-
<property>
-
<name>dfs.namenode.name.dir</name>
-
<value>/hadoop/hadoop-2.7.2/data/dfs/name</value>
-
<description> namenode 存放name table(fsimage)本地目錄(需要修改)</description>
-
</property>
-
<property>
-
<name>dfs.namenode.edits.dir</name>
-
<value>${dfs.namenode.name.dir}</value>
-
<description>namenode粗放 transaction file(edits)本地目錄(需要修改)</description>
-
</property>
-
<property>
-
<name>dfs.datanode.data.dir</name>
-
<value>/hadoop/hadoop-2.7.2/data/dfs/data</value>
-
<description>datanode存放block本地目錄(需要修改)</description>
-
</property>
-
<property>
-
<name>dfs.replication</name>
-
<value>3</value>
-
</property>
-
<!-- 塊大小 (預設) -->
-
<property>
-
<name>dfs.blocksize</name>
-
<value>268435456</value>
-
</property>
-
<!--======================================================================= -->
-
<!--HDFS高可用配置 -->
-
<!--nameservices邏輯名 -->
-
<property>
-
<name>dfs.nameservices</name>
-
<value>mycluster</value>
-
</property>
-
<property>
-
<!--設定NameNode IDs 此版本最大隻支援兩個NameNode -->
-
<name>dfs.ha.namenodes.mycluster</name>
-
<value>nn1,nn2</value>
-
</property>
-
-
<!-- Hdfs HA: dfs.namenode.rpc-address.[nameservice ID] rpc 通訊地址 -->
-
<property>
-
<name>dfs.namenode.rpc-address.mycluster.nn1</name>
-
<value>sht-sgmhadoopnn-01:8020</value>
-
</property>
-
<property>
-
<name>dfs.namenode.rpc-address.mycluster.nn2</name>
-
<value>sht-sgmhadoopnn-02:8020</value>
-
</property>
-
-
<!-- Hdfs HA: dfs.namenode.http-address.[nameservice ID] http 通訊地址 -->
-
<property>
-
<name>dfs.namenode.http-address.mycluster.nn1</name>
-
<value>sht-sgmhadoopnn-01:50070</value>
-
</property>
-
<property>
-
<name>dfs.namenode.http-address.mycluster.nn2</name>
-
<value>sht-sgmhadoopnn-02:50070</value>
-
</property>
-
-
<!--==================Namenode editlog同步 ============================================ -->
-
<!--保證資料恢復 -->
-
<property>
-
<name>dfs.journalnode.http-address</name>
-
<value>0.0.0.0:8480</value>
-
</property>
-
<property>
-
<name>dfs.journalnode.rpc-address</name>
-
<value>0.0.0.0:8485</value>
-
</property>
-
<property>
-
<!--設定JournalNode伺服器地址,QuorumJournalManager 用於儲存editlog -->
-
<!--格式:qjournal://<host1:port1>;<host2:port2>;<host3:port3>/<journalId> 埠同journalnode.rpc-address -->
-
<name>dfs.namenode.shared.edits.dir</name>
-
<value>qjournal://sht-sgmhadoopdn-01:8485;sht-sgmhadoopdn-02:8485;sht-sgmhadoopdn-03:8485/mycluster</value>
-
</property>
-
-
<property>
-
<!--JournalNode存放資料地址 -->
-
<name>dfs.journalnode.edits.dir</name>
-
<value>/hadoop/hadoop-2.7.2/data/dfs/jn</value>
-
</property>
-
<!--==================DataNode editlog同步 ============================================ -->
-
<property>
-
<!--DataNode,Client連線Namenode識別選擇Active NameNode策略 -->
-
<name>dfs.client.failover.proxy.provider.mycluster</name>
-
<value>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider</value>
-
</property>
-
<!--==================Namenode fencing:=============================================== -->
-
<!--Failover後防止停掉的Namenode啟動,造成兩個服務 -->
-
<property>
-
<name>dfs.ha.fencing.methods</name>
-
<value>sshfence</value>
-
</property>
-
<property>
-
<name>dfs.ha.fencing.ssh.private-key-files</name>
-
<value>/root/.ssh/id_rsa</value>
-
</property>
-
<property>
-
<!--多少milliseconds 認為fencing失敗 -->
-
<name>dfs.ha.fencing.ssh.connect-timeout</name>
-
<value>30000</value>
-
</property>
-
-
<!--==================NameNode auto failover base ZKFC and Zookeeper====================== -->
-
<!--開啟基於Zookeeper及ZKFC程式的自動備援設定,監視程式是否死掉 -->
-
<property>
-
<name>dfs.ha.automatic-failover.enabled</name>
-
<value>true</value>
-
</property>
-
<property>
-
<name>ha.zookeeper.quorum</name>
-
<value>sht-sgmhadoopdn-01:2181,sht-sgmhadoopdn-02:2181,sht-sgmhadoopdn-03:2181</value>
-
</property>
-
<property>
-
<!--指定ZooKeeper超時間隔,單位毫秒 -->
-
<name>ha.zookeeper.session-timeout.ms</name>
-
<value>2000</value>
-
</property>
- </configuration>
5.修改$HADOOP_HOME/etc/hadoop/yarn-env.sh
#Yarn Daemon Options
#export YARN_RESOURCEMANAGER_OPTS
#export YARN_NODEMANAGER_OPTS
#export YARN_PROXYSERVER_OPTS
#export HADOOP_JOB_HISTORYSERVER_OPTS
#Yarn Logs
export YARN_LOG_DIR="/hadoop/hadoop-2.7.2/logs"
6.修改$HADOOP_HOEM/etc/hadoop/mapred-site.xml
點選(此處)摺疊或開啟
-
[root@sht-sgmhadoopnn-01 hadoop]# cp mapred-site.xml.template mapred-site.xml
-
[root@sht-sgmhadoopnn-01 hadoop]# vi mapred-site.xml
-
<configuration>
-
<!-- 配置 MapReduce Applications -->
-
<property>
-
<name>mapreduce.framework.name</name>
-
<value>yarn</value>
-
</property>
-
<!-- JobHistory Server ============================================================== -->
-
<!-- 配置 MapReduce JobHistory Server 地址 ,預設: 0.0.0.0:10020 -->
-
<property>
-
<name>mapreduce.jobhistory.address</name>
-
<value>sht-sgmhadoopnn-01:10020</value>
-
</property>
-
<!-- 配置 MapReduce JobHistory Server web ui 地址, 預設: 0.0.0.0:19888 -->
-
<property>
-
<name>mapreduce.jobhistory.webapp.address</name>
-
<value>sht-sgmhadoopnn-01:19888</value>
-
</property>
- </configuration>
7.修改$HADOOP_HOME/etc/hadoop/yarn-site.xml
點選(此處)摺疊或開啟
-
<configuration>
-
<!-- nodemanager 配置 ================================================= -->
-
<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>
-
<description>Address where the localizer IPC is.</description>
-
<name>yarn.nodemanager.localizer.address</name>
-
<value>0.0.0.0:23344</value>
-
</property>
-
<property>
-
<description>NM Webapp address.</description>
-
<name>yarn.nodemanager.webapp.address</name>
-
<value>0.0.0.0:23999</value>
-
</property>
-
-
<!-- HA 配置 =============================================================== -->
-
<!-- Resource Manager Configs -->
-
<property>
-
<name>yarn.resourcemanager.connect.retry-interval.ms</name>
-
<value>2000</value>
-
</property>
-
<property>
-
<name>yarn.resourcemanager.ha.enabled</name>
-
<value>true</value>
-
</property>
-
<property>
-
<name>yarn.resourcemanager.ha.automatic-failover.enabled</name>
-
<value>true</value>
-
</property>
-
<!-- 使嵌入式自動故障轉移。HA環境啟動,與 ZKRMStateStore 配合 處理fencing -->
-
<property>
-
<name>yarn.resourcemanager.ha.automatic-failover.embedded</name>
-
<value>true</value>
-
</property>
-
<!-- 叢集名稱,確保HA選舉時對應的叢集 -->
-
<property>
-
<name>yarn.resourcemanager.cluster-id</name>
-
<value>yarn-cluster</value>
-
</property>
-
<property>
-
<name>yarn.resourcemanager.ha.rm-ids</name>
-
<value>rm1,rm2</value>
-
</property>
-
<!--這裡RM主備結點需要單獨指定,(可選)
-
<property>
-
<name>yarn.resourcemanager.ha.id</name>
-
<value>rm2</value>
-
</property>
-
-->
-
<property>
-
<name>yarn.resourcemanager.scheduler.class</name>
-
<value>org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler</value>
-
</property>
-
<property>
-
<name>yarn.resourcemanager.recovery.enabled</name>
-
<value>true</value>
-
</property>
-
<property>
-
<name>yarn.app.mapreduce.am.scheduler.connection.wait.interval-ms</name>
-
<value>5000</value>
-
</property>
-
<!-- ZKRMStateStore 配置 -->
-
<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>sht-sgmhadoopdn-01:2181,sht-sgmhadoopdn-02:2181,sht-sgmhadoopdn-03:2181</value>
-
</property>
-
<property>
-
<name>yarn.resourcemanager.zk.state-store.address</name>
-
<value>sht-sgmhadoopdn-01:2181,sht-sgmhadoopdn-02:2181,sht-sgmhadoopdn-03:2181</value>
-
</property>
-
<!-- Client訪問RM的RPC地址 (applications manager interface) -->
-
<property>
-
<name>yarn.resourcemanager.address.rm1</name>
-
<value>sht-sgmhadoopnn-01:23140</value>
-
</property>
-
<property>
-
<name>yarn.resourcemanager.address.rm2</name>
-
<value>sht-sgmhadoopnn-02:23140</value>
-
</property>
-
<!-- AM訪問RM的RPC地址(scheduler interface) -->
-
<property>
-
<name>yarn.resourcemanager.scheduler.address.rm1</name>
-
<value>sht-sgmhadoopnn-01:23130</value>
-
</property>
-
<property>
-
<name>yarn.resourcemanager.scheduler.address.rm2</name>
-
<value>sht-sgmhadoopnn-02:23130</value>
-
</property>
-
<!-- RM admin interface -->
-
<property>
-
<name>yarn.resourcemanager.admin.address.rm1</name>
-
<value>sht-sgmhadoopnn-01:23141</value>
-
</property>
-
<property>
-
<name>yarn.resourcemanager.admin.address.rm2</name>
-
<value>sht-sgmhadoopnn-02:23141</value>
-
</property>
-
<!--NM訪問RM的RPC埠 -->
-
<property>
-
<name>yarn.resourcemanager.resource-tracker.address.rm1</name>
-
<value>sht-sgmhadoopnn-01:23125</value>
-
</property>
-
<property>
-
<name>yarn.resourcemanager.resource-tracker.address.rm2</name>
-
<value>sht-sgmhadoopnn-02:23125</value>
-
</property>
-
<!-- RM web application 地址 -->
-
<property>
-
<name>yarn.resourcemanager.webapp.address.rm1</name>
-
<value>sht-sgmhadoopnn-01:8088</value>
-
</property>
-
<property>
-
<name>yarn.resourcemanager.webapp.address.rm2</name>
-
<value>sht-sgmhadoopnn-02:8088</value>
-
</property>
-
<property>
-
<name>yarn.resourcemanager.webapp.https.address.rm1</name>
-
<value>sht-sgmhadoopnn-01:23189</value>
-
</property>
-
<property>
-
<name>yarn.resourcemanager.webapp.https.address.rm2</name>
-
<value>sht-sgmhadoopnn-02:23189</value>
-
</property>
- </configuration>
8.修改slaves
[root@sht-sgmhadoopnn-01 hadoop]# vi slaves
sht-sgmhadoopdn-01
sht-sgmhadoopdn-02
sht-sgmhadoopdn-03
9.分發資料夾
[root@sht-sgmhadoopnn-01 hadoop]# scp -r hadoop-2.7.2 root@sht-sgmhadoopnn-02:/hadoop
[root@sht-sgmhadoopnn-01 hadoop]# scp -r hadoop-2.7.2 root@sht-sgmhadoopdn-01:/hadoop
[root@sht-sgmhadoopnn-01 hadoop]# scp -r hadoop-2.7.2 root@sht-sgmhadoopdn-02:/hadoop
[root@sht-sgmhadoopnn-01 hadoop]# scp -r hadoop-2.7.2 root@sht-sgmhadoopdn-03:/hadoop
八.啟動叢集
另外一種啟動方式:
1.啟動zookeeper
點選(此處)摺疊或開啟
-
command: ./zkServer.sh start|stop|status
-
[root@sht-sgmhadoopdn-01 bin]# ./zkServer.sh start
-
JMX enabled by default
-
Using config: /hadoop/zookeeper/bin/../conf/zoo.cfg
-
Starting zookeeper ... STARTED
-
[root@sht-sgmhadoopdn-01 bin]# jps
-
2073 QuorumPeerMain
-
2106 Jps
-
[root@sht-sgmhadoopdn-02 bin]# ./zkServer.sh start
-
JMX enabled by default
-
Using config: /hadoop/zookeeper/bin/../conf/zoo.cfg
-
Starting zookeeper ... STARTED
-
[root@sht-sgmhadoopdn-02 bin]# jps
-
2073 QuorumPeerMain
-
2106 Jps
-
[root@sht-sgmhadoopdn-03 bin]# ./zkServer.sh start
-
JMX enabled by default
-
Using config: /hadoop/zookeeper/bin/../conf/zoo.cfg
-
Starting zookeeper ... STARTED
-
[root@sht-sgmhadoopdn-03 bin]# jps
-
2073 QuorumPeerMain
- 2106 Jps
2.啟動hadoop(HDFS+YARN)
a.格式化前,先在journalnode 節點機器上先啟動JournalNode程式
點選(此處)摺疊或開啟
-
[root@sht-sgmhadoopdn-01 ~]# cd /hadoop/hadoop-2.7.2/sbin
-
[root@sht-sgmhadoopdn-01 sbin]# hadoop-daemon.sh start journalnode
-
starting journalnode, logging to /hadoop/hadoop-2.7.2/logs/hadoop-root-journalnode-sht-sgmhadoopdn-03.telenav.cn.out
-
[root@sht-sgmhadoopdn-03 sbin]# jps
-
16722 JournalNode
-
16775 Jps
-
15519 QuorumPeerMain
-
[root@sht-sgmhadoopdn-02 ~]# cd /hadoop/hadoop-2.7.2/sbin
-
[root@sht-sgmhadoopdn-02 sbin]# hadoop-daemon.sh start journalnode
-
starting journalnode, logging to /hadoop/hadoop-2.7.2/logs/hadoop-root-journalnode-sht-sgmhadoopdn-03.telenav.cn.out
-
[root@sht-sgmhadoopdn-03 sbin]# jps
-
16722 JournalNode
-
16775 Jps
-
15519 QuorumPeerMain
-
[root@sht-sgmhadoopdn-03 ~]# cd /hadoop/hadoop-2.7.2/sbin
-
[root@sht-sgmhadoopdn-03 sbin]# hadoop-daemon.sh start journalnode
-
starting journalnode, logging to /hadoop/hadoop-2.7.2/logs/hadoop-root-journalnode-sht-sgmhadoopdn-03.telenav.cn.out
-
[root@sht-sgmhadoopdn-03 sbin]# jps
-
16722 JournalNode
-
16775 Jps
- 15519 QuorumPeerMain
b.NameNode格式化
點選(此處)摺疊或開啟
-
[root@sht-sgmhadoopnn-01 bin]# hadoop namenode -format
-
16/02/25 14:05:04 INFO namenode.NameNode: STARTUP_MSG:
-
/************************************************************
-
STARTUP_MSG: Starting NameNode
-
STARTUP_MSG: host = sht-sgmhadoopnn-01.telenav.cn/172.16.101.55
-
STARTUP_MSG: args = [-format]
-
STARTUP_MSG: version = 2.7.2
-
STARTUP_MSG: classpath =
-
……………..
-
………………
-
16/02/25 14:05:07 INFO namenode.FSNamesystem: dfs.namenode.safemode.threshold-pct = 0.9990000128746033
-
16/02/25 14:05:07 INFO namenode.FSNamesystem: dfs.namenode.safemode.min.datanodes = 0
-
16/02/25 14:05:07 INFO namenode.FSNamesystem: dfs.namenode.safemode.extension = 30000
-
16/02/25 14:05:07 INFO metrics.TopMetrics: NNTop conf: dfs.namenode.top.window.num.buckets = 10
-
16/02/25 14:05:07 INFO metrics.TopMetrics: NNTop conf: dfs.namenode.top.num.users = 10
-
16/02/25 14:05:07 INFO metrics.TopMetrics: NNTop conf: dfs.namenode.top.windows.minutes = 1,5,25
-
16/02/25 14:05:07 INFO namenode.FSNamesystem: Retry cache on namenode is enabled
-
16/02/25 14:05:07 INFO namenode.FSNamesystem: Retry cache will use 0.03 of total heap and retry cache entry expiry time is 600000 millis
-
16/02/25 14:05:07 INFO util.GSet: Computing capacity for map NameNodeRetryCache
-
16/02/25 14:05:07 INFO util.GSet: VM type = 64-bit
-
16/02/25 14:05:07 INFO util.GSet: 0.029999999329447746% max memory 889 MB = 273.1 KB
-
16/02/25 14:05:07 INFO util.GSet: capacity = 2^15 = 32768 entries
-
16/02/25 14:05:08 INFO namenode.FSImage: Allocated new BlockPoolId: BP-1182930464-172.16.101.55-1456380308394
-
16/02/25 14:05:08 INFO common.Storage: Storage directory /hadoop/hadoop-2.7.2/data/dfs/name has been successfully formatted.
-
16/02/25 14:05:08 INFO namenode.NNStorageRetentionManager: Going to retain 1 images with txid >= 0
-
16/02/25 14:05:08 INFO util.ExitUtil: Exiting with status 0
-
16/02/25 14:05:08 INFO namenode.NameNode: SHUTDOWN_MSG:
-
/************************************************************
-
SHUTDOWN_MSG: Shutting down NameNode at sht-sgmhadoopnn-01.telenav.cn/172.16.101.55
- ************************************************************/
c.同步NameNode後設資料
點選(此處)摺疊或開啟
-
同步sht-sgmhadoopnn-01 後設資料到sht-sgmhadoopnn-02
-
主要是:dfs.namenode.name.dir,dfs.namenode.edits.dir還應該確保共享儲存目錄下(dfs.namenode.shared.edits.dir ) 包含NameNode 所有的後設資料。
-
[root@sht-sgmhadoopnn-01 hadoop-2.7.2]# pwd
-
/hadoop/hadoop-2.7.2
-
[root@sht-sgmhadoopnn-01 hadoop-2.7.2]# scp -r data/ root@sht-sgmhadoopnn-02:/hadoop/hadoop-2.7.2
-
seen_txid 100% 2 0.0KB/s 00:00
-
fsimage_0000000000000000000 100% 351 0.3KB/s 00:00
-
fsimage_0000000000000000000.md5 100% 62 0.1KB/s 00:00
- VERSION 100% 205 0.2KB/s 00:00
d.初始化ZFCK
點選(此處)摺疊或開啟
-
[root@sht-sgmhadoopnn-01 bin]# hdfs zkfc -formatZK
-
……………..
-
……………..
-
16/02/25 14:14:41 INFO zookeeper.ZooKeeper: Client environment:user.home=/root
-
16/02/25 14:14:41 INFO zookeeper.ZooKeeper: Client environment:user.dir=/hadoop/hadoop-2.7.2/bin
-
16/02/25 14:14:41 INFO zookeeper.ZooKeeper: Initiating client connection, connectString=sht-sgmhadoopdn-01:2181,sht-sgmhadoopdn-02:2181,sht-sgmhadoopdn-03:2181 sessionTimeout=2000 watcher=org.apache.hadoop.ha.ActiveStandbyElector$WatcherWithClientRef@5f4298a5
-
16/02/25 14:14:41 INFO zookeeper.ClientCnxn: Opening socket connection to server sht-sgmhadoopdn-01.telenav.cn/172.16.101.58:2181. Will not attempt to authenticate using SASL (unknown error)
-
16/02/25 14:14:41 INFO zookeeper.ClientCnxn: Socket connection established to sht-sgmhadoopdn-01.telenav.cn/172.16.101.58:2181, initiating session
-
16/02/25 14:14:42 INFO zookeeper.ClientCnxn: Session establishment complete on server sht-sgmhadoopdn-01.telenav.cn/172.16.101.58:2181, sessionid = 0x15316c965750000, negotiated timeout = 4000
-
16/02/25 14:14:42 INFO ha.ActiveStandbyElector: Session connected.
-
16/02/25 14:14:42 INFO ha.ActiveStandbyElector: Successfully created /hadoop-ha/mycluster in ZK.
-
16/02/25 14:14:42 INFO zookeeper.ClientCnxn: EventThread shut down
- 16/02/25 14:14:42 INFO zookeeper.ZooKeeper: Session: 0x15316c965750000 closed
e.啟動HDFS 系統
叢集啟動,在sht-sgmhadoopnn-01執行start-dfs.sh
叢集關閉,在sht-sgmhadoopnn-01執行stop-dfs.sh
#####叢集啟動############
點選(此處)摺疊或開啟
-
[root@sht-sgmhadoopnn-01 sbin]# start-dfs.sh
-
16/02/25 14:21:42 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
-
Starting namenodes on [sht-sgmhadoopnn-01 sht-sgmhadoopnn-02]
-
sht-sgmhadoopnn-01: starting namenode, logging to /hadoop/hadoop-2.7.2/logs/hadoop-root-namenode-sht-sgmhadoopnn-01.telenav.cn.out
-
sht-sgmhadoopnn-02: starting namenode, logging to /hadoop/hadoop-2.7.2/logs/hadoop-root-namenode-sht-sgmhadoopnn-02.telenav.cn.out
-
sht-sgmhadoopdn-01: starting datanode, logging to /hadoop/hadoop-2.7.2/logs/hadoop-root-datanode-sht-sgmhadoopdn-01.telenav.cn.out
-
sht-sgmhadoopdn-02: starting datanode, logging to /hadoop/hadoop-2.7.2/logs/hadoop-root-datanode-sht-sgmhadoopdn-02.telenav.cn.out
-
sht-sgmhadoopdn-03: starting datanode, logging to /hadoop/hadoop-2.7.2/logs/hadoop-root-datanode-sht-sgmhadoopdn-03.telenav.cn.out
-
Starting journal nodes [sht-sgmhadoopdn-01 sht-sgmhadoopdn-02 sht-sgmhadoopdn-03]
-
sht-sgmhadoopdn-01: journalnode running as process 6348. Stop it first.
-
sht-sgmhadoopdn-03: journalnode running as process 16722. Stop it first.
-
sht-sgmhadoopdn-02: journalnode running as process 7197. Stop it first.
-
16/02/25 14:21:56 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
-
Starting ZK Failover Controllers on NN hosts [sht-sgmhadoopnn-01 sht-sgmhadoopnn-02]
-
sht-sgmhadoopnn-01: starting zkfc, logging to /hadoop/hadoop-2.7.2/logs/hadoop-root-zkfc-sht-sgmhadoopnn-01.telenav.cn.out
-
sht-sgmhadoopnn-02: starting zkfc, logging to /hadoop/hadoop-2.7.2/logs/hadoop-root-zkfc-sht-sgmhadoopnn-02.telenav.cn.out
- You have mail in /var/spool/mail/root
####單程式啟動###########
NameNode(sht-sgmhadoopnn-01, sht-sgmhadoopnn-02):
hadoop-daemon.sh start namenode
DataNode(sht-sgmhadoopdn-01, sht-sgmhadoopdn-02, sht-sgmhadoopdn-03):
hadoop-daemon.sh start datanode
JournamNode(sht-sgmhadoopdn-01, sht-sgmhadoopdn-02, sht-sgmhadoopdn-03):
hadoop-daemon.sh start journalnode
ZKFC(sht-sgmhadoopnn-01, sht-sgmhadoopnn-02):
hadoop-daemon.sh start zkfc
f.驗證namenode,datanode,zkfc
1) 程式
點選(此處)摺疊或開啟
-
[root@sht-sgmhadoopnn-01 sbin]# jps
-
12712 Jps
-
12593 DFSZKFailoverController
-
12278 NameNode
-
[root@sht-sgmhadoopnn-02 ~]# jps
-
29714 NameNode
-
29849 DFSZKFailoverController
-
30229 Jps
-
[root@sht-sgmhadoopdn-01 ~]# jps
-
6348 JournalNode
-
8775 Jps
-
559 QuorumPeerMain
-
8509 DataNode
-
[root@sht-sgmhadoopdn-02 ~]# jps
-
9430 Jps
-
9160 DataNode
-
7197 JournalNode
-
2073 QuorumPeerMain
-
[root@sht-sgmhadoopdn-03 ~]# jps
-
16722 JournalNode
-
17369 Jps
-
15519 QuorumPeerMain
- 17214 DataNode
2) 頁面
sht-sgmhadoopnn-01:
sht-sgmhadoopnn-02:
g.啟動YARN運算框架
#####叢集啟動############
1) sht-sgmhadoopnn-01啟動Yarn,命令所在目錄:$HADOOP_HOME/sbin
點選(此處)摺疊或開啟
-
[root@sht-sgmhadoopnn-01 sbin]# start-yarn.sh
-
starting yarn daemons
-
starting resourcemanager, logging to /hadoop/hadoop-2.7.2/logs/yarn-root-resourcemanager-sht-sgmhadoopnn-01.telenav.cn.out
-
sht-sgmhadoopdn-03: starting nodemanager, logging to /hadoop/hadoop-2.7.2/logs/yarn-root-nodemanager-sht-sgmhadoopdn-03.telenav.cn.out
-
sht-sgmhadoopdn-02: starting nodemanager, logging to /hadoop/hadoop-2.7.2/logs/yarn-root-nodemanager-sht-sgmhadoopdn-02.telenav.cn.out
- sht-sgmhadoopdn-01: starting nodemanager, logging to /hadoop/hadoop-2.7.2/logs/yarn-root-nodemanager-sht-sgmhadoopdn-01.telenav.cn.out
2) sht-sgmhadoopnn-02備機啟動RM
點選(此處)摺疊或開啟
-
[root@sht-sgmhadoopnn-02 sbin]# yarn-daemon.sh start resourcemanager
- starting resourcemanager, logging to /hadoop/hadoop-2.7.2/logs/yarn-root-resourcemanager-sht-sgmhadoopnn-02.telenav.cn.out
####單程式啟動###########
1) ResourceManager(sht-sgmhadoopnn-01, sht-sgmhadoopnn-02)
yarn-daemon.sh start resourcemanager
2) NodeManager(sht-sgmhadoopdn-01, sht-sgmhadoopdn-02, sht-sgmhadoopdn-03)
yarn-daemon.sh start nodemanager
######關閉#############
[root@sht-sgmhadoopnn-01 sbin]# stop-yarn.sh
#包含namenode的resourcemanager程式,datanode的nodemanager程式
[root@sht-sgmhadoopnn-02 sbin]# yarn-daemon.sh stop resourcemanager
h.驗證resourcemanager,nodemanager
1) 程式
點選(此處)摺疊或開啟
-
[root@sht-sgmhadoopnn-01 sbin]# jps
-
13611 Jps
-
12593 DFSZKFailoverController
-
12278 NameNode
-
13384 ResourceManager
-
[root@sht-sgmhadoopnn-02 sbin]# jps
-
32265 ResourceManager
-
32304 Jps
-
29714 NameNode
-
29849 DFSZKFailoverController
-
[root@sht-sgmhadoopdn-01 ~]# jps
-
6348 JournalNode
-
559 QuorumPeerMain
-
8509 DataNode
-
10286 NodeManager
-
10423 Jps
-
[root@sht-sgmhadoopdn-02 ~]# jps
-
9160 DataNode
-
10909 NodeManager
-
11937 Jps
-
7197 JournalNode
-
2073 QuorumPeerMain
-
[root@sht-sgmhadoopdn-03 ~]# jps
-
18031 Jps
-
16722 JournalNode
-
17710 NodeManager
-
15519 QuorumPeerMain
- 17214 DataNode
2) 頁面
ResourceManger(Active):
ResourceManger(Standby):
九.監控叢集
[root@sht-sgmhadoopnn-01 ~]# hdfs dfsadmin -report
十.附件及參考
#
#
hadoop :
zookeeper :
參考:
Hadoop-2.3.0-cdh5.0.1完全分散式環境搭建(NameNode,ResourceManager HA):
http://blog.itpub.net/30089851/viewspace-1987620/
如何解決這類問題:The string "--" is not permitted within comments:
http://blog.csdn.net/free4294/article/details/38681095
SecureCRT連線linux終端中文顯示亂碼解決辦法:
http://www.cnblogs.com/qi09/archive/2013/02/05/2892922.html
參照:http://blog.itpub.net/30089851/viewspace-1987620/
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30089851/viewspace-1994585/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- hadoop完全分散式環境搭建Hadoop分散式
- hbase2.0.4完全分散式環境搭建分散式
- hadoop 2.8.5完全分散式環境搭建Hadoop分散式
- 03【線上日誌分析】之hadoop-2.7.3編譯和搭建叢集環境(HDFS HA,Yarn HA)Hadoop編譯Yarn
- Hadoop hdfs完全分散式搭建教程Hadoop分散式
- Hadoop 及Spark 分散式HA執行環境搭建HadoopSpark分散式
- hadoop3.1.0 HDFS快速搭建偽分散式環境Hadoop分散式
- [hadoop]hadoop2.6完全分散式環境搭建Hadoop分散式
- Spark on Yarn 環境搭建SparkYarn
- Kafka 分散式環境搭建Kafka分散式
- HA分散式叢集搭建分散式
- Hbase偽分散式環境搭建分散式
- HDFS分散式叢集搭建分散式
- 搭建FastDFS分散式儲存環境AST分散式
- hadoop 2.0 hdfs HA 搭建Hadoop
- Spark開發-HA環境的搭建Spark
- Hadoop yarn完全分散式安裝筆記HadoopYarn分散式筆記
- hadoop 2.8.5偽分散式環境搭建Hadoop分散式
- Zookeeper — 本地完全分散式 搭建分散式
- hadoop完全分散式搭建Hadoop分散式
- Hbase完全分散式的搭建分散式
- 搭建Ansible實驗環境
- Hadoop--HDFS完全分散式(簡單版)Hadoop分散式
- zabbix分散式監控環境完全編譯安裝部署分散式編譯
- 搭建FastDFS分散式儲存環境(使用Nginx模組)AST分散式Nginx
- OCM實驗-測試環境的搭建
- OAuth2.0分散式系統環境搭建OAuth分散式
- Hadoop框架:叢集模式下分散式環境搭建Hadoop框架模式分散式
- HBase篇--搭建HBase完全分散式叢集分散式
- 搭建yarn(hadoop-2.2.0)環境詳細過程YarnHadoop
- 分散式基礎&專案環境搭建_學習筆記分散式筆記
- Hadoop HDFS 3.3.1分散式儲存搭建Hadoop分散式
- Oracle實驗環境搭建(windows + oracle 11g)OracleWindows
- HDFS分散式儲存分散式
- Hadoop入門(一)之Hadoop偽分散式環境搭建Hadoop分散式
- hadoop之旅2-centerOS7: 搭建分散式hadoop環境HadoopROS分散式
- Hadoop2.7實戰v1.0之HBase1.1.5 HA分散式搭建Hadoop分散式
- Hadoop 2.6 叢集搭建從零開始之4 Hadoop的安裝與配置(完全分散式環境)Hadoop分散式