1,介紹java
從hadoop2.2之後的版本中開始有windows的本地支持的包。官方的hadoop版本中沒有windows的安裝版,可是咱們能夠經過源碼安裝。node
不要試圖經過Cygwin來安裝hadoop,由於這些是徹底不必的。apache
2,windows安裝windows
2.1安裝配置java環境(這部份內容省略)確保配置環境中相似 c:\Program Files\Java\ 中有空格的用windows8的路徑方式替換爲c:\Progra~1\Java\瀏覽器
2.2直接下載官方的hadoop binares包我下載的是 hadoop-2.8.1版本app
2.3 解壓後進入到 hadoop-2.8.1/etc/hadoop目錄,修改hadoop的配置環境,編輯hadoop-env.cmdoop
在接近文件末尾的地方加入測試
set HADOOP_PREFIX=c:\hadoop-2.8.1 set HADOOP_CONF_DIR=%HADOOP_PREFIX%\etc\hadoop set YARN_CONF_DIR=%HADOOP_CONF_DIR% set PATH=%PATH%;%HADOOP_PREFIX%\bin
HADOOP_PREFIX 是你本身的hadoop-2.8.1的目錄路徑spa
2.4修改core-site.xmlcode
<configuration> <property> <name>fs.default.name</name> <value>hdfs://0.0.0.0:19000</value> </property> </configuration>
修改 hdfs-site.xml
<configuration> <property> <name>dfs.replication</name> <value>1</value> </property> </configuration>
最後確保你的slaves文件有這些內容
localhost
默認配置會把HDFS數據元數據和數據文件放在\tmp目錄下面,咱們這樣默認會放在c:\tmp目錄下。
2.5修改YARN配置
<configuration> <property> <name>mapreduce.job.user.name</name> <value>%USERNAME%</value> </property> <property> <name>mapreduce.framework.name</name> <value>yarn</value> </property> <property> <name>yarn.apps.stagingDir</name> <value>/user/%USERNAME%/staging</value> </property> <property> <name>mapreduce.jobtracker.address</name> <value>local</value> </property> </configuration>
記得把%USERNAME%替換爲你當前windows登陸的用戶名
修改 yarn-site.xml
<configuration> <property> <name>yarn.server.resourcemanager.address</name> <value>0.0.0.0:8020</value> </property> <property> <name>yarn.server.resourcemanager.application.expiry.interval</name> <value>60000</value> </property> <property> <name>yarn.server.nodemanager.address</name> <value>0.0.0.0:45454</value> </property> <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.server.nodemanager.remote-app-log-dir</name> <value>/app-logs</value> </property> <property> <name>yarn.nodemanager.log-dirs</name> <value>/dep/logs/userlogs</value> </property> <property> <name>yarn.server.mapreduce-appmanager.attempt-listener.bindAddress</name> <value>0.0.0.0</value> </property> <property> <name>yarn.server.mapreduce-appmanager.client-service.bindAddress</name> <value>0.0.0.0</value> </property> <property> <name>yarn.log-aggregation-enable</name> <value>true</value> </property> <property> <name>yarn.log-aggregation.retain-seconds</name> <value>-1</value> </property> <property> <name>yarn.application.classpath</name> <value>%HADOOP_CONF_DIR%,%HADOOP_COMMON_HOME%/share/hadoop/common/*,%HADOOP_COMMON_HOME%/share/hadoop/common/lib/*,%HADOOP_HDFS_HOME%/share/hadoop/hdfs/*,%HADOOP_HDFS_HOME%/share/hadoop/hdfs/lib/*,%HADOOP_MAPRED_HOME%/share/hadoop/mapreduce/*,%HADOOP_MAPRED_HOME%/share/hadoop/mapreduce/lib/*,%HADOOP_YARN_HOME%/share/hadoop/yarn/*,%HADOOP_YARN_HOME%/share/hadoop/yarn/lib/*</value> </property> </configuration>
2.6 初始化環境變量
運行c:\hadoop-2.8.1\etc\hadoop\hadoop-env.cmd
2.7 格式化文件系統
進入 hadoop-2.8.1\bin,運行.\hdfs.cmd namenode -format
14/01/18 08:36:23 INFO namenode.FSImage: Saving image file \tmp\hadoop-username\dfs\name\current\fsimage.ckpt_0000000000000000000 using no compression 14/01/18 08:36:23 INFO namenode.FSImage: Image file \tmp\hadoop-username\dfs\name\current\fsimage.ckpt_0000000000000000000 of size 200 bytes saved in 0 seconds.
看到一大堆啓動內容若是沒有報錯就啓動正常,通常不會有問題。
3,啓動hadoop hdfs
.\start-dfs.cmd
在hadoop-2.8.1\bin 執行 ./hdfs.cmd dfs -put test.txt / 將一個測試文件加入到hdfs系統文件中。
而後能夠經過 ./hdfs.cmd dfs =ls / 查看文件 具體指令 能夠經過--help查看或者看官方文檔。
啓動yarn
.\start-yarn.cmd
運行一個yarn JOB
.\yarn.cmd jar c:\hadoop-2.8.1\share\hadoop\mapreduce\hadoop-mapreduce-examples-2.8.1.jar wordcount /test.txt /out
打開瀏覽器 http://localhost:50070 it works!!! 因爲是單機模式 localhost:9000 沒法訪問改用localhost:8088