您好,登錄后才能下訂單哦!
一、首先說一下,Hadoop有三種運(yùn)行模式。 第一個(gè)是獨(dú)立(或本地)運(yùn)行模式:無需運(yùn)行任何守護(hù)進(jìn)程,所有程序都在一個(gè)同一個(gè)JVM上執(zhí)行。 第二個(gè)是偽分布模式:Hadoop守護(hù)進(jìn)程運(yùn)行在本地機(jī)器上,模擬一個(gè)小規(guī)模的集群。 第三個(gè)是全分布模式,也就是通常所說的完全分布式模式:Hadoop守護(hù)進(jìn)程運(yùn)行在一個(gè)集群上。 下面簡單介紹下完全分布式的配置: 首先準(zhǔn)備三臺(tái)機(jī)器,系統(tǒng)公共配置部分: 系統(tǒng)信息: [root@hadoop1 ~]# cat /etc/redhat-release CentOS release 6.7 (Final) [centos@hadoop1 ~]$ uname -r 2.6.32-573.el6.x86_64 [root@hadoop1 ~]# uname -m x86_64 公共操作用戶:centos centos用戶在/etc/sudoers中的公共配置: [root@hadoop1 ~]# grep centos /etc/sudoers centos ALL=(ALL) NOPASSWD: ALL 環(huán)境變量如下: [root@hadoop1 ~]# tail -16 /etc/profile #java JAVA_HOME=/home/centos/download/jdk PATH=$JAVA_HOME/bin:$PATH CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export JAVA_HOME export CLASSPATH #hadoop HADOOP_HOME=/home/centos/download/hadoop PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin export PATH 主機(jī)IP域名映射如下: [root@hadoop1 ~]# cat /etc/hosts 10.0.0.101 hadoop1 10.0.0.102 hadoop2 10.0.0.103 hadoop3 主節(jié)點(diǎn)IP為: [root@hadoop1 ~]# ifconfig | awk -F '[ :]+' 'NR==2{print $4}' 10.0.0.101 從節(jié)點(diǎn)IP分別為: [root@hadoop2 ~]# ifconfig | awk -F '[ :]+' 'NR==2{print $4}' 10.0.0.102 [root@hadoop3 ~]# ifconfig | awk -F '[ :]+' 'NR==2{print $4}' 10.0.0.103 Java版本 [root@hadoop1 ~]# java -version java version "1.8.0_65" Java(TM) SE Runtime Environment (build1.8.0_65-b17) Java HotSpot(TM) 64-Bit Server VM (build25.65-b01, mixed mode) Hadoop版本 [root@hadoop1 ~]# hadoop version Hadoop 2.7.3 Subversionhttps://git-wip-us.apache.org/repos/asf/hadoop.git -r baa91f7c6bc9cb92be5982de4719c1c8af91ccff Compiled by root on 2016-08-18T01:41Z Compiled with protoc 2.5.0 From source with checksum2e4ce5f957ea4db193bce3734ff29ff4 This command was run using/home/centos/download/hadoop-2.7.3/share/hadoop/common/hadoop-common-2.7.3.jar 二、配置ssh 首先在三臺(tái)機(jī)器上的家目錄分別執(zhí)行下述生成密鑰對(duì)腳本,這樣的話,三臺(tái)機(jī)器的centos之間就可以免密碼登錄、免密碼傳輸文件等操作。 [centos@hadoop1 ~]$ ll createssh.sh -rwxr-xr-x 1 centos centos 51 May 14 11:05createssh.sh [centos@hadoop1 ~]$ cat createssh.sh #!/bin/sh ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa 然后在三臺(tái)機(jī)器上的家目錄分別執(zhí)行下述分發(fā)公鑰 [centos@hadoop1 ~]$ ll fen.sh -rwxr-xr-x 1 centos centos 142 May 14 12:14fen.sh [centos@hadoop1 ~]$ cat fen.sh #!/bin/sh ssh-copy-id -i ~/.ssh/id_rsa.pub centos@hadoop1 ssh-copy-id -i ~/.ssh/id_rsa.pub centos@hadoop2 ssh-copy-id -i ~/.ssh/id_rsa.pub centos@hadoop3 #上述只是在執(zhí)行的時(shí)候會(huì)輸入yes和系統(tǒng)用戶密碼,其他在執(zhí)行的時(shí)候就不會(huì)再次輸入密碼了。執(zhí)行SSH的目的是,比如在配置好完全分布式的時(shí)候,主節(jié)點(diǎn)會(huì)自動(dòng)吊起從節(jié)點(diǎn)的日志并且往里面寫入數(shù)據(jù),此時(shí)SSH的密鑰對(duì)就起作用了。 #經(jīng)常碰到的坑,要配置三臺(tái)機(jī)器家目錄中.ssh的權(quán)限為700,而且要配置家目錄中.ssh目錄中的authorized_keys權(quán)限為644. [centos@hadoop1 ~]$ chmod 700 .ssh [centos@hadoop1 ~]$ chmod 644 .ssh/authorized_keys 三、重點(diǎn)的配置文件內(nèi)容 #三臺(tái)機(jī)器共同配置 [centos@hadoop1 ~]$ grep JAVA_HOME download/hadoop/etc/hadoop/hadoop-env.sh # The only required environment variable isJAVA_HOME. All others are # set JAVA_HOME in this file, so that it iscorrectly defined on export JAVA_HOME=/home/centos/download/jdk #JAVA環(huán)境變量要在這再配置一下 [centos@hadoop1 ~]$ cat download/hadoop/etc/hadoop/core-site.xml <?xml version="1.0"?> <configuration> <property> <name>fs.defaultFS</name> <value>hdfs://hadoop1</value> </property> </configuration> [centos@hadoop1 ~]$ cat download/hadoop/etc/hadoop/hdfs-site.xml <?xml version="1.0"?> <configuration> <property> <name>dfs.replication</name> <value>2</value>#副本數(shù),對(duì)應(yīng)從節(jié)點(diǎn)數(shù) </property> </configuration> [centos@hadoop1 ~]$ cat download/hadoop/etc/hadoop/mapred-site.xml <?xml version="1.0"?> <configuration> <property> <name>mapreduce.framework.name</name> <value>yarn</value> </property> </configuration> [centos@hadoop1 ~]$ cat download/hadoop/etc/hadoop/yarn-site.xml <?xml version="1.0"?> <configuration> <property> <name>yarn.resourcemanager.hostname</name> <value>hadoop1</value> </property> <property> <name>yarn.nodemanager.aux-services</name> <value>mapreduce_shuffle</value> </property> </configuration> #注意這里只配置從節(jié)點(diǎn)的域名 [centos@hadoop1 ~]$ cat download/hadoop/etc/hadoop/slaves hadoop2 hadoop3 四、啟動(dòng)hadoop #下述命令只在主節(jié)點(diǎn)hadoop1中執(zhí)行! #首先執(zhí)行格式化命令 [centos@hadoop1 ~]$ hadoop namenode -format #然后啟動(dòng)hadoop [centos@hadoop1 ~]$ start-all.sh #查看啟動(dòng)進(jìn)程 #主節(jié)點(diǎn)執(zhí)行,名稱節(jié)點(diǎn)只會(huì)存在于主節(jié)點(diǎn)中,包括文件名稱等內(nèi)容。 [centos@hadoop1 ~]$ jps 2736 SecondaryNameNode 2961 Jps 2889 ResourceManager 2539 NameNode #從節(jié)點(diǎn)執(zhí)行,數(shù)據(jù)節(jié)點(diǎn)只會(huì)存在于從節(jié)點(diǎn),是真正存放數(shù)據(jù)的地方。 [centos@hadoop2 ~]$ jps 2322 NodeManager 2234 DataNode 2380 Jps [centos@hadoop3 ~]$ jps 2481 DataNode 2646 Jps 2569 NodeManager #臨時(shí)文件都生成在了根目錄下的/tmp目錄下 [centos@hadoop1 ~]$ ll /tmp/ total 32 drwxrwxr-x 3 centos centos 4096 May 1414:05 hadoop-centos -rw-rw-r-- 1 centos centos 5 May 14 14:06 hadoop-centos-namenode.pid -rw-rw-r-- 1 centos centos 5 May 14 14:06hadoop-centos-secondarynamenode.pid drwxr-xr-x 2 centos centos 4096 May 1414:06 hsperfdata_centos drwxrwxr-x 3 centos centos 4096 May 1414:06 Jetty_0_0_0_0_50070_hdfs____w2cu08 drwxrwxr-x 3 centos centos 4096 May 1414:06 Jetty_0_0_0_0_50090_secondary____y6aanv drwxrwxr-x 4 centos centos 4096 May 1414:06 Jetty_hadoop1_8088_cluster____.jtly5k -rw-rw-r-- 1 centos centos 5 May 14 14:06yarn-centos-resourcemanager.pid
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。