您好,登錄后才能下訂單哦!
這篇文章主要介紹“Hadoop2.x的安裝步驟”,在日常操作中,相信很多人在Hadoop2.x的安裝步驟問題上存在疑惑,小編查閱了各式資料,整理出簡(jiǎn)單好用的操作方法,希望對(duì)大家解答”Hadoop2.x的安裝步驟”的疑惑有所幫助!接下來,請(qǐng)跟著小編一起來學(xué)習(xí)吧!
一、安裝配置
1.創(chuàng)建hadoop用戶(我是添加到root group,也可以新增hadoop group)
[root@hftclclw0001 ~]# useradd hadoop [root@hftclclw0001 ~]# usermod -g root [root@hftclclw0001 ~]# cat /etc/passwd ... ... hadoop:x:50295:0::/home/hadoop:/bin/bash [root@hftclclw0001 ~]# chmod 644 /etc/suders [root@hftclclw0001 ~]# vi 644 /etc/suders ... ... root ALL=(ALL) ALL hadoop ALL=(ALL) ALL ...
2.ssh免密碼登陸
[hadoop@hftclclw0001 hadoop]$ ssh-keygen -t rsa [hadoop@hftclclw0001 hadoop]$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys [hadoop@hftclclw0001 hadoop]$ tree ~/.ssh/ /home/hadoop/.ssh/ ├── authorized_keys ├── id_rsa ├── id_rsa.pub └── known_hosts 0 directories, 4 files 操作其他各個(gè)機(jī)器,并復(fù)制公鑰(d_rsa.pub)到其他各個(gè)機(jī)器的authorized_keys中。我使用的scp,復(fù)制到其他機(jī)器,再使用cat追加到authorized_keys文件中
3. 下載hadoop-2.x.y.tar.gz
[root@hftclclw0001 hadoop]# pwd /home/hadoop [root@hftclclw0001 hadoop]# tar -zxvf hadoop-2.7.1.tar.gz [root@hftclclw0001 hadoop]# ll total 546584 drwx------ 11 hadoop root 4096 Oct 20 09:05 hadoop-2.7.1 -rw------- 1 hadoop root 210606807 Oct 20 09:00 hadoop-2.7.1.tar.gz drwx------ 13 hadoop root 4096 Oct 20 09:22 spark-1.5.1-bin-hadoop2.6 -rw------- 1 hadoop root 280901736 Oct 20 09:19 spark-1.5.1-bin-hadoop2.6.tgz drwx------ 22 hadoop root 4096 Oct 21 00:07 sqoop-1.99.6-bin-hadoop200 -rw------- 1 hadoop root 68177818 May 5 22:34 sqoop-1.99.6-bin-hadoop200.tar.gz
4.配置hadoop-2.x.y
[hadoop@hftclclw0001 hadoop]$ pwd /home/hadoop/hadoop-2.7.1/etc/hadoop [hadoop@hftclclw0001 hadoop]$ vi hadoop-env.sh # The java implementation to use. export JAVA_HOME=/usr/java/latest => 配置java_home [hadoop@hftclclw0001 hadoop]$ vi core-site.xml <configuration> <property> <name>hadoop.tmp.dir</name> <value>/home/hadoop/hadoop-2.7.1/tmp</value> => 需創(chuàng)建,默認(rèn)在/tmp下 </property> <property> <name>fs.defaultFS</name> <value>hdfs://{master:IP}:9000</value> </property> </configuration> [hadoop@hftclclw0001 hadoop]$ vi hdfs-site.xml <configuration> <property> <name>dfs.http.address</name> <value>{master:ip}:50070</value> </property> <property> <name>dfs.replication</name> <value>2</value> =>我這有3臺(tái)機(jī)器,2臺(tái)datanode 1臺(tái)Namenode </property> </configuration> [hadoop@hftclclw0001 hadoop]$ vi mapred-site.xml <configuration> <property> <name>mapreduce.framework.name</name> <value>yarn</value> </property> </configuration> [hadoop@hftclclw0001 hadoop]$ vi yarn-env.sh ... export JAVA_HOME=/usr/java/latest ... [hadoop@hftclclw0001 hadoop]$ vi yarn-site.xml <property> <name>yarn.resourcemanager.hostname</name> =>需要配置,在啟動(dòng)時(shí)候nodemanager會(huì)訪問resouremanager <value>{master:ip}</value> </property> <property> <name>yarn.nodemanager.aux-services</name> <value>mapreduce_shuffle</value> </property> </configuration> [hadoop@hftclclw0001 hadoop]$ vi masters =>其實(shí)作用的secondary namenode在那個(gè)節(jié)點(diǎn)上 {master:ip} [hadoop@hftclclw0001 hadoop]$ vi slaves =>作用的datanode再那些節(jié)點(diǎn)上 {slave-1:ip} {slave-2:ip}
5. 復(fù)制到其他機(jī)器
[hadoop@hftclclw0001 ~]$ pwd /home/hadoop [hadoop@hftclclw0001 ~]$ scp -r hadoop-2.7.1 hadoop@{ip}:/home/hadoop
6.啟動(dòng)
[hadoop@hftclclw0001 hadoop-2.7.1]$ ./bin/hadoop namenode -format [hadoop@hftclclw0001 hadoop-2.7.1]$ pwd /home/hadoop/hadoop-2.7.1 [hadoop@hftclclw0001 hadoop-2.7.1]$ ./sbin/start-dfs.sh => 啟動(dòng)dfs, jps查看進(jìn)程 master:namenode ,secondary namenode slave:datanode [hadoop@hftclclw0001 hadoop-2.7.1]$ ./sbin/start-yarn.sh =>啟動(dòng)yarn
7.驗(yàn)證
a.jps => 校驗(yàn)各個(gè)進(jìn)程
b.netstat => 校驗(yàn)端口
c.webui => 可以校驗(yàn)cluster整體狀況
d.也可以操作hdfs、或是submit mr job
[hadoop@hftclclw0001 hadoop-2.7.1]$ pwd /home/hadoop/hadoop-2.7.1 [hadoop@hftclclw0001 hadoop-2.7.1]$ ./bin/hdfs dfs -ls / ... ... [hadoop@hftclclw0001 hadoop-2.7.1]$ ./bin/hdfs dfs -mkdir /test ... ... [hadoop@hftclclw0001 hadoop-2.7.1]$ ./bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.1.jar wordcount {in} {out} [hadoop@hftclclw0001 hadoop-2.7.1]$ ./bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.1.jar pi 10 10
二、trouble shooting
文件寫入權(quán)限問題
當(dāng)外部程序?qū)懭雋dfs時(shí),默認(rèn)都要進(jìn)行用戶認(rèn)證。如按照上述配置,只能hadoop賬戶可以寫hdfs
dfs.premissions.enabled=true 即對(duì)用戶進(jìn)行認(rèn)證。修改為false
dfs.datanode.data.dir.perm=700 即本地目錄的寫入權(quán)限。修改為755
到此,關(guān)于“Hadoop2.x的安裝步驟”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識(shí),請(qǐng)繼續(xù)關(guān)注億速云網(wǎng)站,小編會(huì)繼續(xù)努力為大家?guī)砀鄬?shí)用的文章!
免責(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)容。