# hadoop安装-运行

<https://www.jianshu.com/p/34521593f30e>

我的mac安装步骤：

* 1.下载Hadoop(<http://ftp.riken.jp/net/apache/hadoop/common)，我的是`hadoop-2.7.7+spark-2.4.3-bin-hadoop2.7`>
* 设置环境

  cd 到hadoop解压目录，我的是/Users/jiang/Documents/spark/hadoop-2.7.7

  cd 到目录下的etc/hadoop/

  > **1.vim \~/.bash\_profile:**
  >
  > > export JAVA\_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0\_131.jdk/Contents/Home"
  > >
  > > export HADOOP\_HOME="/Users/jiang/Documents/spark/hadoop-2.7.7"
  > >
  > > export PATH=$PATH:$JAVA\_HOME/bin:$HADOOP\_HOME/bin:$HADOOP\_HOME/sbin
  > >
  > > export CLASSPATH=$JAVA\_HOME/lib:$JRE\_HOME/lib:$CLASSPATH
  > >
  > > export HADOOP\_OPTS="-Djava.library.path=$HADOOP\_HOME/lib:$HADOOP\_COMMON\_LIB\_NATIVE\_DIR"
  > >
  > > export HADOOP\_COMMON\_LIB\_NATIVE\_DIR=$HADOOP\_HOME/lib/native
  >
  > **2.vim hadoop-env.sh:**
  >
  > > export JAVA\_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0\_131.jdk/Contents/Home"
  > >
  > > export HADOOP\_HOME="/Users/jiang/Documents/spark/hadoop-2.7.7"
  >
  > **3.vim core-site.xml:**
  >
  > 指定NameNode的主机名与端口
  >
  > > &#x20;​hadoop.tmp.dir ​file:/Users/jiang/Documents/spark/hadoop-2.7.7/tmp ​Abase for other temporary directories. ​fs.defaultFS ​hdfs\://localhost:8020
  >
  > **4.hdfs-site.xml:**
  >
  > 下面的value是hdfs文件节点路径
  >
  > > &#x20;​dfs.replication ​1 ​dfs.namenode.name.dir ​file:/Users/jiang/Documents/spark/hadoop-2.7.7/tmp/dfs/name
  >
  > **5.mapred-site.xml:**
  >
  > > &#x20;​mapreduce.framework.name ​yarn
  >
  > **6.yarn-site.xml:**
  >
  > > &#x20;​yarn.nodemanager.aux-services ​mapreduce\_shuffleyarn.nodemanager.env-whitelistJAVA\_HOME,HADOOP\_COMMON\_HOME,HADOOP\_HDFS\_HOME,HADOOP\_CONF\_DIR,CLASSPATH\_PREPEND\_DISTCACHE,HADOOP\_YARN\_HOME,HADOOP\_MAPRED\_HOME
  >
  > **7.格式化HDFS:**
  >
  > > 执行： hdfs namenode -format
  > >
  > > 在上面设置的hdfs节点路径下就会多出文件
  >
  > **8.启动-查看**
  >
  > > 执行：start-all.sh
  > >
  > > 输入：jps，看是否有多个信息出现(NameNode、NodeManager)
  >
  > **9.web页面查看**
  >
  > <http://localhost:50070/>
  >
  > <http://localhost:8088/>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://im-qianuxn.gitbook.io/pytorch/ji-suan-ji/spark-hadoop/install-hadoop.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
