1.修改主機名及hosts文件10.205.22.185 nn1 (主)作用namenode,resourcemanager,datanode,zk,hive,sqoop10.205.22.186 nn2 (備)作用namenode,resourcemanager,datanode,zk10.205...
1.修改主機名及hosts文件
10.205.22.185 nn1 (主)作用namenode,resourcemanager,datanode,zk,hive,sqoop 10.205.22.186 nn2 (備)作用namenode,resourcemanager,datanode,zk 10.205.22.187 dn1 作用datanode,zk
1.1配置ssh免密碼登錄
主節點能免密碼登錄各個從節點
ssh nn1 ssh nn2 ssh dn1
2. 安裝jdk1.8和zookeeper,hive,sqoop可搭建成功後再安裝
2.1修改profile文件,配置環境變數
export JAVA_HOME=/usr/java/jdk1.8.0_65 export JRE_HOME=/usr/java/jdk1.8.0_65/jre export HADOOP_HOME=/app/hadoop-2.7.1 export HIVE_HOME=/app/hive export SQOOP_HOME=/app/sqoop export ZOOKEEPER_HOME=/app/zookeeper-3.4.6 export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$ZOOKEEPER_HOME/bin:$HIVE_HOME/bin:$SQOOP_HOME/bin:$MAVEN_HOME/bin export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib ulimit -SHn 65536
2.2 修改zookeeper配置文件zoo.cfg
添加:
server.1= nn1:2888:3888 server.2= nn2:2888:3888 server.3= dn1:2888:3888
3.安裝hadoop-2.7.1,修改配置文件
創建相應的目錄
mkdir -p /home/hadoop/tmp mkdir -p /home/hadoop/hdfs/data mkdir -p /home/hadoop/journal mkdir -p /home/hadoop/name
修改slaves文件
nn1
nn2
dn1
修改hadoop-env.sh文件
export JAVA_HOME=/usr/java/jdk1.8.0_65
3.1配置hdfs-site.xml
<configuration> <property> <name>dfs.nameservices</name> <value>masters</value> </property> <property> <name>dfs.ha.namenodes.masters</name> <value>nn1,nn2</value> </property> <property> <name>dfs.namenode.rpc-address.masters.nn1</name> <value>nn1:9000</value> </property> <property> <name>dfs.namenode.http-address.masters.nn1</name> <value>nn1:50070</value> </property> <property> <name>dfs.namenode.rpc-address.masters.nn2</name> <value>nn2:9000</value> </property> <property> <name>dfs.namenode.http-address.masters.nn2</name> <value>nn2:50070</value> </property> <property> <name>dfs.datanode.data.dir</name> <value>file:/home/hadoop/hdfs/data</value> </property> <property> <name>dfs.replication</name> <value>2</value> </property> <property> <name>dfs.namenode.name.dir</name> <value>file:/home/hadoop/name</value> </property> <property> <name>dfs.namenode.shared.edits.dir</name> <value>qjournal://nn1:8485;nn2:8485;dn1:8485/masters</value> </property> <property> <name>dfs.journalnode.edits.dir</name> <value>/home/hadoop/journal</value> </property> <property> <name>dfs.ha.automatic-failover.enabled</name> <value>true</value> </property> <property> <name>dfs.client.failover.proxy.provider.masters</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>/root/.ssh/id_rsa</value> </property> <property> <name>dfs.ha.fencing.ssh.connect-timeout</name> <value>30000</value> </property> </configuration>
3.2配置core-site.xml文件
<configuration> <property> <name>fs.defaultFS</name> <value>hdfs://masters</value> </property> <property> <name>hadoop.tmp.dir</name> <value>/home/hadoop/tmp</value> </property> <property> <name>ha.zookeeper.quorum</name> <value>nn1:2181,nn2:2181,dn1:2181</value> </property> <property> <name>io.compression.codecs</name> <value>org.apache.hadoop.io.compress.GzipCodec,org.apache.hadoop.io.compress.DefaultCodec,com.hadoop.compression.lzo.LzoCodec,com.hadoop.compression.lzo.LzopCodec,org.apache.hadoop.io.compress.BZip2Codec</value> </property> <property> <name>io.compression.codec.lzo.class</name> <value>com.hadoop.compression.lzo.LzoCodec</value> </property> </configuration>
3.3配置yarn-site.xml文件
<configuration> <property> <name>yarn.resourcemanager.ha.enabled</name> <value>true</value> </property> <property> <name>yarn.resourcemanager.cluster-id</name> <value>rm-cluster</value> </property> <property> <name>yarn.resourcemanager.ha.rm-ids</name> <value>rm1,rm2</value> </property> <property> <name>yarn.resourcemanager.ha.automatic-failover.enabled</name> <value>true</value> </property> <property> <name>yarn.resourcemanager.ha.automatic-failover.embedded</name> <value>true</value> </property> <property> <name>yarn.resourcemanager.hostname.rm1</name> <value>nn1</value> </property> <property> <name>yarn.resourcemanager.hostname.rm2</name> <value>nn2</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>nn1:2181,nn2:2181,dn1:2181</value> </property> <property> <name>yarn.resourcemanager.scheduler.address.rm1</name> <value>nn1:8030</value> </property> <property> <name>yarn.resourcemanager.scheduler.address.rm2</name> <value>nn2:8030</value> </property> <property> <name>yarn.resourcemanager.resource-tracker.address.rm1</name> <value>nn1:8031</value> </property> <property> <name>yarn.resourcemanager.resource-tracker.address.rm2</name> <value>nn2:8031</value> </property> <property> <name>yarn.resourcemanager.address.rm1</name> <value>nn1:8032</value> </property> <property> <name>yarn.resourcemanager.address.rm2</name> <value>nn2:8032</value> </property> <property> <name>yarn.resourcemanager.admin.address.rm1</name> <value>nn1:8033</value> </property> <property> <name>yarn.resourcemanager.admin.address.rm2</name> <value>nn2:8033</value> </property> <property> <name>yarn.resourcemanager.webapp.address.rm1</name> <value>nn1:8088</value> </property> <property> <name>yarn.resourcemanager.webapp.address.rm2</name> <value>nn2:8088</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.client.failover-proxy-provider</name> <value>org.apache.hadoop.yarn.client.ConfiguredRMFailoverProxyProvider</value> </property> </configuration>
3.4配置mapred-site.xml文件
<configuration> <property> <name>mapreduce.framework.name</name> <value>yarn</value> </property> <property> <name>mapreduce.jobhistory.address</name> <value>nn1:10020</value> </property> <property> <name>mapreduce.jobhistory.webapp.address</name> <value>nn2:19888</value> </property> <property> <name>mapred.compress.map.output</name> <value>true</value> </property> <property> <name>mapred.map.output.compression.codec</name> <value>com.hadoop.compression.lzo.LzoCodec</value> </property> <property> <name>mapred.child.env</name> <value>LD_LIBRARY_PATH=/usr/local/lzo/lib</value> </property> </configuration>
3.5同步hadoop到各個節點,並配置上述相關文件
4.啟動服務
4.1在各個節點啟動zookeeper,查看狀態
zkServer.sh start zkServer.sh status
在主節點格式化zookeeper
hdfs zkfc -formatZK
4.2在各個節點啟日誌程式
hadoop-daemon.sh start journalnode
4.3在主namenode節點格式化hadoop
hadoop namenode -format
4.4在主namenode節點啟動namenode進程
hadoop-daemon.sh start namenode
4.5在備節點執行命令,這個是把備namenode節點的目錄格式化並把元數據從主namenode節點同步過來
hdfs namenode –bootstrapStandby hadoop-daemon.sh start namenode 啟動namenode yarn-daemon.sh start resourcemanager 啟動resourcemanager
4.6啟動其他相關服務
start-dfs.sh start-yarn.sh
4.7 查看高可用狀態
hdfs haadmin -getServiceState nn1/nn2 查看namenode
yarn rmadmin -getServiceState rm1/rm2 查看resourcemanager
4.8登錄web查看狀態
http://nn1:50070 http://nn1:8088