主要是ssh免密碼登錄部分有所區別。僞分佈式全部節點位於一臺主機,一次免密碼登錄其實是免密碼登錄本機;徹底分佈式要求免密碼登錄集羣內全部機器。node
在屢次安裝以後我的推薦使用CentOS安裝,網絡鏈接方式使用橋接(後來看到NAT的貌似更合理,但沒有嘗試)。在使用ubuntu桌面版本期間網絡鏈接不穩定,無規律出現宿主機與虛擬機沒法鏈接的情況。linux
ubuntu桌面版的好處:不用關閉iptables、selinux;額外步驟:開啓root用戶web
CentOS我使用的是最簡版,如下以CentOS最簡版本安裝爲例介紹。shell
安裝虛擬機和Linuxapache
安裝jdk(建議配置環境變量)、下載解壓Hadoopubuntu
關閉linux的iptables、seLinux(chkconfig iptables off、/etc/selinux/config)centos
設置靜態IP(/etc/sysconfig/network-scripts/ifcfg-eth0、/etc/resolv.conf)網絡
重啓網絡(/etc/init.d/network restart)app
修改主機名(/etc/sysconfig/network)ssh
配置hosts(/etc/hosts)
配置yum源/etc/yum.repos.d/yum.repo
靜態IP配置文件示例:
DEVICE=eth0 ONBOOT=yes BOOTPROTO=none IPADDR=192.168.1.120 NETMASK=255.255.255.0 GATEWAY=192.168.1.1
yum文件配置示例:
[name] name=myyum baseurl=http://mirrors.163.com/centos/6.5/os/x86_64 gpgcheck=0
ssh-keygen -t rsa cd ~/.ssh scp ./id_rsa.pub root@192.168.1.112:/root/.ssh/authorized_keys
1.>生成ssh密鑰位於~/.ssh文件夾
2.>將公鑰複製的集羣內某一主機(注意後面的位置與本身機器設置保持一致)
3.>集羣內全部主機重複1.>,將全部公鑰集中存儲在一臺機器的anthorized_keys文件
4.>將存有全部主機公鑰的authorized_keys文件複製到集羣全部主機
全部配置文件位於hadoop安裝目錄下的conf目錄下
注意:全部配置文件僅僅是示例,具體內容應與本身集羣的設置保持一致
1.>hadoop-env.sh(修改jdk安裝位置便可)
2.>core-site.xml
<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <!-- Put site-specific property overrides in this file. --> <configuration> <property> <name>fs.default.name</name> <value>hdfs://backup01:9000</value> </property> <property> <name>hadoop.tmp.dir</name> <value>/usr/local/hadoop_tmp</value> </property> </configuration>
3.>hdfs-site.xml
<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <!-- Put site-specific property overrides in this file. --> <configuration> <property> <name>dfs.replication</name> <value>2</value> </property> </configuration>
4.>mapred-site.xml
<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <!-- Put site-specific property overrides in this file. --> <configuration> <property> <name>mapred.job.tracker</name> <value>backup01:9001</value> </property> </configuration>
5.>master(寫入主節點主機名)
6.>slaves(寫入從節點主機名)
1.>SCP命令複製hadoop文件夾至集羣全部主機
2.>格式化namenode:
$HADOOP_HOME$/bin hadoop namenode -format
注意:不要重複格式化
$HADOOP_HOME$/bin start-all.sh
若是沒有什麼異常。至此,Hadoop1.x徹底分佈式安裝完成。
與hadoop1.x安裝相似,主要不一樣集中在配置文件和啓動方式,修改配置文件以前工做於安裝hadoop1.x一致
7個配置文件
hadoop/etc/hadoop/hadoop-env.sh(選擇jdk)
hadoop/etc/hadoop/yarn-sev.sh(選擇jdk)
hadoop/etc/hadoop/slaves(寫入從節點)
hadoop/etc/hadoop/core-site.xml
<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <configuration> <property> <name>fs.defaultFS</name> <value>hdfs://h1:9000</value> </property> <property> <name>io.file.buffer.size</name> <value>131072</value> </property> <property> <name>hadoop.tmp.dir</name> <value>file:/usr/local/hadoop/tmp</value> </property> <property> <name>hadoop.proxyuser.hduser.hosts</name> <value>*</value> </property> <property> <name>hadoop.proxyuser.hduser.groups</name> <value>*</value> </property> </configuration>
hadoop/etc/hadoop/hdfs-site.xml
<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <configuration> <property> <name>dfs.namenode.secondary.http-address</name> <value>h1:9001</value> </property> <property> <name>dfs.namenode.name.dir</name> <value>file:/usr/local/hadoop/name</value> </property> <property> <name>dfs.namenode.data.dir</name> <value>file:/usr/local/hadoop/data</value> </property> <property> <name>dfs.replication</name> <value>2</value> </property> <property> <name>dfs.webhdfs.enabled</name> <value>true</value> </property> </configuration>
hadoop/etc/hadoop/mapred-site.xml
<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <configuration> <property> <name>mapreduce.framework.name</name> <value>yarn</value> </property> <property> <name>mapreduce.jobhistory.address</name> <value>h1:10020</value> </property> <property> <name>mapredece.jobhistory.webapp.address</name> <value>h1:19888</value> </property> </configuration>
hadoop/etc/hadoop/yarn-site.xml
<?xml version="1.0"?> <configuration> <!-- Site specific YARN configuration properties --> <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.resourcemanager.address</name> <value>h1:8032</value> </property> <property> <name>yarn.resourcemanager.scheduler.address</name> <value>h1:8030</value> </property> <property> <name>yarn.resourcemanager.resource-tracker.address</name> <value>h1:8031</value> </property> <property> <name>yarn.resourcemanager.admin.address</name> <value>h1:8033</value> </property> <property> <name>yarn.resourcemanager.webapp.address</name> <value>h1:8088</value> </property> </configuration>
./bin/hdfs namenode –format
./sbin/start -all.sh
總結寫的很倉促,可能不夠詳盡,甚至有內容錯誤,但願發現的朋友及時指正。
好久不使用CentOS,對OS的基本命令和設置遺忘甚多,感謝舍長的幫助讓我順利完成安裝。
Hadoop MapReduce Cookbook
Hadoop基礎教程
其餘來自互聯網的資料