建站服務(wù)器
一、首先說(shuō)一下,Hadoop有三種運(yùn)行模式。 第一個(gè)是獨(dú)立(或本地)運(yùn)行模式:無(wú)需運(yùn)行任何守護(hù)進(jìn)程,所有程序都在一個(gè)同一個(gè)JVM上執(zhí)行。 第二個(gè)是偽分布模式:Hadoop守護(hù)進(jìn)程運(yùn)行在本地機(jī)器上,模擬一個(gè)小規(guī)模的集群。 第三個(gè)是全分布模式,也就是通常所說(shuō)的完全分布式模式:Hadoop守護(hù)進(jìn)程運(yùn)行在一個(gè)集群上。 下面簡(jiǎn)單介紹下完全分布式的配置: 首先準(zhǔn)備三臺(tái)機(jī)器,系統(tǒng)公共配置部分: 系統(tǒng)信息: [root@hadoop1~]#cat/etc/redhat-release CentOSrelease6.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~]#grepcentos/etc/sudoers centosALL=(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 exportJAVA_HOME exportCLASSPATH #hadoop HADOOP_HOME=/home/centos/download/hadoop PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin exportPATH 主機(jī)IP域名映射如下: [root@hadoop1~]#cat/etc/hosts 10.0.0.101hadoop1 10.0.0.102hadoop2 10.0.0.103hadoop3 主節(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 javaversion1.8.0_65 Java(TM)SERuntimeEnvironment(build1.8.0_65-b17) JavaHotSpot(TM)64-BitServerVM(build25.65-b01,mixedmode) Hadoop版本 [root@hadoop1~]#hadoopversion Hadoop2.7.3 Subversionhttps://git-wip-us.apache.org/repos/asf/hadoop.git-rbaa91f7c6bc9cb92be5982de4719c1c8af91ccff Compiledbyrooton2016-08-18T01:41Z Compiledwithprotoc2.5.0 Fromsourcewithchecksum2e4ce5f957ea4db193bce3734ff29ff4 Thiscommandwasrunusing/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~]$llcreatessh.sh -rwxr-xr-x1centoscentos51May1411:05createssh.sh [centos@hadoop1~]$catcreatessh.sh #!/bin/sh ssh-keygen-trsa-P\'\'-f~/.ssh/id_rsa 然后在三臺(tái)機(jī)器上的家目錄分別執(zhí)行下述分發(fā)公鑰 [centos@hadoop1~]$llfen.sh -rwxr-xr-x1centoscentos142May1412:14fen.sh [centos@hadoop1~]$catfen.sh #!/bin/sh ssh-copy-id-i~/.ssh/id_rsa.pubcentos@hadoop1 ssh-copy-id-i~/.ssh/id_rsa.pubcentos@hadoop2 ssh-copy-id-i~/.ssh/id_rsa.pubcentos@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~]$chmod700.ssh [centos@hadoop1~]$chmod644.ssh/authorized_keys 三、重點(diǎn)的配置文件內(nèi)容 #三臺(tái)機(jī)器共同配置 [centos@hadoop1~]$grepJAVA_HOMEdownload/hadoop/etc/hadoop/hadoop-env.sh #TheonlyrequiredenvironmentvariableisJAVA_HOME.Allothersare #setJAVA_HOMEinthisfile,sothatitiscorrectlydefinedon exportJAVA_HOME=/home/centos/download/jdk#JAVA環(huán)境變量要在這再配置一下 [centos@hadoop1~]$catdownload/hadoop/etc/hadoop/core-site.xml <?xmlversion=1.0?> <configuration> <property> <name>fs.defaultFS</name> <value>hdfs://hadoop1</value> </property> </configuration> [centos@hadoop1~]$catdownload/hadoop/etc/hadoop/hdfs-site.xml <?xmlversion=1.0?> <configuration> <property> <name>dfs.replication</name> <value>2</value>#副本數(shù),對(duì)應(yīng)從節(jié)點(diǎn)數(shù) </property> </configuration> [centos@hadoop1~]$catdownload/hadoop/etc/hadoop/mapred-site.xml <?xmlversion=1.0?> <configuration> <property> <name>mapreduce.framework.name</name> <value>yarn</value> </property> </configuration> [centos@hadoop1~]$catdownload/hadoop/etc/hadoop/yarn-site.xml <?xmlversion=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~]$catdownload/hadoop/etc/hadoop/slaves hadoop2 hadoop3 四、啟動(dòng)hadoop #下述命令只在主節(jié)點(diǎn)hadoop1中執(zhí)行! #首先執(zhí)行格式化命令 [centos@hadoop1~]$hadoopnamenode-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 2736SecondaryNameNode 2961Jps 2889ResourceManager 2539NameNode #從節(jié)點(diǎn)執(zhí)行,數(shù)據(jù)節(jié)點(diǎn)只會(huì)存在于從節(jié)點(diǎn),是真正存放數(shù)據(jù)的地方。 [centos@hadoop2~]$jps 2322NodeManager 2234DataNode 2380Jps [centos@hadoop3~]$jps 2481DataNode 2646Jps 2569NodeManager #臨時(shí)文件都生成在了根目錄下的/tmp目錄下 [centos@hadoop1~]$ll/tmp/ total32 drwxrwxr-x3centoscentos4096May1414:05hadoop-centos -rw-rw-r--1centoscentos5May1414:06hadoop-centos-namenode.pid -rw-rw-r--1centoscentos5May1414:06hadoop-centos-secondarynamenode.pid drwxr-xr-x2centoscentos4096May1414:06hsperfdata_centos drwxrwxr-x3centoscentos4096May1414:06Jetty_0_0_0_0_50070_hdfs____w2cu08 drwxrwxr-x3centoscentos4096May1414:06Jetty_0_0_0_0_50090_secondary____y6aanv drwxrwxr-x4centoscentos4096May1414:06Jetty_hadoop1_8088_cluster____.jtly5k -rw-rw-r--1centoscentos5May1414:06yarn-centos-resourcemanager.pid
本文名稱:Hadoop完全分布式配置
當(dāng)前網(wǎng)址:http://www.rwnh.cn/article12/cpoigc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供自適應(yīng)網(wǎng)站、ChatGPT、定制網(wǎng)站、App設(shè)計(jì)、企業(yè)建站、App開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)