轉載地址:http://www.open-open.com/lib/view/open1435761287778.htmlhtml
整體思路,準備主從服務器,配置主服務器能夠無密碼SSH登陸從服務器,解壓安裝JDK,解壓安裝Hadoop,配置hdfs、mapreduce等主從關係。
一、環境,3臺CentOS6.5,64位,Hadoop2.7.3須要64位Linux,操做系統十幾分鍾就能夠安裝完成,
Master 192.168.0.182
Slave1 192.168.0.183
Slave2 192.168.0.184
二、SSH免密碼登陸,由於Hadoop須要經過SSH登陸到各個節點進行操做,我用的是root用戶,每臺服務器都生成公鑰,再合併到authorized_keys
(1)CentOS默認沒有啓動ssh無密登陸,去掉/etc/ssh/sshd_config其中2行的註釋,每臺服務器都要設置,
java
注意:執行這步的時候可能會報一個錯誤:node
java.net.UnknownHostException: tiancunPC: tiancunPC: unknown error
at java.net.InetAddress.getLocalHost(InetAddress.java:1505)
at org.apache.hadoop.net.DNS.resolveLocalHostname(DNS.java:264)
at org.apache.hadoop.net.DNS.<clinit>(DNS.java:57)
at org.apache.hadoop.hdfs.server.namenode.NNStorage.newBlockPoolID(NNStorage.java:982)
at org.apache.hadoop.hdfs.server.namenode.NNStorage.newNamespaceInfo(NNStorage.java:591)
at org.apache.hadoop.hdfs.server.namenode.FSImage.format(FSImage.java:157)
at org.apache.hadoop.hdfs.server.namenode.NameNode.format(NameNode.java:992)
at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1434)
at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1559)
Caused by: java.net.UnknownHostException: tiancunPC: unknown error
at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress 2.lookupAllHostAddr(InetAddress.java:928)atjava.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323)atjava.net.InetAddress.getLocalHost(InetAddress.java:1500)…8more16/11/1119:15:23WARNnet.DNS:Unabletodetermineaddressofthehost−fallingbackto「localhost」addressjava.net.UnknownHostException:tiancunPC:tiancunPC:unknownerroratjava.net.InetAddress.getLocalHost(InetAddress.java:1505)atorg.apache.hadoop.net.DNS.resolveLocalHostIPAddress(DNS.java:287)atorg.apache.hadoop.net.DNS.<clinit>(DNS.java:58)atorg.apache.hadoop.hdfs.server.namenode.NNStorage.newBlockPoolID(NNStorage.java:982)atorg.apache.hadoop.hdfs.server.namenode.NNStorage.newNamespaceInfo(NNStorage.java:591)atorg.apache.hadoop.hdfs.server.namenode.FSImage.format(FSImage.java:157)atorg.apache.hadoop.hdfs.server.namenode.NameNode.format(NameNode.java:992)atorg.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1434)atorg.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1559)Causedby:java.net.UnknownHostException:tiancunPC:unknownerroratjava.net.Inet4AddressImpl.lookupAllHostAddr(NativeMethod)atjava.net.InetAddress 2.lookupAllHostAddr(InetAddress.java:928)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323)
at java.net.InetAddress.getLocalHost(InetAddress.java:1500)
… 8 morelinux
linux中使用hostname查看爲:web
[root@tiancunPC hadoop-2.7.3]# hostname
tiancunPCapache
查看/etc/hosts爲:vim
[root@tiancunPC hadoop-2.7.3]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6瀏覽器
難怪會映射不到,修改/etc/hosts服務器
[root@tiancunPC hadoop-2.7.3]# cat /etc/hosts
127.0.0.1 tiancunPC localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6markdown
對應修改另外兩個機器的主機名,在執行那個命令就能夠了
(2)所有啓動sbin/start-all.sh,也能夠分開sbin/start-dfs.sh、sbin/start-yarn.sh
執行sbin/start-all.sh 可能會有錯誤提示:
maps to localhost(IP), but this does not map back to the address
解決辦法:
修改 /etc/ssh/ssh_config
vim /etc/ssh/ssh_config
GSSAPIAuthentication no
解決辦法:從新啓動一下hadoop
(3)中止的話,輸入命令,sbin/stop-all.sh (4)輸入命令,jps,能夠看到相關信息 1三、Web訪問,要先開放端口或者直接關閉防火牆 (1)輸入命令,systemctl stop firewalld.service(CentOS6.5沒有找到這個命令,在CentOS7中出現) (2)瀏覽器打開http://192.168.0.182:8088/ (3)瀏覽器打開http://192.168.0.182:50070/ 1四、安裝完成。這只是大數據應用的開始,以後的工做就是,結合本身的狀況,編寫程序調用Hadoop的接口,發揮hdfs、mapreduce的做用。